A small feature request on FileSearchPath::findChildFiles recursivly. It would be cool to have a search depth limit option for findChildFiles just in case users set search directory like C:.
I am not very sure if itās possible, but a optional for setting the maximum files required could come in handy.
Surely the smart thing to do would be to ask the user if they really mean āc:ā, and if so, search the whole thing?
Just use a DirectoryIterator and stop asking it for files when youāve got enough.
I really donāt like either of these ideas - it feels wrong to put artificial limits on a file search, either in terms of depth or file count. If youāre searching for files, then presumably you donāt know what files are there, so how can you know what the limits are before youāve searched?
Iām exploring searching for a file starting from C:\ and iām wondering if there is a way to perform the recursive search on a separate thread, so it doesnāt appear that my app has frozen.
calling
File f("/");
FileSearchPath path(f.getFullPathName() );
Array<File> resultFiles;
path.findChildFiles(resultFiles, TypeOfFileToFind::findFiles, true, "someName");
takes a really long time, as it is scanning the ENTIRE drive.
iām not sure if running it on its own thread would work either, as there really isnāt a place to pause execution, is there? Perhaps iām mistaken about how threads work internally.
Check out the DirectoryContentsList class which uses a separate Thread for searching
Rail
gotcha. Seems handy, but it doesnāt do recursive searching:
void DirectoryContentsList::refresh()
{
clear();
if (root.isDirectory())
{
fileFindHandle = new DirectoryIterator (root, false, "*", fileTypeFlags);
shouldStop = false;
thread.addTimeSliceClient (this);
}
}
I need to do recursive searching, so that āfalseā in the DirectoryIterator constructor needs to be true⦠any ideas?
Just use your own thread, with a DirectoryIterator. You can stop iterating any time you like.
I was suggesting you check out the class to see how itās implemented in JUCE to see how you can make your own class.
Rail