![]() |
F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
|
FileSystem class. More...
#include <Os/FileSystem.hpp>
Public Member Functions | |
| ~FileSystemCommon () | |
| Destructor. More... | |
| FileSystemHandle * | getHandle () |
| return the underlying FileSystem handle (implementation specific) More... | |
| Status | _removeDirectory (const char *path) |
| Remove a directory at the specified path. More... | |
| Status | _removeFile (const char *path) |
| Remove a file at the specified path. More... | |
| Status | _rename (const char *sourcePath, const char *destPath) |
| Rename a file from source to destination. More... | |
| Status | _getFreeSpace (const char *path, FwSizeType &totalBytes, FwSizeType &freeBytes) |
| Get filesystem free and total space in bytes on the filesystem containing the specified path. More... | |
| Status | _getWorkingDirectory (char *path, FwSizeType bufferSize) |
| Get the current working directory. More... | |
| Status | _changeWorkingDirectory (const char *path) |
| Change the current working directory to the specified path. More... | |
| Status | _getPathType (const char *path, PathType &pathType) |
| Get the type of the path (file, directory, etc.) More... | |
Static Public Member Functions | |
| static Status | removeDirectory (const char *path) |
| Remove a directory at the specified path. More... | |
| static Status | removeFile (const char *path) |
| Remove a file at the specified path. More... | |
| static Status | rename (const char *sourcePath, const char *destPath) |
| Rename a file from source to destination. More... | |
| static Status | getFreeSpace (const char *path, FwSizeType &totalBytes, FwSizeType &freeBytes) |
| Get filesystem free and total space in bytes on the filesystem containing the specified path. More... | |
| static Status | getWorkingDirectory (char *path, FwSizeType bufferSize) |
| Get the current working directory. More... | |
| static Status | changeWorkingDirectory (const char *path) |
| Change the current working directory to the specified path. More... | |
| static bool | exists (const char *path) |
| Return true if the path exists, false otherwise. More... | |
| static PathType | getPathType (const char *path) |
| Return the type of the path (file, directory, or doesn't exist) More... | |
| static Status | touch (const char *path) |
| Touch a file at the specified path, creating it if it doesn't exist. More... | |
| static Status | createDirectory (const char *path, bool errorIfAlreadyExists=false) |
| Create a new directory at the specified path. More... | |
| static Status | appendFile (const char *sourcePath, const char *destPath, bool createMissingDest=false) |
| Append the source file to the destination file. More... | |
| static Status | copyFile (const char *sourcePath, const char *destPath) |
| Copy a file from the source path to the destination path. More... | |
| static Status | moveFile (const char *sourcePath, const char *destPath) |
| Move a file from sourcePath to destPath. More... | |
| static Status | getFileSize (const char *path, FwSizeType &size) |
| Get the size of the file (in bytes) at the specified path. More... | |
| static void | init () |
| initialize singleton More... | |
| static FileSystemCommon & | getSingleton () |
| get a reference to singleton More... | |
Additional Inherited Members | |
Public Types inherited from Os::FileSystemUserInterface | |
| enum | Status { OP_OK, ALREADY_EXISTS, NO_SPACE, NO_PERMISSION, NOT_DIR, IS_DIR, NOT_EMPTY, INVALID_PATH, DOESNT_EXIST, FILE_LIMIT, BUSY, NO_MORE_FILES, BUFFER_TOO_SMALL, EXDEV_ERROR, OVERFLOW_ERROR, NOT_SUPPORTED, OTHER_ERROR } |
| enum | PathType { FILE, DIRECTORY, OTHER, NOT_EXIST } |
Static Public Attributes inherited from Os::FileSystemUserInterface | |
| static constexpr FwSizeType | FILE_SYSTEM_FILE_CHUNK_SIZE = FW_FILE_CHUNK_SIZE |
| Size of file system chunk. More... | |
FileSystem class.
This class provides a common interface for file system operations. This class uses the singleton pattern and should be accessed through its static functions, for example using Os::FileSystem::removeFile(path).
Definition at line 24 of file FileSystem.hpp.
| Os::FileSystemCommon< T >::~FileSystemCommon | ( | ) |
Destructor.
Definition at line 321 of file FileSystem.hpp.
| FileSystemCommon< T >::Status Os::FileSystemCommon< T >::_changeWorkingDirectory | ( | const char * | path | ) |
Change the current working directory to the specified path.
It is invalid to pass nullptr as the path.
| path | The path of the new working directory |
Definition at line 361 of file FileSystem.hpp.
| FileSystemCommon< T >::Status Os::FileSystemCommon< T >::_getFreeSpace | ( | const char * | path, |
| FwSizeType & | totalBytes, | ||
| FwSizeType & | freeBytes | ||
| ) |
Get filesystem free and total space in bytes on the filesystem containing the specified path.
It is invalid to pass nullptr as the path.
| path | The path on the filesystem to query |
| totalBytes | Reference to store the total bytes on the filesystem |
| freeBytes | Reference to store the free bytes on the filesystem |
Definition at line 367 of file FileSystem.hpp.
| FileSystemCommon< T >::Status Os::FileSystemCommon< T >::_getPathType | ( | const char * | path, |
| PathType & | pathType | ||
| ) |
Get the type of the path (file, directory, etc.)
It is invalid to pass nullptr as the path.
| path | The path to check |
| pathType | Reference to store the path type |
Definition at line 348 of file FileSystem.hpp.
| FileSystemCommon< T >::Status Os::FileSystemCommon< T >::_getWorkingDirectory | ( | char * | path, |
| FwSizeType | bufferSize | ||
| ) |
Get the current working directory.
Writes the current working directory path to the provided buffer of size bufferSize. If the buffer is too small to hold the full path, the function will return BUFFER_TOO_SMALL.
It is invalid to pass nullptr as the path. It is invalid to pass a bufferSize of 0.
| path | Buffer to store the current working directory path |
| bufferSize | Size of the buffer |
Definition at line 354 of file FileSystem.hpp.
| FileSystemCommon< T >::Status Os::FileSystemCommon< T >::_removeDirectory | ( | const char * | path | ) |
Remove a directory at the specified path.
It is invalid to pass nullptr as the path.
| path | The path of the directory to remove |
Definition at line 329 of file FileSystem.hpp.
| FileSystemCommon< T >::Status Os::FileSystemCommon< T >::_removeFile | ( | const char * | path | ) |
Remove a file at the specified path.
It is invalid to pass nullptr as the path.
| path | The path of the file to remove |
Definition at line 335 of file FileSystem.hpp.
| FileSystemCommon< T >::Status Os::FileSystemCommon< T >::_rename | ( | const char * | sourcePath, |
| const char * | destPath | ||
| ) |
Rename a file from source to destination.
If the rename fails due to a cross-device operation, this function should return EXDEV_ERROR and moveFile can be used instead to force a copy-and-remove.
It is invalid to pass nullptr as sourcePath or destPath.
| sourcePath | The path of the source file |
| destPath | The path of the destination file |
Definition at line 341 of file FileSystem.hpp.
|
static |
Append the source file to the destination file.
This function opens both files, and iteratively reads the source by chunks and writes chunks to the destination. If the destination file does not exist and createMissingDest is true, a new file is created.
It is invalid to pass nullptr as either the source or destination path.
| sourcePath | The path of the source file |
| destPath | The path of the destination file |
| createMissingDest | If true, creates a new file if the destination doesn't exist |
Definition at line 498 of file FileSystem.hpp.
|
static |
Change the current working directory to the specified path.
It is invalid to pass nullptr as the path.
| path | The path of the new working directory |
Definition at line 411 of file FileSystem.hpp.
|
static |
Copy a file from the source path to the destination path.
This function opens both files, and iteratively reads the source by chunks and writes chunks to the destination.
It is invalid to pass nullptr as either the source or destination path.
| sourcePath | The path of the source file |
| destPath | The path of the destination file |
Definition at line 472 of file FileSystem.hpp.
|
static |
Create a new directory at the specified path.
The optional errorIfAlreadyExists (default=false) parameter can be set to true to return an error status if the directory already exists.
It is invalid to pass nullptr as the path.
| path | The path where the new directory will be created |
| errorIfAlreadyExists | If true, returns an error if the directory already exists |
Definition at line 427 of file FileSystem.hpp.
|
static |
Return true if the path exists, false otherwise.
It is invalid to pass nullptr as the path.
| path | The path to check for existence |
Definition at line 467 of file FileSystem.hpp.
|
static |
Get the size of the file (in bytes) at the specified path.
It is invalid to pass nullptr as the path.
| path | The path of the file |
| size | Reference to store the size of the file |
Definition at line 552 of file FileSystem.hpp.
|
static |
Get filesystem free and total space in bytes on the filesystem containing the specified path.
It is invalid to pass nullptr as the path.
| path | The path on the filesystem to query |
| totalBytes | Reference to store the total bytes on the filesystem |
| freeBytes | Reference to store the free bytes on the filesystem |
Definition at line 416 of file FileSystem.hpp.
| FileSystemHandle * Os::FileSystemCommon< T >::getHandle | ( | ) |
return the underlying FileSystem handle (implementation specific)
Definition at line 324 of file FileSystem.hpp.
|
static |
Return the type of the path (file, directory, or doesn't exist)
It is invalid to pass nullptr as the path.
| path | The path to check for existence |
Definition at line 456 of file FileSystem.hpp.
|
static |
get a reference to singleton
Definition at line 381 of file FileSystem.hpp.
|
static |
Get the current working directory.
Writes the current working directory path to the provided buffer of size bufferSize. If the buffer is too small to hold the full path, the function will return BUFFER_TOO_SMALL.
It is invalid to pass nullptr as the path. It is invalid to pass a bufferSize of 0.
| path | Buffer to store the current working directory path |
| bufferSize | Size of the buffer |
Definition at line 406 of file FileSystem.hpp.
|
static |
initialize singleton
Definition at line 375 of file FileSystem.hpp.
|
static |
Move a file from sourcePath to destPath.
This is done by first trying to rename, and if renaming fails, copy it and then remove the original
It is invalid to pass nullptr as either the source or destination path.
| sourcePath | The path of the source file |
| destPath | The path of the destination file |
Definition at line 533 of file FileSystem.hpp.
|
static |
Remove a directory at the specified path.
It is invalid to pass nullptr as the path.
| path | The path of the directory to remove |
Definition at line 391 of file FileSystem.hpp.
|
static |
Remove a file at the specified path.
It is invalid to pass nullptr as the path.
| path | The path of the file to remove |
Definition at line 396 of file FileSystem.hpp.
|
static |
Rename a file from source to destination.
If the rename fails due to a cross-device operation, this function should return EXDEV_ERROR and moveFile can be used instead to force a copy-and-remove.
It is invalid to pass nullptr as sourcePath or destPath.
| sourcePath | The path of the source file |
| destPath | The path of the destination file |
Definition at line 401 of file FileSystem.hpp.
|
static |
Touch a file at the specified path, creating it if it doesn't exist.
It is invalid to pass nullptr as the path.
| path | The path of the file to touch |
Definition at line 443 of file FileSystem.hpp.