From 788ec44615c9ea9e15282adf10c84c1df337f0d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1ty=C3=A1s=20Mustoha?= Date: Mon, 22 Apr 2024 15:28:34 +0200 Subject: [PATCH] Use standard XDG paths on Linux for saving user data --- src/common/path.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/common/path.cpp b/src/common/path.cpp index 76a5732a..760cf962 100644 --- a/src/common/path.cpp +++ b/src/common/path.cpp @@ -45,10 +45,19 @@ std::string GetHomeDirectory() return result; #else // catch-all for Linux-based systems - std::string result(".smw/"); - char* folder = getenv("HOME"); - if (folder) - result = std::string(folder) + "/" + result; + std::string result; +#ifdef USE_SDL2 + char* prefPath = SDL_GetPrefPath(nullptr, "supermariowar"); + if (prefPath) { + result = prefPath; + SDL_free(prefPath); + } +#else + char* home = getenv("HOME"); + if (home) { + result = std::string(home) + "/.smw/"; + } +#endif return result; #endif }