distortos  v0.7.0
object-oriented C++ RTOS for microcontrollers
distortos::Directory Class Referenceabstract

#include "distortos/FileSystem/Directory.hpp"

Inheritance diagram for distortos::Directory:
[legend]

Public Member Functions

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

Detailed Description

Directory class is an interface for a directory.

Constructor & Destructor Documentation

◆ ~Directory()

virtual distortos::Directory::~Directory ( )
virtualdefault

Directory's destructor.

Precondition
Directory is closed.

Member Function Documentation

◆ close()

virtual int distortos::Directory::close ( )
pure virtual

Closes directory.

Similar to closedir()

Note
Even if error code is returned, the directory must not be used.
Precondition
Directory is opened.
Postcondition
Directory is closed.
Returns
0 on success, error code otherwise

Implemented in distortos::Littlefs1Directory.

◆ getPosition()

virtual std::pair<int, off_t> distortos::Directory::getPosition ( )
pure virtual

Returns current position in the directory.

Similar to telldir()

Precondition
Directory is opened.
Returns
pair with return code (0 on success, error code otherwise) and current position in the directory

Implemented in distortos::Littlefs1Directory.

◆ lock()

virtual void distortos::Directory::lock ( )
pure virtual

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.

Implemented in distortos::Littlefs1Directory.

◆ read()

virtual int distortos::Directory::read ( dirent entry)
pure virtual

Reads next entry from directory.

Similar to readdir_r()

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);

Implemented in distortos::Littlefs1Directory.

◆ rewind()

virtual int distortos::Directory::rewind ( )
pure virtual

Resets current position in the directory.

Similar to rewinddir()

Precondition
Directory is opened.
Returns
0 on success, error code otherwise

Implemented in distortos::Littlefs1Directory.

◆ seek()

virtual int distortos::Directory::seek ( off_t  position)
pure virtual

Moves position in the directory.

Similar to seekdir()

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

Implemented in distortos::Littlefs1Directory.

◆ unlock()

virtual void distortos::Directory::unlock ( )
pure virtual

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.

Implemented in distortos::Littlefs1Directory.


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