Create path_set_config and path_is_config_empty

This commit is contained in:
twinaphex 2016-09-17 13:04:12 +02:00
parent ec45dbaf0c
commit 0aa2cf5019
4 changed files with 30 additions and 9 deletions

26
paths.c
View File

@ -445,12 +445,32 @@ void path_clear_core(void)
*path_libretro = '\0';
}
const char *path_get_config(void)
bool path_is_config_empty(void)
{
global_t *global = global_get_ptr();
if (!string_is_empty(global->path.config))
return global->path.config;
if (global && string_is_empty(global->path.config))
return true;
return false;
}
void path_set_config(const char *path)
{
global_t *global = global_get_ptr();
if (!global)
return;
strlcpy(global->path.config, path, sizeof(global->path.config));
}
const char *path_get_config(void)
{
if (!path_is_config_empty())
{
global_t *global = global_get_ptr();
if (global)
return global->path.config;
}
return NULL;
}

View File

@ -49,6 +49,10 @@ void path_clear_core(void);
const char *path_get_config(void);
void path_set_config(const char *path);
bool path_is_config_empty(void);
enum rarch_content_type path_is_media_type(const char *path);
RETRO_END_DECLS

View File

@ -563,8 +563,7 @@ static void retroarch_parse_input(int argc, char *argv[])
break;
case 'c':
strlcpy(global->path.config, optarg,
sizeof(global->path.config));
path_set_config(optarg);
break;
case 'r':

View File

@ -1085,16 +1085,14 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data)
char *game_options_path = NULL;
bool ret = false;
char buf[PATH_MAX_LENGTH] = {0};
global_t *global = global_get_ptr();
settings_t *settings = config_get_ptr();
const char *options_path = settings->path.core_options;
const struct retro_variable *vars =
(const struct retro_variable*)data;
if (string_is_empty(options_path)
&& !string_is_empty(global->path.config))
if (string_is_empty(options_path) && !path_is_config_empty())
{
fill_pathname_resolve_relative(buf, global->path.config,
fill_pathname_resolve_relative(buf, path_get_config(),
file_path_str(FILE_PATH_CORE_OPTIONS_CONFIG), sizeof(buf));
options_path = buf;
}