Iterates files and directories inside a given path. More...
#include <FileSystemIterator.h>
Classes | |
struct | Entry |
Contains information on a file or directory. More... | |
struct | Options |
Options when iterating (recursive and other options) More... | |
Public Types | |
enum class | Type { Directory , File } |
Entry type (File or Directory) More... | |
using | InternalOpaque = OpaqueObject< InternalDefinition > |
Public Member Functions | |
~FileSystemIterator () | |
Destroys the FileSystemIterator object. More... | |
const Entry & | get () const |
Get current Entry being iterated. More... | |
Result | checkErrors () |
Check if any error happened during iteration. More... | |
Result | init (StringView directory) |
Initializes the iterator on a given directory. More... | |
Result | enumerateNext () |
Returned string is only valid until next enumerateNext call and/or another init call. More... | |
Result | recurseSubdirectory () |
Recurse into current item (assuming Entry::isDirectory == true ) More... | |
Public Attributes | |
Options | options |
Options to control recursive behaviour and other options. More... | |
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:
|
strong |
Entry type (File or Directory)
SC::FileSystemIterator::~FileSystemIterator | ( | ) |
Destroys the FileSystemIterator object.
|
inline |
Check if any error happened during iteration.
Result SC::FileSystemIterator::enumerateNext | ( | ) |
Returned string is only valid until next enumerateNext call and/or another init call.
Moves iterator to next file
|
inline |
Get current Entry being iterated.
Result SC::FileSystemIterator::init | ( | StringView | directory | ) |
Initializes the iterator on a given directory.
directory | Directory to iterate |
Result SC::FileSystemIterator::recurseSubdirectory | ( | ) |
Recurse into current item (assuming Entry::isDirectory == true
)