diff options
author | John Emmas <johne53@tiscali.co.uk> | 2014-03-10 16:05:40 +0000 |
---|---|---|
committer | John Emmas <johne53@tiscali.co.uk> | 2014-03-10 16:24:11 +0000 |
commit | a4752e057d6a265aee919acdf348adccab9126a7 (patch) | |
tree | 4ba2f3cce0b2a83c49b38a8d8a4177c138922f43 /libs/ardour/filesystem_paths.cc | |
parent | e0678ce30f226fdffbee2fe59d29edf70bac36fc (diff) |
Modify 'user_config_directory()' and 'user_cache_directory()' so that (on Windows) they'll always return a directory that's guaranteed to be writable (in Windows, this isn't always true for the user's home folder)
Diffstat (limited to 'libs/ardour/filesystem_paths.cc')
-rw-r--r-- | libs/ardour/filesystem_paths.cc | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/libs/ardour/filesystem_paths.cc b/libs/ardour/filesystem_paths.cc index a523e35730..acb691d7db 100644 --- a/libs/ardour/filesystem_paths.cc +++ b/libs/ardour/filesystem_paths.cc @@ -30,6 +30,11 @@ #include "i18n.h" +#ifdef PLATFORM_WINDOWS +#include "shlobj.h" +#include "pbd/windows_special_dirs.h" +#endif + using namespace PBD; namespace ARDOUR { @@ -54,8 +59,14 @@ user_config_directory () if ((c = getenv ("XDG_CONFIG_HOME")) != 0) { p = c; } else { - const string home_dir = Glib::get_home_dir(); +#ifdef PLATFORM_WINDOWS + std::string home_dir; + if (0 != PBD::get_win_special_folder(CSIDL_LOCAL_APPDATA)) + home_dir = PBD::get_win_special_folder(CSIDL_LOCAL_APPDATA); +#else + const string home_dir = Glib::get_home_dir(); +#endif if (home_dir.empty ()) { error << "Unable to determine home directory" << endmsg; exit (1); @@ -104,7 +115,14 @@ user_cache_directory () if ((c = getenv ("XDG_CACHE_HOME")) != 0) { p = c; } else { +#ifdef PLATFORM_WINDOWS + std::string home_dir; + + if (0 != PBD::get_win_special_folder(CSIDL_LOCAL_APPDATA)) + home_dir = PBD::get_win_special_folder(CSIDL_LOCAL_APPDATA); +#else const string home_dir = Glib::get_home_dir(); +#endif if (home_dir.empty ()) { error << "Unable to determine home directory" << endmsg; |