(360/PS3) rarch_manage_libretro_set_first_file - no more dependency on

HAVE_CONFIGFILE
This commit is contained in:
Twinaphex 2012-05-28 18:33:25 +02:00
parent eca9b3ddc9
commit 10ad19bf76
4 changed files with 55 additions and 54 deletions

View File

@ -195,7 +195,12 @@ static void init_settings (bool load_libretro_path)
#ifdef HAVE_LIBRETRO_MANAGEMENT
if(load_libretro_path)
rarch_manage_libretro_set_first_file(SYS_CONFIG_FILE, "game:\\", ".xex");
{
CONFIG_GET_STRING(libretro, "libretro_path");
if(!strcmp(g_settings.libretro, ""))
rarch_manage_libretro_set_first_file("game:\\", ".xex");
}
#endif
// g_settings

View File

@ -610,67 +610,58 @@ bool rarch_manage_libretro_install(const char *full_path, const char *path, cons
return return_code;
}
#ifdef HAVE_CONFIGFILE
void rarch_manage_libretro_set_first_file(const char * conf_name, const char *libretro_path, const char * exe_ext)
void rarch_manage_libretro_set_first_file(const char *libretro_path, const char * exe_ext)
{
#ifdef _XBOX
char fname_tmp[PATH_MAX];
#endif
config_file_t * conf = config_file_new(conf_name);
//We need to set libretro to the first entry in the cores
//directory so that it will be saved to the config file
CONFIG_GET_STRING(libretro, "libretro_path");
char ** dir_list = dir_list_new(libretro_path, exe_ext);
if(!strcmp(g_settings.libretro, ""))
if (!dir_list)
{
//We need to set libretro to the first entry in the cores
//directory so that it will be saved to the config file
char ** dir_list = dir_list_new(libretro_path, exe_ext);
if (!dir_list)
{
RARCH_ERR("Couldn't read directory.\n");
return;
}
const char * first_exe = dir_list[0];
if(first_exe)
{
#ifdef _XBOX
fill_pathname_base(fname_tmp, first_exe, sizeof(fname_tmp));
if(strcmp(fname_tmp, "RetroArch-Salamander.xex") == 0)
{
RARCH_WARN("First entry is RetroArch Salamander itself, increment entry by one and check if it exists.\n");
first_exe = dir_list[1];
fill_pathname_base(fname_tmp, first_exe, sizeof(fname_tmp));
if(!first_exe)
{
RARCH_ERR("Unlikely error happened - no second entry - no choice but to set it to RetroArch Salamander\n");
first_exe = dir_list[0];
fill_pathname_base(fname_tmp, first_exe, sizeof(fname_tmp));
}
}
RARCH_LOG("Set first entry in libretro core dir to libretro path: [%s].\n", fname_tmp);
snprintf(g_settings.libretro, sizeof(g_settings.libretro), "game:\\%s", fname_tmp);
#else
RARCH_LOG("Set first entry in libretro core dir to libretro path: [%s].\n", first_exe);
strlcpy(g_settings.libretro, first_exe, sizeof(g_settings.libretro));
#endif
}
else
{
RARCH_ERR("Failed to set first .xex entry to libretro path.\n");
}
dir_list_free(dir_list);
RARCH_ERR("Couldn't read directory.\n");
return;
}
}
const char * first_exe = dir_list[0];
if(first_exe)
{
#ifdef _XBOX
fill_pathname_base(fname_tmp, first_exe, sizeof(fname_tmp));
if(strcmp(fname_tmp, "RetroArch-Salamander.xex") == 0)
{
RARCH_WARN("First entry is RetroArch Salamander itself, increment entry by one and check if it exists.\n");
first_exe = dir_list[1];
fill_pathname_base(fname_tmp, first_exe, sizeof(fname_tmp));
if(!first_exe)
{
RARCH_ERR("Unlikely error happened - no second entry - no choice but to set it to RetroArch Salamander\n");
first_exe = dir_list[0];
fill_pathname_base(fname_tmp, first_exe, sizeof(fname_tmp));
}
}
RARCH_LOG("Set first entry in libretro core dir to libretro path: [%s].\n", fname_tmp);
snprintf(g_settings.libretro, sizeof(g_settings.libretro), "game:\\%s", fname_tmp);
#else
RARCH_LOG("Set first entry in libretro core dir to libretro path: [%s].\n", first_exe);
strlcpy(g_settings.libretro, first_exe, sizeof(g_settings.libretro));
#endif
}
else
{
RARCH_ERR("Failed to set first .xex entry to libretro path.\n");
}
dir_list_free(dir_list);
}
#endif
/*============================================================

View File

@ -106,7 +106,7 @@ void rarch_input_set_keybind(unsigned player, unsigned keybind_action, uint64_t
============================================================ */
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 * conf_name, const char *libretro_path, const char * exe_ext);
void rarch_manage_libretro_set_first_file(const char *libretro_path, const char * exe_ext);
#endif
/*============================================================

View File

@ -165,7 +165,12 @@ static void init_settings(bool load_libretro_path)
#ifdef HAVE_LIBRETRO_MANAGEMENT
if(load_libretro_path)
rarch_manage_libretro_set_first_file(SYS_CONFIG_FILE, LIBRETRO_DIR_PATH, ".SELF");
{
CONFIG_GET_STRING(libretro, "libretro_path");
if(!strcmp(g_settings.libretro, ""))
rarch_manage_libretro_set_first_file(LIBRETRO_DIR_PATH, ".SELF");
}
#endif
CONFIG_GET_STRING(cheat_database, "cheat_database");