13
0

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)

This commit is contained in:
John Emmas 2014-03-10 16:05:40 +00:00
parent e0678ce30f
commit a4752e057d

View File

@ -30,6 +30,11 @@
#include "i18n.h" #include "i18n.h"
#ifdef PLATFORM_WINDOWS
#include "shlobj.h"
#include "pbd/windows_special_dirs.h"
#endif
using namespace PBD; using namespace PBD;
namespace ARDOUR { namespace ARDOUR {
@ -54,8 +59,14 @@ user_config_directory ()
if ((c = getenv ("XDG_CONFIG_HOME")) != 0) { if ((c = getenv ("XDG_CONFIG_HOME")) != 0) {
p = c; p = c;
} else { } 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 ()) { if (home_dir.empty ()) {
error << "Unable to determine home directory" << endmsg; error << "Unable to determine home directory" << endmsg;
exit (1); exit (1);
@ -104,7 +115,14 @@ user_cache_directory ()
if ((c = getenv ("XDG_CACHE_HOME")) != 0) { if ((c = getenv ("XDG_CACHE_HOME")) != 0) {
p = c; p = c;
} else { } 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(); const string home_dir = Glib::get_home_dir();
#endif
if (home_dir.empty ()) { if (home_dir.empty ()) {
error << "Unable to determine home directory" << endmsg; error << "Unable to determine home directory" << endmsg;