17 #ifndef MBED_FILESYSTEM_H 18 #define MBED_FILESYSTEM_H 20 #include "platform/platform.h" 22 #include "platform/FileBase.h" 23 #include "platform/FileHandle.h" 24 #include "platform/DirHandle.h" 25 #include "platform/FileSystemLike.h" 26 #include "BlockDevice.h" 34 typedef void *fs_file_t;
35 typedef void *fs_dir_t;
101 virtual int remove(
const char *path);
109 virtual int rename(
const char *path,
const char *newpath);
117 virtual int stat(
const char *path,
struct stat *st);
125 virtual int mkdir(
const char *path, mode_t mode);
148 virtual int file_open(fs_file_t *file,
const char *path,
int flags) = 0;
155 virtual int file_close(fs_file_t file) = 0;
164 virtual ssize_t file_read(fs_file_t file,
void *buffer,
size_t size) = 0;
173 virtual ssize_t file_write(fs_file_t file,
const void *buffer,
size_t size) = 0;
180 virtual int file_sync(fs_file_t file);
188 virtual int file_isatty(fs_file_t file);
200 virtual off_t file_seek(fs_file_t file, off_t offset,
int whence) = 0;
207 virtual off_t file_tell(fs_file_t file);
214 virtual void file_rewind(fs_file_t file);
221 virtual off_t file_size(fs_file_t file);
234 virtual int file_truncate(fs_file_t file, off_t length);
242 virtual int dir_open(fs_dir_t *dir,
const char *path);
249 virtual int dir_close(fs_dir_t dir);
257 virtual ssize_t dir_read(fs_dir_t dir,
struct dirent *ent);
265 virtual void dir_seek(fs_dir_t dir, off_t offset);
272 virtual off_t dir_tell(fs_dir_t dir);
278 virtual void dir_rewind(fs_dir_t dir);
285 virtual size_t dir_size(fs_dir_t dir);
virtual int stat(const char *path, struct stat *st)
Store information about the file in a stat structure.
FileSystem(const char *name=NULL)
File system lifetime.
Represents a directory stream.
virtual int mount(BlockDevice *bd)=0
Mount a file system to a block device.
A hardware device capable of writing and reading blocks.
virtual int open(FileHandle **file, const char *path, int flags)
defined(DOXYGEN_ONLY)
A filesystem-like object is one that can be used to open file-like objects though it by fopen("/name/...
virtual int mkdir(const char *path, mode_t mode)
Create a directory in the file system.
virtual int reformat(BlockDevice *bd=NULL)
Reformat a file system.
virtual int rename(const char *path, const char *newpath)
Rename a file in the file system.
virtual int unmount()=0
Unmount a file system from the underlying block device.
static FileSystem * get_default_instance()
Return the default file system.
virtual int statvfs(const char *path, struct statvfs *buf)
Store information about the mounted file system in a statvfs structure.