From bf6f2d4ac276dd21c6a837ec3795d7a03d3d0bdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ed=C3=AAnis=20Freindorfer=20Azevedo?= Date: Thu, 30 May 2019 20:34:37 -0300 Subject: [PATCH] Change where the config dir is created. On Windows, if there is a `vbam.ini` where the exe is, we should not create the configuration directory `%LOCALAPPDATA%\visualboyadvance-m`. --- src/common/ConfigManager.cpp | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/common/ConfigManager.cpp b/src/common/ConfigManager.cpp index fe363736..7b68f4ae 100644 --- a/src/common/ConfigManager.cpp +++ b/src/common/ConfigManager.cpp @@ -659,6 +659,12 @@ const char* FindConfigFile(const char *name) return name; } + struct stat s; + std::string homeDirTmp = get_xdg_user_config_home() + DOT_DIR; + homeDir = (char *)homeDirTmp.c_str(); + if (stat(homeDir, &s) == -1 || !S_ISDIR(s.st_mode)) + mkdir(homeDir, 0755); + if (homeDir) { sprintf(path, "%s%c%s", homeDir, FILE_SEP, name); if (FileExists(path)) @@ -730,12 +736,6 @@ const char* FindConfigFile(const char *name) void LoadConfigFile() { - struct stat s; - std::string homeDirTmp = get_xdg_user_config_home() + DOT_DIR; - homeDir = (char *)homeDirTmp.c_str(); - if (stat(homeDir, &s) == -1 || !S_ISDIR(s.st_mode)) - mkdir(homeDir, 0755); - if (preferences == NULL) { const char* configFile = FindConfigFile("vbam.ini"); @@ -745,12 +745,6 @@ void LoadConfigFile() void SaveConfigFile() { - struct stat s; - std::string homeDirTmp = get_xdg_user_config_home() + DOT_DIR; - homeDir = (char *)homeDirTmp.c_str(); - if (stat(homeDir, &s) == -1 || !S_ISDIR(s.st_mode)) - mkdir(homeDir, 0755); - const char* configFile = FindConfigFile("vbam.ini"); if (configFile != NULL)