mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-22 23:26:15 +00:00
Also support AppData/Local to allow a non-roaming config
--HG-- branch : develop
This commit is contained in:
parent
e2d60e8183
commit
9602fcc8f0
2 changed files with 17 additions and 7 deletions
|
@ -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.
|
||||
|
|
|
@ -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"));
|
||||
|
|
Loading…
Reference in a new issue