Skip to content

Commit

Permalink
Use standard XDG paths on Linux for saving user data
Browse files Browse the repository at this point in the history
  • Loading branch information
mmatyas committed Apr 22, 2024
1 parent e63375d commit 788ec44
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/common/path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 788ec44

Please sign in to comment.