Libretro management refactor

This commit is contained in:
Twinaphex 2012-05-28 19:39:31 +02:00
parent b43d4a27b9
commit cf77233896
4 changed files with 26 additions and 18 deletions

View File

@ -199,7 +199,11 @@ static void init_settings (bool load_libretro_path)
CONFIG_GET_STRING(libretro, "libretro_path"); CONFIG_GET_STRING(libretro, "libretro_path");
if(!strcmp(g_settings.libretro, "")) if(!strcmp(g_settings.libretro, ""))
rarch_manage_libretro_set_first_file("game:\\", ".xex"); {
const char *first_file = rarch_manage_libretro_set_first_file("game:\\", ".xex");
if(first_file != NULL)
strlcpy(g_settings.libretro, first_file, sizeof(g_settings.libretro));
}
} }
#endif #endif

View File

@ -102,28 +102,28 @@ bool rarch_manage_libretro_install(const char *full_path, const char *path, cons
return return_code; return return_code;
} }
void rarch_manage_libretro_set_first_file(const char *libretro_path, const char * exe_ext) const char * rarch_manage_libretro_set_first_file(const char *libretro_path, const char * exe_ext)
{ {
#ifdef _XBOX
char fname_tmp[PATH_MAX];
#endif
//We need to set libretro to the first entry in the cores //We need to set libretro to the first entry in the cores
//directory so that it will be saved to the config file //directory so that it will be saved to the config file
char ** dir_list = dir_list_new(libretro_path, exe_ext); char ** dir_list = dir_list_new(libretro_path, exe_ext);
const char * retstr = NULL;
const char * first_exe;
if (!dir_list) if (!dir_list)
{ {
RARCH_ERR("Couldn't read directory.\n"); RARCH_ERR("Couldn't read directory.\n");
return; goto error;
} }
const char * first_exe = dir_list[0]; first_exe = dir_list[0];
if(first_exe) if(first_exe)
{ {
#ifdef _XBOX #ifdef _XBOX
char fname_tmp[PATH_MAX];
fill_pathname_base(fname_tmp, first_exe, sizeof(fname_tmp)); fill_pathname_base(fname_tmp, first_exe, sizeof(fname_tmp));
if(strcmp(fname_tmp, "RetroArch-Salamander.xex") == 0) if(strcmp(fname_tmp, "RetroArch-Salamander.xex") == 0)
@ -140,17 +140,17 @@ void rarch_manage_libretro_set_first_file(const char *libretro_path, const char
} }
} }
RARCH_LOG("Set first entry in libretro core dir to libretro path: [%s].\n", fname_tmp); retstr = fname_tmp;
snprintf(g_settings.libretro, sizeof(g_settings.libretro), "game:\\%s", fname_tmp);
#else #else
RARCH_LOG("Set first entry in libretro core dir to libretro path: [%s].\n", first_exe); retstr = first_exe;
strlcpy(g_settings.libretro, first_exe, sizeof(g_settings.libretro));
#endif #endif
} RARCH_LOG("Set first entry in libretro core dir to libretro path: [%s].\n", retstr);
else goto end;
{
RARCH_ERR("Failed to set first .xex entry to libretro path.\n");
} }
error:
RARCH_ERR("Failed to set first entry to libretro path.\n");
end:
dir_list_free(dir_list); dir_list_free(dir_list);
return retstr;
} }

View File

@ -20,6 +20,6 @@
#include "../boolean.h" #include "../boolean.h"
bool rarch_manage_libretro_install(const char *full_path, const char *path, const char *exe_ext); bool rarch_manage_libretro_install(const char *full_path, const char *path, const char *exe_ext);
void rarch_manage_libretro_set_first_file(const char *libretro_path, const char * exe_ext); const char * rarch_manage_libretro_set_first_file(const char *libretro_path, const char * exe_ext);
#endif #endif

View File

@ -169,7 +169,11 @@ static void init_settings(bool load_libretro_path)
CONFIG_GET_STRING(libretro, "libretro_path"); CONFIG_GET_STRING(libretro, "libretro_path");
if(!strcmp(g_settings.libretro, "")) if(!strcmp(g_settings.libretro, ""))
rarch_manage_libretro_set_first_file(LIBRETRO_DIR_PATH, ".SELF"); {
const char *first_file = rarch_manage_libretro_set_first_file(LIBRETRO_DIR_PATH, ".SELF");
if(first_file != NULL)
strlcpy(g_settings.libretro, first_file, sizeof(g_settings.libretro));
}
} }
#endif #endif