Create path_get

This commit is contained in:
twinaphex 2016-09-29 08:23:41 +02:00
parent 4e50b7d5be
commit be81edad84
7 changed files with 35 additions and 30 deletions

View File

@ -1499,7 +1499,7 @@ static bool command_event_save_core_config(void)
} }
/* Infer file name based on libretro core. */ /* Infer file name based on libretro core. */
if (!string_is_empty(path_get_core()) && path_file_exists(path_get_core())) if (!string_is_empty(path_get(RARCH_PATH_CORE)) && path_file_exists(path_get(RARCH_PATH_CORE)))
{ {
unsigned i; unsigned i;
RARCH_LOG("%s\n", msg_hash_to_str(MSG_USING_CORE_NAME_FOR_NEW_CONFIG)); RARCH_LOG("%s\n", msg_hash_to_str(MSG_USING_CORE_NAME_FOR_NEW_CONFIG));
@ -1511,7 +1511,7 @@ static bool command_event_save_core_config(void)
fill_pathname_base_noext( fill_pathname_base_noext(
config_name, config_name,
path_get_core(), path_get(RARCH_PATH_CORE),
sizeof(config_name)); sizeof(config_name));
fill_pathname_join(config_path, config_dir, config_name, fill_pathname_join(config_path, config_dir, config_name,
@ -1842,14 +1842,14 @@ bool command_event(enum event_command cmd, void *data)
core_info_ctx_find_t info_find; core_info_ctx_find_t info_find;
#if defined(HAVE_DYNAMIC) #if defined(HAVE_DYNAMIC)
if (string_is_empty(path_get_core())) if (string_is_empty(path_get(RARCH_PATH_CORE)))
return false; return false;
#endif #endif
libretro_get_system_info( libretro_get_system_info(
path_get_core(), path_get(RARCH_PATH_CORE),
system, system,
ptr); ptr);
info_find.path = path_get_core(); info_find.path = path_get(RARCH_PATH_CORE);
if (!core_info_load(&info_find)) if (!core_info_load(&info_find))
{ {

View File

@ -2049,10 +2049,10 @@ static bool config_load_file(const char *path, bool set_defaults,
} }
/* Safe-guard against older behavior. */ /* Safe-guard against older behavior. */
if (path_is_directory(path_get_core())) if (path_is_directory(path_get(RARCH_PATH_CORE)))
{ {
RARCH_WARN("\"libretro_path\" is a directory, using this for \"libretro_directory\" instead.\n"); RARCH_WARN("\"libretro_path\" is a directory, using this for \"libretro_directory\" instead.\n");
strlcpy(settings->directory.libretro, path_get_core(), strlcpy(settings->directory.libretro, path_get(RARCH_PATH_CORE),
sizeof(settings->directory.libretro)); sizeof(settings->directory.libretro));
path_clear_core(); path_clear_core();
} }
@ -2283,7 +2283,7 @@ bool config_load_override(void)
/* Store the libretro_path we're using since it will be /* Store the libretro_path we're using since it will be
* overwritten by the override when reloading. */ * overwritten by the override when reloading. */
strlcpy(buf, path_get_core(), sizeof(buf)); strlcpy(buf, path_get(RARCH_PATH_CORE), sizeof(buf));
/* Toggle has_save_path to false so it resets */ /* Toggle has_save_path to false so it resets */
retroarch_override_setting_unset(RARCH_OVERRIDE_SETTING_STATE_PATH); retroarch_override_setting_unset(RARCH_OVERRIDE_SETTING_STATE_PATH);

View File

@ -222,7 +222,7 @@ static void load_dynamic_core(void)
retroarch_fail(1, "init_libretro_sym()"); retroarch_fail(1, "init_libretro_sym()");
} }
if (string_is_empty(path_get_core())) if (string_is_empty(path_get(RARCH_PATH_CORE)))
{ {
RARCH_ERR("RetroArch is built for dynamic libretro cores, but " RARCH_ERR("RetroArch is built for dynamic libretro cores, but "
"libretro_path is not set. Cannot continue.\n"); "libretro_path is not set. Cannot continue.\n");
@ -237,12 +237,12 @@ static void load_dynamic_core(void)
path_get_core_size()); path_get_core_size());
RARCH_LOG("Loading dynamic libretro core from: \"%s\"\n", RARCH_LOG("Loading dynamic libretro core from: \"%s\"\n",
path_get_core()); path_get(RARCH_PATH_CORE));
lib_handle = dylib_load(path_get_core()); lib_handle = dylib_load(path_get(RARCH_PATH_CORE));
if (!lib_handle) if (!lib_handle)
{ {
RARCH_ERR("Failed to open libretro core: \"%s\"\n", RARCH_ERR("Failed to open libretro core: \"%s\"\n",
path_get_core()); path_get(RARCH_PATH_CORE));
RARCH_ERR("Error(s): %s\n", dylib_error()); RARCH_ERR("Error(s): %s\n", dylib_error());
retroarch_fail(1, "load_dynamic()"); retroarch_fail(1, "load_dynamic()");
} }
@ -1265,7 +1265,7 @@ bool rarch_environment_cb(unsigned cmd, void *data)
{ {
const char **path = (const char**)data; const char **path = (const char**)data;
#ifdef HAVE_DYNAMIC #ifdef HAVE_DYNAMIC
*path = path_get_core(); *path = path_get(RARCH_PATH_CORE);
#else #else
*path = NULL; *path = NULL;
#endif #endif

View File

@ -302,7 +302,7 @@ static int win32_drag_query_file(HWND hwnd, WPARAM wparam)
if(!string_is_equal(info->systemname, current_core->systemname)) if(!string_is_equal(info->systemname, current_core->systemname))
break; break;
if(string_is_equal(path_get_core(), info->path)) if(string_is_equal(path_get(RARCH_PATH_CORE), info->path))
{ {
/* Our previous core supports the current rom */ /* Our previous core supports the current rom */
content_ctx_info_t content_info = {0}; content_ctx_info_t content_info = {0};

22
paths.c
View File

@ -318,7 +318,7 @@ static bool path_init_subsystem(void)
info = libretro_find_subsystem_info( info = libretro_find_subsystem_info(
system->subsystem.data, system->subsystem.data,
system->subsystem.size, system->subsystem.size,
path_get_subsystem()); path_get(RARCH_PATH_SUBSYSTEM));
/* We'll handle this error gracefully later. */ /* We'll handle this error gracefully later. */
@ -468,11 +468,6 @@ void path_fill_names(void)
/* Core file path */ /* Core file path */
const char *path_get_subsystem(void)
{
return subsystem_path;
}
const char *path_get_basename(void) const char *path_get_basename(void)
{ {
return path_main_basename; return path_main_basename;
@ -483,9 +478,20 @@ char *path_get_core_ptr(void)
return path_libretro; return path_libretro;
} }
const char *path_get_core(void) const char *path_get(enum rarch_path_type type)
{ {
return path_libretro; switch (type)
{
case RARCH_PATH_SUBSYSTEM:
return subsystem_path;
case RARCH_PATH_CORE:
return path_libretro;
default:
case RARCH_PATH_NONE:
break;
}
return NULL;
} }
bool path_is_core_empty(void) bool path_is_core_empty(void)

View File

@ -55,6 +55,7 @@ void path_fill_names(void);
/* set functions */ /* set functions */
bool path_set(enum rarch_path_type type, const char *path); bool path_set(enum rarch_path_type type, const char *path);
void path_set_redirect(void); void path_set_redirect(void);
@ -79,7 +80,7 @@ struct string_list *path_get_subsystem_list(void);
/* get functions */ /* get functions */
const char *path_get_subsystem(void); const char *path_get(enum rarch_path_type type);
bool path_get_content(char **fullpath); bool path_get_content(char **fullpath);
@ -87,8 +88,6 @@ const char *path_get_current_savefile_dir(void);
const char *path_get_basename(void); const char *path_get_basename(void);
const char *path_get_core(void);
const char *path_get_core_options(void); const char *path_get_core_options(void);
const char *path_get_config(void); const char *path_get_config(void);

View File

@ -601,13 +601,13 @@ static const struct retro_subsystem_info *init_content_file_subsystem(bool *ret)
if (system) if (system)
special = special =
libretro_find_subsystem_info(system->subsystem.data, libretro_find_subsystem_info(system->subsystem.data,
system->subsystem.size, path_get_subsystem()); system->subsystem.size, path_get(RARCH_PATH_SUBSYSTEM));
if (!special) if (!special)
{ {
RARCH_ERR( RARCH_ERR(
"Failed to find subsystem \"%s\" in libretro implementation.\n", "Failed to find subsystem \"%s\" in libretro implementation.\n",
path_get_subsystem()); path_get(RARCH_PATH_SUBSYSTEM));
goto error; goto error;
} }
@ -848,8 +848,8 @@ static void menu_content_environment_get(int *argc, char *argv[],
if (fullpath && *fullpath) if (fullpath && *fullpath)
wrap_args->content_path = fullpath; wrap_args->content_path = fullpath;
if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_LIBRETRO)) if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_LIBRETRO))
wrap_args->libretro_path = string_is_empty(path_get_core()) ? NULL : wrap_args->libretro_path = string_is_empty(path_get(RARCH_PATH_CORE)) ? NULL :
path_get_core(); path_get(RARCH_PATH_CORE);
} }
#endif #endif
@ -952,7 +952,7 @@ static bool task_load_content(content_ctx_info_t *content_info,
#endif #endif
break; break;
default: default:
core_path = path_get_core(); core_path = path_get(RARCH_PATH_CORE);
core_name = info->library_name; core_name = info->library_name;
break; break;
} }