(ovr) define paths for override files

This commit is contained in:
radius 2016-08-26 00:44:05 -05:00
parent 02d164b9e4
commit 45ca269573
3 changed files with 62 additions and 7 deletions

View File

@ -1567,12 +1567,12 @@ static bool command_event_save_core_config(void)
* Saves current configuration file to disk, and (optionally)
* autosave state.
**/
void command_event_save_current_config(bool overrides)
void command_event_save_current_config(int override_type)
{
settings_t *settings = config_get_ptr();
global_t *global = global_get_ptr();
if (!overrides)
if (!override_type)
{
if (settings->config_save_on_exit && !string_is_empty(global->path.config))
@ -1613,7 +1613,7 @@ void command_event_save_current_config(bool overrides)
bool ret = false;
char msg[128] = {0};
ret = config_save_file_diff();
ret = config_save_file_diff(override_type);
return;
}
}
@ -2316,10 +2316,10 @@ bool command_event(enum event_command cmd, void *data)
return false;
break;
case CMD_EVENT_MENU_SAVE_CURRENT_CONFIG:
command_event_save_current_config(false);
command_event_save_current_config(OVERRIDE_NONE);
break;
case CMD_EVENT_MENU_SAVE_CURRENT_CONFIG_OVERRIDE:
command_event_save_current_config(true);
command_event_save_current_config(OVERRIDE_CORE);
break;
case CMD_EVENT_MENU_SAVE_CONFIG:
if (!command_event_save_core_config())

View File

@ -3393,13 +3393,22 @@ bool config_save_file(const char *path)
*
* Returns: true (1) on success, otherwise returns false (0).
**/
bool config_save_file_diff()
bool config_save_file_diff(int override_type)
{
unsigned i = 0;
bool ret = false;
char buf[PATH_MAX_LENGTH] = {0};
char config_directory[PATH_MAX_LENGTH] = {0};
char core_path[PATH_MAX_LENGTH] = {0};
char game_path[PATH_MAX_LENGTH] = {0};
const char *core_name = NULL;
const char *game_name = NULL;
config_file_t *new_conf = NULL;
global_t *global = global_get_ptr();
settings_t *overrides = config_get_ptr();
settings_t *settings = (settings_t*)calloc(1, sizeof(settings_t));
rarch_system_info_t *system = NULL;
struct config_bool_setting *bool_settings =
(struct config_bool_setting*) malloc(PATH_MAX_LENGTH *sizeof(struct config_bool_setting));
@ -3432,6 +3441,47 @@ bool config_save_file_diff()
int string_settings_size = 0;
int path_settings_size = 0;
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
if (system)
core_name = system->info.library_name;
if (global)
game_name = path_basename(global->name.base);
if (string_is_empty(core_name) || string_is_empty(game_name))
return false;
fill_pathname_application_special(config_directory, sizeof(config_directory),
APPLICATION_SPECIAL_DIRECTORY_CONFIG);
/* Concatenate strings into full paths for core_path, game_path */
fill_pathname_join_special_ext(game_path,
config_directory, core_name,
game_name,
file_path_str(FILE_PATH_CONFIG_EXTENSION),
sizeof(game_path));
fill_pathname_join_special_ext(core_path,
config_directory, core_name,
core_name,
file_path_str(FILE_PATH_CONFIG_EXTENSION),
sizeof(core_path));
if (override_type == OVERRIDE_CORE)
{
RARCH_LOG ("Overrides: path %s\n", core_path);
/* Create a new config file from core_path */
new_conf = config_file_new(core_path);
}
else if(override_type == OVERRIDE_GAME)
{
RARCH_LOG ("Overrides: path %s\n", game_path);
/* Create a new config file from core_path */
new_conf = config_file_new(game_path);
}
else
return false;
/* Load the original config file in memory */
config_load_file(global->path.config, false, settings);
@ -3512,6 +3562,7 @@ bool config_save_file_diff()
free(string_overrides);
free(path_settings);
free(path_overrides);
free(settings);
return false;
}

View File

@ -25,6 +25,10 @@
#include "gfx/video_driver.h"
#include "driver.h"
#define OVERRIDE_NONE 0
#define OVERRIDE_CORE 1
#define OVERRIDE_GAME 2
#ifndef MAX_USERS
#define MAX_USERS 16
#endif
@ -661,7 +665,7 @@ bool config_save_file(const char *path);
*
* Returns: true (1) on success, otherwise returns false (0).
**/
bool config_save_file_diff();
bool config_save_file_diff(int override_type);
/* Replaces currently loaded configuration file with
* another one. Will load a dummy core to flush state