Guys, I’m doing a TreeView that lists more than one file type. EG: WAV, SFZ, FXP, FXB, … and I added an option to check if the folders have the actual files found.
I’m using the isDirectorySuitable call. So I create a DirectoryIterator call and check if all sub folders contains any file with those extensions. The problem is that DirectoryIterator only handles one extension at a time. I tried to figure out how it works, but I rather ask here before I start re-inventing the wheel. :oops:
wildcards.addTokens (wildcardPatterns.toLowerCase(), T(";,"), T("\"'"));
wildcards.trim();
wildcards.removeEmptyStrings();
for (int i = wildcards.size(); --i >= 0;)
{
if (wildcards[i] == T("*.*")) wildcards.set (i, T("*"));
}
}
//-----------------------------------------------------------------------------------------------------------
bool myFilter::isDirectorySuitable (const File& file) const
{
if (scanFolder)
{
if (stopScan) return false;
bool Found = false;
if (!stopScan)
{
DirectoryIterator iter (file, true);
while(iter.next())
{
if (stopScan) break;
String filename = iter.getFile().getLinkedTarget().getFileName();
for (int i = wildcards.size(); --i >= 0;)
{
if (filename.matchesWildcard(wildcards[i], true))
{
Found = true;
break;
}
}
if (Found) break;
}
}
return Found;
}
return true;
}[/code]
Now, when scanFolder is True, it will check if the folder and all sub-folders have ANY of the wildcard files. You can also set stopScan to True if the user has clicked a STOP button. (very handy)