From a8fac8f8e990ba5aa91d0e9f3725f5275b35683a Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 18 Jun 2016 19:47:05 +0200 Subject: [PATCH] Changed: Under Linux, it's recommended to put user application data in ~/.local/share --HG-- branch : develop --- code/nel/src/misc/path.cpp | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/code/nel/src/misc/path.cpp b/code/nel/src/misc/path.cpp index 061c938a5..9737589f7 100644 --- a/code/nel/src/misc/path.cpp +++ b/code/nel/src/misc/path.cpp @@ -1784,7 +1784,9 @@ std::string CPath::getApplicationDirectory(const std::string &appName, bool loca std::string CFileContainer::getApplicationDirectory(const std::string &appName, bool local) { static std::string appPaths[2]; + std::string &appPath = appPaths[local ? 1 : 0]; + if (appPath.empty()) { #ifdef NL_OS_WINDOWS @@ -1800,26 +1802,21 @@ std::string CFileContainer::getApplicationDirectory(const std::string &appName, SHGetSpecialFolderPathW(NULL, buffer, CSIDL_APPDATA, TRUE); } appPath = CPath::standardizePath(wideToUtf8(buffer)); -#elif defined(NL_OS_MAC) - appPath = CPath::standardizePath(getenv("HOME")); - appPath += "/Library/Application Support/"; #else - appPath = CPath::standardizePath(getenv("HOME")); -#endif - } + // get user home directory from HOME environment variable + const char* homePath = getenv("HOME"); + appPath = CPath::standardizePath(homePath ? homePath : "."); - std::string path = appPath; -#ifdef NL_OS_WINDOWS - if (!appName.empty()) - path = CPath::standardizePath(path + appName); -#elif defined(NL_OS_MAC) - path = CPath::standardizePath(path + appName); +#if defined(NL_OS_MAC) + appPath += "Library/Application Support/"; #else - if (!appName.empty()) - path = CPath::standardizePath(path + "." + toLower(appName)); + // recommended for applications data that are owned by user + appPath += ".local/share/"; +#endif #endif + } - return path; + return CPath::standardizePath(appPath + appName); } std::string CPath::getTemporaryDirectory()