diff --git a/dynamic.c b/dynamic.c index b504844c87..762067c7e9 100644 --- a/dynamic.c +++ b/dynamic.c @@ -1027,8 +1027,7 @@ bool rarch_environment_cb(unsigned cmd, void *data) if (string_is_empty(settings->directory.system)) { char *fullpath = NULL; - if (runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath) && - fullpath) + if (path_get_content(&fullpath) && fullpath) { char temp_path[PATH_MAX_LENGTH] = {0}; diff --git a/frontend/drivers/platform_gx.c b/frontend/drivers/platform_gx.c index 4590fecb80..a4d5a2f36d 100644 --- a/frontend/drivers/platform_gx.c +++ b/frontend/drivers/platform_gx.c @@ -386,7 +386,7 @@ static void frontend_gx_exitspawn(char *s, size_t len) { fill_pathname_join(new_path, g_defaults.dir.core, salamander_name, sizeof(new_path)); - runloop_ctl(RUNLOOP_CTL_SET_CONTENT_PATH, new_path); + path_set_content(new_path); } } break; diff --git a/frontend/drivers/platform_ps3.c b/frontend/drivers/platform_ps3.c index 3747d7a19b..4e2e89490b 100644 --- a/frontend/drivers/platform_ps3.c +++ b/frontend/drivers/platform_ps3.c @@ -403,7 +403,7 @@ static void frontend_ps3_exec(const char *path, bool should_load_game) RARCH_LOG("Attempt to load executable: [%s].\n", path); #ifndef IS_SALAMANDER - runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath); + path_get_content(&fullpath); if (should_load_game && !string_is_empty(fullpath)) { diff --git a/frontend/drivers/platform_psp.c b/frontend/drivers/platform_psp.c index 72725d9f06..32ca741476 100644 --- a/frontend/drivers/platform_psp.c +++ b/frontend/drivers/platform_psp.c @@ -336,7 +336,7 @@ static void frontend_psp_exec(const char *path, bool should_load_game) args = strlen(argp) + 1; #ifndef IS_SALAMANDER - runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath); + path_get_content(&fullpath); if (should_load_game && !string_is_empty(fullpath)) { diff --git a/frontend/drivers/platform_wii.c b/frontend/drivers/platform_wii.c index a1227774fe..93bc4b55cb 100644 --- a/frontend/drivers/platform_wii.c +++ b/frontend/drivers/platform_wii.c @@ -138,7 +138,7 @@ void system_exec_wii(const char *_path, bool should_load_game) #else char *fullpath = NULL; - runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath); + path_get_content(&fullpath); strlcpy(game_path, fullpath, sizeof(game_path)); #endif } diff --git a/frontend/drivers/platform_xdk.cpp b/frontend/drivers/platform_xdk.cpp index b5a92a6161..94d013036e 100644 --- a/frontend/drivers/platform_xdk.cpp +++ b/frontend/drivers/platform_xdk.cpp @@ -1265,7 +1265,7 @@ static void frontend_xdk_exec(const char *path, bool should_load_game) #ifdef _XBOX char *fullpath = NULL; - runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath); + path_get_content(&fullpath); #if defined(_XBOX1) LAUNCH_DATA ptr; diff --git a/gfx/common/win32_common.cpp b/gfx/common/win32_common.cpp index 0ea3b22de8..55090b3849 100644 --- a/gfx/common/win32_common.cpp +++ b/gfx/common/win32_common.cpp @@ -142,7 +142,7 @@ INT_PTR CALLBACK PickCoreProc(HWND hDlg, UINT message, unsigned i; /* Add items to list. */ - runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath); + path_get_content(&fullpath); core_info_get_list(&core_info_list); core_info_list_get_supported_cores(core_info_list, (const char*)fullpath, &core_info, &list_size); @@ -175,7 +175,7 @@ INT_PTR CALLBACK PickCoreProc(HWND hDlg, UINT message, { int lbItem; const core_info_t *info = NULL; - runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath); + path_get_content(&fullpath); HWND hwndList = GetDlgItem(hDlg, ID_CORELISTBOX); lbItem = (int)SendMessage(hwndList, LB_GETCURSEL, 0, 0); core_info_get_list(&core_info_list); @@ -286,7 +286,7 @@ static int win32_drag_query_file(HWND hwnd, WPARAM wparam) if (!list_size) return 0; - runloop_ctl(RUNLOOP_CTL_SET_CONTENT_PATH,szFilename); + path_set_content(szFilename); if (!path_is_core_empty()) { diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 00ad93ac20..0907897841 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -2665,7 +2665,7 @@ static int menu_displaylist_parse_horizontal_content_actions( if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu)) return -1; - runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath); + path_get_content(&fullpath); if (!rarch_ctl(RARCH_CTL_IS_DUMMY_CORE, NULL) && string_is_equal(menu->deferred_path, fullpath)) diff --git a/paths.c b/paths.c index b0d28242a4..bee3fa4526 100644 --- a/paths.c +++ b/paths.c @@ -50,6 +50,7 @@ static char path_main_basename[PATH_MAX_LENGTH] = {0} ; +static char path_content[PATH_MAX_LENGTH] = {0}; static char current_savefile_dir[PATH_MAX_LENGTH] = {0}; static char path_libretro[PATH_MAX_LENGTH] = {0}; static char path_config_file[PATH_MAX_LENGTH] = {0}; @@ -208,7 +209,8 @@ void path_set_basename(const char *path) { char *dst = NULL; - runloop_ctl(RUNLOOP_CTL_SET_CONTENT_PATH, (void*)path); + path_set_content(path); + strlcpy(path_main_basename, path, sizeof(path_main_basename)); #ifdef HAVE_COMPRESSION @@ -560,11 +562,33 @@ void path_clear_config_append(void) *path_config_append_file = '\0'; } +void path_clear_content(void) +{ + *path_content = '\0'; +} + +bool path_set_content(const char *path) +{ + if (!path) + return false; + strlcpy(path_content, path, sizeof(path_content)); + return true; +} + void path_set_config_append(const char *path) { strlcpy(path_config_append_file, path, sizeof(path_config_append_file)); } +bool path_get_content(char **fullpath) +{ + if (!fullpath) + return false; + *fullpath = (char*)path_content; + + return true; +} + const char *path_get_config_append(void) { if (!path_is_config_append_empty()) diff --git a/paths.h b/paths.h index d5079d63ea..060e10f04e 100644 --- a/paths.h +++ b/paths.h @@ -41,6 +41,8 @@ void path_fill_names(void); void path_set_redirect(void); +bool path_set_content(const char *path); + void path_set_names(const char *path); void path_set_special(char **argv, unsigned num_content); @@ -65,6 +67,8 @@ char *path_get_core_ptr(void); /* get functions */ +bool path_get_content(char **fullpath); + const char *path_get_current_savefile_dir(void); const char *path_get_basename(void); @@ -81,6 +85,8 @@ const char *path_get_config_append(void); void path_clear_basename(void); +void path_clear_content(void); + void path_clear_core(void); void path_clear_config(void); diff --git a/retroarch.c b/retroarch.c index fd813e4c37..07bfc8f803 100644 --- a/retroarch.c +++ b/retroarch.c @@ -947,7 +947,7 @@ static void retroarch_main_init_media(void) ) return; - if (!runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath)) + if (!path_get_content(&fullpath)) return; if (string_is_empty(fullpath)) diff --git a/runloop.c b/runloop.c index a85fbc2ce0..8a0364319f 100644 --- a/runloop.c +++ b/runloop.c @@ -106,7 +106,6 @@ typedef struct event_cmd_state static rarch_system_info_t runloop_system; static struct retro_frame_time_callback runloop_frame_time; -static char runloop_fullpath[PATH_MAX_LENGTH] = {0}; static char runloop_default_shader_preset[PATH_MAX_LENGTH] = {0}; static retro_keyboard_event_t runloop_key_event = NULL; static retro_keyboard_event_t runloop_frontend_key_event = NULL; @@ -717,25 +716,6 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) path_set_core(fullpath); } break; - case RUNLOOP_CTL_CLEAR_CONTENT_PATH: - *runloop_fullpath = '\0'; - break; - case RUNLOOP_CTL_GET_CONTENT_PATH: - { - char **fullpath = (char**)data; - if (!fullpath) - return false; - *fullpath = (char*)runloop_fullpath; - } - break; - case RUNLOOP_CTL_SET_CONTENT_PATH: - { - const char *fullpath = (const char*)data; - if (!fullpath) - return false; - strlcpy(runloop_fullpath, fullpath, sizeof(runloop_fullpath)); - } - break; case RUNLOOP_CTL_CLEAR_DEFAULT_SHADER_PRESET: *runloop_default_shader_preset = '\0'; break; @@ -781,7 +761,7 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) command_event(CMD_EVENT_LOG_FILE_DEINIT, NULL); rarch_ctl(RARCH_CTL_UNSET_BLOCK_CONFIG_READ, NULL); - runloop_ctl(RUNLOOP_CTL_CLEAR_CONTENT_PATH, NULL); + path_clear_content(); runloop_overrides_active = false; core_unset_input_descriptors(); diff --git a/runloop.h b/runloop.h index fe22da5609..bc7d3112f3 100644 --- a/runloop.h +++ b/runloop.h @@ -62,10 +62,6 @@ enum runloop_ctl_state RUNLOOP_CTL_SET_NONBLOCK_FORCED, RUNLOOP_CTL_UNSET_NONBLOCK_FORCED, - RUNLOOP_CTL_GET_CONTENT_PATH, - RUNLOOP_CTL_SET_CONTENT_PATH, - RUNLOOP_CTL_CLEAR_CONTENT_PATH, - RUNLOOP_CTL_GET_DEFAULT_SHADER_PRESET, RUNLOOP_CTL_SET_DEFAULT_SHADER_PRESET, RUNLOOP_CTL_CLEAR_DEFAULT_SHADER_PRESET, diff --git a/tasks/task_content.c b/tasks/task_content.c index be0ea1103f..b35da14abc 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -682,7 +682,7 @@ static bool init_content_file_set_attribs( attr.i |= system->info.need_fullpath << 1; attr.i |= (!content_does_not_need_content()) << 2; - if (!runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath) + if (!path_get_content(&fullpath) && content_does_not_need_content() && settings->set_supports_no_game_enable) string_list_append(content, "", attr); @@ -826,7 +826,7 @@ static void menu_content_environment_get(int *argc, char *argv[], if (!wrap_args) return; - runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath); + path_get_content(&fullpath); wrap_args->no_content = menu_driver_ctl( RARCH_MENU_CTL_HAS_LOAD_NO_CONTENT, NULL); @@ -871,7 +871,7 @@ static bool task_load_content(content_ctx_info_t *content_info, char msg[PATH_MAX_LENGTH] = {0}; char *fullpath = NULL; - runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath); + path_get_content(&fullpath); if (launched_from_menu) { @@ -999,13 +999,13 @@ static bool command_event_cmd_exec(const char *data, #endif #endif - runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath); + path_get_content(&fullpath); if (fullpath != (void*)data) { - runloop_ctl(RUNLOOP_CTL_CLEAR_CONTENT_PATH, NULL); + path_clear_content(); if (!string_is_empty(data)) - runloop_ctl(RUNLOOP_CTL_SET_CONTENT_PATH, (void*)data); + path_set_content(data); } #if defined(HAVE_DYNAMIC) @@ -1091,7 +1091,7 @@ bool task_push_content_load_default( case CONTENT_MODE_LOAD_NOTHING_WITH_CURRENT_CORE_FROM_MENU: case CONTENT_MODE_LOAD_NOTHING_WITH_VIDEO_PROCESSOR_CORE_FROM_MENU: case CONTENT_MODE_LOAD_NOTHING_WITH_NET_RETROPAD_CORE_FROM_MENU: - runloop_ctl(RUNLOOP_CTL_CLEAR_CONTENT_PATH, NULL); + path_clear_content(); break; default: break; @@ -1106,7 +1106,7 @@ bool task_push_content_load_default( case CONTENT_MODE_LOAD_CONTENT_WITH_FFMPEG_CORE_FROM_MENU: case CONTENT_MODE_LOAD_CONTENT_WITH_IMAGEVIEWER_CORE_FROM_MENU: case CONTENT_MODE_LOAD_CONTENT_WITH_NEW_CORE_FROM_MENU: - runloop_ctl(RUNLOOP_CTL_SET_CONTENT_PATH, (void*)fullpath); + path_set_content(fullpath); break; default: break; @@ -1245,7 +1245,7 @@ bool task_push_content_load_default( { char *fullpath = NULL; - runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath); + path_get_content(&fullpath); command_event_cmd_exec(fullpath, mode); command_event(CMD_EVENT_QUIT, NULL); } diff --git a/ui/drivers/ui_cocoa.m b/ui/drivers/ui_cocoa.m index 621d2243e8..c8de4ff15e 100644 --- a/ui/drivers/ui_cocoa.m +++ b/ui/drivers/ui_cocoa.m @@ -289,7 +289,7 @@ static char** waiting_argv; NULL, NULL); } else - runloop_ctl(RUNLOOP_CTL_SET_CONTENT_PATH, (void*)__core.UTF8String); + path_set_content(__core.UTF8String); [sender replyToOpenOrPrint:NSApplicationDelegateReplySuccess]; } @@ -328,7 +328,7 @@ static void open_core_handler(ui_browser_window_state_t *state, bool result) && settings->set_supports_no_game_enable) { content_ctx_info_t content_info = {0}; - runloop_ctl(RUNLOOP_CTL_CLEAR_CONTENT_PATH, NULL); + path_clear_content(); task_push_content_load_default( NULL, NULL, &content_info, @@ -355,7 +355,7 @@ static void open_document_handler(ui_browser_window_state_t *state, bool result) if (system) core_name = system->library_name; - runloop_ctl(RUNLOOP_CTL_SET_CONTENT_PATH, (void*)state->result); + path_set_content(state->result); if (core_name) { diff --git a/ui/drivers/ui_win32.c b/ui/drivers/ui_win32.c index b81854620e..68c6c3b590 100644 --- a/ui/drivers/ui_win32.c +++ b/ui/drivers/ui_win32.c @@ -580,7 +580,8 @@ LRESULT win32_menu_loop(HWND owner, WPARAM wparam) case ID_M_LOAD_CONTENT: { content_ctx_info_t content_info = {0}; - runloop_ctl(RUNLOOP_CTL_SET_CONTENT_PATH, win32_file); + + path_set_content(win32_file); do_wm_close = true; task_push_content_load_default(