# Utils\_file ## **Overview** Performs operations on a file. This module allows you to performs file operations such as to open, close, read, and write a file, and to obtain the file size. The filing system varies according to the hardware platform. The following limitations are imposed on a platform that uses the Serial Peripheral Interface Flash Filing System \(SPIFFS\): **Since:** 1.0 **Version:** 1.0 ## **Summary** ## Files
Performs operations on a file, including to open, close, write, read, and delete a file. |
Defines the offset position used by UtilsFileSeek in a file to start offsetting from the file header. |
|
Defines the offset position used by UtilsFileSeek in a file to start offsetting from the current read and write position. |
|
Defines the offset position used by UtilsFileSeek in a file to start offsetting from the end of the file. |
|
O_RDONLY_FS 00 |
Defines a flag used byUtilsFileOpen to open a file in read-only mode. |
O_WRONLY_FS 01 |
Defines a flag used by UtilsFileOpen to open a file in write-only mode. |
O_RDWR_FS 02 |
Defines a flag used by UtilsFileOpen to open a file in read-and-write mode. |
O_CREAT_FS 0100 |
Defines a flag used by UtilsFileOpen to create a file when the file to open does not exist. |
O_EXCL_FS 0200 |
Defines a flag used by UtilsFileOpen to check whether the file to open exists when O_CREAT_FS is already set. |
O_TRUNC_FS 01000 |
Defines a flag used by UtilsFileOpen to clear the file content if the file exists and can be opened in write mode. |
O_APPEND_FS 02000 |
Defines a flag used by UtilsFileOpen to start reading or writing from the end of a file. |
UtilsFileOpen (const char *path, int oflag, int mode) |
|
UtilsFileClose (int fd) |
|
UtilsFileRead (int fd, char *buf, unsigned int len) |
Reads a specified length of data from a file with the specified file descriptor and writes the data into the buffer. |
UtilsFileWrite (int fd, const char *buf, unsigned int len) |
Writes a specified length of data into a file with the specified file descriptor. |
UtilsFileDelete (const char *path) |
|
UtilsFileStat (const char *path, unsigned int *fileSize) |
|
UtilsFileSeek (int fd, int offset, unsigned int whence) |
|
UtilsFileCopy (const char *src, const char *dest) |
|
UtilsFileMove (const char *src, const char *dest) |
fd | Indicates the file descriptor of the file to close. |
src | Indicates the source file to copy. |
dest | Indicates the target file. |
path | Indicates the file to delete. |
src | Indicates the source file. |
dest | Indicates the target file. |
path | Indicates the file to open or create. |
oflag | Indicates the mode of opening a file. The following modes are supported. These modes can be used together, with each of them identified by "or". |
mode | Used for function compatibility. This parameter does not take effect in any scenario. |
For details, see O_RDONLY_FS. |
|
For details, see O_WRONLY_FS. |
|
For details, see O_RDWR_FS. |
|
For details, see O_CREAT_FS. |
|
For details, see O_EXCL_FS. |
|
For details, see O_TRUNC_FS. |
|
For details, see O_APPEND_FS. |
fd | Indicates the file descriptor of the file to read. |
buf | Indicates the buffer that stores the read data. This is an output parameter. |
len | Indicates the length of the data to read. |
path | Indicates the file name. |
fileSize | Indicates the file size. This is an output parameter. |
fd | Indicates the file descriptor of the file where to write the data. |
buf | Indicates the data to write. |
len | Indicates the length of the data to write. |