fix(config): rutes per plataforma a createSystemFolder
This commit is contained in:
1 parent
babb111b6f
commit
583acb9053
2 files changed
+23
-9
No files matched your search
@@ -69,8 +69,9 @@ Director::Director() {
|
||||
std::exit(1);
|
||||
}
|
||||
|
||||
// Prepara la carpeta de sistema (~/.config/jailgames/aee_arcade/) i carrega
|
||||
// les opcions; si no existeix config.yaml el crea amb els defaults.
|
||||
// Prepara la carpeta de sistema (per plataforma: %APPDATA% a Windows,
|
||||
// ~/Library/Application Support a macOS, ~/.config a Linux) i carrega les
|
||||
// opcions; si no existeix config.yaml el crea amb els defaults.
|
||||
createSystemFolder();
|
||||
|
||||
// Gamepad: descobreix mandos presents silenciosament. Cal fer-ho ABANS
|
||||
@@ -331,17 +332,29 @@ Director::~Director() {
|
||||
}
|
||||
|
||||
void Director::createSystemFolder() {
|
||||
// Volem la config a $XDG_CONFIG_HOME/jailgames/aee_arcade/ (defecte
|
||||
// ~/.config/jailgames/aee_arcade/). SDL_GetPrefPath apunta a XDG_DATA_HOME
|
||||
// (.local/share), que és el lloc per a dades, no per a configuració.
|
||||
const char* xdg = std::getenv("XDG_CONFIG_HOME");
|
||||
// Carpeta de configuració per plataforma:
|
||||
// - Windows: %APPDATA%\jailgames\aee_arcade\
|
||||
// - macOS: ~/Library/Application Support/jailgames/aee_arcade/
|
||||
// - Linux: $XDG_CONFIG_HOME/jailgames/aee_arcade/ (defecte
|
||||
// ~/.config/jailgames/aee_arcade/)
|
||||
// No fem servir SDL_GetPrefPath: a Linux apunta a XDG_DATA_HOME
|
||||
// (~/.local/share), que és per a dades, no per a configuració.
|
||||
std::string base;
|
||||
#ifdef _WIN32
|
||||
const char* appdata = std::getenv("APPDATA");
|
||||
base = (appdata != nullptr && *appdata != '\0') ? std::string(appdata) : ".";
|
||||
#elif defined(__APPLE__)
|
||||
const char* home = std::getenv("HOME");
|
||||
base = (home != nullptr) ? std::string(home) + "/Library/Application Support" : ".";
|
||||
#else
|
||||
const char* xdg = std::getenv("XDG_CONFIG_HOME");
|
||||
if (xdg != nullptr && *xdg != '\0') {
|
||||
base = xdg;
|
||||
} else {
|
||||
const char* home = std::getenv("HOME");
|
||||
base = (home != nullptr) ? std::string(home) + "/.config" : ".";
|
||||
}
|
||||
#endif
|
||||
system_folder_ = base + "/jailgames/aee_arcade/";
|
||||
|
||||
std::error_code error;
|
||||
|
||||
Reference in new issue
Block a user