From 49f050b386666f66e8ce82bab5d59288b702169c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 27 May 2016 16:42:20 +0200 Subject: [PATCH] Move config_replace to configuration.c --- configuration.c | 40 ++++++++++++++++++++++++++++++++++++++++ configuration.h | 5 +++++ menu/cbs/menu_cbs_ok.c | 2 +- retroarch.c | 37 ------------------------------------- 4 files changed, 46 insertions(+), 38 deletions(-) diff --git a/configuration.c b/configuration.c index edc1badd01..24c32a5493 100644 --- a/configuration.c +++ b/configuration.c @@ -27,6 +27,7 @@ #include "file_path_special.h" #include "audio/audio_driver.h" #include "configuration.h" +#include "content.h" #include "config.def.h" #include "input/input_config.h" #include "input/input_keymaps.h" @@ -39,6 +40,8 @@ #include "verbosity.h" #include "lakka.h" +#include "tasks/tasks_internal.h" + #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -2970,3 +2973,40 @@ bool config_save_file(const char *path) config_file_free(conf); return ret; } + +/* Replaces currently loaded configuration file with + * another one. Will load a dummy core to flush state + * properly. */ +bool config_replace(char *path) +{ + content_ctx_info_t content_info = {0}; + 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. */ + + if (!rarch_task_push_content_load_default( + NULL, NULL, + &content_info, + CORE_TYPE_DUMMY, + CONTENT_MODE_LOAD_NOTHING_WITH_DUMMY_CORE, + NULL, NULL)) + return false; + + return true; +} diff --git a/configuration.h b/configuration.h index 80def93888..32ca1bc2a3 100644 --- a/configuration.h +++ b/configuration.h @@ -560,6 +560,11 @@ bool config_save_autoconf_profile(const char *path, unsigned user); **/ bool config_save_file(const char *path); +/* Replaces currently loaded configuration file with + * another one. Will load a dummy core to flush state + * properly. */ +bool config_replace(char *path); + bool config_init(void); void config_free(void); diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index bee11a2d40..95f9488a7b 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -778,7 +778,7 @@ static int generic_action_ok(const char *path, flush_type = MENU_SETTINGS; menu_display_set_msg_force(true); - if (retroarch_replace_config(action_path)) + if (config_replace(action_path)) { bool pending_push = false; menu_navigation_ctl(MENU_NAVIGATION_CTL_CLEAR, &pending_push); diff --git a/retroarch.c b/retroarch.c index 3d8febf6ad..f518036d78 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1522,43 +1522,6 @@ 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) -{ - content_ctx_info_t content_info = {0}; - 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. */ - - if (!rarch_task_push_content_load_default( - NULL, NULL, - &content_info, - CORE_TYPE_DUMMY, - CONTENT_MODE_LOAD_NOTHING_WITH_DUMMY_CORE, - NULL, NULL)) - return false; - - return true; -} - void retroarch_set_pathnames(const char *path) { global_t *global = global_get_ptr();