5 #ifndef Os_SandboxedFile_hpp_ 6 #define Os_SandboxedFile_hpp_ 67 void configure(
const char* allowedDirectory);
void configure(const char *allowedDirectory)
Configure the allowed sandbox directory.
Os::FileInterface::Status flush()
Flush file contents to storage.
PlatformSizeType FwSizeType
bool isOpen() const
Check if the file is open.
Os::FileInterface::Status calculateCrc(U32 &crc)
Calculate CRC32 of the entire file.
Os::FileInterface::Status position(FwSizeType &position_result)
Get file pointer position.
Os::FileInterface::Status seek(FwSignedSizeType offset, Os::FileInterface::SeekType seekType)
Seek file pointer.
A wrapper around Os::File that restricts file access to an allowed directory.
~SandboxedFile()
Destroy the SandboxedFile (closes the underlying file if open)
PlatformSignedSizeType FwSignedSizeType
SandboxedFile & operator=(const SandboxedFile &)=delete
Non-copy-assignable.
SandboxedFile()
Construct a SandboxedFile with default sandbox of /
const char * getSandboxDirectory() const
Get the configured sandbox directory.
Os::FileInterface::Status open(const char *path, Os::FileInterface::Mode mode, Os::FileInterface::OverwriteType overwrite=Os::FileInterface::NO_OVERWRITE)
Open a file, validating the path against the sandbox directory.
bool isConfigured() const
Check if a sandbox directory has been configured.
Os::FileInterface::Status size(FwSizeType &size_result)
Get size of currently open file.
Os::FileInterface::Status write(const U8 *buffer, FwSizeType &size, Os::FileInterface::WaitType wait)
Write data to the file.
uint8_t U8
8-bit unsigned integer
Do NOT overwrite existing files.
Os::FileInterface::Status preallocate(FwSizeType offset, FwSizeType length)
Pre-allocate file storage.
Os::FileInterface::Status read(U8 *buffer, FwSizeType &size, Os::FileInterface::WaitType wait)
Read data from the file.
void close()
Close the file.