GODT-2020: fix xdg_{home,cache}_home variables

This commit is contained in:
tpeacock19
2022-11-02 07:54:06 -07:00
committed by Romain LE JEUNE
parent cb871ce4bc
commit 9548f984eb

View File

@ -84,11 +84,12 @@ QString userConfigDir()
dir += "/Library/Application Support";
#else
dir = qgetenv ("XDG_CONFIG_HOME");
if (dir.isEmpty())
if (dir.isEmpty()) {
dir = qgetenv ("HOME");
if (dir.isEmpty())
throw Exception("neither $XDG_CONFIG_HOME nor $HOME are defined");
dir += "/.config";
}
#endif
QString const folder = QDir(dir).absoluteFilePath(configFolder);
QDir().mkpath(folder);
@ -115,11 +116,12 @@ QString userCacheDir()
dir += "/Library/Caches";
#else
dir = qgetenv ("XDG_CACHE_HOME");
if (dir.isEmpty())
if (dir.isEmpty()) {
dir = qgetenv ("HOME");
if (dir.isEmpty())
throw Exception("neither XDG_CACHE_HOME nor $HOME are defined");
dir += "/.cache";
}
#endif
QString const folder = QDir(dir).absoluteFilePath(configFolder);