From 10ad19bf76fb2a5cbf44b8f24deabfd5e0648cc2 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Mon, 28 May 2012 18:33:25 +0200 Subject: [PATCH] (360/PS3) rarch_manage_libretro_set_first_file - no more dependency on HAVE_CONFIGFILE --- 360/main.c | 7 +++- console/console_ext.c | 93 +++++++++++++++++++------------------------ console/console_ext.h | 2 +- ps3/main.c | 7 +++- 4 files changed, 55 insertions(+), 54 deletions(-) diff --git a/360/main.c b/360/main.c index 1582df7b69..8d202322a3 100644 --- a/360/main.c +++ b/360/main.c @@ -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 diff --git a/console/console_ext.c b/console/console_ext.c index 3d229c017b..303ebf8407 100644 --- a/console/console_ext.c +++ b/console/console_ext.c @@ -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 /*============================================================ diff --git a/console/console_ext.h b/console/console_ext.h index 068e22acdb..447c1d4820 100644 --- a/console/console_ext.h +++ b/console/console_ext.h @@ -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 /*============================================================ diff --git a/ps3/main.c b/ps3/main.c index 1f5b4e4c49..caaf68eba2 100644 --- a/ps3/main.c +++ b/ps3/main.c @@ -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");