#include "distortos/FileSystem/littlefs1/Littlefs1File.hpp"
|
| ~Littlefs1File () override |
| Littlefs1File's destructor. More...
|
|
int | close () override |
| Closes file. More...
|
|
std::pair< int, off_t > | getPosition () override |
| Returns current file offset. More...
|
|
std::pair< int, off_t > | getSize () override |
| Returns size of file. More...
|
|
int | getStatus (struct stat &status) override |
| Returns status of file. More...
|
|
std::pair< int, bool > | isATerminal () override |
| Tells whether the file is a terminal. More...
|
|
void | lock () override |
| Locks the file for exclusive use by current thread. More...
|
|
std::pair< int, size_t > | read (void *buffer, size_t size) override |
| Reads data from file. More...
|
|
int | rewind () override |
| Resets current file offset. More...
|
|
std::pair< int, off_t > | seek (Whence whence, off_t offset) override |
| Moves file offset. More...
|
|
int | synchronize () override |
| Synchronizes state of a file, ensuring all cached writes are finished. More...
|
|
void | unlock () override |
| Unlocks the file which was previously locked by current thread. More...
|
|
std::pair< int, size_t > | write (const void *buffer, size_t size) override |
| Writes data to file. More...
|
|
virtual | ~File ()=default |
| File's destructor. More...
|
|
| File (const File &)=delete |
|
File & | operator= (const File &)=delete |
|
|
class | Littlefs1FileSystem |
|
◆ ~Littlefs1File()
distortos::Littlefs1File::~Littlefs1File |
( |
| ) |
|
|
override |
◆ Littlefs1File()
Littlefs1File's constructor.
- Parameters
-
[in] | fileSystem | is a reference to owner file system |
◆ close()
int distortos::Littlefs1File::close |
( |
| ) |
|
|
overridevirtual |
Closes file.
Similar to close()
- Note
- Even if error code is returned, the file must not be used.
- Warning
- This function must not be called from interrupt context!
- Precondition
- File is opened.
- Postcondition
- File is closed.
- Returns
- 0 on success, error code otherwise
- converted error codes returned by lfs1_file_close();
Implements distortos::File.
◆ getPosition()
std::pair< int, off_t > distortos::Littlefs1File::getPosition |
( |
| ) |
|
|
overridevirtual |
Returns current file offset.
Similar to ftello()
- Warning
- This function must not be called from interrupt context!
- Precondition
- File is opened.
- Returns
- pair with return code (0 on success, error code otherwise) and current file offset, bytes; error codes:
- converted error codes returned by lfs1_file_tell();
Implements distortos::File.
◆ getSize()
std::pair< int, off_t > distortos::Littlefs1File::getSize |
( |
| ) |
|
|
overridevirtual |
Returns size of file.
- Warning
- This function must not be called from interrupt context!
- Precondition
- File is opened.
- Returns
- pair with return code (0 on success, error code otherwise) and size of file, bytes; error codes:
- converted error codes returned by lfs1_file_size();
Implements distortos::File.
◆ getStatus()
int distortos::Littlefs1File::getStatus |
( |
struct stat & |
status | ) |
|
|
overridevirtual |
Returns status of file.
Similar to fstat()
st_mode
and st_size
fields are set in all cases. All other fields are zero-initialized.
- Warning
- This function must not be called from interrupt context!
- Precondition
- File is opened.
- Parameters
-
[out] | status | is a reference to stat struct into which status of file will be written |
- Returns
- 0 on success, error code otherwise:
Implements distortos::File.
◆ isATerminal()
std::pair< int, bool > distortos::Littlefs1File::isATerminal |
( |
| ) |
|
|
overridevirtual |
Tells whether the file is a terminal.
Similar to isatty()
- Warning
- This function must not be called from interrupt context!
- Precondition
- File is opened.
- Returns
- pair with return code (0 on success, error code otherwise) and bool telling whether the file is a terminal (true) or not (false)
Implements distortos::File.
◆ lock()
void distortos::Littlefs1File::lock |
( |
| ) |
|
|
overridevirtual |
Locks the file for exclusive use by current thread.
When the object is locked, any call to any member function from other thread will be blocked until the object is unlocked. Locking is optional, but may be useful when more than one operation must be done atomically.
- Note
- Locks are recursive.
- Warning
- This function must not be called from interrupt context!
- Precondition
- The number of recursive locks of device is less than 65535.
- Postcondition
- Device is locked.
Implements distortos::File.
◆ open()
int distortos::Littlefs1File::open |
( |
const char * |
path, |
|
|
int |
flags |
|
) |
| |
|
private |
Opens file.
- Precondition
- File is not opened.
-
path is valid.
-
flags are valid.
- Parameters
-
[in] | path | is the path of file that will be opened, must be valid |
[in] | flags | are file status flags, must be valid, for list of available flags and valid combinations see open() |
- Returns
- 0 on success, error code otherwise:
- ENOMEM - unable to allocate memory for file;
- converted error codes returned by lfs1_file_open();
◆ read()
std::pair< int, size_t > distortos::Littlefs1File::read |
( |
void * |
buffer, |
|
|
size_t |
size |
|
) |
| |
|
overridevirtual |
Reads data from file.
Similar to read()
- Warning
- This function must not be called from interrupt context!
- Precondition
- File is opened.
-
buffer is valid.
- Parameters
-
[out] | buffer | is the buffer into which the data will be read, must be valid |
[in] | size | is the size of buffer, bytes |
- Returns
- pair with return code (0 on success, error code otherwise) and number of read bytes (valid even when error code is returned); error codes:
- converted error codes returned by lfs1_file_read();
Implements distortos::File.
◆ rewind()
int distortos::Littlefs1File::rewind |
( |
| ) |
|
|
overridevirtual |
Resets current file offset.
Similar to rewind()
- Warning
- This function must not be called from interrupt context!
- Precondition
- File is opened.
- Returns
- 0 on success, error code otherwise:
- converted error codes returned by lfs1_file_rewind();
Implements distortos::File.
◆ seek()
std::pair< int, off_t > distortos::Littlefs1File::seek |
( |
Whence |
whence, |
|
|
off_t |
offset |
|
) |
| |
|
overridevirtual |
Moves file offset.
Similar to lseek()
- Warning
- This function must not be called from interrupt context!
- Precondition
- File is opened.
- Parameters
-
[in] | whence | selects the mode of operation: Whence::beginning will set file offset to offset, Whence::current will set file offset to its current value plus offset, Whence::end will set file offset to the size of the file plus offset |
[in] | offset | is the value of offset, bytes |
- Returns
- pair with return code (0 on success, error code otherwise) and current file offset, bytes; error codes:
- converted error codes returned by lfs1_file_seek();
Implements distortos::File.
◆ synchronize()
int distortos::Littlefs1File::synchronize |
( |
| ) |
|
|
overridevirtual |
Synchronizes state of a file, ensuring all cached writes are finished.
Similar to fsync()
- Warning
- This function must not be called from interrupt context!
- Precondition
- File is opened.
- Returns
- 0 on success, error code otherwise:
- converted error codes returned by lfs1_file_sync();
Implements distortos::File.
◆ unlock()
void distortos::Littlefs1File::unlock |
( |
| ) |
|
|
overridevirtual |
Unlocks the file which was previously locked by current thread.
- Note
- Locks are recursive.
- Warning
- This function must not be called from interrupt context!
- Precondition
- This function is called by the thread that locked the device.
Implements distortos::File.
◆ write()
std::pair< int, size_t > distortos::Littlefs1File::write |
( |
const void * |
buffer, |
|
|
size_t |
size |
|
) |
| |
|
overridevirtual |
Writes data to file.
Similar to write()
- Warning
- This function must not be called from interrupt context!
- Precondition
- File is opened.
-
buffer is valid.
- Parameters
-
[in] | buffer | is the buffer with data that will be written, must be valid |
[in] | size | is the size of buffer, bytes |
- Returns
- pair with return code (0 on success, error code otherwise) and number of written bytes (valid even when error code is returned); error codes:
- converted error codes returned by lfs1_file_write();
Implements distortos::File.
◆ buffer_
std::unique_ptr<uint8_t[]> distortos::Littlefs1File::buffer_ |
|
private |
◆ configuration_
lfs1_file_config distortos::Littlefs1File::configuration_ |
|
private |
littlefs-v1 file configuration
◆ file_
lfs1_file_t distortos::Littlefs1File::file_ |
|
private |
◆ fileSystem_
reference to owner file system
◆ opened_
bool distortos::Littlefs1File::opened_ |
|
private |
true if file is opened, false otherwise
The documentation for this class was generated from the following files: