![]() |
F´ Flight Software - C/C++ Documentation
devel
A framework for building embedded system applications to NASA flight quality standards.
|
#include <Os/File.hpp>
Public Types | |
| enum | Mode { OPEN_NO_MODE , OPEN_READ , OPEN_WRITE , OPEN_SYNC_WRITE , OPEN_SYNC_DIRECT_WRITE , OPEN_CREATE , OPEN_APPEND } |
| enum | Status { OP_OK , DOESNT_EXIST , NO_SPACE , NO_PERMISSION , BAD_SIZE , NOT_OPENED , FILE_EXISTS , OTHER_ERROR } |
Public Member Functions | |
| File () | |
| Constructor. More... | |
| virtual | ~File () |
| Destructor. Will close file if still open. More... | |
| Status | prealloc (NATIVE_INT_TYPE offset, NATIVE_INT_TYPE len) |
| Status | open (const char *fileName, Mode mode) |
| open file. Writing creates file if it doesn't exist More... | |
| Status | open (const char *fileName, Mode mode, bool include_excl) |
| open file. Writing creates file if it doesn't exist More... | |
| bool | isOpen () |
| check if file descriptor is open or not. More... | |
| Status | seek (NATIVE_INT_TYPE offset, bool absolute=true) |
| seek to location. If absolute = true, absolute from beginning of file More... | |
| Status | flush () |
| flush data to disk. No-op on systems that do not support. More... | |
| Status | read (void *buffer, NATIVE_INT_TYPE &size, bool waitForFull=true) |
| waitForFull = true to wait for all bytes to be read More... | |
| Status | write (const void *buffer, NATIVE_INT_TYPE &size, bool waitForDone=true) |
| write size; will return amount written or errno More... | |
| Status | bulkWrite (const void *buffer, NATIVE_UINT_TYPE &totalSize, NATIVE_INT_TYPE chunkSize) |
| write size; will return amount written or errno More... | |
| void | close () |
| close file More... | |
| NATIVE_INT_TYPE | getLastError () |
| read back last error code (typically errno) More... | |
| const char * | getLastErrorString () |
| get a string of the last error (typically from strerror) More... | |
| Status | calculateCRC32 (U32 &crc) |
| calculates the CRC32 of the file More... | |
Static Public Member Functions | |
| static Status | niceCRC32 (U32 &crc, const char *fileName) |
| Calculates CRC32 of file, not burdening FS. More... | |
| enum Os::File::Mode |
| Enumerator | |
|---|---|
| OPEN_NO_MODE | File mode not yet selected. |
| OPEN_READ | Open file for reading. |
| OPEN_WRITE | Open file for writing. |
| OPEN_SYNC_WRITE | Open file for writing; writes don't return until data is on disk. |
| OPEN_SYNC_DIRECT_WRITE | Open file for writing, bypassing all caching. Requires data alignment. |
| OPEN_CREATE | Open file for writing and truncates file if it exists, ie same flags as creat() |
| OPEN_APPEND | Open file for appending. |
| enum Os::File::Status |
| Enumerator | |
|---|---|
| OP_OK | Operation was successful. |
| DOESNT_EXIST | File doesn't exist (for read) |
| NO_SPACE | No space left. |
| NO_PERMISSION | No permission to read/write file. |
| BAD_SIZE | Invalid size parameter. |
| NOT_OPENED | file hasn't been opened yet |
| FILE_EXISTS | file already exist (for CREATE with O_EXCL enabled) |
| OTHER_ERROR | A catch-all for other errors. Have to look in implementation-specific code. |
|
virtual |
| File::Status Os::File::bulkWrite | ( | const void * | buffer, |
| NATIVE_UINT_TYPE & | totalSize, | ||
| NATIVE_INT_TYPE | chunkSize | ||
| ) |
| File::Status Os::File::calculateCRC32 | ( | U32 & | crc | ) |
| File::Status Os::File::flush | ( | ) |
| NATIVE_INT_TYPE Os::File::getLastError | ( | ) |
| const char * Os::File::getLastErrorString | ( | ) |
| bool Os::File::isOpen | ( | ) |
|
static |
Calculates CRC32 of file, not burdening FS.
Definition at line 16 of file FileCommon.cpp.
| File::Status Os::File::open | ( | const char * | fileName, |
| File::Mode | mode | ||
| ) |
| File::Status Os::File::open | ( | const char * | fileName, |
| File::Mode | mode, | ||
| bool | include_excl | ||
| ) |
| File::Status Os::File::prealloc | ( | NATIVE_INT_TYPE | offset, |
| NATIVE_INT_TYPE | len | ||
| ) |
| File::Status Os::File::read | ( | void * | buffer, |
| NATIVE_INT_TYPE & | size, | ||
| bool | waitForFull = true |
||
| ) |
| File::Status Os::File::seek | ( | NATIVE_INT_TYPE | offset, |
| bool | absolute = true |
||
| ) |
| File::Status Os::File::write | ( | const void * | buffer, |
| NATIVE_INT_TYPE & | size, | ||
| bool | waitForDone = true |
||
| ) |