Move config_replace to configuration.c
This commit is contained in:
parent
a70d8e43d9
commit
49f050b386
|
@ -27,6 +27,7 @@
|
||||||
#include "file_path_special.h"
|
#include "file_path_special.h"
|
||||||
#include "audio/audio_driver.h"
|
#include "audio/audio_driver.h"
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
|
#include "content.h"
|
||||||
#include "config.def.h"
|
#include "config.def.h"
|
||||||
#include "input/input_config.h"
|
#include "input/input_config.h"
|
||||||
#include "input/input_keymaps.h"
|
#include "input/input_keymaps.h"
|
||||||
|
@ -39,6 +40,8 @@
|
||||||
#include "verbosity.h"
|
#include "verbosity.h"
|
||||||
#include "lakka.h"
|
#include "lakka.h"
|
||||||
|
|
||||||
|
#include "tasks/tasks_internal.h"
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -2970,3 +2973,40 @@ bool config_save_file(const char *path)
|
||||||
config_file_free(conf);
|
config_file_free(conf);
|
||||||
return ret;
|
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;
|
||||||
|
}
|
||||||
|
|
|
@ -560,6 +560,11 @@ bool config_save_autoconf_profile(const char *path, unsigned user);
|
||||||
**/
|
**/
|
||||||
bool config_save_file(const char *path);
|
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);
|
bool config_init(void);
|
||||||
|
|
||||||
void config_free(void);
|
void config_free(void);
|
||||||
|
|
|
@ -778,7 +778,7 @@ static int generic_action_ok(const char *path,
|
||||||
flush_type = MENU_SETTINGS;
|
flush_type = MENU_SETTINGS;
|
||||||
menu_display_set_msg_force(true);
|
menu_display_set_msg_force(true);
|
||||||
|
|
||||||
if (retroarch_replace_config(action_path))
|
if (config_replace(action_path))
|
||||||
{
|
{
|
||||||
bool pending_push = false;
|
bool pending_push = false;
|
||||||
menu_navigation_ctl(MENU_NAVIGATION_CTL_CLEAR, &pending_push);
|
menu_navigation_ctl(MENU_NAVIGATION_CTL_CLEAR, &pending_push);
|
||||||
|
|
37
retroarch.c
37
retroarch.c
|
@ -1522,43 +1522,6 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data)
|
||||||
return true;
|
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)
|
void retroarch_set_pathnames(const char *path)
|
||||||
{
|
{
|
||||||
global_t *global = global_get_ptr();
|
global_t *global = global_get_ptr();
|
||||||
|
|
Loading…
Reference in New Issue