|
|
@@ -23,6 +23,7 @@ |
|
|
|
#include <plugin/Plugin.hpp> |
|
|
|
#include <engine/Module.hpp> |
|
|
|
#include <app/common.hpp> |
|
|
|
#include <osdialog.h> |
|
|
|
|
|
|
|
|
|
|
|
namespace rack { |
|
|
@@ -39,9 +40,9 @@ static void initSystemDir() { |
|
|
|
} |
|
|
|
|
|
|
|
// Environment variable overrides |
|
|
|
const char* env = getenv("RACK_SYSTEM_DIR"); |
|
|
|
if (env) { |
|
|
|
systemDir = env; |
|
|
|
const char* envSystem = getenv("RACK_SYSTEM_DIR"); |
|
|
|
if (envSystem) { |
|
|
|
systemDir = envSystem; |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
@@ -93,35 +94,70 @@ static void initUserDir() { |
|
|
|
} |
|
|
|
|
|
|
|
// Environment variable overrides |
|
|
|
const char* env = getenv("RACK_USER_DIR"); |
|
|
|
if (env) { |
|
|
|
userDir = env; |
|
|
|
const char* envUser = getenv("RACK_USER_DIR"); |
|
|
|
if (envUser) { |
|
|
|
userDir = envUser; |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
std::string oldUserDir; |
|
|
|
|
|
|
|
#if defined ARCH_WIN |
|
|
|
// Get "My Documents" path |
|
|
|
wchar_t documentsBufW[MAX_PATH] = L"."; |
|
|
|
HRESULT result = SHGetFolderPathW(NULL, CSIDL_MYDOCUMENTS, NULL, SHGFP_TYPE_CURRENT, documentsBufW); |
|
|
|
assert(result == S_OK); |
|
|
|
userDir = system::join(string::UTF16toUTF8(documentsBufW), "Rack" + APP_VERSION_MAJOR); |
|
|
|
|
|
|
|
// Rack <2.5.0 used "My Documents/Rack2" |
|
|
|
oldUserDir = system::join(string::UTF16toUTF8(documentsBufW), "Rack" + APP_VERSION_MAJOR); |
|
|
|
|
|
|
|
// TODO new userDir |
|
|
|
#endif |
|
|
|
|
|
|
|
#if defined ARCH_MAC |
|
|
|
// Get home directory |
|
|
|
struct passwd* pw = getpwuid(getuid()); |
|
|
|
assert(pw); |
|
|
|
userDir = system::join(pw->pw_dir, "Documents", "Rack" + APP_VERSION_MAJOR); |
|
|
|
|
|
|
|
// Rack <2.5.0 used ~/Documents/Rack2 |
|
|
|
oldUserDir = system::join(pw->pw_dir, "Documents", "Rack" + APP_VERSION_MAJOR); |
|
|
|
|
|
|
|
// TODO new userDir |
|
|
|
#endif |
|
|
|
|
|
|
|
#if defined ARCH_LIN |
|
|
|
// Get home directory |
|
|
|
const char* homeBuf = getenv("HOME"); |
|
|
|
if (!homeBuf) { |
|
|
|
// Get home path |
|
|
|
const char* envHome = getenv("HOME"); |
|
|
|
if (!envHome) { |
|
|
|
struct passwd* pw = getpwuid(getuid()); |
|
|
|
assert(pw); |
|
|
|
homeBuf = pw->pw_dir; |
|
|
|
envHome = pw->pw_dir; |
|
|
|
} |
|
|
|
std::string homeDir = envHome; |
|
|
|
|
|
|
|
// Get XDG data path |
|
|
|
const char* envData = getenv("XDG_DATA_HOME"); |
|
|
|
if (envData) { |
|
|
|
userDir = envData; |
|
|
|
} |
|
|
|
else { |
|
|
|
userDir = system::join(homeDir, ".local", "share"); |
|
|
|
} |
|
|
|
userDir = system::join(homeBuf, ".Rack" + APP_VERSION_MAJOR); |
|
|
|
userDir = system::join(userDir, "Rack" + APP_VERSION_MAJOR); |
|
|
|
|
|
|
|
// Rack <2.5.0 used ~/.Rack2 |
|
|
|
oldUserDir = system::join(homeDir, ".Rack" + APP_VERSION_MAJOR); |
|
|
|
#endif |
|
|
|
|
|
|
|
// If userDir doesn't exist but oldUserDir does, move it. |
|
|
|
if (!system::isDirectory(userDir) && system::isDirectory(oldUserDir)) { |
|
|
|
std::string msg = "Your Rack user folder has been moved from"; |
|
|
|
msg += "\n" + oldUserDir; |
|
|
|
msg += "\nto"; |
|
|
|
msg += "\n" + userDir; |
|
|
|
osdialog_message(OSDIALOG_ERROR, OSDIALOG_OK, msg.c_str()); |
|
|
|
system::rename(oldUserDir, userDir); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void init() { |
|
|
|