Sming Framework API
Sming - Open Source framework for high efficiency WiFi SoC ESP8266 native development with C++ language.
|
Access file system. More...
Enumerations | |
enum | FileOpenFlags { eFO_ReadOnly = SPIFFS_RDONLY, eFO_WriteOnly = SPIFFS_WRONLY, eFO_ReadWrite = eFO_ReadOnly | eFO_WriteOnly, eFO_CreateIfNotExist = SPIFFS_CREAT, eFO_Append = SPIFFS_APPEND, eFO_Truncate = SPIFFS_TRUNC, eFO_CreateNewAlways = eFO_CreateIfNotExist | eFO_Truncate } |
File open flags. More... | |
enum | SeekOriginFlags { eSO_FileStart = SPIFFS_SEEK_SET, eSO_CurrentPos = SPIFFS_SEEK_CUR, eSO_FileEnd = SPIFFS_SEEK_END } |
File seek flags. More... | |
Functions | |
static FileOpenFlags | operator| (FileOpenFlags lhs, FileOpenFlags rhs) |
file_t | fileOpen (const String &name, FileOpenFlags flags) |
Open file. More... | |
void | fileClose (file_t file) |
Clode file. More... | |
size_t | fileWrite (file_t file, const void *data, size_t size) |
Write to file. More... | |
size_t | fileRead (file_t file, void *data, size_t size) |
Read from file. More... | |
int | fileSeek (file_t file, int offset, SeekOriginFlags origin) |
Position file cursor. More... | |
bool | fileIsEOF (file_t file) |
Check if at end of file. More... | |
int32_t | fileTell (file_t file) |
Get position in file. More... | |
int | fileFlush (file_t file) |
Flush pending writes. More... | |
int | fileLastError (file_t fd) |
Get last file system error code. More... | |
void | fileClearLastError (file_t fd) |
Clear last file system error. More... | |
int | fileSetContent (const String &fileName, const char *content) |
Create or replace file with defined content. More... | |
int | fileSetContent (const String &fileName, const String &content) |
Create or replace file with defined content. More... | |
uint32_t | fileGetSize (const String &fileName) |
Get size of file. More... | |
void | fileRename (const String &oldName, const String &newName) |
Rename file. More... | |
Vector< String > | fileList () |
Get list of files on file system. More... | |
String | fileGetContent (const String &fileName) |
Read content of a file. More... | |
int | fileGetContent (const String &fileName, char *buffer, int bufSize) |
Read content of a file. More... | |
int | fileStats (const String &name, spiffs_stat *stat) |
int | fileStats (file_t file, spiffs_stat *stat) |
int | fileDelete (const String &name) |
Delete file. More... | |
int | fileDelete (file_t file) |
Delete file. More... | |
bool | fileExist (const String &name) |
Check if a file exists on file system. More... | |
Access file system.
enum FileOpenFlags |
enum SeekOriginFlags |
void fileClearLastError | ( | file_t | fd | ) |
Clear last file system error.
fd | Not used |
void fileClose | ( | file_t | file | ) |
Clode file.
file | ID of file to open |
int fileDelete | ( | const String & | name | ) |
Delete file.
name | Name of file to delete |
int | error code, 0 on success |
int fileDelete | ( | file_t | file | ) |
Delete file.
file | ID of file to delete |
int | error code, 0 on success |
bool fileExist | ( | const String & | name | ) |
Check if a file exists on file system.
name | Name of file to check for |
bool | True if file exists |
int fileFlush | ( | file_t | file | ) |
Flush pending writes.
file | File ID |
int | Size of last file written or negative error number |
int fileGetContent | ( | const String & | fileName, |
char * | buffer, | ||
int | bufSize | ||
) |
Read content of a file.
fileName | Name of file to read from |
buffer | Pointer to a character buffer in to which to read the file content |
bufSize | Quantity of bytes to read from file |
int | Quantity of bytes read from file or zero on failure |
uint32_t fileGetSize | ( | const String & | fileName | ) |
Get size of file.
fileName | Name of file |
uint32_t | Size of file in bytes |
bool fileIsEOF | ( | file_t | file | ) |
Check if at end of file.
file | File ID |
bool | True if at end of file |
int fileLastError | ( | file_t | fd | ) |
Get last file system error code.
fd | Not used |
int | Error code of last file system operation |
Get list of files on file system.
Vector<String> | Vector of strings. Each string element contains the name of a file on the file system |
file_t fileOpen | ( | const String & | name, |
FileOpenFlags | flags | ||
) |
Open file.
name | File name |
flags | Mode to open file |
file | File ID or negative error code |
size_t fileRead | ( | file_t | file, |
void * | data, | ||
size_t | size | ||
) |
Read from file.
file | File ID |
data | Pointer to data buffer in to which to read data |
size | Quantity of data elements to read from file |
size_t | Quantity of data elements actually read from file or negative error code |
Rename file.
oldName | Original name of file to rename |
newName | New name for file |
int fileSeek | ( | file_t | file, |
int | offset, | ||
SeekOriginFlags | origin | ||
) |
Position file cursor.
file | File ID |
offset | Quantity of bytes to move cursor |
origin | Position from where to move cursor |
Offset | within file or negative error code |
int fileSetContent | ( | const String & | fileName, |
const char * | content | ||
) |
Create or replace file with defined content.
fileName | Name of file to create or replace |
content | Pointer to c-string containing content to populate file with |
int | Positive integer represents the numbers of bytes written. |
int | Negative integer represents the error code of last file system operation. |
Create or replace file with defined content.
fileName | Name of file to create or replace |
content | String containing content to populate file with |
int | Positive integer represents the numbers of bytes written. |
int | Negative integer represents the error code of last file system operation. |
int fileStats | ( | const String & | name, |
spiffs_stat * | stat | ||
) |
brief Get file statistics
name | File name |
stat | Pointer to SPIFFS statistic structure to populate |
int | -1 on error |
int fileStats | ( | file_t | file, |
spiffs_stat * | stat | ||
) |
brief Get file statistics
file | File ID |
stat | Pointer to SPIFFS statistic structure to populate |
int | -1 on error |
int32_t fileTell | ( | file_t | file | ) |
Get position in file.
file | File ID |
int32_t | Read / write cursor position |
size_t fileWrite | ( | file_t | file, |
const void * | data, | ||
size_t | size | ||
) |
Write to file.
file | File ID |
data | Pointer to data to write to file |
size | Quantity of data elements to write to file |
size_t | Quantity of data elements actually written to file or negative error code |