1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-02-05 03:50:07 +00:00

Added File::isRoot()

This commit is contained in:
tpoole 2017-05-09 17:59:07 +01:00
parent abd8fafa69
commit f1409640f8
3 changed files with 14 additions and 1 deletions

View file

@ -103,6 +103,11 @@ static String removeEllipsis (const String& path)
return path;
}
bool File::isRoot() const
{
return fullPath.isNotEmpty() && *this == getParentDirectory();
}
String File::parseAbsolutePath (const String& p)
{
if (p.isEmpty())

View file

@ -120,6 +120,14 @@ public:
*/
bool isDirectory() const;
/** Checks whether the path of this file represents the root of a file system,
irrespective of its existance.
This will return true for "C:", "D:", etc on Windows and "/" on other
platforms.
*/
bool isRoot() const;
/** Returns the size of the file in bytes.
@returns the number of bytes in the file, or 0 if it doesn't exist.

View file

@ -164,7 +164,7 @@ void FileChooser::showPlatformDialog (Array<File>& results, const String& title_
auto parentDirectory = currentFileOrDirectory.getParentDirectory();
// Handle nonexistent root directories in the same way as existing ones
if (currentFileOrDirectory.isDirectory() || parentDirectory == currentFileOrDirectory)
if (currentFileOrDirectory.isDirectory() || currentFileOrDirectory.isRoot())
{
info.initialPath = currentFileOrDirectory.getFullPathName();
}