Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: mbed-os-example-blinky-gr-lychee GR-Boads_Camera_sample GR-Boards_Audio_Recoder GR-Boads_Camera_DisplayApp ... more
FileSystem Class Reference
[Filesystem]
A filesystem-like object is one that can be used to open files though it by fopen("/name/filename", flags) More...
#include <FileSystem.h>
Inherits mbed::FileBase.
Inherited by FATFileSystem.
Public Member Functions | |
| FileSystem (const char *name=NULL) | |
| FileSystem lifetime. | |
| virtual int | mount (BlockDevice *bd)=0 |
| Mounts a filesystem to a block device. | |
| virtual int | unmount ()=0 |
| Unmounts a filesystem from the underlying block device. | |
| virtual int | remove (const char *path)=0 |
| Remove a file from the filesystem. | |
| virtual int | rename (const char *path, const char *newpath)=0 |
| Rename a file in the filesystem. | |
| virtual int | stat (const char *path, struct stat *st)=0 |
| Store information about the file in a stat structure. | |
| virtual int | mkdir (const char *path, mode_t mode) |
| Create a directory in the filesystem. | |
Protected Member Functions | |
| virtual int | file_open (fs_file_t *file, const char *path, int flags)=0 |
| Open a file on the filesystem. | |
| virtual int | file_close (fs_file_t file)=0 |
| Close a file. | |
| virtual ssize_t | file_read (fs_file_t file, void *buffer, size_t len)=0 |
| Read the contents of a file into a buffer. | |
| virtual ssize_t | file_write (fs_file_t file, const void *buffer, size_t len)=0 |
| Write the contents of a buffer to a file. | |
| virtual int | file_sync (fs_file_t file) |
| Flush any buffers associated with the file. | |
| 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. | |
| 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. | |
| virtual off_t | file_tell (fs_file_t file) |
| Get the file position of the file. | |
| virtual void | file_rewind (fs_file_t file) |
| Rewind the file position to the beginning of the file. | |
| virtual size_t | file_size (fs_file_t file) |
| Get the size of the file. | |
| virtual int | dir_open (fs_dir_t *dir, const char *path) |
| Open a directory on the filesystem. | |
| virtual int | dir_close (fs_dir_t dir) |
| Close a directory. | |
| virtual ssize_t | dir_read (fs_dir_t dir, struct dirent *ent) |
| Read the next directory entry. | |
| virtual void | dir_seek (fs_dir_t dir, off_t offset) |
| Set the current position of the directory. | |
| virtual off_t | dir_tell (fs_dir_t dir) |
| Get the current position of the directory. | |
| virtual void | dir_rewind (fs_dir_t dir) |
| Rewind the current position to the beginning of the directory. | |
| virtual size_t | dir_size (fs_dir_t dir) |
| Get the sizeof the directory. | |
Detailed Description
A filesystem-like object is one that can be used to open files though it by fopen("/name/filename", flags)
Implementations must define at least open (the default definitions of the rest of the functions just return error values).
Synchronization level: Set by subclass
Definition at line 42 of file FileSystem.h.
Constructor & Destructor Documentation
| FileSystem | ( | const char * | name = NULL ) |
FileSystem lifetime.
Member Function Documentation
| virtual int dir_close | ( | fs_dir_t | dir ) | [protected, virtual] |
Close a directory.
- Parameters:
-
dir Dir handle return 0 on success, negative error code on failure
Reimplemented in FATFileSystem.
| virtual int dir_open | ( | fs_dir_t * | dir, |
| const char * | path | ||
| ) | [protected, virtual] |
Open a directory on the filesystem.
- Parameters:
-
dir Destination for the handle to the directory path Name of the directory to open
- Returns:
- 0 on success, negative error code on failure
Reimplemented in FATFileSystem.
| virtual ssize_t dir_read | ( | fs_dir_t | dir, |
| struct dirent * | ent | ||
| ) | [protected, virtual] |
Read the next directory entry.
- Parameters:
-
dir Dir handle ent The directory entry to fill out
- Returns:
- 1 on reading a filename, 0 at end of directory, negative error on failure
Reimplemented in FATFileSystem.
| virtual void dir_rewind | ( | fs_dir_t | dir ) | [protected, virtual] |
Rewind the current position to the beginning of the directory.
- Parameters:
-
dir Dir handle
Reimplemented in FATFileSystem.
| virtual void dir_seek | ( | fs_dir_t | dir, |
| off_t | offset | ||
| ) | [protected, virtual] |
Set the current position of the directory.
- Parameters:
-
dir Dir handle offset Offset of the location to seek to, must be a value returned from dir_tell
Reimplemented in FATFileSystem.
| virtual size_t dir_size | ( | fs_dir_t | dir ) | [protected, virtual] |
| virtual off_t dir_tell | ( | fs_dir_t | dir ) | [protected, virtual] |
Get the current position of the directory.
- Parameters:
-
dir Dir handle
- Returns:
- Position of the directory that can be passed to dir_rewind
Reimplemented in FATFileSystem.
| virtual int file_close | ( | fs_file_t | file ) | [protected, pure virtual] |
Close a file.
- Parameters:
-
file File handle return 0 on success, negative error code on failure
Implemented in FATFileSystem.
| virtual int file_isatty | ( | fs_file_t | file ) | [protected, virtual] |
Check if the file in an interactive terminal device If so, line buffered behaviour is used by default.
- Parameters:
-
file File handle
- Returns:
- True if the file is a terminal
| virtual int file_open | ( | fs_file_t * | file, |
| const char * | path, | ||
| int | flags | ||
| ) | [protected, pure virtual] |
Open a file on the filesystem.
- Parameters:
-
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
- Returns:
- 0 on success, negative error code on failure
Implemented in FATFileSystem.
| virtual ssize_t file_read | ( | fs_file_t | file, |
| void * | buffer, | ||
| size_t | len | ||
| ) | [protected, pure virtual] |
Read the contents of a file into a buffer.
- Parameters:
-
file File handle buffer The buffer to read in to size The number of bytes to read
- Returns:
- The number of bytes read, 0 at end of file, negative error on failure
Implemented in FATFileSystem.
| virtual void file_rewind | ( | fs_file_t | file ) | [protected, virtual] |
Rewind the file position to the beginning of the file.
- Parameters:
-
file File handle
- Note:
- This is equivalent to file_seek(file, 0, FS_SEEK_SET)
| virtual off_t file_seek | ( | fs_file_t | file, |
| off_t | offset, | ||
| int | whence | ||
| ) | [protected, pure virtual] |
Move the file position to a given offset from from a given location.
- Parameters:
-
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
- Returns:
- The new offset of the file
Implemented in FATFileSystem.
| virtual size_t file_size | ( | fs_file_t | file ) | [protected, virtual] |
Get the size of the file.
- Parameters:
-
file File handle
- Returns:
- Size of the file in bytes
Reimplemented in FATFileSystem.
| virtual int file_sync | ( | fs_file_t | file ) | [protected, virtual] |
Flush any buffers associated with the file.
- Parameters:
-
file File handle
- Returns:
- 0 on success, negative error code on failure
Reimplemented in FATFileSystem.
| virtual off_t file_tell | ( | fs_file_t | file ) | [protected, virtual] |
Get the file position of the file.
- Parameters:
-
file File handle
- Returns:
- The current offset in the file
Reimplemented in FATFileSystem.
| virtual ssize_t file_write | ( | fs_file_t | file, |
| const void * | buffer, | ||
| size_t | len | ||
| ) | [protected, pure virtual] |
Write the contents of a buffer to a file.
- Parameters:
-
file File handle buffer The buffer to write from size The number of bytes to write
- Returns:
- The number of bytes written, negative error on failure
Implemented in FATFileSystem.
| virtual int mkdir | ( | const char * | path, |
| mode_t | mode | ||
| ) | [virtual] |
Create a directory in the filesystem.
- Parameters:
-
path The name of the directory to create. mode The permissions with which to create the directory
- Returns:
- 0 on success, negative error code on failure
Reimplemented in FATFileSystem.
| virtual int mount | ( | BlockDevice * | bd ) | [pure virtual] |
Mounts a filesystem to a block device.
- Parameters:
-
bd BlockDevice to mount to
- Returns:
- 0 on success, negative error code on failure
Implemented in FATFileSystem.
| virtual int remove | ( | const char * | path ) | [pure virtual] |
Remove a file from the filesystem.
- Parameters:
-
path The name of the file to remove.
- Returns:
- 0 on success, negative error code on failure
Implemented in FATFileSystem.
| virtual int rename | ( | const char * | path, |
| const char * | newpath | ||
| ) | [pure virtual] |
Rename a file in the filesystem.
- Parameters:
-
path The name of the file to rename. newpath The name to rename it to
- Returns:
- 0 on success, negative error code on failure
Implemented in FATFileSystem.
| virtual int stat | ( | const char * | path, |
| struct stat * | st | ||
| ) | [pure virtual] |
Store information about the file in a stat structure.
- Parameters:
-
path The name of the file to find information about st The stat buffer to write to
- Returns:
- 0 on success, negative error code on failure
Implemented in FATFileSystem.
| virtual int unmount | ( | ) | [pure virtual] |
Unmounts a filesystem from the underlying block device.
- Returns:
- 0 on success, negative error code on failure
Implemented in FATFileSystem.
Generated on Tue Jul 12 2022 11:02:42 by
1.7.2