Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
DirHandle Class Reference
[DirHandle functions]
Represents a directory stream. More...
#include <DirHandle.h>
Inherits NonCopyable< DirHandle >.
Inherited by Dir, and LocalDirHandle.
Public Member Functions | |
virtual ssize_t | read (struct dirent *ent)=0 |
Read the next directory entry. | |
virtual int | close ()=0 |
Close a directory. | |
virtual void | seek (off_t offset)=0 |
Set the current position of the directory. | |
virtual off_t | tell ()=0 |
Get the current position of the directory. | |
virtual void | rewind ()=0 |
Rewind the current position to the beginning of the directory. | |
virtual size_t | size () |
Get the sizeof the directory. | |
MBED_DEPRECATED_SINCE ("mbed-os-5.4","Replaced by DirHandle::close") virtual int closedir() | |
Closes the directory. | |
MBED_DEPRECATED_SINCE ("mbed-os-5.4","Replaced by DirHandle::read") virtual struct dirent *readdir() | |
Return the directory entry at the current position, and advances the position to the next entry. | |
MBED_DEPRECATED_SINCE ("mbed-os-5.4","Replaced by DirHandle::rewind") virtual void rewinddir() | |
Resets the position to the beginning of the directory. | |
MBED_DEPRECATED_SINCE ("mbed-os-5.4","Replaced by DirHandle::tell") virtual off_t telldir() | |
Returns the current position of the DirHandle. | |
MBED_DEPRECATED_SINCE ("mbed-os-5.4","Replaced by DirHandle::seek") virtual void seekdir(off_t location) | |
Sets the position of the DirHandle. | |
Private Member Functions | |
MBED_DEPRECATED ("Invalid copy construction of a NonCopyable resource.") NonCopyable(const NonCopyable &) | |
NonCopyable copy constructor. | |
MBED_DEPRECATED ("Invalid copy assignment of a NonCopyable resource.") NonCopyable &operator | |
NonCopyable copy assignment operator. |
Detailed Description
Represents a directory stream.
Objects of this type are returned by an opendir function. The core functions are read and seek, but only a subset needs to be provided.
If a FileSystemLike class defines the opendir method, then the directories of an object of that type can be accessed by DIR *d = opendir("/example/directory") (or opendir("/example") to open the root of the filesystem), and then using readdir(d) etc.
The root directory is considered to contain all FileHandle and FileSystem objects, so the DIR* returned by opendir("/") will reflect this.
- Note:
- to create a directory,
- See also:
- Dir
- Note:
- Synchronization level: Set by subclass
Definition at line 49 of file DirHandle.h.
Member Function Documentation
virtual int close | ( | ) | [pure virtual] |
MBED_DEPRECATED_SINCE | ( | "mbed-os-5.4" | , |
"Replaced by DirHandle::seek" | |||
) |
Sets the position of the DirHandle.
- Parameters:
-
location The location to seek to. Must be a value returned by telldir.
Definition at line 150 of file DirHandle.h.
MBED_DEPRECATED_SINCE | ( | "mbed-os-5.4" | , |
"Replaced by DirHandle::read" | |||
) |
Return the directory entry at the current position, and advances the position to the next entry.
- Returns:
- A pointer to a dirent structure representing the directory entry at the current position, or NULL on reaching end of directory or error.
Definition at line 122 of file DirHandle.h.
MBED_DEPRECATED_SINCE | ( | "mbed-os-5.4" | , |
"Replaced by DirHandle::rewind" | |||
) |
Resets the position to the beginning of the directory.
Definition at line 132 of file DirHandle.h.
MBED_DEPRECATED_SINCE | ( | "mbed-os-5.4" | , |
"Replaced by DirHandle::tell" | |||
) |
Returns the current position of the DirHandle.
- Returns:
- the current position, -1 on error.
Definition at line 142 of file DirHandle.h.
MBED_DEPRECATED_SINCE | ( | "mbed-os-5.4" | , |
"Replaced by DirHandle::close" | |||
) |
Closes the directory.
- Returns:
- 0 on success, -1 on error.
Definition at line 110 of file DirHandle.h.
virtual ssize_t read | ( | struct dirent * | ent ) | [pure virtual] |
Read the next directory entry.
- Parameters:
-
ent The directory entry to fill out
- Returns:
- 1 on reading a filename, 0 at end of directory, negative error on failure
Implemented in Dir.
virtual void rewind | ( | ) | [pure virtual] |
Rewind the current position to the beginning of the directory.
Implemented in Dir.
virtual void seek | ( | off_t | offset ) | [pure virtual] |
Set the current position of the directory.
- Parameters:
-
offset Offset of the location to seek to, must be a value returned from tell
Implemented in Dir.
virtual size_t size | ( | ) | [virtual] |
Get the sizeof the directory.
- Returns:
- Number of files in the directory
Reimplemented in Dir.
Definition at line 87 of file DirHandle.h.
virtual off_t tell | ( | ) | [pure virtual] |
Get the current position of the directory.
- Returns:
- Position of the directory that can be passed to rewind
Implemented in Dir.
Generated on Tue Jul 12 2022 12:47:32 by
