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'; *path_libretro = '\0';
} }
const char *path_get_config(void) bool path_is_config_empty(void)
{ {
global_t *global = global_get_ptr(); global_t *global = global_get_ptr();
if (!string_is_empty(global->path.config)) if (global && string_is_empty(global->path.config))
return 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; return NULL;
} }

View File

@ -49,6 +49,10 @@ void path_clear_core(void);
const char *path_get_config(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); enum rarch_content_type path_is_media_type(const char *path);
RETRO_END_DECLS RETRO_END_DECLS

View File

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

View File

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