From b171323b915f74c139574e40f403b9d99fd15806 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Thu, 4 Feb 2016 13:02:32 +0100 Subject: [PATCH] Also support AppData/Local to allow a non-roaming config --- code/nel/include/nel/misc/path.h | 4 ++-- code/nel/src/misc/path.cpp | 20 +++++++++++++++----- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/code/nel/include/nel/misc/path.h b/code/nel/include/nel/misc/path.h index 9c3e2e21b..1fa049fa5 100644 --- a/code/nel/include/nel/misc/path.h +++ b/code/nel/include/nel/misc/path.h @@ -230,7 +230,7 @@ public: /** Get application directory. * \return directory where applications should write files. */ - std::string getApplicationDirectory(const std::string &appName = ""); + std::string getApplicationDirectory(const std::string &appName = "", bool local = false); /** Get a temporary directory. * \return temporary directory where applications should write files. @@ -540,7 +540,7 @@ public: /** Get application directory. * \return directory where applications should write files. */ - static std::string getApplicationDirectory(const std::string &appName = ""); + static std::string getApplicationDirectory(const std::string &appName = "", bool local = false); /** Get a temporary directory. * \return temporary directory where applications should write files. diff --git a/code/nel/src/misc/path.cpp b/code/nel/src/misc/path.cpp index 58370eb2b..aa66f0fd7 100644 --- a/code/nel/src/misc/path.cpp +++ b/code/nel/src/misc/path.cpp @@ -1777,19 +1777,29 @@ std::string CFileContainer::getWindowsDirectory() #endif } -std::string CPath::getApplicationDirectory(const std::string &appName) +std::string CPath::getApplicationDirectory(const std::string &appName, bool local) { - return getInstance()->_FileContainer.getApplicationDirectory(appName); + return getInstance()->_FileContainer.getApplicationDirectory(appName, local); } -std::string CFileContainer::getApplicationDirectory(const std::string &appName) +std::string CFileContainer::getApplicationDirectory(const std::string &appName, bool local) { - static std::string appPath; + static std::string appPaths[2]; + std::string &appPath = appPaths[local ? 1 : 0]; if (appPath.empty()) { #ifdef NL_OS_WINDOWS wchar_t buffer[MAX_PATH]; - SHGetSpecialFolderPathW(NULL, buffer, CSIDL_APPDATA, TRUE); +#ifdef CSIDL_LOCAL_APPDATA + if (local) + { + SHGetSpecialFolderPathW(NULL, buffer, CSIDL_LOCAL_APPDATA, TRUE); + } + else +#endif + { + SHGetSpecialFolderPathW(NULL, buffer, CSIDL_APPDATA, TRUE); + } appPath = CPath::standardizePath(ucstring((ucchar*)buffer).toUtf8()); #elif defined(NL_OS_MAC) appPath = CPath::standardizePath(getenv("HOME"));