(RARCH_CONSOLE) Setup default_paths properly

This commit is contained in:
twinaphex 2014-05-31 08:15:57 +02:00
parent a970973415
commit da51530f0e
7 changed files with 70 additions and 52 deletions

View File

@ -22,8 +22,14 @@
typedef struct
{
char config_path[PATH_MAX];
char autoconfig_dir[PATH_MAX];
char assets_dir[PATH_MAX];
char core_dir[PATH_MAX];
char core_info_dir[PATH_MAX];
char overlay_dir[PATH_MAX];
char port_dir[PATH_MAX];
char shader_dir[PATH_MAX];
char savestate_dir[PATH_MAX];
char sram_dir[PATH_MAX];
char system_dir[PATH_MAX];

View File

@ -39,10 +39,26 @@ default_paths_t default_paths;
static void rarch_get_environment_console(void)
{
#if defined(RARCH_CONSOLE) || defined(__QNX__)
path_mkdir(default_paths.port_dir);
path_mkdir(default_paths.system_dir);
path_mkdir(default_paths.savestate_dir);
path_mkdir(default_paths.sram_dir);
if (*default_paths.autoconfig_dir)
path_mkdir(default_paths.autoconfig_dir);
if (*default_paths.assets_dir)
path_mkdir(default_paths.assets_dir);
if (*default_paths.core_dir)
path_mkdir(default_paths.core_dir);
if (*default_paths.core_info_dir)
path_mkdir(default_paths.core_info_dir);
if (*default_paths.overlay_dir)
path_mkdir(default_paths.overlay_dir);
if (*default_paths.port_dir)
path_mkdir(default_paths.port_dir);
if (*default_paths.shader_dir)
path_mkdir(default_paths.shader_dir);
if (*default_paths.savestate_dir)
path_mkdir(default_paths.savestate_dir);
if (*default_paths.sram_dir)
path_mkdir(default_paths.sram_dir);
if (*default_paths.system_dir)
path_mkdir(default_paths.system_dir);
#endif
}
#endif

View File

@ -49,7 +49,6 @@ extern void system_exec_wii(const char *path, bool should_load_game);
#include <fat.h>
#ifdef IS_SALAMANDER
char config_path[512];
char libretro_path[512];
static void find_and_set_first_file(void)
@ -72,7 +71,7 @@ static void frontend_gx_salamander_init(void)
char tmp_str[512] = {0};
bool config_file_exists;
if (path_file_exists(config_path))
if (path_file_exists(default_paths.config_path))
config_file_exists = true;
//try to find CORE executable
@ -89,7 +88,7 @@ static void frontend_gx_salamander_init(void)
{
if(config_file_exists)
{
config_file_t * conf = config_file_new(config_path);
config_file_t * conf = config_file_new(default_paths.config_path);
if (!conf) // stupid libfat bug or something; somtimes it says the file is there when it doesn't
config_file_exists = false;
else
@ -111,7 +110,7 @@ static void frontend_gx_salamander_init(void)
{
config_file_t *new_conf = config_file_new(NULL);
config_set_string(new_conf, "libretro_path", libretro_path);
config_file_write(new_conf, config_path);
config_file_write(new_conf, default_paths.config_path);
config_file_free(new_conf);
}
}
@ -243,11 +242,7 @@ static void frontend_gx_get_environment_settings(int argc, char *argv[], void *a
snprintf(default_paths.port_dir, sizeof(default_paths.port_dir), "%.*s/retroarch", device_end - default_paths.core_dir, default_paths.core_dir);
else
fill_pathname_join(default_paths.port_dir, default_paths.port_dir, "retroarch", sizeof(default_paths.port_dir));
#ifdef IS_SALAMANDER
fill_pathname_join(config_path, default_paths.port_dir, "retroarch.cfg", sizeof(config_path));
#else
fill_pathname_join(g_extern.config_path, default_paths.port_dir, "retroarch.cfg", sizeof(g_extern.config_path));
#endif
fill_pathname_join(default_paths.config_path, default_paths.port_dir, "retroarch.cfg", sizeof(default_paths.config_path));
fill_pathname_join(default_paths.system_dir, default_paths.port_dir, "system", sizeof(default_paths.system_dir));
fill_pathname_join(default_paths.sram_dir, default_paths.port_dir, "savefiles", sizeof(default_paths.sram_dir));
fill_pathname_join(default_paths.savestate_dir, default_paths.port_dir, "savefiles", sizeof(default_paths.savestate_dir));

View File

@ -49,7 +49,6 @@ SYS_PROCESS_PARAM(1001, 0x200000)
#include <cell/pad.h>
#include <cell/sysmodule.h>
char config_path[512];
char libretro_path[512];
static void find_and_set_first_file(void)
@ -88,7 +87,7 @@ static void frontend_ps3_salamander_init(void)
char tmp_str[PATH_MAX];
bool config_file_exists = false;
if (path_file_exists(config_path))
if (path_file_exists(default_paths.config_path))
config_file_exists = true;
//try to find CORE executable
@ -105,7 +104,7 @@ static void frontend_ps3_salamander_init(void)
{
if (config_file_exists)
{
config_file_t * conf = config_file_new(config_path);
config_file_t * conf = config_file_new(default_paths.config_path);
config_get_array(conf, "libretro_path", tmp_str, sizeof(tmp_str));
config_file_free(conf);
strlcpy(libretro_path, tmp_str, sizeof(libretro_path));
@ -120,7 +119,7 @@ static void frontend_ps3_salamander_init(void)
{
config_file_t *new_conf = config_file_new(NULL);
config_set_string(new_conf, "libretro_path", libretro_path);
config_file_write(new_conf, config_path);
config_file_write(new_conf, default_paths.config_path);
config_file_free(new_conf);
}
}
@ -242,24 +241,19 @@ static void frontend_ps3_get_environment_settings(int argc, char *argv[], void *
}
fill_pathname_join(default_paths.core_dir, default_paths.port_dir, "cores", sizeof(default_paths.core_dir));
fill_pathname_join(default_paths.core_info_dir, default_paths.port_dir, "cores", sizeof(default_paths.core_info_dir));
fill_pathname_join(default_paths.savestate_dir, default_paths.core_dir, "savestates", sizeof(default_paths.savestate_dir));
fill_pathname_join(default_paths.sram_dir, default_paths.core_dir, "savefiles", sizeof(default_paths.sram_dir));
fill_pathname_join(default_paths.system_dir, default_paths.core_dir, "system", sizeof(default_paths.system_dir));
/* now we fill in all the variables */
#if defined(HAVE_CG) || defined(HAVE_GLSL)
fill_pathname_join(g_settings.video.shader_dir, default_paths.core_dir, "shaders", sizeof(g_settings.video.shader_dir));
#endif
#ifdef IS_SALAMANDER
fill_pathname_join(config_path, default_paths.port_dir, "retroarch.cfg", sizeof(config_path));
#else
fill_pathname_join(g_extern.overlay_dir, default_paths.core_dir, "overlays", sizeof(g_extern.overlay_dir));
fill_pathname_join(default_paths.shader_dir, default_paths.core_dir, "shaders", sizeof(default_paths.shader_dir));
fill_pathname_join(default_paths.config_path, default_paths.port_dir, "retroarch.cfg", sizeof(default_paths.config_path));
fill_pathname_join(default_paths.overlay_dir, default_paths.core_dir, "overlays", sizeof(default_paths.overlay_dir));
fill_pathname_join(default_paths.assets_dir, default_paths.core_dir, "media", sizeof(default_paths.assets_dir));
#ifndef IS_SALAMANDER
#ifdef HAVE_RMENU
fill_pathname_join(g_extern.menu_texture_path, default_paths.core_dir, "borders/Menu/main-menu_1080p.png",
sizeof(g_extern.menu_texture_path));
#endif
fill_pathname_join(g_extern.config_path, default_paths.port_dir, "retroarch.cfg", sizeof(g_extern.config_path));
#endif
}
}

View File

@ -64,9 +64,7 @@ static void frontend_psp_get_environment_settings(int argc, char *argv[], void *
fill_pathname_join(default_paths.savestate_dir, default_paths.core_dir, "savestates", sizeof(default_paths.savestate_dir));
fill_pathname_join(default_paths.sram_dir, default_paths.core_dir, "savefiles", sizeof(default_paths.sram_dir));
fill_pathname_join(default_paths.system_dir, default_paths.core_dir, "system", sizeof(default_paths.system_dir));
/* now we fill in all the variables */
fill_pathname_join(g_extern.config_path, default_paths.port_dir, "retroarch.cfg", sizeof(g_extern.config_path));
fill_pathname_join(default_paths.config_path, default_paths.port_dir, "retroarch.cfg", sizeof(default_paths.config_path));
}
int callback_thread(SceSize args, void *argp)

View File

@ -29,7 +29,6 @@
#include "../../file.h"
#ifdef IS_SALAMANDER
char config_path[512];
char libretro_path[512];
static void find_and_set_first_file(void)
@ -81,7 +80,7 @@ static void frontend_xdk_salamander_init(void)
char tmp_str[PATH_MAX];
bool config_file_exists = false;
if(path_file_exists(config_path))
if(path_file_exists(default_paths.config_path))
config_file_exists = true;
//try to find CORE executable
@ -102,7 +101,7 @@ static void frontend_xdk_salamander_init(void)
{
if(config_file_exists)
{
config_file_t * conf = config_file_new(config_path);
config_file_t * conf = config_file_new(default_paths.config_path);
config_get_array(conf, "libretro_path", tmp_str, sizeof(tmp_str));
strlcpy(libretro_path, tmp_str, sizeof(libretro_path));
}
@ -120,7 +119,7 @@ static void frontend_xdk_salamander_init(void)
{
config_file_t *new_conf = config_file_new(NULL);
config_set_string(new_conf, "libretro_path", libretro_path);
config_file_write(new_conf, config_path);
config_file_write(new_conf, default_paths.config_path);
config_file_free(new_conf);
}
}
@ -224,11 +223,8 @@ static void frontend_xdk_get_environment_settings(int argc, char *argv[], void *
#if defined(_XBOX1)
strlcpy(default_paths.core_dir, "D:", sizeof(default_paths.core_dir));
#ifdef IS_SALAMANDER
fill_pathname_join(config_path, default_paths.core_dir, "retroarch.cfg", sizeof(config_path));
#else
fill_pathname_join(g_extern.config_path, default_paths.core_dir, "retroarch.cfg", sizeof(g_extern.config_path));
#endif
strlcpy(default_paths.core_info_dir, "D:", sizeof(default_paths.core_info_dir));
fill_pathname_join(default_paths.config_path, default_paths.core_dir, "retroarch.cfg", sizeof(default_paths.config_path));
fill_pathname_join(default_paths.savestate_dir, default_paths.core_dir, "savestates", sizeof(default_paths.savestate_dir));
fill_pathname_join(default_paths.sram_dir, default_paths.core_dir, "savefiles", sizeof(default_paths.sram_dir));
fill_pathname_join(default_paths.system_dir, default_paths.core_dir, "system", sizeof(default_paths.system_dir));
@ -238,11 +234,10 @@ static void frontend_xdk_get_environment_settings(int argc, char *argv[], void *
#endif
#elif defined(_XBOX360)
strlcpy(default_paths.core_dir, "game:", sizeof(default_paths.core_dir));
#ifdef IS_SALAMANDER
strlcpy(config_path, "game:\\retroarch.cfg", sizeof(config_path));
#else
strlcpy(default_paths.core_info_dir, "game:", sizeof(default_paths.core_info_dir));
strlcpy(default_paths.config_path, "game:\\retroarch.cfg", sizeof(default_paths.config_path));
#ifndef IS_SALAMANDER
strlcpy(g_settings.screenshot_directory, "game:", sizeof(g_settings.screenshot_directory));
strlcpy(g_extern.config_path, "game:\\retroarch.cfg", sizeof(g_extern.config_path));
#endif
strlcpy(default_paths.savestate_dir, "game:\\savestates", sizeof(default_paths.savestate_dir));
strlcpy(default_paths.sram_dir, "game:\\savefiles", sizeof(default_paths.sram_dir));

View File

@ -428,14 +428,12 @@ void config_set_defaults(void)
g_settings.core_specific_config = default_core_specific_config;
#ifdef RARCH_CONSOLE
strlcpy(g_settings.system_directory, default_paths.system_dir, sizeof(g_settings.system_directory));
g_settings.video.msg_pos_x = 0.05f;
g_settings.video.msg_pos_y = 0.90f;
g_settings.video.aspect_ratio = -1.0f;
// g_extern
strlcpy(g_extern.savefile_dir, default_paths.sram_dir, sizeof(g_extern.savefile_dir));
g_extern.console.screen.gamma_correction = DEFAULT_GAMMA;
g_extern.lifecycle_state |= (1ULL << MODE_AUDIO_CUSTOM_BGM_ENABLE);
g_extern.lifecycle_state |= (1ULL << MODE_VIDEO_TRIPLE_BUFFERING_ENABLE);
@ -443,12 +441,6 @@ void config_set_defaults(void)
g_extern.lifecycle_state |= (1ULL << MODE_VIDEO_FLICKER_FILTER_ENABLE);
g_extern.console.screen.resolutions.current.id = 0;
strlcpy(g_extern.savestate_dir, default_paths.savestate_dir, sizeof(g_extern.savestate_dir));
g_extern.state_slot = 0;
g_extern.audio_data.mute = 0;
g_extern.verbose = true;
g_extern.console.sound.mode = SOUND_MODE_NORMAL;
#ifdef _XBOX1
g_extern.console.sound.volume_level = 0;
@ -483,6 +475,28 @@ void config_set_defaults(void)
if (default_config_path)
fill_pathname_expand_special(g_extern.config_path, default_config_path, sizeof(g_extern.config_path));
#ifdef RARCH_CONSOLE
if (*default_paths.assets_dir)
strlcpy(g_settings.assets_directory, default_paths.assets_dir, sizeof(g_settings.assets_directory));
if (*default_paths.core_dir)
strlcpy(g_settings.libretro_directory, default_paths.core_dir, sizeof(g_settings.libretro_directory));
if (*default_paths.core_info_dir)
strlcpy(g_settings.libretro_info_path, default_paths.core_info_dir, sizeof(g_settings.libretro_info_path));
if (*default_paths.overlay_dir)
strlcpy(g_extern.overlay_dir, default_paths.overlay_dir, sizeof(g_extern.overlay_dir));
if (*default_paths.shader_dir)
strlcpy(g_settings.video.shader_dir, default_paths.shader_dir, sizeof(g_settings.video.shader_dir));
if (*default_paths.savestate_dir)
strlcpy(g_extern.savestate_dir, default_paths.savestate_dir, sizeof(g_extern.savestate_dir));
if (*default_paths.sram_dir)
strlcpy(g_extern.savefile_dir, default_paths.sram_dir, sizeof(g_extern.savefile_dir));
if (*default_paths.system_dir)
strlcpy(g_settings.system_directory, default_paths.system_dir, sizeof(g_settings.system_directory));
if (*default_paths.config_path)
strlcpy(g_extern.config_path, default_paths.config_path, sizeof(g_extern.config_path));
#endif
g_extern.config_save_on_exit = config_save_on_exit;
/* Avoid reloading config on every ROM load */