(configuration.c) Cleanups

This commit is contained in:
twinaphex 2019-07-04 17:29:29 +02:00
parent 3067ce6285
commit 1f17dea0d8
3 changed files with 30 additions and 21 deletions

View File

@ -3523,21 +3523,29 @@ success:
return true; return true;
} }
static void parse_config_file(void) /**
* config_parse_file:
*
* Loads a config file and reads all the values into memory.
*
*/
void config_parse_file(void)
{ {
const char *config_path = path_get(RARCH_PATH_CONFIG);
if (path_is_empty(RARCH_PATH_CONFIG)) if (path_is_empty(RARCH_PATH_CONFIG))
{ {
RARCH_LOG("[config] Loading default config.\n"); RARCH_LOG("[config] Loading default config.\n");
} }
RARCH_LOG("[config] loading config from: %s.\n", config_path); {
const char *config_path = path_get(RARCH_PATH_CONFIG);
RARCH_LOG("[config] loading config from: %s.\n", config_path);
if (config_load_file(config_path, config_get_ptr())) if (!config_load_file(config_path, config_get_ptr()))
return; {
RARCH_ERR("[config] couldn't find config at path: \"%s\"\n",
RARCH_ERR("[config] couldn't find config at path: \"%s\"\n", config_path);
config_path); }
}
} }
/** /**
@ -3548,15 +3556,8 @@ static void parse_config_file(void)
*/ */
void config_load(void) void config_load(void)
{ {
/* Flush out some states that could have been
* set by core environment variables */
core_unset_input_descriptors();
if (rarch_ctl(RARCH_CTL_IS_BLOCK_CONFIG_READ, NULL))
return;
config_set_defaults(); config_set_defaults();
parse_config_file(); config_parse_file();
} }
/** /**

View File

@ -746,12 +746,12 @@ const char *config_get_midi_driver_options(void);
const char *config_get_default_record(void); const char *config_get_default_record(void);
/** /**
* config_load: * config_parse_file:
* *
* Loads a config file and reads all the values into memory. * Loads a config file and reads all the values into memory.
* *
*/ */
void config_load(void); void config_parse_file(void);
/** /**
* config_load_override: * config_load_override:

View File

@ -260,8 +260,9 @@ static retro_bits_t has_set_libretro_device;
static bool has_set_core = false; static bool has_set_core = false;
#ifdef HAVE_DISCORD #ifdef HAVE_DISCORD
bool discord_is_inited = false; bool discord_is_inited = false;
#endif #endif
static bool rarch_block_config_read = false;
static bool rarch_is_inited = false; static bool rarch_is_inited = false;
static bool rarch_error_on_init = false; static bool rarch_error_on_init = false;
static bool rarch_force_fullscreen = false; static bool rarch_force_fullscreen = false;
@ -13677,8 +13678,16 @@ static void retroarch_parse_input_and_config(int argc, char *argv[])
} }
} }
/* Flush out some states that could have been set
* by core environment variables. */
core_unset_input_descriptors();
/* Load the config file now that we know what it is */ /* Load the config file now that we know what it is */
config_load(); if (!rarch_block_config_read)
{
config_set_defaults();
config_parse_file();
}
/* Second pass: All other arguments override the config file */ /* Second pass: All other arguments override the config file */
optind = 1; optind = 1;
@ -14484,7 +14493,6 @@ static void runloop_task_msg_queue_push(
bool rarch_ctl(enum rarch_ctl_state state, void *data) bool rarch_ctl(enum rarch_ctl_state state, void *data)
{ {
static bool has_set_username = false; static bool has_set_username = false;
static bool rarch_block_config_read = false;
static bool rarch_patch_blocked = false; static bool rarch_patch_blocked = false;
static bool runloop_missing_bios = false; static bool runloop_missing_bios = false;
/* TODO/FIXME - not used right now? */ /* TODO/FIXME - not used right now? */