Browse Source

Fix for File::isDirectory on posix when given a File::nonexistent. Also added unit tests for this.

tags/2021-05-28
jules 10 years ago
parent
commit
58105cde57
2 changed files with 7 additions and 2 deletions
  1. +5
    -0
      modules/juce_core/files/juce_File.cpp
  2. +2
    -2
      modules/juce_core/native/juce_posix_SharedCode.h

+ 5
- 0
modules/juce_core/files/juce_File.cpp View File

@@ -916,6 +916,11 @@ public:
const File temp (File::getSpecialLocation (File::tempDirectory));
expect (! File::nonexistent.exists());
expect (! File::nonexistent.existsAsFile());
expect (! File::nonexistent.isDirectory());
#if ! JUCE_WINDOWS
expect (File("/").isDirectory());
#endif
expect (home.isDirectory());
expect (home.exists());
expect (! home.existsAsFile());


+ 2
- 2
modules/juce_core/native/juce_posix_SharedCode.h View File

@@ -265,8 +265,8 @@ bool File::isDirectory() const
{
juce_statStruct info;
return fullPath.isEmpty()
|| (juce_stat (fullPath, info) && ((info.st_mode & S_IFDIR) != 0));
return fullPath.isNotEmpty()
&& (juce_stat (fullPath, info) && ((info.st_mode & S_IFDIR) != 0));
}
bool File::exists() const


Loading…
Cancel
Save