Iterates files and directories inside a given path.
More...
#include <FileSystemIterator.h>
Iterates files and directories inside a given path.
FileSystemIterator uses an iterator pattern to enumerate files instead of a callback. This allows avoiding blocking on enumeration of very large directories and also the allocation of a huge number of strings to hold all filenames. When configuring an iteration, the caller can ask for a fully recursive enumeration or manually call SC::FileSystemIterator::recurseSubdirectory when the current SC::FileSystemIterator::Entry item (obtained with SC::FileSystemIterator::get) matches a directory of interest.
Example of recursive iteration of a directory:
If only some directories should be recursed, manual recursion can help speeding up directory iteration:
◆ Type
◆ ~FileSystemIterator()
SC::FileSystemIterator::~FileSystemIterator |
( |
| ) |
|
◆ checkErrors()
Result SC::FileSystemIterator::checkErrors |
( |
| ) |
|
|
inlinenodiscard |
Check if any error happened during iteration.
- Returns
- A valid Result if no errors have happened during file system iteration
◆ enumerateNext()
Result SC::FileSystemIterator::enumerateNext |
( |
| ) |
|
|
nodiscard |
Returned string is only valid until next enumerateNext call and/or another init call.
Moves iterator to next file
- Returns
- Valid result if there are more files to iterate
◆ get()
const Entry & SC::FileSystemIterator::get |
( |
| ) |
const |
|
inline |
Get current Entry being iterated.
- Returns
- Current entry
◆ init()
Initializes the iterator on a given directory.
- Parameters
-
directory | Directory to iterate |
- Returns
- Valid result if directory exists and is accessible
◆ recurseSubdirectory()
Result SC::FileSystemIterator::recurseSubdirectory |
( |
| ) |
|
|
nodiscard |
Recurse into current item (assuming Entry::isDirectory == true
)
- Returns
- Valid result if current item is a directory and it can be accessed successfully
◆ options
Options SC::FileSystemIterator::options |
Options to control recursive behaviour and other options.
The documentation for this struct was generated from the following file: