26StringArray DirectoryIterator::parseWildcards (
const String& pattern)
29 s.addTokens (pattern,
";,",
"\"'");
31 s.removeEmptyStrings();
35bool DirectoryIterator::fileMatches (
const StringArray& wildcards,
const String& filename)
37 for (
auto& w : wildcards)
38 if (filename.matchesWildcard (w, ! File::areFileNamesCaseSensitive()))
44bool DirectoryIterator::next()
46 return next (
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr);
49JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE (
"-Wdeprecated-declarations")
50JUCE_BEGIN_IGNORE_WARNINGS_MSVC (4996)
52bool DirectoryIterator::next (
bool* isDirResult,
bool* isHiddenResult,
int64* fileSize,
53 Time* modTime, Time* creationTime,
bool* isReadOnly)
57 hasBeenAdvanced =
true;
59 if (subIterator !=
nullptr)
61 if (subIterator->next (isDirResult, isHiddenResult, fileSize, modTime, creationTime, isReadOnly))
68 bool isDirectory, isHidden =
false, shouldContinue =
false;
70 while (fileFinder.next (filename, &isDirectory,
72 fileSize, modTime, creationTime, isReadOnly))
76 if (! filename.containsOnly (
"."))
83 const auto mayRecurseIntoPossibleHiddenDir = [
this, &isHidden]
88 const auto mayRecurseIntoPossibleSymlink = [
this, &fullPath]
91 || ! fullPath.isSymbolicLink()
93 && knownPaths->find (fullPath.getLinkedTarget()) == knownPaths->end());
96 if (isRecursive && mayRecurseIntoPossibleHiddenDir() && mayRecurseIntoPossibleSymlink())
97 subIterator.reset (
new DirectoryIterator (fullPath,
true, wildCard, whatToLookFor, followSymlinks, knownPaths));
107 if (matches && (isRecursive || wildCards.size() > 1))
108 matches = fileMatches (wildCards, filename);
111 matches = ! isHidden;
115 currentFile = fullPath;
116 if (isHiddenResult !=
nullptr) *isHiddenResult = isHidden;
117 if (isDirResult !=
nullptr) *isDirResult = isDirectory;
122 if (subIterator !=
nullptr)
124 shouldContinue =
true;
130 if (! shouldContinue)
135JUCE_END_IGNORE_WARNINGS_GCC_LIKE
136JUCE_END_IGNORE_WARNINGS_MSVC
138const File& DirectoryIterator::getFile()
const
140 if (subIterator !=
nullptr && subIterator->hasBeenAdvanced)
141 return subIterator->getFile();
149float DirectoryIterator::getEstimatedProgress()
const
151 if (totalNumFiles < 0)
154 if (totalNumFiles <= 0)
157 auto detailedIndex = (subIterator !=
nullptr) ? (
float) index + subIterator->getEstimatedProgress()
160 return jlimit (0.0f, 1.0f, detailedIndex / (
float) totalNumFiles);
@ ignoreHiddenFiles
Add this flag to avoid returning any hidden files in the results.
@ findDirectories
Use this flag to indicate that you want to find directories.
@ findFilesAndDirectories
Use this flag to indicate that you want to find both files and directories.
@ findFiles
Use this flag to indicate that you want to find files.
@ yes
Requests that a file system traversal follow all symbolic links.
@ noCycles
Requests that a file system traversal may follow symbolic links, but should attempt to skip any symbo...
static File createFileWithoutCheckingPath(const String &absolutePath) noexcept
Creates a file that simply contains this string, without doing the sanity-checking that the normal co...
Type jlimit(Type lowerLimit, Type upperLimit, Type valueToConstrain) noexcept
Constrains a value to keep it within a given range.
long long int64
A platform-independent 64-bit integer type.