From 725334d78cb776bde9c9f107ff3b7ab79c7c5a50 Mon Sep 17 00:00:00 2001 From: jules Date: Sat, 31 Aug 2013 16:15:07 +0100 Subject: [PATCH] Added File::commonDocumentsDirectory enum. --- modules/juce_core/files/juce_File.h | 27 ++++++++++++------- .../juce_core/native/juce_android_Files.cpp | 2 +- modules/juce_core/native/juce_linux_Files.cpp | 6 ++--- modules/juce_core/native/juce_mac_Files.mm | 1 + modules/juce_core/native/juce_win32_Files.cpp | 1 + 5 files changed, 22 insertions(+), 15 deletions(-) diff --git a/modules/juce_core/files/juce_File.h b/modules/juce_core/files/juce_File.h index 972070167e..6780e11d21 100644 --- a/modules/juce_core/files/juce_File.h +++ b/modules/juce_core/files/juce_File.h @@ -762,6 +762,15 @@ public: /** The folder that contains the user's desktop objects. */ userDesktopDirectory, + /** The most likely place where a user might store their music files. */ + userMusicDirectory, + + /** The most likely place where a user might store their movie files. */ + userMoviesDirectory, + + /** The most likely place where a user might store their picture files. */ + userPicturesDirectory, + /** The folder in which applications store their persistent user-specific settings. On Windows, this might be "\Documents and Settings\username\Application Data". On the Mac, it might be "~/Library". If you're going to store your settings in here, @@ -779,6 +788,13 @@ public: */ commonApplicationDataDirectory, + /** A place to put documents which are shared by all users of the machine. + On Windows this may be somewhere like "C:\Users\Public\Documents", on OSX it + will be something like "/Users/Shared". Other OSes may have no such concept + though, so be careful. + */ + commonDocumentsDirectory, + /** The folder that should be used for temporary files. Always delete them when you're finished, to keep the user's computer tidy! */ @@ -821,16 +837,7 @@ public: So on windows, this would be something like "c:\program files", on the Mac "/Applications", or "/usr" on linux. */ - globalApplicationsDirectory, - - /** The most likely place where a user might store their music files. */ - userMusicDirectory, - - /** The most likely place where a user might store their movie files. */ - userMoviesDirectory, - - /** The most likely place where a user might store their picture files. */ - userPicturesDirectory + globalApplicationsDirectory }; /** Finds the location of a special type of file or directory, such as a home folder or diff --git a/modules/juce_core/native/juce_android_Files.cpp b/modules/juce_core/native/juce_android_Files.cpp index 30a530af37..5727581a81 100644 --- a/modules/juce_core/native/juce_android_Files.cpp +++ b/modules/juce_core/native/juce_android_Files.cpp @@ -112,13 +112,13 @@ File File::getSpecialLocation (const SpecialLocationType type) return File (android.appDataDir); case commonApplicationDataDirectory: + case commonDocumentsDirectory: return File (android.appDataDir); case globalApplicationsDirectory: return File ("/system/app"); case tempDirectory: - //return File (AndroidStatsHelpers::getSystemProperty ("java.io.tmpdir")); return File (android.appDataDir).getChildFile (".temp"); case invokedExecutableFile: diff --git a/modules/juce_core/native/juce_linux_Files.cpp b/modules/juce_core/native/juce_linux_Files.cpp index a953cba2b9..63682460f2 100644 --- a/modules/juce_core/native/juce_linux_Files.cpp +++ b/modules/juce_core/native/juce_linux_Files.cpp @@ -168,11 +168,8 @@ File File::getSpecialLocation (const SpecialLocationType type) const char* homeDir = getenv ("HOME"); if (homeDir == nullptr) - { - struct passwd* const pw = getpwuid (getuid()); - if (pw != nullptr) + if (struct passwd* const pw = getpwuid (getuid())) homeDir = pw->pw_dir; - } return File (CharPointer_UTF8 (homeDir)); } @@ -183,6 +180,7 @@ File File::getSpecialLocation (const SpecialLocationType type) case userPicturesDirectory: return resolveXDGFolder ("XDG_PICTURES_DIR", "~"); case userDesktopDirectory: return resolveXDGFolder ("XDG_DESKTOP_DIR", "~/Desktop"); case userApplicationDataDirectory: return File ("~"); + case commonDocumentsDirectory: case commonApplicationDataDirectory: return File ("/var"); case globalApplicationsDirectory: return File ("/usr"); diff --git a/modules/juce_core/native/juce_mac_Files.mm b/modules/juce_core/native/juce_mac_Files.mm index cee6b2cb4d..d2be92e35d 100644 --- a/modules/juce_core/native/juce_mac_Files.mm +++ b/modules/juce_core/native/juce_mac_Files.mm @@ -213,6 +213,7 @@ File File::getSpecialLocation (const SpecialLocationType type) case userPicturesDirectory: resultPath = "~/Pictures"; break; case userApplicationDataDirectory: resultPath = "~/Library"; break; case commonApplicationDataDirectory: resultPath = "/Library"; break; + case commonDocumentsDirectory: resultPath = "/Users/Shared"; break; case globalApplicationsDirectory: resultPath = "/Applications"; break; case invokedExecutableFile: diff --git a/modules/juce_core/native/juce_win32_Files.cpp b/modules/juce_core/native/juce_win32_Files.cpp index 75b3ad918d..8c8ab918c7 100644 --- a/modules/juce_core/native/juce_win32_Files.cpp +++ b/modules/juce_core/native/juce_win32_Files.cpp @@ -518,6 +518,7 @@ File JUCE_CALLTYPE File::getSpecialLocation (const SpecialLocationType type) case userDesktopDirectory: csidlType = CSIDL_DESKTOP; break; case userApplicationDataDirectory: csidlType = CSIDL_APPDATA; break; case commonApplicationDataDirectory: csidlType = CSIDL_COMMON_APPDATA; break; + case commonDocumentsDirectory: csidlType = CSIDL_COMMON_DOCUMENTS; break; case globalApplicationsDirectory: csidlType = CSIDL_PROGRAM_FILES; break; case userMusicDirectory: csidlType = 0x0d; /*CSIDL_MYMUSIC*/ break; case userMoviesDirectory: csidlType = 0x0e; /*CSIDL_MYVIDEO*/ break;