🟩 Enumerates files and directories inside a given path
SaneCppFileSystemIterator.h is a library that enumerates files and directories at a given path.
🟩 Usable
The library is simple but gets the job done.
Some relevant blog posts are:
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. The maximum number of nested recursion levels that will be allowed depends on the size of the FileSystemIterator::FolderState span (can be a static array) passed in during init by the caller.
Example of recursive iteration of a directory:
If only some directories should be recursed, manual recursion can help speeding up directory iteration:
🟦 Complete Features:
💡 Unplanned Features:
LOC counts exclude comments. Library counts files physically under Libraries/FileSystemIterator. Single File counts SaneCppFileSystemIterator.h. Standalone counts SaneCppFileSystemIteratorStandalone.h and intentionally includes dependency payloads.
| Metric | Header | Source | Sum |
|---|---|---|---|
| Library | 92 | 402 | 494 |
| Single File | 1121 | 977 | 2098 |
| Standalone | 1121 | 977 | 2098 |