317 void close()
override;
495 static const U32 INITIAL_CRC = 0xFFFFFFFF;
496 Mode m_mode = Mode::OPEN_NO_MODE;
497 const CHAR* m_path =
nullptr;
499 U32 m_crc = File::INITIAL_CRC;
uint8_t U8
8-bit unsigned integer
#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.
C++-compatible configuration header for fprime configuration.
U8 FileHandleStorage[FW_FILE_HANDLE_MAX_SIZE]
Status seek(FwSignedSizeType offset, SeekType seekType) override
seek the file pointer to the given offset
Status incrementalCrc(FwSignedSizeType &size)
calculate the CRC32 of the next section of data
Status read(U8 *buffer, FwSignedSizeType &size)
read data from this file into supplied buffer bounded by size
Status flush() override
flush file contents to storage
Status size(FwSignedSizeType &size_result) override
get size of currently open file
void close() override
close the file, if not opened then do nothing
Status finalizeCrc(U32 &crc)
finalize and retrieve the CRC value
Status readline(U8 *buffer, FwSignedSizeType &size, WaitType wait)
read a line from the file using \n as the delimiter
FileHandle * getHandle() override
returns the raw file handle
Os::FileInterface::Status open(const char *path, Mode mode)
open file with supplied path and mode
Status preallocate(FwSignedSizeType offset, FwSignedSizeType length) override
pre-allocate file storage
Status position(FwSignedSizeType &position_result) override
get file pointer position of the currently open file
Status calculateCrc(U32 &crc)
calculate the CRC32 of the entire file
bool isOpen() const
determine if the file is open
File & operator=(const File &other)
assignment operator that copies the internal representation
Status write(const U8 *buffer, FwSignedSizeType &size)
write data to this file from the supplied buffer bounded by size
virtual void close()=0
close the file, if not opened then do nothing
virtual Status size(FwSignedSizeType &size_result)=0
get size of currently open file
virtual Status preallocate(FwSignedSizeType offset, FwSignedSizeType length)=0
pre-allocate file storage
@ WAIT
Do wait for read/write operation to finish.
@ NO_WAIT
Do not wait for read/write operation to finish.
virtual Status flush()=0
flush file contents to storage
@ NO_OVERWRITE
Do NOT overwrite existing files.
@ OVERWRITE
Overwrite file when it exists and creation was requested.
static FileInterface * getDelegate(FileHandleStorage &aligned_placement_new_memory, const FileInterface *to_copy=nullptr)
provide a pointer to a file delegate object
virtual Status write(const U8 *buffer, FwSignedSizeType &size, WaitType wait)=0
read data from this file into supplied buffer bounded by size
virtual Status position(FwSignedSizeType &position_result)=0
get file pointer position of the currently open file
virtual Status open(const char *path, Mode mode, OverwriteType overwrite)=0
open file with supplied path and mode
virtual Status read(U8 *buffer, FwSignedSizeType &size, WaitType wait)=0
read data from this file into supplied buffer bounded by size
@ NOT_SUPPORTED
Kernel or file system does not support operation.
@ INVALID_ARGUMENT
Invalid argument passed in.
@ INVALID_MODE
Mode for file access is invalid for current operation.
@ NO_PERMISSION
No permission to read/write file.
@ MAX_STATUS
Maximum value of status.
@ NOT_OPENED
file hasn't been opened yet
@ OTHER_ERROR
A catch-all for other errors. Have to look in implementation-specific code.
@ BAD_SIZE
Invalid size parameter.
@ OP_OK
Operation was successful.
@ DOESNT_EXIST
File doesn't exist (for read)
@ FILE_EXISTS
file already exist (for CREATE with O_EXCL enabled)
@ ABSOLUTE
Absolute seek from beginning of file.
@ RELATIVE
Relative seek from current file offset.
@ MAX_OPEN_MODE
Maximum value of mode.
@ OPEN_NO_MODE
File mode not yet selected.
@ OPEN_WRITE
Open file for writing.
@ OPEN_CREATE
Open file for writing and truncates file if it exists, ie same flags as creat()
@ OPEN_READ
Open file for reading.
@ OPEN_APPEND
Open file for appending.
@ OPEN_SYNC_WRITE
Open file for writing; writes don't return until data is on disk.
virtual FileHandle * getHandle()=0
returns the raw file handle
virtual Status seek(FwSignedSizeType offset, SeekType seekType)=0
seek the file pointer to the given offset
virtual ~FileInterface()=default
base implementation of FileHandle