diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 638e479d2e..081e1449af 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -589,7 +589,7 @@ static int action_ok_playlist_entry(const char *path, return action_ok_file_load_with_detect_core(entry_path, label, type, selection_ptr, entry_idx); } - rarch_playlist_load_content(playlist, selection_ptr); + menu_content_playlist_load(playlist, selection_ptr); if (is_history) { diff --git a/menu/menu_content.c b/menu/menu_content.c index a97dea2527..4f271a9800 100644 --- a/menu/menu_content.c +++ b/menu/menu_content.c @@ -14,7 +14,9 @@ */ #include +#include #include +#include #include "menu_content.h" #include "menu_driver.h" @@ -24,9 +26,11 @@ #include "../core_info.h" #include "../configuration.h" +#include "../dynamic.h" #include "../defaults.h" #include "../frontend/frontend.h" #include "../playlist.h" +#include "../libretro_private.h" #include "../retroarch.h" #include "../runloop.h" #include "../verbosity.h" @@ -137,6 +141,69 @@ bool menu_content_load(void) return true; } +/** + * menu_content_playlist_load: + * @playlist : Playlist handle. + * @idx : Index in playlist. + * + * Initializes core and loads content based on playlist entry. + **/ +void menu_content_playlist_load(void *data, unsigned idx) +{ + const char *core_path = NULL; + const char *path = NULL; + content_playlist_t *playlist = (content_playlist_t*)data; + + if (!playlist) + return; + + content_playlist_get_index(playlist, + idx, &path, NULL, &core_path, NULL, NULL, NULL); + + if (path && !string_is_empty(path)) + { + unsigned i; + RFILE *fp = NULL; + char *path_check = NULL; + char *path_tolower = strdup(path); + + for (i = 0; i < strlen(path_tolower); ++i) + path_tolower[i] = tolower(path_tolower[i]); + + if (strstr(path_tolower, ".zip")) + strstr(path_tolower, ".zip")[4] = '\0'; + else if (strstr(path_tolower, ".7z")) + strstr(path_tolower, ".7z")[3] = '\0'; + + path_check = (char *)calloc(strlen(path_tolower) + 1, sizeof(char)); + strncpy(path_check, path, strlen(path_tolower)); + + fp = retro_fopen(path_check, RFILE_MODE_READ, -1); + if (!fp) + { + runloop_msg_queue_push("File could not be loaded.\n", 1, 100, true); + RARCH_LOG("File at %s failed to load.\n", path_check); + free(path_tolower); + free(path_check); + return; + } + retro_fclose(fp); + free(path_tolower); + free(path_check); + } + + runloop_ctl(RUNLOOP_CTL_SET_LIBRETRO_PATH, (void*)core_path); + + if (path) + menu_driver_ctl(RARCH_MENU_CTL_UNSET_LOAD_NO_CONTENT, NULL); + else + menu_driver_ctl(RARCH_MENU_CTL_SET_LOAD_NO_CONTENT, NULL); + + rarch_environment_cb(RETRO_ENVIRONMENT_EXEC, (void*)path); + + event_cmd_ctl(EVENT_CMD_LOAD_CORE, NULL); +} + /** * menu_content_defer_core: * @core_info : Core info list handle. diff --git a/menu/menu_content.h b/menu/menu_content.h index e7aa6275e7..3f181f7ae4 100644 --- a/menu/menu_content.h +++ b/menu/menu_content.h @@ -35,6 +35,15 @@ extern "C" { **/ bool menu_content_load(void); +/** + * menu_content_playlist_load: + * @playlist : Playlist handle. + * @idx : Index in playlist. + * + * Initializes core and loads content based on playlist entry. + **/ +void menu_content_playlist_load(void *data, unsigned index); + /** * menu_content_defer_core: * @core_info : Core info list handle. diff --git a/retroarch.c b/retroarch.c index 8049f5e459..7c480a3ec6 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1521,71 +1521,6 @@ void rarch_main_deinit(void) rarch_ctl(RARCH_CTL_UNSET_INITED, NULL); } -/** - * rarch_playlist_load_content: - * @playlist : Playlist handle. - * @idx : Index in playlist. - * - * Initializes core and loads content based on playlist entry. - **/ -void rarch_playlist_load_content(void *data, unsigned idx) -{ - const char *core_path = NULL; - const char *path = NULL; - content_playlist_t *playlist = (content_playlist_t*)data; - - if (!playlist) - return; - - content_playlist_get_index(playlist, - idx, &path, NULL, &core_path, NULL, NULL, NULL); - - if (path && !string_is_empty(path)) - { - unsigned i; - RFILE *fp = NULL; - char *path_check = NULL; - char *path_tolower = strdup(path); - - for (i = 0; i < strlen(path_tolower); ++i) - path_tolower[i] = tolower(path_tolower[i]); - - if (strstr(path_tolower, ".zip")) - strstr(path_tolower, ".zip")[4] = '\0'; - else if (strstr(path_tolower, ".7z")) - strstr(path_tolower, ".7z")[3] = '\0'; - - path_check = (char *)calloc(strlen(path_tolower) + 1, sizeof(char)); - strncpy(path_check, path, strlen(path_tolower)); - - fp = retro_fopen(path_check, RFILE_MODE_READ, -1); - if (!fp) - { - runloop_msg_queue_push("File could not be loaded.\n", 1, 100, true); - RARCH_LOG("File at %s failed to load.\n", path_check); - free(path_tolower); - free(path_check); - return; - } - retro_fclose(fp); - free(path_tolower); - free(path_check); - } - - runloop_ctl(RUNLOOP_CTL_SET_LIBRETRO_PATH, (void*)core_path); - -#ifdef HAVE_MENU - if (path) - menu_driver_ctl(RARCH_MENU_CTL_UNSET_LOAD_NO_CONTENT, NULL); - else - menu_driver_ctl(RARCH_MENU_CTL_SET_LOAD_NO_CONTENT, NULL); -#endif - - rarch_environment_cb(RETRO_ENVIRONMENT_EXEC, (void*)path); - - event_cmd_ctl(EVENT_CMD_LOAD_CORE, NULL); -} - int rarch_info_get_capabilities(enum rarch_capabilities type, char *s, size_t len) { switch (type) diff --git a/retroarch.h b/retroarch.h index 4adfba6b3e..7255db4b42 100644 --- a/retroarch.h +++ b/retroarch.h @@ -199,15 +199,6 @@ void rarch_main_init_wrap(const struct rarch_main_wrap *args, **/ void rarch_main_deinit(void); -/** - * rarch_playlist_load_content: - * @playlist : Playlist handle. - * @idx : Index in playlist. - * - * Initializes core and loads content based on playlist entry. - **/ -void rarch_playlist_load_content(void *data, unsigned index); - void rarch_set_paths(const char *path); int rarch_info_get_capabilities(enum rarch_capabilities type, char *s, size_t len);