diff --git a/command.c b/command.c index e859ff59f2..e2029b5c6c 100644 --- a/command.c +++ b/command.c @@ -1569,43 +1569,52 @@ static bool command_event_save_core_config(void) **/ void command_event_save_current_config(bool overrides) { - if (overrides) - return; - settings_t *settings = config_get_ptr(); global_t *global = global_get_ptr(); - if (settings->config_save_on_exit && !string_is_empty(global->path.config)) + if (!overrides) + { + + if (settings->config_save_on_exit && !string_is_empty(global->path.config)) + { + bool ret = false; + char msg[128] = {0}; + const char *config_path = config_get_active_path(); + + /* Save last core-specific config to the default config location, + * needed on consoles for core switching and reusing last good + * config for new cores. + */ + + /* Flush out the core specific config. */ + if (config_path) + ret = config_save_file(config_path); + + if (ret) + { + snprintf(msg, sizeof(msg), "%s \"%s\".", + msg_hash_to_str(MSG_SAVED_NEW_CONFIG_TO), + global->path.config); + RARCH_LOG("%s\n", msg); + } + else + { + snprintf(msg, sizeof(msg), "%s \"%s\".", + msg_hash_to_str(MSG_FAILED_SAVING_CONFIG_TO), + global->path.config); + RARCH_ERR("%s\n", msg); + } + + runloop_msg_queue_push(msg, 1, 180, true); + } + } + else { bool ret = false; char msg[128] = {0}; - const char *config_path = config_get_active_path(); - /* Save last core-specific config to the default config location, - * needed on consoles for core switching and reusing last good - * config for new cores. - */ - - /* Flush out the core specific config. */ - if (config_path) - ret = config_save_file(config_path); - - if (ret) - { - snprintf(msg, sizeof(msg), "%s \"%s\".", - msg_hash_to_str(MSG_SAVED_NEW_CONFIG_TO), - global->path.config); - RARCH_LOG("%s\n", msg); - } - else - { - snprintf(msg, sizeof(msg), "%s \"%s\".", - msg_hash_to_str(MSG_FAILED_SAVING_CONFIG_TO), - global->path.config); - RARCH_ERR("%s\n", msg); - } - - runloop_msg_queue_push(msg, 1, 180, true); + ret = config_save_file_diff(); + return; } } diff --git a/configuration.c b/configuration.c index ec2436c674..bc88ab4648 100644 --- a/configuration.c +++ b/configuration.c @@ -1294,9 +1294,10 @@ static bool config_load_file(const char *path, bool set_defaults, char tmp_append_path[PATH_MAX_LENGTH] = {0}; /* Don't destroy append_config_path. */ unsigned msg_color = 0; config_file_t *conf = NULL; + global_t *global = global_get_ptr(); + if (!settings) settings = config_get_ptr(); - global_t *global = global_get_ptr(); struct config_bool_setting_ptr bool_settings[] = { { "video_windowed_fullscreen", &settings->video.windowed_fullscreen}, @@ -2221,7 +2222,7 @@ bool config_load_override(void) /* Reset save paths. */ retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_STATE_PATH); retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_SAVE_PATH); - + global->path.append_config[0] = '\0'; return true; } @@ -3314,6 +3315,33 @@ bool config_save_file(const char *path) return ret; } +/** + * config_save_file: + * @path : Path that shall be written to. + * + * Writes a config file to disk. + * + * Returns: true (1) on success, otherwise returns false (0). + **/ +bool config_save_file_diff() +{ + unsigned i = 0; + bool ret = false; + settings_t *settings = config_get_ptr(); + settings_t *orig = (settings_t*)calloc(1, sizeof(settings_t)); + global_t *global = global_get_ptr(); + + /* Load the original config file in memory */ + config_load_file(global->path.config, false, orig); + + /* Test to compare with a well known setting */ + /*RARCH_LOG ("Rewind: %d %d\n", settings->rewind_enable, orig->rewind_enable); + RARCH_LOG ("DBG: %d %d\n", settings->debug_panel_enable, orig->cheevos.enable); + RARCH_LOG ("FPS: %d %d\n", settings->fps_show, orig->fps_show); + RARCH_LOG ("FPS: %s %s\n", settings->username, orig->username);*/ + return false; +} + /* Replaces currently loaded configuration file with * another one. Will load a dummy core to flush state * properly. */ diff --git a/configuration.h b/configuration.h index b75c773f6e..8ef4948ce1 100644 --- a/configuration.h +++ b/configuration.h @@ -653,6 +653,16 @@ bool config_save_autoconf_profile(const char *path, unsigned user); **/ bool config_save_file(const char *path); +/** + * config_save_file_diff: + * @path : Path that shall be written to. + * + * Writes a config file override to disk. + * + * Returns: true (1) on success, otherwise returns false (0). + **/ +bool config_save_file_diff(); + /* Replaces currently loaded configuration file with * another one. Will load a dummy core to flush state * properly. */