31     m_delegate(*
FileInterface::getDelegate(m_handle_storage, &other.m_delegate)) {
 
   37         this->m_mode = other.m_mode;
 
   38         this->m_path = other.m_path;
 
   39         this->m_crc = other.m_crc;
 
   46     return this->
open(filepath, requested_mode, OverwriteType::NO_OVERWRITE);
 
   52     FW_ASSERT(File::Mode::OPEN_NO_MODE < requested_mode && File::Mode::MAX_OPEN_MODE > requested_mode);
 
   53     FW_ASSERT((0 <= this->m_mode) && (this->m_mode < Mode::MAX_OPEN_MODE));
 
   54     FW_ASSERT((0 <= overwrite) && (overwrite < OverwriteType::MAX_OVERWRITE_TYPE));
 
   57         return File::Status::INVALID_MODE;
 
   59     File::Status status = this->m_delegate.
open(filepath, requested_mode, overwrite);
 
   61         this->m_mode = requested_mode;
 
   62         this->m_path = filepath;
 
   64         this->m_crc = File::INITIAL_CRC;
 
   72     FW_ASSERT(this->m_mode < Mode::MAX_OPEN_MODE);
 
   73     FW_ASSERT((0 <= this->m_mode) && (this->m_mode < Mode::MAX_OPEN_MODE));
 
   74     this->m_delegate.
close();
 
   75     this->m_mode = Mode::OPEN_NO_MODE;
 
   76     this->m_path = 
nullptr;
 
   81     FW_ASSERT((0 <= this->m_mode) && (this->m_mode < Mode::MAX_OPEN_MODE));
 
   82     return this->m_mode != Mode::OPEN_NO_MODE;
 
   87     FW_ASSERT((0 <= this->m_mode) && (this->m_mode < Mode::MAX_OPEN_MODE));
 
   89         return File::Status::NOT_OPENED;
 
   91     return this->m_delegate.
size(size_result);
 
   96     FW_ASSERT((0 <= this->m_mode) && (this->m_mode < Mode::MAX_OPEN_MODE));
 
   99         return File::Status::NOT_OPENED;
 
  101     return this->m_delegate.
position(position_result);
 
  108     FW_ASSERT((0 <= this->m_mode) && (this->m_mode < Mode::MAX_OPEN_MODE));
 
  111         return File::Status::NOT_OPENED;
 
  113         return File::Status::INVALID_MODE;
 
  115     return this->m_delegate.
preallocate(offset, length);
 
  120     FW_ASSERT((0 <= seekType) && (seekType < SeekType::MAX_SEEK_TYPE));
 
  122     FW_ASSERT((seekType == File::SeekType::RELATIVE) || (offset >= 0));
 
  123     FW_ASSERT((0 <= this->m_mode) && (this->m_mode < Mode::MAX_OPEN_MODE));
 
  126         return File::Status::NOT_OPENED;
 
  128     return this->m_delegate.
seek(offset, seekType);
 
  133     FW_ASSERT(this->m_mode < Mode::MAX_OPEN_MODE);
 
  136         return File::Status::NOT_OPENED;
 
  138         return File::Status::INVALID_MODE;
 
  140     return this->m_delegate.
flush();
 
  144     return this->
read(buffer, 
size, WaitType::WAIT);
 
  151     FW_ASSERT(this->m_mode < Mode::MAX_OPEN_MODE);
 
  155         return File::Status::NOT_OPENED;
 
  158         return File::Status::INVALID_MODE;
 
  160     return this->m_delegate.
read(buffer, 
size, wait);
 
  164     return this->
write(buffer, 
size, WaitType::WAIT);
 
  172     FW_ASSERT(this->m_mode < Mode::MAX_OPEN_MODE);
 
  176         return File::Status::NOT_OPENED;
 
  179         return File::Status::INVALID_MODE;
 
  181     return this->m_delegate.
write(buffer, 
size, wait);
 
  193     for (
FwSizeType i = 0; i < std::numeric_limits<FwSizeType>::max(); i++) {
 
  212         status = File::Status::NOT_OPENED;
 
  214         status = File::Status::INVALID_MODE;
 
  217         status = this->
read(this->m_crc_buffer, 
size, File::WaitType::NO_WAIT);
 
  218         if (
OP_OK == status) {
 
  233     this->m_crc = File::INITIAL_CRC;
 
  242     FW_ASSERT(this->m_mode < Mode::MAX_OPEN_MODE);
 
  246         return File::Status::NOT_OPENED;
 
  249         return File::Status::INVALID_MODE;
 
  261         read = current_chunk_size;
 
  262         status = this->
read(buffer + i, 
read, wait);
 
  264             (void) this->
seek(original_location, File::SeekType::ABSOLUTE);
 
  275             if (buffer[j] == 
'\n') {
 
  279                 (void) this->
seek(original_location + j + 1, File::SeekType::ABSOLUTE);
 
#define FW_MIN(a, b)
MIN macro.
 
uint8_t U8
8-bit unsigned integer
 
PlatformSignedSizeType FwSignedSizeType
 
#define FW_FILE_CHUNK_SIZE
Chunk size for working with files in the OSAL layer.
 
PlatformSizeType FwSizeType
 
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
 
virtual Status flush()=0
flush file contents to storage
 
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
 
@ OP_OK
Operation was successful.
 
@ OPEN_NO_MODE
File mode not yet selected.
 
@ OPEN_READ
Open file for reading.
 
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
 
unsigned long update_crc_32(unsigned long crc, char c)
 
@ OP_OK
Operation succeeded.
 
@ OTHER_ERROR
A catch-all for other errors. Have to look in implementation-specific code.
 
base implementation of FileHandle