From e2ec1586ba27c3de37ef9db40c18521a9c87d68f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 16 Oct 2012 15:18:40 +0200 Subject: [PATCH] (Android) Loads a config file now from either $(INTERNAL_STORAGE)/retroarch.cfg, $(EXTERNAL_STORAGE)/retroarch.cfg, or /mnt/extsd/retroarch.cfg. will need to find a better catch-all location to put this and just use the rest as fallbacks --- settings.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/settings.c b/settings.c index 99ae71a6ed..c3e9f62fcd 100644 --- a/settings.c +++ b/settings.c @@ -278,6 +278,55 @@ static config_file_t *open_default_config_file(void) } if (!conf) conf = config_file_new("/etc/retroarch.cfg"); +#elif defined(ANDROID) + bool succeeded = false; + char *home = getenv("EXTERNAL_STORAGE"); + char conf_path[PATH_MAX]; + + if(home) + { + strlcpy(conf_path, home, sizeof(conf_path)); + strlcat(conf_path, "/retroarch.cfg", sizeof(conf_path)); + conf = config_file_new(conf_path); + + if(!conf) + RARCH_WARN("Could not load config file: [%s].\n", conf_path); + else + succeeded = true; + } + + if (!succeeded) + { + home = NULL; + home = getenv("INTERNAL_STORAGE"); + + if(home) + { + strlcpy(conf_path, home, sizeof(conf_path)); + strlcat(conf_path, "/retroarch.cfg", sizeof(conf_path)); + RARCH_WARN("Trying: [%s].\n", conf_path); + conf = config_file_new(conf_path); + + if(!conf) + RARCH_WARN("Could not load config file: [%s].\n", conf_path); + } + + if(conf) + succeeded = true; + } + + // Try this as a last chance (EXTSD)... + if (!succeeded) + { + RARCH_WARN("Trying last fallback: [%s].\n", "/mnt/extsd/retroarch.cfg"); + conf = config_file_new("/mnt/extsd/retroarch.cfg"); + + if(conf) + { + RARCH_LOG("Successfully loaded config file: [%s].\n", "/mnt/extsd/retroarch.cfg"); + succeeded = true; + } + } #elif !defined(__CELLOS_LV2__) && !defined(_XBOX) const char *xdg = getenv("XDG_CONFIG_HOME"); if (!xdg)