File::containsSubDirectories()


#1

It could be neat to have this function added to the File class. I added it into JUCE because I have a Treeview that shows “+” 'es in front of items that are dirs and that contain subdirs, and shows “-” in front of items that are dirs and do not contain subdirs, so the user is well informed.

[code]bool File::containsSubDirs() const throw()
{
bool result=false;

if (isDirectory())
{
    String path (fullPath);
    if (! path.endsWithChar (separator))
        path += separator;

    String filename;
    bool isDirectory, isHidden;

    void* const handle = juce_findFileStart (path,
                                             T("*"),
                                             filename,
                                             &isDirectory, &isHidden,
                                             0, 0, 0, 0);

    if (handle != 0)
    {
        do
        {
			if (isDirectory)
			{
				result=true;
				break;
			}

        } while (juce_findFileNext (handle, filename, &isDirectory, &isHidden, 0, 0, 0, 0));

        juce_findFileClose (handle);
    }
}

return result;

}[/code]


#2

Nice method - I’m sure there’s room for that! Thanks!