F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
FileInterface.hpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title Os/Interfaces/FileInterface.hpp
3 // \brief pure-virtual interface implemented by Os::File implementations
4 // ======================================================================
5 #ifndef OS_INTERFACES_FILEINTERFACE_HPP_
6 #define OS_INTERFACES_FILEINTERFACE_HPP_
7 
9 
10 namespace Os {
11 
12 // This class encapsulates a very simple file interface that has the most often-used features
14  public:
15  virtual ~FileInterface() = default;
16 
33  virtual Status open(const char* path, Mode mode, OverwriteType overwrite) = 0;
34 
40  virtual void close() = 0;
41 
48  virtual Status size(FwSizeType& size_result) = 0;
49 
56  virtual Status position(FwSizeType& position_result) = 0;
57 
70  virtual Status preallocate(FwSizeType offset, FwSizeType length) = 0;
71 
81  virtual Status seek(FwSignedSizeType offset, SeekType seekType) = 0;
82 
90  virtual Status flush() = 0;
91 
110  virtual Status read(U8* buffer, FwSizeType& size, WaitType wait) = 0;
111 
130  virtual Status write(const U8* buffer, FwSizeType& size, WaitType wait) = 0;
131 
139  virtual FileHandle* getHandle() = 0;
140 };
141 
142 } // namespace Os
143 
144 #endif // OS_INTERFACES_FILEINTERFACE_HPP_
virtual Status open(const char *path, Mode mode, OverwriteType overwrite)=0
open file with supplied path and mode
base implementation of FileHandle
PlatformSizeType FwSizeType
virtual void close()=0
close the file, if not opened then do nothing
PlatformSignedSizeType FwSignedSizeType
virtual FileHandle * getHandle()=0
returns the raw file handle
virtual ~FileInterface()=default
virtual Status size(FwSizeType &size_result)=0
get size of currently open file
virtual Status flush()=0
flush file contents to storage
virtual Status seek(FwSignedSizeType offset, SeekType seekType)=0
seek the file pointer to the given offset
types and constants shared by users of Os::File and by its implementations
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:54
virtual Status write(const U8 *buffer, FwSizeType &size, WaitType wait)=0
read data from this file into supplied buffer bounded by size
virtual Status preallocate(FwSizeType offset, FwSizeType length)=0
pre-allocate file storage
virtual Status position(FwSizeType &position_result)=0
get file pointer position of the currently open file
virtual Status read(U8 *buffer, FwSizeType &size, WaitType wait)=0
read data from this file into supplied buffer bounded by size