🌐
English
File System API#
OFFS is the name of the Oasis File System.
It is called within the oasis::fs namespace.
The Oasis File System is managed using the offs.fuse, mkfs.offs, and fsck.offs tools. When an application executes these commands using functions like system or popen, it is recommended to run them in an independent process and handle the results via IPC. Refer to the Pipe IPC example.
Header File#
OasisFS.h
Functions#
int32_t
setup
(
key_value_map_t &
parameters
)
OasisFS.h
Oasis initializes OFFS. If
oasis::initialize has already been called, it is not necessary to call this function.
Parameters
parameters
The key-value map required for OFFS initialization.
Return Value
- 0: Success
- -1: Failure
The key-value map required for OFFS initialization is as follows:
Key
Default
M
Description
offs-qsize-max
10240
Specifies the maximum size of the internal write queue of the file system. Measured in KBytes. It does not allocate memory.
offs-disable
0
Disables the use of the file system. If "1", components such as recording or playback cannot save and read files.
offs-overwrite-if-exist
1
Specifies whether to overwrite a file if a file with the same name exists. Overwrites if the value is 1. If it is not overwritten, it is created with a modified name.
offs-cache-size
0
Specifies the internal read cache size of the file system. Measured in KBytes. If the value is 0, it is not used.
int32_t
cleanup
(
)
OasisFS.h
Oasis releases OFFS. If
oasis::finalize has already been called, it is not necessary to call this function.
Return Value
- 0: Success
- -1: Failure
int32_t
start
(
)
OasisFS.h
Oasis starts OFFS. If
oasis::initialize has already been called, it is not necessary to call this function. It will be ignored if it has already been started.
Return Value
- 0: Success
- -1: Failure
void
stop
(
)
OasisFS.h
Oasis stops OFFS. If
oasis::finalize has already been called, it is not necessary to call this function.
bool
isConnected
(
)
OasisFS.h
Verifies whether Oasis is connected to OFFS.
Return Value
- true: Connected to OFFS.
- false: Not connected to OFFS.
bool
isBusy
(
)
OasisFS.h
Verifies whether OFFS is currently writing recording data.
Return Value
- true: Writing data.
- false: Not writing data.
void
clearStatusError
(
)
OasisFS.h
Clears errors that occurred while OFFS was creating, moving, reading, or writing a file. After clearing, task requests can proceed to the file system.
int32_t
enableOffsOverwriteIfFileExists
(
bool
enable
)
OasisFS.h
Specifies whether to overwrite a file if a file with the same name already exists in the folder during file creation.
Parameters
enable
Overwrites the file if
true. Saves it with a unique modified name if false.
Return Value
- 0: Success
- -1: Failure
int32_t
offsLockFile
(
const char *
file_path
)
OasisFS.h
Locks the specified file to prevent it from being deleted or moved. Used for preserving files.
Parameters
file_path
The absolute path of the file to lock. The file must exist within the OFFS mounted path.
Return Value
- 0: Success
- -1: Failure
int32_t
offsUnlockFile
(
const char *
file_path
)
OasisFS.h
Unlocks a locked file.
Parameters
file_path
The absolute path of the file to unlock. The file must exist within the OFFS mounted path.
Return Value
- 0: Success
- -1: Failure
int32_t
offsIsFileLocked
(
const char *
file_path
,
bool *
locked
)
OasisFS.h
Verifies whether a file is locked.
Parameters
file_path
The absolute path of the file to verify.
locked
OUT
Returns
true if locked, and returns false if not locked.
Return Value
- 0: Success
- -1: Failure
int32_t
offsGetLockedFileNames
(
const char *
dir_path
,
std::list<std::string> &
filenames
)
OasisFS.h
Obtains a list of locked files from the specified folder.
Parameters
dir_path
The folder path.
filenames
OUT
Returns the list of file names.
Return Value
Returns the number of files on success. Returns -1 on failure.
!!! Warning
Using this function requires formatting the storage device again.
int32_t
offsListFiles
(
const char *
dir_path
,
std::list<OffsListEntry> &
files
)
OasisFS.h
Obtains a list of files in the specified folder. This obtains more detailed information about each file than standard shell commands.
Parameters
dir_path
The folder path to scan. The folder path must exist within the OFFS mounted path.
files
OUT
Returns the list of files. Refer to the Structures section below for details on
OffsListEntry.
Return Value
Returns 0 on success, and returns a negative errno value on failure.
int32_t
offsConfigLocalFormatInfo
(
const char *
folder_path
,
size_t
file_size
)
OasisFS.h
Modifies the format environment conditions of a folder when OFFS uses a temporary folder space within the device instead of mounting via an SD card device path. If a file is created and stored in a folder that is not yet in the OFFS folder list, the maximum size of the file is limited to 16MB.
Parameters
folder_path
The folder path. The folder path does not exist within the OFFS mounted path.
file_size
The file size to change. Specifying a value of "0" deletes the corresponding folder from the OFFS folder list. If the specified folder does not exist, it creates the folder name and its maximum file size information to add it to the OFFS folder list.
Return Value
- 0: Success
- -1: Failure
Structures#
struct
OffsListEntry
OasisFS.h
Used as a parameter when calling the
oasis::fs::offsListFiles API.
Member Type & Name
Description
char filename_[]
The file name. Max length is
OFFS_LIST_FILENAME_MAX.size_t size_
The file size.
uint64_t created_
The creation date. It has a
time_t type and can be converted into a date and time string using the time and localtime_r functions.uint64_t modified_
The modification date. It has a
time_t type and can be converted into a date and time string using the time and localtime_r functions.int32_t seconds_
The recording playback time, measured in seconds.
uint32_t flags_
If the value is
0x00000001, this file is currently being written. Otherwise, the value is 0.The file name length is defined in OasisFS.h as follows:
#define OFFS_LIST_FILENAME_MAX 128