From 132fe47c7df374639a0d226ffeedfb29c5976ac5 Mon Sep 17 00:00:00 2001 From: Sacha Date: Sun, 24 Nov 2013 16:57:59 +1000 Subject: [PATCH] Use XDG Directory Specification for Linux. See: http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html Means that everyone will have to manually move their existing config's. Fixes #4623 --- Qt/QtHost.cpp | 13 +++++++++++-- UI/NativeApp.cpp | 11 +++++++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Qt/QtHost.cpp b/Qt/QtHost.cpp index e4f29465f..fbe16fb6f 100644 --- a/Qt/QtHost.cpp +++ b/Qt/QtHost.cpp @@ -243,7 +243,16 @@ void NativeInit(int argc, const char *argv[], const char *savegame_directory, co isMessagePending = false; std::string user_data_path = savegame_directory; +#ifdef Q_OS_LINUX + char* config = getenv("XDG_CONFIG_HOME"); + if (!config) { + config = getenv("HOME"); + strcat(config, "/.config"); + } + std::string memcard_path = std::string(config) + "/ppsspp/"; +#else std::string memcard_path = QDir::homePath().toStdString() + "/.ppsspp/"; +#endif VFSRegister("", new DirectoryAssetReader("assets/")); VFSRegister("", new DirectoryAssetReader(user_data_path.c_str())); @@ -251,7 +260,7 @@ void NativeInit(int argc, const char *argv[], const char *savegame_directory, co g_Config.AddSearchPath(user_data_path); g_Config.AddSearchPath(memcard_path + "PSP/SYSTEM/"); - g_Config.SetDefaultPath(g_Config.memCardDirectory + "PSP/SYSTEM/"); + g_Config.SetDefaultPath(memcard_path + "PSP/SYSTEM/"); g_Config.Load(); i18nrepo.LoadIni(g_Config.sLanguageIni); @@ -305,7 +314,7 @@ void NativeInit(int argc, const char *argv[], const char *savegame_directory, co g_Config.currentDirectory = QDir::homePath().toStdString(); } - g_Config.memCardDirectory = QDir::homePath().toStdString() + "/.ppsspp/"; + g_Config.memCardDirectory = memcard_path; #if defined(Q_OS_LINUX) std::string program_path = QCoreApplication::applicationDirPath().toStdString(); diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index c6334b68f..600858eb1 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -249,13 +249,11 @@ void NativeInit(int argc, const char *argv[], // We want this to be FIRST. #ifdef USING_QT_UI VFSRegister("", new AssetsAssetReader()); -#else -#if defined(BLACKBERRY) || defined(IOS) +#elif defined(BLACKBERRY) || defined(IOS) // Packed assets are included in app VFSRegister("", new DirectoryAssetReader(external_directory)); #else VFSRegister("", new DirectoryAssetReader("assets/")); -#endif #endif VFSRegister("", new DirectoryAssetReader(savegame_directory)); @@ -272,7 +270,12 @@ void NativeInit(int argc, const char *argv[], g_Config.memCardDirectory = user_data_path; g_Config.flash0Directory = std::string(external_directory) + "/flash0/"; #elif !defined(_WIN32) - g_Config.memCardDirectory = std::string(getenv("HOME")) + "/.ppsspp/"; + char* config = getenv("XDG_CONFIG_HOME"); + if (!config) { + config = getenv("HOME"); + strcat(config, "/.config"); + } + g_Config.memCardDirectory = std::string(config) + "/ppsspp/"; std::string program_path = File::GetExeDirectory(); if (program_path.empty()) g_Config.flash0Directory = g_Config.memCardDirectory + "/flash0/";