LittleFileSystem, a little file system. More...
#include <LittleFileSystem.h>
Public Member Functions | |
LittleFileSystem (const char *name=NULL, mbed::BlockDevice *bd=NULL, lfs_size_t read_size=MBED_LFS_READ_SIZE, lfs_size_t prog_size=MBED_LFS_PROG_SIZE, lfs_size_t block_size=MBED_LFS_BLOCK_SIZE, lfs_size_t lookahead=MBED_LFS_LOOKAHEAD) | |
Lifetime of the LittleFileSystem. More... | |
virtual int | mount (mbed::BlockDevice *bd) |
Mount a file system to a block device. More... | |
virtual int | unmount () |
Unmount a file system from the underlying block device. More... | |
virtual int | reformat (mbed::BlockDevice *bd) |
Reformat a file system. More... | |
virtual int | remove (const char *path) |
Remove a file from the file system. More... | |
virtual int | rename (const char *path, const char *newpath) |
Rename a file in the file system. More... | |
virtual int | stat (const char *path, struct stat *st) |
Store information about the file in a stat structure. More... | |
virtual int | mkdir (const char *path, mode_t mode) |
Create a directory in the file system. More... | |
virtual int | statvfs (const char *path, struct statvfs *buf) |
Store information about the mounted file system in a statvfs structure. More... | |
FileHandle * | open (const char *path, int flags) |
Open a file on the filesystem. More... | |
DirHandle * | opendir (const char *path) |
Open a directory on the filesystem. More... | |
Static Public Member Functions | |
static int | format (mbed::BlockDevice *bd, lfs_size_t read_size=MBED_LFS_READ_SIZE, lfs_size_t prog_size=MBED_LFS_PROG_SIZE, lfs_size_t block_size=MBED_LFS_BLOCK_SIZE, lfs_size_t lookahead=MBED_LFS_LOOKAHEAD) |
Format a block device with the LittleFileSystem. More... | |
static FileSystem * | get_default_instance () |
Return the default file system. More... | |
Protected Member Functions | |
virtual int | open (FileHandle **file, const char *path, int flags) |
defined(DOXYGEN_ONLY) More... | |
virtual int | open (DirHandle **dir, const char *path) |
Open a directory on the filesystem. More... | |
LittleFileSystem, a little file system.
Synchronization level: Thread safe
Definition at line 35 of file LittleFileSystem.h.
LittleFileSystem | ( | const char * | name = NULL , |
mbed::BlockDevice * | bd = NULL , |
||
lfs_size_t | read_size = MBED_LFS_READ_SIZE , |
||
lfs_size_t | prog_size = MBED_LFS_PROG_SIZE , |
||
lfs_size_t | block_size = MBED_LFS_BLOCK_SIZE , |
||
lfs_size_t | lookahead = MBED_LFS_LOOKAHEAD |
||
) |
Lifetime of the LittleFileSystem.
name | Name of the file system in the tree. |
bd | Block device to mount. Mounted immediately if not NULL. |
read_size | Minimum size of a block read. This determines the size of read buffers. This may be larger than the physical read size to improve performance by caching more of the block device. |
prog_size | Minimum size of a block program. This determines the size of program buffers. This may be larger than the physical program size to improve performance by caching more of the block device. |
block_size | Size of an erasable block. This does not impact ram consumption and may be larger than the physical erase size. However, this should be kept small as each file currently takes up an entire block. |
lookahead | Number of blocks to lookahead during block allocation. A larger lookahead reduces the number of passes required to allocate a block. The lookahead buffer requires only 1 bit per block so it can be quite large with little ram impact. Should be a multiple of 32. |
|
static |
Format a block device with the LittleFileSystem.
The block device to format should be mounted when this function is called.
bd | This is the block device that will be formatted. |
read_size | Minimum size of a block read. This determines the size of read buffers. This may be larger than the physical read size to improve performance by caching more of the block device. |
prog_size | Minimum size of a block program. This determines the size of program buffers. This may be larger than the physical program size to improve performance by caching more of the block device. |
block_size | Size of an erasable block. This does not impact ram consumption and may be larger than the physical erase size. However, this should be kept small as each file currently takes up an entire block. |
lookahead | Number of blocks to lookahead during block allocation. A larger lookahead reduces the number of passes required to allocate a block. The lookahead buffer requires only 1 bit per block so it can be quite large with little ram impact. Should be a multiple of 32. |
|
staticinherited |
Return the default file system.
Returns the default file system based on the default block device configuration. Use the components in target.json or application config to change the default block device and affect the default filesystem. SD block device => FAT filesystem QSPIF, SPIF, DATAFLASH or FLAHIAP block device => LITTLE filesystem
An application can override all target settings by implementing FileSystem::get_default_instance() - the default definition is weak, and calls get_target_default_instance().
|
virtual |
Create a directory in the file system.
path | The name of the directory to create. |
mode | The permissions with which to create the directory. |
Reimplemented from FileSystem.
|
virtual |
Mount a file system to a block device.
bd | Block device to mount to. |
Implements FileSystem.
|
inherited |
Open a file on the filesystem.
path | The name of the file to open |
flags | The flags to open the file in, one of O_RDONLY, O_WRONLY, O_RDWR, bitwise or'd with one of O_CREAT, O_TRUNC, O_APPEND |
int open(FileHandle **, ...)
for propagating error codes Definition at line 64 of file FileSystemLike.h.
|
protectedvirtualinherited |
defined(DOXYGEN_ONLY)
Implements FileSystemHandle.
|
protectedvirtualinherited |
Open a directory on the filesystem.
dir | Destination for the handle to the directory |
path | Name of the directory to open |
Reimplemented from FileSystemHandle.
|
inherited |
Open a directory on the filesystem.
path | Name of the directory to open |
int open(DirHandle **, ...)
for propagating error codes Definition at line 79 of file FileSystemLike.h.
|
virtual |
Reformat a file system.
Results in an empty and mounted file system.
bd | Block device to reformat and mount. If NULL, the mounted Block device is used. Note: If mount fails, bd must be provided. Default: NULL |
Reimplemented from FileSystem.
|
virtual |
Remove a file from the file system.
path | The name of the file to remove. |
Reimplemented from FileSystem.
|
virtual |
Rename a file in the file system.
path | The name of the file to rename. |
newpath | The name to rename it to. |
Reimplemented from FileSystem.
Store information about the file in a stat structure.
path | The name of the file to find information about. |
st | The stat buffer to write to. |
Reimplemented from FileSystem.
Store information about the mounted file system in a statvfs structure.
path | The name of the file to find information about. |
buf | The stat buffer to write to. |
Reimplemented from FileSystem.
|
virtual |
Unmount a file system from the underlying block device.
Implements FileSystem.