27 const String& pattern,
int type)
28 : wildCards (parseWildcards (pattern)),
29 fileFinder (directory, (recursive || wildCards.size() > 1) ?
"*" : pattern),
31 path (
File::addTrailingSeparator (directory.getFullPathName())),
33 isRecursive (recursive)
37 jassert (type > 0 && type <= 7);
53 bool DirectoryIterator::fileMatches (
const StringArray& wildcards,
const String& filename)
55 for (
auto& w : wildcards)
64 return next (
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr);
68 Time* modTime,
Time* creationTime,
bool* isReadOnly)
72 hasBeenAdvanced =
true;
74 if (subIterator !=
nullptr)
76 if (subIterator->next (isDirResult, isHiddenResult, fileSize, modTime, creationTime, isReadOnly))
83 bool isDirectory, isHidden =
false, shouldContinue =
false;
85 while (fileFinder.next (filename, &isDirectory,
87 fileSize, modTime, creationTime, isReadOnly))
99 true, wildCard, whatToLookFor));
109 if (matches && (isRecursive || wildCards.
size() > 1))
110 matches = fileMatches (wildCards, filename);
113 matches = ! isHidden;
118 if (isHiddenResult !=
nullptr) *isHiddenResult = isHidden;
119 if (isDirResult !=
nullptr) *isDirResult = isDirectory;
124 if (subIterator !=
nullptr)
126 shouldContinue =
true;
132 if (! shouldContinue)
139 if (subIterator !=
nullptr && subIterator->hasBeenAdvanced)
140 return subIterator->getFile();
143 jassert (hasBeenAdvanced);
150 if (totalNumFiles < 0)
153 if (totalNumFiles <= 0)
156 auto detailedIndex = (subIterator !=
nullptr) ? index + subIterator->getEstimatedProgress()
159 return jlimit (0.0f, 1.0f, detailedIndex / totalNumFiles);
const File & getFile() const
float getEstimatedProgress() const
DirectoryIterator(const File &directory, bool isRecursive, const String &wildCard="*", int whatToLookFor=File::findFiles)
int getNumberOfChildFiles(int whatToLookFor, const String &wildCardPattern="*") const
@ findFilesAndDirectories
static bool areFileNamesCaseSensitive()
static File createFileWithoutCheckingPath(const String &absolutePath) noexcept
void removeEmptyStrings(bool removeWhitespaceStrings=true)
int size() const noexcept
int addTokens(StringRef stringToTokenise, bool preserveQuotedStrings)
bool containsOnly(StringRef charactersItMightContain) const noexcept