// File open flags
enum lfs_open_flags {
// open flags
LFS_O_RDONLY = 1, // Open a file as read only
#ifndef LFS_READONLY
LFS_O_WRONLY = 2, // Open a file as write only
LFS_O_RDWR = 3, // Open a file as read and write
LFS_O_CREAT = 0x0100, // Create a file if it does not exist
LFS_O_EXCL = 0x0200, // Fail if a file already exists
LFS_O_TRUNC = 0x0400, // Truncate the existing file to zero size
LFS_O_APPEND = 0x0800, // Move to end of file on every write
#endif
// internally used flags
#ifndef LFS_READONLY
LFS_F_DIRTY = 0x010000, // File does not match storage
LFS_F_WRITING = 0x020000, // File has been written since last flush
#endif
LFS_F_READING = 0x040000, // File has been read since last flush
#ifndef LFS_READONLY
LFS_F_ERRED = 0x080000, // An error occurred during write
#endif
LFS_F_INLINE = 0x100000, // Currently inlined in directory entry
};
Here it is read, write, and append, but can it be similar to C's fopen to open files with rb, wb binary file?
I try to use directly LFS_O_WRONLY | LFS_O_CREAT
to write and use LFS_O_RDONLY
to read.
The GitHub page says:
Once mounted, the littlefs provides a full set of POSIX-like file and directory functions...
The POSIX file function using open
, read
and write
have no "text" mode. All files are read and written in "binary" mode.
So if LFS is "POSIX-like" then it also must do binary file reading and writing.
The text mode handling of fopen
and its related reading and writing functions is done on a higher level, usually to translate OS-specific newline conventions.