4#include "../Foundation/Result.h"
5#include "../Foundation/StringPath.h"
45#if SC_PLATFORM_WINDOWS
46 void* fileDescriptor = (
void*)(
long long)-1;
48 int fileDescriptor = -1;
49 void* dirEnumerator =
nullptr;
51 size_t textLengthInBytes = 0;
67#if SC_PLATFORM_WINDOWS
68 void* parentFileDescriptor =
nullptr;
70 int parentFileDescriptor = 0;
88 const Entry&
get()
const {
return currentEntry; }
121 int currentEntry = -1;
127 size_t size()
const {
return size_t(currentEntry + 1); }
128 bool isEmpty()
const {
return currentEntry == -1; }
130 RecurseStack recurseStack;
133 Result errorResult = Result(
true);
134 bool errorsChecked =
false;
136#if SC_PLATFORM_WINDOWS
137 bool expectDotDirectories =
true;
138 wchar_t currentPathString[MaxPath];
141 char currentPathString[MaxPath];
143 Result enumerateNextInternal(Entry& entry);
144 Result recurseSubdirectoryInternal(Entry& entry);
unsigned long size_t
Platform independent unsigned size type.
Definition PrimitiveTypes.h:56
unsigned long long uint64_t
Platform independent (8) bytes unsigned int.
Definition PrimitiveTypes.h:42
unsigned int uint32_t
Platform independent (4) bytes unsigned int.
Definition PrimitiveTypes.h:38
Contains information on a file or directory.
Definition FileSystemIterator.h:58
bool isDirectory() const
Check if current entry is a directory.
Definition FileSystemIterator.h:65
uint32_t level
Current level of nesting from start of iteration.
Definition FileSystemIterator.h:61
StringSpan path
Absolute path of the current entry.
Definition FileSystemIterator.h:60
StringSpan name
Name of current entry (file with extension or directory)
Definition FileSystemIterator.h:59
Type type
Tells if it's a file or a directory.
Definition FileSystemIterator.h:62
Holds state of a folder when recursing into it to list its files.
Definition FileSystemIterator.h:44
Options when iterating (recursive and other options)
Definition FileSystemIterator.h:76
bool forwardSlashes
true will return paths forward slash / even on Windows
Definition FileSystemIterator.h:78
bool recursive
true will recurse automatically into subdirectories
Definition FileSystemIterator.h:77
Iterates files and directories inside a given path without allocating any memory.
Definition FileSystemIterator.h:34
const Entry & get() const
Get current Entry being iterated.
Definition FileSystemIterator.h:88
Result init(StringSpan directory, Span< FolderState > recursiveEntries)
Initializes the iterator on a given directory.
Options options
Options to control recursive behaviour and other options.
Definition FileSystemIterator.h:81
Result checkErrors()
Check if any error happened during iteration.
Definition FileSystemIterator.h:92
Result recurseSubdirectory()
Recurse into current item (assuming Entry::isDirectory == true)
Result enumerateNext()
Returned string is only valid until next enumerateNext call and/or another init call.
~FileSystemIterator()
Destroys the FileSystemIterator object.
Type
Entry type (File or Directory)
Definition FileSystemIterator.h:37
An ascii string used as boolean result. SC_TRY macro forwards errors to caller.
Definition Result.h:12
View over a contiguous sequence of items (pointer + size in elements).
Definition Span.h:29
static constexpr size_t MaxPath
Maximum size of paths on current native platform.
Definition StringPath.h:17
An read-only view over a string (to avoid including Strings library when parsing is not needed).
Definition StringSpan.h:31