mirror of
https://github.com/libretro/RetroArch
synced 2025-02-12 18:40:25 +00:00
Create path_set_config and path_is_config_empty
This commit is contained in:
parent
ec45dbaf0c
commit
0aa2cf5019
26
paths.c
26
paths.c
@ -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;
|
||||||
}
|
}
|
||||||
|
4
paths.h
4
paths.h
@ -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
|
||||||
|
@ -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':
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user