distortos  v0.7.0
object-oriented C++ RTOS for microcontrollers
distortos::Littlefs1Directory Class Reference

#include "distortos/FileSystem/littlefs1/Littlefs1Directory.hpp"

Inheritance diagram for distortos::Littlefs1Directory:
[legend]
Collaboration diagram for distortos::Littlefs1Directory:
[legend]

Public Member Functions

 ~Littlefs1Directory () override
 Littlefs1Directory's destructor. More...
 
int close () override
 Closes directory. More...
 
std::pair< int, off_t > getPosition () override
 Returns current position in the directory. More...
 
void lock () override
 Locks the directory for exclusive use by current thread. More...
 
int read (dirent &entry) override
 Reads next entry from directory. More...
 
int rewind () override
 Resets current position in the directory. More...
 
int seek (off_t position) override
 Moves position in the directory. More...
 
void unlock () override
 Unlocks the directory which was previously locked by current thread. More...
 
- Public Member Functions inherited from distortos::Directory
virtual ~Directory ()=default
 Directory's destructor. More...
 
 Directory (const Directory &)=delete
 
Directoryoperator= (const Directory &)=delete
 

Private Member Functions

constexpr Littlefs1Directory (Littlefs1FileSystem &fileSystem)
 Littlefs1Directory's constructor. More...
 
int open (const char *path)
 Opens directory. More...
 

Private Attributes

lfs1_dir_t directory_
 littlefs-v1 directory More...
 
Littlefs1FileSystemfileSystem_
 reference to owner file system More...
 
bool opened_
 true if directory is opened, false otherwise More...
 

Friends

class Littlefs1FileSystem
 

Detailed Description

Littlefs1Directory class is a littlefs-v1 directory.

Constructor & Destructor Documentation

◆ ~Littlefs1Directory()

distortos::Littlefs1Directory::~Littlefs1Directory ( )
override

Littlefs1Directory's destructor.

Precondition
Directory is closed.

◆ Littlefs1Directory()

constexpr distortos::Littlefs1Directory::Littlefs1Directory ( Littlefs1FileSystem fileSystem)
inlineexplicitprivate

Littlefs1Directory's constructor.

Parameters
[in]fileSystemis a reference to owner file system

Member Function Documentation

◆ close()

int distortos::Littlefs1Directory::close ( )
overridevirtual

Closes directory.

Similar to closedir()

Note
Even if error code is returned, the directory must not be used.
Warning
This function must not be called from interrupt context!
Precondition
Directory is opened.
Postcondition
Directory is closed.
Returns
0 on success, error code otherwise:
  • converted error codes returned by lfs1_dir_close();

Implements distortos::Directory.

Here is the call graph for this function:

◆ getPosition()

std::pair< int, off_t > distortos::Littlefs1Directory::getPosition ( )
overridevirtual

Returns current position in the directory.

Similar to telldir()

Warning
This function must not be called from interrupt context!
Precondition
Directory is opened.
Returns
pair with return code (0 on success, error code otherwise) and current position in the directory; error codes:
  • converted error codes returned by lfs1_dir_tell();

Implements distortos::Directory.

Here is the call graph for this function:

◆ lock()

void distortos::Littlefs1Directory::lock ( )
overridevirtual

Locks the directory 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 directory is less than 65535.
Postcondition
Directory is locked.

Implements distortos::Directory.

Here is the call graph for this function:

◆ open()

int distortos::Littlefs1Directory::open ( const char *  path)
private

Opens directory.

Precondition
Directory is not opened.
path is valid.
Parameters
[in]pathis the path of directory that will be opened, must be valid
Returns
0 on success, error code otherwise:
  • converted error codes returned by lfs1_dir_open();
Here is the call graph for this function:
Here is the caller graph for this function:

◆ read()

int distortos::Littlefs1Directory::read ( dirent entry)
overridevirtual

Reads next entry from directory.

Similar to readdir_r()

d_name field is set in all cases. All other fields are zero-initialized.

Warning
This function must not be called from interrupt context!
Precondition
Directory is opened.
Parameters
[out]entryis a reference to dirent struct into which next entry from directory will be written
Returns
0 on success, error code otherwise:
  • ENOENT - current position in the directory is invalid (i.e. end of the directory reached);
  • converted error codes returned by lfs1_dir_read();

Implements distortos::Directory.

Here is the call graph for this function:

◆ rewind()

int distortos::Littlefs1Directory::rewind ( )
overridevirtual

Resets current position in the directory.

Similar to rewinddir()

Warning
This function must not be called from interrupt context!
Precondition
Directory is opened.
Returns
0 on success, error code otherwise:
  • converted error codes returned by lfs1_dir_rewind();

Implements distortos::Directory.

Here is the call graph for this function:

◆ seek()

int distortos::Littlefs1Directory::seek ( off_t  position)
overridevirtual

Moves position in the directory.

Similar to seekdir()

Warning
This function must not be called from interrupt context!
Precondition
Directory is opened.
Parameters
[in]positionis the value of position, must be a value previously returned by getPosition()!
Returns
0 on success, error code otherwise:
  • converted error codes returned by lfs1_dir_seek();

Implements distortos::Directory.

Here is the call graph for this function:

◆ unlock()

void distortos::Littlefs1Directory::unlock ( )
overridevirtual

Unlocks the directory 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 directory.

Implements distortos::Directory.

Here is the call graph for this function:

Member Data Documentation

◆ directory_

lfs1_dir_t distortos::Littlefs1Directory::directory_
private

littlefs-v1 directory

◆ fileSystem_

Littlefs1FileSystem& distortos::Littlefs1Directory::fileSystem_
private

reference to owner file system

◆ opened_

bool distortos::Littlefs1Directory::opened_
private

true if directory is opened, false otherwise


The documentation for this class was generated from the following files: