Changed: Under Linux, it's recommended to put user application data in ~/.local/share
This commit is contained in:
parent
583c540995
commit
01c0f01df8
1 changed files with 13 additions and 16 deletions
|
@ -1784,7 +1784,9 @@ std::string CPath::getApplicationDirectory(const std::string &appName, bool loca
|
||||||
std::string CFileContainer::getApplicationDirectory(const std::string &appName, bool local)
|
std::string CFileContainer::getApplicationDirectory(const std::string &appName, bool local)
|
||||||
{
|
{
|
||||||
static std::string appPaths[2];
|
static std::string appPaths[2];
|
||||||
|
|
||||||
std::string &appPath = appPaths[local ? 1 : 0];
|
std::string &appPath = appPaths[local ? 1 : 0];
|
||||||
|
|
||||||
if (appPath.empty())
|
if (appPath.empty())
|
||||||
{
|
{
|
||||||
#ifdef NL_OS_WINDOWS
|
#ifdef NL_OS_WINDOWS
|
||||||
|
@ -1800,26 +1802,21 @@ std::string CFileContainer::getApplicationDirectory(const std::string &appName,
|
||||||
SHGetSpecialFolderPathW(NULL, buffer, CSIDL_APPDATA, TRUE);
|
SHGetSpecialFolderPathW(NULL, buffer, CSIDL_APPDATA, TRUE);
|
||||||
}
|
}
|
||||||
appPath = CPath::standardizePath(wideToUtf8(buffer));
|
appPath = CPath::standardizePath(wideToUtf8(buffer));
|
||||||
#elif defined(NL_OS_MAC)
|
|
||||||
appPath = CPath::standardizePath(getenv("HOME"));
|
|
||||||
appPath += "/Library/Application Support/";
|
|
||||||
#else
|
#else
|
||||||
appPath = CPath::standardizePath(getenv("HOME"));
|
// get user home directory from HOME environment variable
|
||||||
|
const char* homePath = getenv("HOME");
|
||||||
|
appPath = CPath::standardizePath(homePath ? homePath : ".");
|
||||||
|
|
||||||
|
#if defined(NL_OS_MAC)
|
||||||
|
appPath += "Library/Application Support/";
|
||||||
|
#else
|
||||||
|
// recommended for applications data that are owned by user
|
||||||
|
appPath += ".local/share/";
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string path = appPath;
|
return CPath::standardizePath(appPath + appName);
|
||||||
#ifdef NL_OS_WINDOWS
|
|
||||||
if (!appName.empty())
|
|
||||||
path = CPath::standardizePath(path + appName);
|
|
||||||
#elif defined(NL_OS_MAC)
|
|
||||||
path = CPath::standardizePath(path + appName);
|
|
||||||
#else
|
|
||||||
if (!appName.empty())
|
|
||||||
path = CPath::standardizePath(path + "." + toLower(appName));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return path;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CPath::getTemporaryDirectory()
|
std::string CPath::getTemporaryDirectory()
|
||||||
|
|
Loading…
Reference in a new issue