F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
Loading...
Searching...
No Matches
File.hpp
Go to the documentation of this file.
1// ======================================================================
2// \title Os/Posix/File.hpp
3// \brief posix implementation for Os::File, header and test definitions
4// ======================================================================
5#include <Os/File.hpp>
6#ifndef OS_POSIX_FILE_HPP
7#define OS_POSIX_FILE_HPP
8
9namespace Os {
10namespace Posix {
11namespace File {
12
22
29class PosixFile : public FileInterface {
30 public:
33 PosixFile() = default;
34
36 PosixFile(const PosixFile& other);
37
39 PosixFile& operator=(const PosixFile& other);
40
43 ~PosixFile() override = default;
44
45 // ------------------------------------
46 // Functions overrides
47 // ------------------------------------
48
65 Os::FileInterface::Status open(const char* path, Mode mode, OverwriteType overwrite) override;
66
72 void close() override;
73
80 Status size(FwSignedSizeType& size_result) override;
81
88 Status position(FwSignedSizeType& position_result) override;
89
102 Status preallocate(FwSignedSizeType offset, FwSignedSizeType length) override;
103
113 Status seek(FwSignedSizeType offset, SeekType seekType) override;
114
122 Status flush() override;
123
142 Status read(U8* buffer, FwSignedSizeType& size, WaitType wait) override;
143
162 Status write(const U8* buffer, FwSignedSizeType& size, WaitType wait) override;
163
171 FileHandle* getHandle() override;
172
173 private:
175 PosixFileHandle m_handle;
176};
177} // namespace File
178} // namespace Posix
179} // namespace Os
180
181#endif // OS_POSIX_FILE_HPP
uint8_t U8
8-bit unsigned integer
Definition BasicTypes.h:30
int PlatformIntType
DefaultTypes.hpp provides fallback defaults for the platform types.
PlatformSignedSizeType FwSignedSizeType
Definition FpConfig.h:30
posix implementation of Os::File
Definition File.hpp:29
Status position(FwSignedSizeType &position_result) override
get file pointer position of the currently open file
Definition File.cpp:126
void close() override
close the file, if not opened then do nothing
Definition File.cpp:95
Status seek(FwSignedSizeType offset, SeekType seekType) override
seek the file pointer to the given offset
Definition File.cpp:186
Status preallocate(FwSignedSizeType offset, FwSignedSizeType length) override
pre-allocate file storage
Definition File.cpp:138
Status read(U8 *buffer, FwSignedSizeType &size, WaitType wait) override
read data from this file into supplied buffer bounded by size
Definition File.cpp:208
Status write(const U8 *buffer, FwSignedSizeType &size, WaitType wait) override
read data from this file into supplied buffer bounded by size
Definition File.cpp:244
FileHandle * getHandle() override
returns the raw file handle
Definition File.cpp:281
PosixFile()=default
constructor
Status size(FwSignedSizeType &size_result) override
get size of currently open file
Definition File.cpp:103
Status flush() override
flush file contents to storage
Definition File.cpp:199
PosixFile & operator=(const PosixFile &other)
assignment operator that copies the internal representation
Definition File.cpp:53
~PosixFile() override=default
destructor
Os::FileInterface::Status open(const char *path, Mode mode, OverwriteType overwrite) override
open file with supplied path and mode
Definition File.cpp:60
base implementation of FileHandle
Definition File.hpp:14
PlatformIntType m_file_descriptor
Posix file descriptor.
Definition File.hpp:20
static constexpr PlatformIntType INVALID_FILE_DESCRIPTOR
Definition File.hpp:16
static constexpr PlatformIntType ERROR_RETURN_VALUE
Definition File.hpp:17