DirectoryIterator always checks for hidden file flag


#1

Hi Jules,

I think there is a bug in juce_mac_Files.mm :

    bool next (String& filenameFound,
               bool* const isDir, bool* const isHidden, int64* const fileSize,
               Time* const modTime, Time* const creationTime, bool* const isReadOnly)
    {
[...]
        if (isHidden != nullptr)
                *isHidden = FileHelpers::isHiddenFile (fullPath);

In fact the isHidden bool* is never null because the bool it refers to is defined as a stack variable (then ==false) in juce_DirectoryIterator.cpp :

    bool isDirectory, isHidden;
    while (fileFinder.next (filename, &isDirectory, &isHidden, fileSize, modTime, creationTime, isReadOnly))
    {

This makes scanning much more time consuming than it should be since the OS function getting the file flags is really slow…


#2

Interesting point, thanks… I think I can optimise that for some cases if the File::ignoreHiddenFiles flag hasn’t been set.