Bug in File::isDirectory on Mac



I've just found some inconsistency in File::isDirectory() implementations.

The documentation says: 

Checks whether the file is a directory that exists [...]  returns true only if the file is a directory which actually exists, so false if it's a file or doesn't exist at all.

So I assume that File::nonexistent.isDirectory() should return false because "it doesn't exist at all".
In fact on Windows it returns false but on Mac it returns trueShouldn't we get the same results?




Just curious - if you put these two lines in the file unit test (grep for FileTests, and enable JUCE_UNIT_TESTS), do you get the same issue?

expect (! File::nonexistent.existsAsFile());
expect (! File::nonexistent.isDirectory());

It's probably a bit excessive, but I wouldn't see why the file unit test wouldn't have those two lines above - I don't think it would hurt anything!


Of course it could be added, but first it should be fixed in File::isDirectory() in juce_posix_SharedCode.h

First part of return statement makes the difference...

bool File::isDirectory() const
    juce_statStruct info;
    return fullPath.isEmpty()
            || (juce_stat (fullPath, info) && ((info.st_mode & S_IFDIR) != 0));


Thanks - I've tweaked this now.