Move find_and_set_first_file to frontend_salamander.c

This commit is contained in:
twinaphex 2014-06-05 00:51:47 +02:00
parent c86281e5b8
commit 137ce497bd
5 changed files with 28 additions and 61 deletions

View File

@ -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;

View File

@ -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

View File

@ -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);

View File

@ -47,25 +47,7 @@ SYS_PROCESS_PARAM(1001, 0x200000)
#include <np/drm.h>
#include <cell/sysmodule.h>
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);

View File

@ -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