F´ Flight Software - C/C++ Documentation  devel
A framework for building embedded system applications to NASA flight quality standards.
File.hpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title Os/Stub/File.hpp
3 // \brief stub file definitions for Os::File
4 // ======================================================================
5 #include "Os/File.hpp"
6 
7 #ifndef OS_STUB_FILE_HPP
8 #define OS_STUB_FILE_HPP
9 namespace Os {
10 namespace Stub {
11 namespace File {
12 
13 struct StubFileHandle : public FileHandle {};
14 
19 class StubFile : public FileInterface {
20  public:
23  StubFile() = default;
24 
27  ~StubFile() override = default;
28 
29  // ------------------------------------
30  // Functions overrides
31  // ------------------------------------
32 
46  Os::FileInterface::Status open(const char *path, Mode mode, OverwriteType overwrite) override;
47 
52  void close() override;
53 
60  Status size(FwSignedSizeType &size_result) override;
61 
68  Status position(FwSignedSizeType &position_result) override;
69 
81  Status preallocate(FwSignedSizeType offset, FwSignedSizeType length) override;
82 
91  Status seek(FwSignedSizeType offset, SeekType seekType) override;
92 
99  Status flush() override;
100 
114  Status read(U8 *buffer, FwSignedSizeType &size, WaitType wait) override;
115 
129  Status write(const U8 *buffer, FwSignedSizeType &size, WaitType wait) override;
130 
138  FileHandle *getHandle() override;
139 
140 
141 private:
143  StubFileHandle m_handle;
144 };
145 
146 } // namespace File
147 } // namespace Stub
148 } // namespace Os
149 #endif // OS_STUB_FILE_HPP
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:30
PlatformSignedSizeType FwSignedSizeType
Definition: FpConfig.h:30
stub implementation of Os::File
Definition: File.hpp:19
Status preallocate(FwSignedSizeType offset, FwSignedSizeType length) override
pre-allocate file storage
Definition: File.cpp:28
Status read(U8 *buffer, FwSignedSizeType &size, WaitType wait) override
read data from this file into supplied buffer bounded by size
Definition: File.cpp:43
Status size(FwSignedSizeType &size_result) override
get size of currently open file
Definition: File.cpp:18
void close() override
close the file, if not opened then do nothing
Definition: File.cpp:16
Os::FileInterface::Status open(const char *path, Mode mode, OverwriteType overwrite) override
open file with supplied path and mode
Definition: File.cpp:11
Status seek(FwSignedSizeType offset, SeekType seekType) override
seek the file pointer to the given offset
Definition: File.cpp:33
FileHandle * getHandle() override
returns the raw file handle
Definition: File.cpp:53
Status flush() override
flush file contents to storage
Definition: File.cpp:38
Status write(const U8 *buffer, FwSignedSizeType &size, WaitType wait) override
read data from this file into supplied buffer bounded by size
Definition: File.cpp:48
~StubFile() override=default
destructor
Status position(FwSignedSizeType &position_result) override
get file pointer position of the currently open file
Definition: File.cpp:23
StubFile()=default
constructor
base implementation of FileHandle
Definition: File.hpp:14