mirror of
https://github.com/libretro/RetroArch
synced 2025-02-28 12:40:23 +00:00
Cleanups - in open_default_config_file
This commit is contained in:
parent
a7e16d2830
commit
6374422d1f
71
settings.c
71
settings.c
@ -735,11 +735,13 @@ static void config_set_defaults(void)
|
|||||||
**/
|
**/
|
||||||
static config_file_t *open_default_config_file(void)
|
static config_file_t *open_default_config_file(void)
|
||||||
{
|
{
|
||||||
|
bool saved = false;
|
||||||
char conf_path[PATH_MAX_LENGTH], app_path[PATH_MAX_LENGTH];
|
char conf_path[PATH_MAX_LENGTH], app_path[PATH_MAX_LENGTH];
|
||||||
config_file_t *conf = NULL;
|
config_file_t *conf = NULL;
|
||||||
|
|
||||||
(void)conf_path;
|
(void)conf_path;
|
||||||
(void)app_path;
|
(void)app_path;
|
||||||
|
(void)saved;
|
||||||
|
|
||||||
#if defined(_WIN32) && !defined(_XBOX)
|
#if defined(_WIN32) && !defined(_XBOX)
|
||||||
fill_pathname_application_path(app_path, sizeof(app_path));
|
fill_pathname_application_path(app_path, sizeof(app_path));
|
||||||
@ -760,11 +762,13 @@ static config_file_t *open_default_config_file(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (conf)
|
||||||
|
goto exit;
|
||||||
|
|
||||||
/* Try to create a new config file. */
|
/* Try to create a new config file. */
|
||||||
if (!conf)
|
|
||||||
{
|
{
|
||||||
conf = config_file_new(NULL);
|
conf = config_file_new(NULL);
|
||||||
bool saved = false;
|
|
||||||
if (conf)
|
if (conf)
|
||||||
{
|
{
|
||||||
/* Since this is a clean config file, we can
|
/* Since this is a clean config file, we can
|
||||||
@ -775,9 +779,7 @@ static config_file_t *open_default_config_file(void)
|
|||||||
saved = config_file_write(conf, conf_path);
|
saved = config_file_write(conf, conf_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (saved)
|
if (!saved)
|
||||||
RARCH_WARN("Created new config file in: \"%s\".\n", conf_path);
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
/* WARN here to make sure user has a good chance of seeing it. */
|
/* WARN here to make sure user has a good chance of seeing it. */
|
||||||
RARCH_ERR("Failed to create new config file in: \"%s\".\n",
|
RARCH_ERR("Failed to create new config file in: \"%s\".\n",
|
||||||
@ -785,6 +787,8 @@ static config_file_t *open_default_config_file(void)
|
|||||||
config_file_free(conf);
|
config_file_free(conf);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RARCH_WARN("Created new config file in: \"%s\".\n", conf_path);
|
||||||
}
|
}
|
||||||
#elif defined(OSX)
|
#elif defined(OSX)
|
||||||
const char *home = getenv("HOME");
|
const char *home = getenv("HOME");
|
||||||
@ -800,29 +804,28 @@ static config_file_t *open_default_config_file(void)
|
|||||||
"retroarch.cfg", sizeof(conf_path));
|
"retroarch.cfg", sizeof(conf_path));
|
||||||
conf = config_file_new(conf_path);
|
conf = config_file_new(conf_path);
|
||||||
|
|
||||||
if (!conf)
|
if (conf)
|
||||||
|
goto exit;
|
||||||
|
|
||||||
|
conf = config_file_new(NULL);
|
||||||
|
|
||||||
|
if (conf)
|
||||||
{
|
{
|
||||||
bool saved = false;
|
config_set_bool(conf, "config_save_on_exit", true);
|
||||||
conf = config_file_new(NULL);
|
saved = config_file_write(conf, conf_path);
|
||||||
|
|
||||||
if (conf)
|
|
||||||
{
|
|
||||||
config_set_bool(conf, "config_save_on_exit", true);
|
|
||||||
saved = config_file_write(conf, conf_path);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (saved)
|
|
||||||
RARCH_WARN("Created new config file in: \"%s\".\n", conf_path);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* WARN here to make sure user has a good chance of seeing it. */
|
|
||||||
RARCH_ERR("Failed to create new config file in: \"%s\".\n",
|
|
||||||
conf_path);
|
|
||||||
config_file_free(conf);
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!saved)
|
||||||
|
{
|
||||||
|
/* WARN here to make sure user has a good chance of seeing it. */
|
||||||
|
RARCH_ERR("Failed to create new config file in: \"%s\".\n",
|
||||||
|
conf_path);
|
||||||
|
config_file_free(conf);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
RARCH_WARN("Created new config file in: \"%s\".\n", conf_path);
|
||||||
#elif !defined(__CELLOS_LV2__) && !defined(_XBOX)
|
#elif !defined(__CELLOS_LV2__) && !defined(_XBOX)
|
||||||
const char *xdg = getenv("XDG_CONFIG_HOME");
|
const char *xdg = getenv("XDG_CONFIG_HOME");
|
||||||
const char *home = getenv("HOME");
|
const char *home = getenv("HOME");
|
||||||
@ -855,9 +858,13 @@ static config_file_t *open_default_config_file(void)
|
|||||||
conf = config_file_new(conf_path);
|
conf = config_file_new(conf_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Try to create a new config file. */
|
if (conf)
|
||||||
if (!conf && (home || xdg))
|
goto exit;
|
||||||
|
|
||||||
|
if (home || xdg)
|
||||||
{
|
{
|
||||||
|
/* Try to create a new config file. */
|
||||||
|
|
||||||
char basedir[PATH_MAX_LENGTH];
|
char basedir[PATH_MAX_LENGTH];
|
||||||
|
|
||||||
/* XDG_CONFIG_HOME falls back to $HOME/.config. */
|
/* XDG_CONFIG_HOME falls back to $HOME/.config. */
|
||||||
@ -886,7 +893,6 @@ static config_file_t *open_default_config_file(void)
|
|||||||
else
|
else
|
||||||
conf = config_file_new(NULL);
|
conf = config_file_new(NULL);
|
||||||
|
|
||||||
bool saved = false;
|
|
||||||
if (conf)
|
if (conf)
|
||||||
{
|
{
|
||||||
/* Since this is a clean config file, we can safely use config_save_on_exit. */
|
/* Since this is a clean config file, we can safely use config_save_on_exit. */
|
||||||
@ -894,9 +900,7 @@ static config_file_t *open_default_config_file(void)
|
|||||||
saved = config_file_write(conf, conf_path);
|
saved = config_file_write(conf, conf_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (saved)
|
if (!saved)
|
||||||
RARCH_WARN("Created new config file in: \"%s\".\n", conf_path);
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
/* WARN here to make sure user has a good chance of seeing it. */
|
/* WARN here to make sure user has a good chance of seeing it. */
|
||||||
RARCH_ERR("Failed to create new config file in: \"%s\".\n", conf_path);
|
RARCH_ERR("Failed to create new config file in: \"%s\".\n", conf_path);
|
||||||
@ -904,10 +908,13 @@ static config_file_t *open_default_config_file(void)
|
|||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RARCH_WARN("Created new config file in: \"%s\".\n", conf_path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
exit:
|
||||||
if (!conf)
|
if (!conf)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user