A filesystem object provides filesystem operations and file operations for the File and Dir classes on a block device. More...
#include <FileSystem.h>
Public Member Functions | |
FileSystem (const char *name=NULL) | |
FileSystem lifetime. More... | |
virtual int | mount (BlockDevice *bd)=0 |
Mounts a filesystem to a block device. More... | |
virtual int | unmount ()=0 |
Unmounts a filesystem from the underlying block device. More... | |
virtual int | reformat (BlockDevice *bd=NULL) |
Reformats a filesystem, results in an empty and mounted filesystem. More... | |
virtual int | remove (const char *path) |
Remove a file from the filesystem. More... | |
virtual int | rename (const char *path, const char *newpath) |
Rename a file in the filesystem. 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 filesystem. More... | |
virtual int | statvfs (const char *path, struct statvfs *buf) |
Store information about the mounted filesystem 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 FileSystem * | get_default_instance () |
Return the default filesystem. More... | |
Protected Member Functions | |
virtual int | file_open (fs_file_t *file, const char *path, int flags)=0 |
Open a file on the filesystem. More... | |
virtual int | file_close (fs_file_t file)=0 |
Close a file. More... | |
virtual ssize_t | file_read (fs_file_t file, void *buffer, size_t size)=0 |
Read the contents of a file into a buffer. More... | |
virtual ssize_t | file_write (fs_file_t file, const void *buffer, size_t size)=0 |
Write the contents of a buffer to a file. More... | |
virtual int | file_sync (fs_file_t file) |
Flush any buffers associated with the file. More... | |
virtual int | file_isatty (fs_file_t file) |
Check if the file in an interactive terminal device If so, line buffered behaviour is used by default. More... | |
virtual off_t | file_seek (fs_file_t file, off_t offset, int whence)=0 |
Move the file position to a given offset from from a given location. More... | |
virtual off_t | file_tell (fs_file_t file) |
Get the file position of the file. More... | |
virtual void | file_rewind (fs_file_t file) |
Rewind the file position to the beginning of the file. More... | |
virtual off_t | file_size (fs_file_t file) |
Get the size of the file. More... | |
virtual int | dir_open (fs_dir_t *dir, const char *path) |
Open a directory on the filesystem. More... | |
virtual int | dir_close (fs_dir_t dir) |
Close a directory. More... | |
virtual ssize_t | dir_read (fs_dir_t dir, struct dirent *ent) |
Read the next directory entry. More... | |
virtual void | dir_seek (fs_dir_t dir, off_t offset) |
Set the current position of the directory. More... | |
virtual off_t | dir_tell (fs_dir_t dir) |
Get the current position of the directory. More... | |
virtual void | dir_rewind (fs_dir_t dir) |
Rewind the current position to the beginning of the directory. More... | |
virtual size_t | dir_size (fs_dir_t dir) |
Get the sizeof the directory. More... | |
virtual int | open (FileHandle **file, const char *path, int flags) |
Open a file on the filesystem. More... | |
virtual int | open (DirHandle **dir, const char *path) |
Open a directory on the filesystem. More... | |
A filesystem object provides filesystem operations and file operations for the File and Dir classes on a block device.
Implementations must provide at minimum file operations and mount operations for block devices.
Definition at line 49 of file FileSystem.h.
FileSystem | ( | const char * | name = NULL | ) |
FileSystem lifetime.
name | Name to add filesystem to tree as |
|
protectedvirtual |
Close a directory.
dir | Dir handle |
Reimplemented in LittleFileSystem, and FATFileSystem.
|
protectedvirtual |
Open a directory on the filesystem.
dir | Destination for the handle to the directory |
path | Name of the directory to open |
Reimplemented in LittleFileSystem, and FATFileSystem.
|
protectedvirtual |
Read the next directory entry.
dir | Dir handle |
ent | The directory entry to fill out |
Reimplemented in LittleFileSystem, and FATFileSystem.
|
protectedvirtual |
Rewind the current position to the beginning of the directory.
dir | Dir handle |
Reimplemented in LittleFileSystem, and FATFileSystem.
|
protectedvirtual |
Set the current position of the directory.
dir | Dir handle |
offset | Offset of the location to seek to, must be a value returned from dir_tell |
Reimplemented in LittleFileSystem, and FATFileSystem.
|
protectedvirtual |
|
protectedvirtual |
Get the current position of the directory.
dir | Dir handle |
Reimplemented in LittleFileSystem, and FATFileSystem.
|
protectedpure virtual |
Close a file.
file | File handle |
Implemented in LittleFileSystem, and FATFileSystem.
|
protectedvirtual |
Check if the file in an interactive terminal device If so, line buffered behaviour is used by default.
file | File handle |
|
protectedpure virtual |
Open a file on the filesystem.
file | Destination for the handle to a newly created file |
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 |
Implemented in LittleFileSystem, and FATFileSystem.
|
protectedpure virtual |
Read the contents of a file into a buffer.
file | File handle |
buffer | The buffer to read in to |
size | The number of bytes to read |
Implemented in LittleFileSystem, and FATFileSystem.
|
protectedvirtual |
Rewind the file position to the beginning of the file.
file | File handle |
|
protectedpure virtual |
Move the file position to a given offset from from a given location.
file | File handle |
offset | The offset from whence to move to |
whence | The start of where to seek SEEK_SET to start from beginning of file, SEEK_CUR to start from current position in file, SEEK_END to start from end of file |
Implemented in LittleFileSystem, and FATFileSystem.
|
protectedvirtual |
Get the size of the file.
file | File handle |
Reimplemented in LittleFileSystem, and FATFileSystem.
|
protectedvirtual |
Flush any buffers associated with the file.
file | File handle |
Reimplemented in LittleFileSystem, and FATFileSystem.
|
protectedvirtual |
Get the file position of the file.
file | File handle |
Reimplemented in LittleFileSystem, and FATFileSystem.
|
protectedpure virtual |
Write the contents of a buffer to a file.
file | File handle |
buffer | The buffer to write from |
size | The number of bytes to write |
Implemented in LittleFileSystem, and FATFileSystem.
|
static |
Return the default filesystem.
Returns the default FileSystem base on the default BlockDevice 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 SPIF block device => LITTLE filesystem DATAFLASH block device => LITTLE filesystem
An application can override all target settings by implementing FileSystem::get_default_instance() themselves - the default definition is weak, and calls get_target_default_instance().
|
virtual |
Create a directory in the filesystem.
path | The name of the directory to create. |
mode | The permissions with which to create the directory |
Reimplemented from FileSystemHandle.
Reimplemented in LittleFileSystem, and FATFileSystem.
|
pure virtual |
Mounts a filesystem to a block device.
bd | BlockDevice to mount to |
Implemented in LittleFileSystem, and FATFileSystem.
|
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.
|
protectedvirtual |
Open a file on the filesystem.
file | Destination for the handle to a newly created file |
filename | 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 |
Implements FileSystemHandle.
|
protectedvirtual |
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 |
Reformats a filesystem, results in an empty and mounted filesystem.
bd | BlockDevice to reformat and mount. If NULL, the mounted block device will be used. Note: if mount fails, bd must be provided. Default: NULL |
Reimplemented in LittleFileSystem, and FATFileSystem.
|
virtual |
Remove a file from the filesystem.
path | The name of the file to remove. |
Reimplemented from FileSystemHandle.
Reimplemented in LittleFileSystem, and FATFileSystem.
|
virtual |
Rename a file in the filesystem.
path | The name of the file to rename. |
newpath | The name to rename it to |
Reimplemented from FileSystemHandle.
Reimplemented in LittleFileSystem, and FATFileSystem.
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 FileSystemHandle.
Reimplemented in LittleFileSystem, and FATFileSystem.
Store information about the mounted filesystem in a statvfs structure.
path | The name of the file to find information about |
buf | The stat buffer to write to |
Reimplemented from FileSystemHandle.
Reimplemented in LittleFileSystem, and FATFileSystem.
|
pure virtual |
Unmounts a filesystem from the underlying block device.
Implemented in LittleFileSystem, and FATFileSystem.