From a842a490f90bd7dc7f033e9f966bc3fc6059aa5d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 27 Sep 2015 02:18:45 +0200 Subject: [PATCH] Refactor rarch_fill_pathnames --- command_event.c | 4 ++-- retroarch.c | 40 ++++++++++++++++++---------------------- retroarch.h | 6 +++--- 3 files changed, 23 insertions(+), 27 deletions(-) diff --git a/command_event.c b/command_event.c index 5d3e1f3880..85cebf5951 100644 --- a/command_event.c +++ b/command_event.c @@ -368,7 +368,7 @@ void event_disk_control_append_image(const char *path) * started out in a single disk case, and that this way * of doing it makes the most sense. */ rarch_set_paths(path); - rarch_fill_pathnames(); + rarch_ctl(RARCH_ACTION_STATE_FILL_PATHNAMES, NULL); } event_command(EVENT_CMD_AUTOSAVE_INIT); @@ -691,7 +691,7 @@ static bool event_init_content(void) return true; if (!global->inited.core.no_content) - rarch_fill_pathnames(); + rarch_ctl(RARCH_ACTION_STATE_FILL_PATHNAMES, NULL); if (!init_content_file()) return false; diff --git a/retroarch.c b/retroarch.c index 2d04aa497d..35b4dad919 100644 --- a/retroarch.c +++ b/retroarch.c @@ -999,28 +999,6 @@ static void rarch_init_savefile_paths(void) } } -void rarch_fill_pathnames(void) -{ - global_t *global = global_get_ptr(); - - rarch_init_savefile_paths(); - strlcpy(global->bsv.movie_path, global->name.savefile, - sizeof(global->bsv.movie_path)); - - if (!*global->name.base) - return; - - if (!*global->name.ups) - fill_pathname_noext(global->name.ups, global->name.base, ".ups", - sizeof(global->name.ups)); - if (!*global->name.bps) - fill_pathname_noext(global->name.bps, global->name.base, ".bps", - sizeof(global->name.bps)); - if (!*global->name.ips) - fill_pathname_noext(global->name.ips, global->name.base, ".ips", - sizeof(global->name.ips)); -} - static bool init_state(void) { driver_t *driver = driver_get_ptr(); @@ -1432,6 +1410,24 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data) if (pretro_api_version() != RETRO_API_VERSION) RARCH_WARN("%s\n", msg_hash_to_str(MSG_LIBRETRO_ABI_BREAK)); break; + case RARCH_ACTION_STATE_FILL_PATHNAMES: + rarch_init_savefile_paths(); + strlcpy(global->bsv.movie_path, global->name.savefile, + sizeof(global->bsv.movie_path)); + + if (!*global->name.base) + return false; + + if (!*global->name.ups) + fill_pathname_noext(global->name.ups, global->name.base, ".ups", + sizeof(global->name.ups)); + if (!*global->name.bps) + fill_pathname_noext(global->name.bps, global->name.base, ".bps", + sizeof(global->name.bps)); + if (!*global->name.ips) + fill_pathname_noext(global->name.ips, global->name.base, ".ips", + sizeof(global->name.ips)); + break; case RARCH_ACTION_STATE_NONE: default: return false; diff --git a/retroarch.h b/retroarch.h index 79944222ef..ce8fa5f963 100644 --- a/retroarch.h +++ b/retroarch.h @@ -91,7 +91,9 @@ enum rarch_ctl_state * Make sure we haven't compiled for something we cannot run. * Ideally, code would get swapped out depending on CPU support, * but this will do for now. */ - RARCH_ACTION_STATE_VALIDATE_CPU_FEATURES + RARCH_ACTION_STATE_VALIDATE_CPU_FEATURES, + + RARCH_ACTION_STATE_FILL_PATHNAMES }; enum rarch_content_type @@ -189,8 +191,6 @@ int rarch_defer_core(core_info_list_t *data, const char *dir, const char *path, const char *menu_label, char *s, size_t len); -void rarch_fill_pathnames(void); - /** * rarch_init_system_av_info: *