From fd27c1b7ca674831d6183dab8c94fc047256def3 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 6 May 2013 00:05:41 +0200 Subject: [PATCH] (RARCH_CONSOLE) Check if needed directories exist and if not, create them --- frontend/frontend_console.c | 18 ++++++++++++++++++ frontend/platform/platform_gx.c | 32 +------------------------------- frontend/platform/platform_ps3.c | 6 +++--- 3 files changed, 22 insertions(+), 34 deletions(-) diff --git a/frontend/frontend_console.c b/frontend/frontend_console.c index 371fe209d1..9f623e61cd 100644 --- a/frontend/frontend_console.c +++ b/frontend/frontend_console.c @@ -76,6 +76,17 @@ static bool libretro_install_core(const char *path_prefix, return true; } +#define MAKE_DIR(x) {\ + if (!path_is_directory((x)))\ + {\ + RARCH_WARN("Directory \"%s\" does not exists, creating\n", (x));\ + if (mkdir((x), 0777) != 0)\ + {\ + RARCH_ERR("Could not create directory \"%s\"\n", (x));\ + }\ + }\ +} + int rarch_main(int argc, char *argv[]) { system_init(); @@ -92,6 +103,13 @@ int rarch_main(int argc, char *argv[]) g_extern.verbose = true; get_environment_settings(argc, argv); + + MAKE_DIR(default_paths.port_dir); + MAKE_DIR(default_paths.system_dir); + MAKE_DIR(default_paths.savestate_dir); + MAKE_DIR(default_paths.sram_dir); + MAKE_DIR(default_paths.input_presets_dir); + config_load(); /* FIXME - when dummy loading becomes possible perhaps change this param */ diff --git a/frontend/platform/platform_gx.c b/frontend/platform/platform_gx.c index edde30396b..06d922235a 100644 --- a/frontend/platform/platform_gx.c +++ b/frontend/platform/platform_gx.c @@ -60,17 +60,6 @@ }\ } -#define MAKE_DIR(x) {\ - if (!path_is_directory((x)))\ - {\ - RARCH_WARN("Directory \"%s\" does not exists, creating\n", (x));\ - if (mkdir((x), 0777) != 0)\ - {\ - RARCH_ERR("Could not create directory \"%s\"\n", (x));\ - }\ - }\ -} - #ifdef IS_SALAMANDER static void find_and_set_first_file(void) @@ -93,16 +82,7 @@ static void salamander_init_settings(void) char tmp_str[512] = {0}; bool config_file_exists; - if(!path_file_exists(default_paths.config_path)) - { - FILE * f; - config_file_exists = false; - RARCH_ERR("Config file \"%s\" doesn't exist. Creating...\n", default_paths.config_path); - MAKE_DIR(default_paths.port_dir); - f = fopen(default_paths.config_path, "w"); - fclose(f); - } - else + if (path_file_exists(default_paths.config_path)) config_file_exists = true; //try to find CORE executable @@ -268,16 +248,6 @@ static void get_environment_settings(int argc, char *argv[]) snprintf(default_paths.filebrowser_startup_dir, sizeof(default_paths.filebrowser_startup_dir), default_paths.filesystem_root_dir); snprintf(default_paths.sram_dir, sizeof(default_paths.sram_dir), "%s/sram", default_paths.port_dir); snprintf(default_paths.input_presets_dir, sizeof(default_paths.input_presets_dir), "%s/input", default_paths.port_dir); - -#ifndef IS_SALAMANDER - MAKE_DIR(default_paths.port_dir); - MAKE_DIR(default_paths.system_dir); - MAKE_DIR(default_paths.savestate_dir); - MAKE_DIR(default_paths.sram_dir); - MAKE_DIR(default_paths.input_presets_dir); - - MAKE_FILE(g_extern.config_path); -#endif } extern void __exception_setreload(int t); diff --git a/frontend/platform/platform_ps3.c b/frontend/platform/platform_ps3.c index 93a855ec84..0bb7bdcbe6 100644 --- a/frontend/platform/platform_ps3.c +++ b/frontend/platform/platform_ps3.c @@ -86,7 +86,7 @@ static void salamander_init_settings(void) char tmp_str[PATH_MAX]; bool config_file_exists = false; - if(path_file_exists(default_paths.config_path)) + if (path_file_exists(default_paths.config_path)) config_file_exists = true; //try to find CORE executable @@ -101,7 +101,7 @@ static void salamander_init_settings(void) } else { - if(config_file_exists) + if (config_file_exists) { config_file_t * conf = config_file_new(default_paths.config_path); config_get_array(conf, "libretro_path", tmp_str, sizeof(tmp_str)); @@ -109,7 +109,7 @@ static void salamander_init_settings(void) snprintf(default_paths.libretro_path, sizeof(default_paths.libretro_path), tmp_str); } - if(!config_file_exists || !strcmp(default_paths.libretro_path, "")) + if (!config_file_exists || !strcmp(default_paths.libretro_path, "")) { find_and_set_first_file(); }