diff --git a/frontend/frontend_salamander.c b/frontend/frontend_salamander.c index bcae1b2c43..5990d75750 100644 --- a/frontend/frontend_salamander.c +++ b/frontend/frontend_salamander.c @@ -49,7 +49,7 @@ static void find_first_libretro_core(char *first_file, RARCH_LOG("Searching for valid libretro implementation in: \"%s\".\n", dir); - struct string_list *list = dir_list_new(dir, ext, false); + struct string_list *list = (struct string_list*)dir_list_new(dir, ext, false); if (!list) { RARCH_ERR("Couldn't read directory. Cannot infer default libretro core.\n"); @@ -59,7 +59,7 @@ static void find_first_libretro_core(char *first_file, for (size_t i = 0; i < list->size && !ret; i++) { RARCH_LOG("Checking library: \"%s\".\n", list->elems[i].data); - const char * libretro_elem = list->elems[i].data; + const char *libretro_elem = list->elems[i].data; if (libretro_elem) { @@ -86,6 +86,24 @@ static void find_first_libretro_core(char *first_file, dir_list_free(list); } +static void find_and_set_first_file(char *path, size_t sizeof_path, const char *ext) +{ + //Last fallback - we'll need to start the first executable file + // we can find in the RetroArch cores directory + + char first_file[PATH_MAX] = {0}; + find_first_libretro_core(first_file, sizeof(first_file), + default_paths.core_dir, ext); + + if(first_file) + { + fill_pathname_join(path, default_paths.core_dir, first_file, sizeof(path)); + RARCH_LOG("libretro_path now set to: %s.\n", path); + } + else + RARCH_ERR("Failed last fallback - RetroArch Salamander will exit.\n"); +} + int main(int argc, char *argv[]) { void *args = NULL; diff --git a/frontend/frontend_salamander.h b/frontend/frontend_salamander.h index a4bc1455f1..0048e77e9a 100644 --- a/frontend/frontend_salamander.h +++ b/frontend/frontend_salamander.h @@ -22,4 +22,7 @@ static void find_first_libretro_core(char *first_file, size_t size_of_first_file, const char *dir, const char * ext); +static void find_and_set_first_file(char *path, size_t sizeof_path, + const char *ext); + #endif diff --git a/frontend/platform/platform_gx.c b/frontend/platform/platform_gx.c index 7db1e50c73..3a0b1cc9c9 100644 --- a/frontend/platform/platform_gx.c +++ b/frontend/platform/platform_gx.c @@ -53,24 +53,6 @@ extern void system_exec_wii(const char *path, bool should_load_game); #ifdef IS_SALAMANDER char libretro_path[PATH_MAX]; -static void find_and_set_first_file(const char *ext) -{ - //Last fallback - we'll need to start the first executable file - // we can find in the RetroArch cores directory - - char first_file[PATH_MAX] = {0}; - find_first_libretro_core(first_file, sizeof(first_file), - default_paths.core_dir, ext); - - if(first_file) - { - fill_pathname_join(libretro_path, default_paths.core_dir, first_file, sizeof(libretro_path)); - RARCH_LOG("libretro_path now set to: %s.\n", libretro_path); - } - else - RARCH_ERR("Failed last fallback - RetroArch Salamander will exit.\n"); -} - static void frontend_gx_salamander_init(void) { char tmp_str[PATH_MAX] = {0}; @@ -93,7 +75,7 @@ static void frontend_gx_salamander_init(void) } if(!config_file_exists || !strcmp(libretro_path, "")) - find_and_set_first_file("dol"); + find_and_set_first_file(libretro_path, sizeof(libretro_path), "dol"); else { RARCH_LOG("Start [%s] found in retroarch.cfg.\n", libretro_path); diff --git a/frontend/platform/platform_ps3.c b/frontend/platform/platform_ps3.c index 86007b53d2..1591a819ba 100644 --- a/frontend/platform/platform_ps3.c +++ b/frontend/platform/platform_ps3.c @@ -47,25 +47,7 @@ SYS_PROCESS_PARAM(1001, 0x200000) #include #include -char libretro_path[512]; - -static void find_and_set_first_file(const char *ext) -{ - //Last fallback - we'll need to start the first executable file - // we can find in the RetroArch cores directory - - char first_file[PATH_MAX]; - find_first_libretro_core(first_file, sizeof(first_file), - default_paths.core_dir, ext); - - if(first_file) - { - fill_pathname_join(libretro_path, default_paths.core_dir, first_file, sizeof(libretro_path)); - RARCH_LOG("libretro_path now set to: %s.\n", libretro_path); - } - else - RARCH_ERR("Failed last fallback - RetroArch Salamander will exit.\n"); -} +char libretro_path[PATH_MAX]; static void frontend_ps3_salamander_init(void) { @@ -85,7 +67,7 @@ static void frontend_ps3_salamander_init(void) } if (!config_file_exists || !strcmp(libretro_path, "")) - find_and_set_first_file("SELF"); + find_and_set_first_file(libretro_path, sizeof(libretro_path), "SELF"); else RARCH_LOG("Start [%s] found in retroarch.cfg.\n", libretro_path); diff --git a/frontend/platform/platform_xdk.c b/frontend/platform/platform_xdk.c index 0048dc9434..80e70b525c 100644 --- a/frontend/platform/platform_xdk.c +++ b/frontend/platform/platform_xdk.c @@ -30,24 +30,6 @@ #ifdef IS_SALAMANDER char libretro_path[512]; -static void find_and_set_first_file(const char *ext) -{ - //Last fallback - we'll need to start the first executable file - // we can find in the RetroArch cores directory - - char first_file[PATH_MAX] = {0}; - find_first_libretro_core(first_file, sizeof(first_file), - default_paths.core_dir, ext); - - if(first_file) - { - fill_pathname_join(libretro_path, default_paths.core_dir, first_file, sizeof(libretro_path)); - RARCH_LOG("libretro_path now set to: %s.\n", libretro_path); - } - else - RARCH_ERR("Failed last fallback - RetroArch Salamander will exit.\n"); -} - static void frontend_xdk_salamander_init(void) { (void)state; @@ -69,9 +51,9 @@ static void frontend_xdk_salamander_init(void) if(!config_file_exists || !strcmp(libretro_path, "")) { #if defined(_XBOX360) - find_and_set_first_file("xex"); + find_and_set_first_file(libretro_path, sizeof(libretro_path), "xex"); #elif defined(_XBOX1) - find_and_set_first_file("xbe"); + find_and_set_first_file(libretro_path, sizeof(libretro_path), "xbe"); #endif } else