diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 818266fe99..c9d9a25328 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -772,7 +772,7 @@ static int generic_action_ok(const char *path, flush_type = MENU_SETTINGS; menu_display_set_msg_force(true); - if (rarch_ctl(RARCH_CTL_REPLACE_CONFIG, action_path)) + if (retroarch_replace_config(action_path)) { bool pending_push = false; menu_navigation_ctl(MENU_NAVIGATION_CTL_CLEAR, &pending_push); diff --git a/retroarch.c b/retroarch.c index 73d24c472c..725582914a 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1463,29 +1463,6 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data) break; case RARCH_CTL_IS_BLOCK_CONFIG_READ: return rarch_block_config_read; - case RARCH_CTL_REPLACE_CONFIG: - { - char *path = (char*)data; - - if (!path) - return false; - - /* If config file to be replaced is the same as the - * current config file, exit. */ - if (string_is_equal(path, global->path.config)) - return false; - - if (settings->config_save_on_exit && *global->path.config) - config_save_file(global->path.config); - - strlcpy(global->path.config, path, sizeof(global->path.config)); - - rarch_ctl(RARCH_CTL_UNSET_BLOCK_CONFIG_READ, NULL); - - *settings->path.libretro = '\0'; /* Load core in new config. */ - } - runloop_ctl(RUNLOOP_CTL_PREPARE_DUMMY, NULL); - break; case RARCH_CTL_MENU_RUNNING: #ifdef HAVE_MENU menu_driver_ctl(RARCH_MENU_CTL_SET_TOGGLE, NULL); @@ -1532,6 +1509,36 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data) return true; } +/* Replaces currently loaded configuration file with + * another one. Will load a dummy core to flush state + * properly. */ +bool retroarch_replace_config(char *path) +{ + settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); + + if (!path) + return false; + + /* If config file to be replaced is the same as the + * current config file, exit. */ + if (string_is_equal(path, global->path.config)) + return false; + + if (settings->config_save_on_exit && *global->path.config) + config_save_file(global->path.config); + + strlcpy(global->path.config, path, sizeof(global->path.config)); + + rarch_ctl(RARCH_CTL_UNSET_BLOCK_CONFIG_READ, NULL); + + *settings->path.libretro = '\0'; /* Load core in new config. */ + + runloop_ctl(RUNLOOP_CTL_PREPARE_DUMMY, NULL); + + return true; +} + void retroarch_set_pathnames(const char *path) { global_t *global = global_get_ptr(); diff --git a/retroarch.h b/retroarch.h index 24b3c78a1f..f1678210f7 100644 --- a/retroarch.h +++ b/retroarch.h @@ -81,10 +81,6 @@ enum rarch_ctl_state RARCH_CTL_MENU_RUNNING_FINISHED, - /* Replaces currently loaded configuration file with - * another one. Will load a dummy core to flush state - * properly. */ - RARCH_CTL_REPLACE_CONFIG, /* Validates CPU features for given processor architecture. * Make sure we haven't compiled for something we cannot run. @@ -166,6 +162,11 @@ void retroarch_set_pathnames(const char *path); void retroarch_fill_pathnames(void); +/* Replaces currently loaded configuration file with + * another one. Will load a dummy core to flush state + * properly. */ +bool retroarch_replace_config(char *path); + /** * retroarch_fail: * @error_code : Error code.