6 #ifndef _OS_FILESYSTEM_HPP_
7 #define _OS_FILESYSTEM_HPP_
90 virtual Status _rename(
const char* sourcePath,
const char* destPath) = 0;
158 Status _rename(
const char* sourcePath,
const char* destPath)
override;
223 static Status rename(
const char* sourcePath,
const char* destPath);
267 static bool exists(
const char* path);
309 static Status appendFile(
const char* sourcePath,
const char* destPath,
bool createMissingDest=
false);
321 static Status copyFile(
const char* sourcePath,
const char* destPath);
333 static Status moveFile(
const char* sourcePath,
const char* destPath);
#define FW_HANDLE_ALIGNMENT
Alignment of handle storage.
PlatformSignedSizeType FwSignedSizeType
#define FW_FILE_CHUNK_SIZE
Chunk size for working with files in the OSAL layer.
PlatformSizeType FwSizeType
C++-compatible configuration header for fprime configuration.
U8 FileSystemHandleStorage[FW_FILESYSTEM_HANDLE_MAX_SIZE]
static Status moveFile(const char *sourcePath, const char *destPath)
Move a file from sourcePath to destPath.
static void init()
initialize singleton
static bool exists(const char *path)
Return true if the path exists, false otherwise.
static FileSystem & getSingleton()
get a reference to singleton
~FileSystem() final
Destructor.
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.
Status _getFreeSpace(const char *path, FwSizeType &totalBytes, FwSizeType &freeBytes) override
Get filesystem free and total space in bytes on the filesystem containing the specified path.
Status _changeWorkingDirectory(const char *path) override
Change the current working directory to the specified path.
static Status appendFile(const char *sourcePath, const char *destPath, bool createMissingDest=false)
Append the source file to the destination file.
Status _rename(const char *sourcePath, const char *destPath) override
Rename a file from source to destination.
static Status removeFile(const char *path)
Remove a file at the specified path.
static Status removeDirectory(const char *path)
Remove a directory at the specified path.
static Status copyFile(const char *sourcePath, const char *destPath)
Copy a file from the source path to the destination path.
static PathType getPathType(const char *path)
Return the type of the path (file, directory, or doesn't exist)
FileSystemHandle * getHandle() override
return the underlying FileSystem handle (implementation specific)
static Status getWorkingDirectory(char *path, FwSizeType bufferSize)
Get the current working directory.
static Status rename(const char *sourcePath, const char *destPath)
Rename a file from source to destination.
static Status getFileSize(const char *path, FwSignedSizeType &size)
Get the size of the file (in bytes) at the specified path.
static Status changeWorkingDirectory(const char *path)
Change the current working directory to the specified path.
static Status createDirectory(const char *path, bool errorIfAlreadyExists=false)
Create a new directory at the specified path.
Status _removeDirectory(const char *path) override
Remove a directory at the specified path.
Status _removeFile(const char *path) override
Remove a file at the specified path.
static Status touch(const char *path)
Touch a file at the specified path, creating it if it doesn't exist.
Status _getWorkingDirectory(char *path, FwSizeType bufferSize) override
Get the current working directory.
virtual Status _removeDirectory(const char *path)=0
Remove a directory at the specified path.
@ NO_MORE_FILES
Directory stream has no more files.
@ ALREADY_EXISTS
File already exists.
@ NO_PERMISSION
No permission to write.
@ OP_OK
Operation was successful.
@ NOT_DIR
Path is not a directory.
@ OTHER_ERROR
other OS-specific error
@ IS_DIR
Path is a directory.
@ NOT_SUPPORTED
Operation is not supported by the current implementation.
@ NOT_EMPTY
directory is not empty
@ BUFFER_TOO_SMALL
Buffer size is too small to hold full path (for getWorkingDirectory)
@ DOESNT_EXIST
Path doesn't exist.
@ BUSY
Operand is in use by the system or by a process.
@ FILE_LIMIT
Too many files or links.
@ INVALID_PATH
Path is too long, too many sym links, etc.
virtual Status _getFreeSpace(const char *path, FwSizeType &totalBytes, FwSizeType &freeBytes)=0
Get filesystem free and total space in bytes on the filesystem containing the specified path.
static constexpr FwSignedSizeType FILE_SYSTEM_FILE_CHUNK_SIZE
Size of file system chunk.
static FileSystemInterface * getDelegate(FileSystemHandleStorage &aligned_new_memory)
provide a pointer to a FileSystem delegate object
FileSystemInterface & operator=(const FileSystemInterface &other)=delete
assignment operator is forbidden
@ DIRECTORY
Path is a directory.
@ NOT_EXIST
Path does not exist.
virtual Status _removeFile(const char *path)=0
Remove a file at the specified path.
virtual FileSystemHandle * getHandle()=0
return the underlying FileSystem handle (implementation specific)
FileSystemInterface(const FileSystemInterface &other)=delete
copy constructor is forbidden
virtual ~FileSystemInterface()=default
default virtual destructor
virtual Status _changeWorkingDirectory(const char *path)=0
Change the current working directory to the specified path.
FileSystemInterface()=default
default constructor
virtual Status _rename(const char *sourcePath, const char *destPath)=0
Rename (or move) a file from source to destination.
virtual Status _getWorkingDirectory(char *path, FwSizeType bufferSize)=0
Get the current working directory.