From a9b1ff737c6f04573b3e1dc1a98881c4a31915fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Sat, 11 Jan 2020 00:50:02 +0100 Subject: [PATCH] FS: Use PHYSFS_getPrefDir on Linux/FreeBSD too Follow-up to #19 which did the change for macOS. It appears to work as expected on Linux too. Tested on a distro where XDG_DATA_HOME is undefined by default, and `PHYSFS_getPrefDir` also resolves to `~/.local/share/VVVVVV/`. The first organization parameter is unused on Linux and macOS. --- desktop_version/CONTRIBUTORS.txt | 5 ++++- desktop_version/src/FileSystemUtils.cpp | 14 +------------- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/desktop_version/CONTRIBUTORS.txt b/desktop_version/CONTRIBUTORS.txt index f9138a2a..bb3c3dce 100644 --- a/desktop_version/CONTRIBUTORS.txt +++ b/desktop_version/CONTRIBUTORS.txt @@ -1,7 +1,10 @@ Contributors ------------ +(Ordered alphabetically by last name.) + * Christoph Böhmwalder (@chrboe) +* Marvin Scholz (@ePirat) * Elijah Stone * Emmanuel Vadot (@evadot) -* Marvin Scholz (@ePirat) +* Rémi Verschelde (@akien-mga) diff --git a/desktop_version/src/FileSystemUtils.cpp b/desktop_version/src/FileSystemUtils.cpp index 8ad999f9..ce703273 100644 --- a/desktop_version/src/FileSystemUtils.cpp +++ b/desktop_version/src/FileSystemUtils.cpp @@ -159,19 +159,7 @@ std::vector FILESYSTEM_getLevelDirFileNames() void PLATFORM_getOSDirectory(char* output) { -#if defined(__linux__) || defined(__FreeBSD__) - const char *homeDir = getenv("XDG_DATA_HOME"); - if (homeDir == NULL) - { - strcpy(output, PHYSFS_getUserDir()); - strcat(output, ".local/share/VVVVVV/"); - } - else - { - strcpy(output, homeDir); - strcat(output, "/VVVVVV/"); - } -#elif defined(__APPLE__) +#if defined(__linux__) || defined(__FreeBSD__) || defined(__APPLE__) strcpy(output, PHYSFS_getPrefDir("distractionware", "VVVVVV")); #elif defined(_WIN32) SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, output);