Fix data directory when using XDG (#470)

Since 7fbed05135
musikcube detects `$XDG_CONFIG_HOME` with `GetHomeDirectory`.
There is an intermediate call to `getDataDirectoryRoot` though which
appends `/.config`, stemming from when `GetHomeDirectory` would actually
return `$HOME`. This leads to the situation where on most systems where
config home is already under `$HOME/.config/` musikcube will create
`$HOME/.config/.config/musikcube` for itself.

We fix this by removing the `getDataDirectoryRoot` shim entirely.

Signed-off-by: Robert Günzler <r@gnzler.io>
This commit is contained in:
Robert Günzler 2021-11-15 00:43:51 +01:00 committed by GitHub
parent fe2e4747da
commit 4f5e233126
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -81,14 +81,6 @@ static inline void silentDelete(const std::string fn) {
namespace musik { namespace core { namespace musik { namespace core {
static std::string getDataDirectoryRoot() {
#ifdef WIN32
return GetHomeDirectory();
#else
return GetHomeDirectory() + "/.config";
#endif
}
std::string GetPluginDirectory() { std::string GetPluginDirectory() {
std::string path(GetApplicationDirectory()); std::string path(GetApplicationDirectory());
path.append("/plugins/"); path.append("/plugins/");
@ -166,7 +158,7 @@ namespace musik { namespace core {
directory = std::string(result); directory = std::string(result);
} }
else { else {
directory = std::string(std::getenv("HOME")); directory = std::string(std::getenv("HOME")) + std::string("/.config/");
} }
#endif #endif
@ -174,7 +166,7 @@ namespace musik { namespace core {
} }
std::string GetDataDirectory(bool create) { std::string GetDataDirectory(bool create) {
std::string directory = getDataDirectoryRoot() + std::string("/musikcube/"); std::string directory = GetHomeDirectory() + std::string("/musikcube/");
if (create) { if (create) {
try { try {