mirror of
https://github.com/libretro/RetroArch
synced 2025-03-12 04:14:23 +00:00
(RARCH_CONSOLE) Check if needed directories exist and if not,
create them
This commit is contained in:
parent
5e839e5d74
commit
fd27c1b7ca
@ -76,6 +76,17 @@ static bool libretro_install_core(const char *path_prefix,
|
|||||||
return true;
|
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[])
|
int rarch_main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
system_init();
|
system_init();
|
||||||
@ -92,6 +103,13 @@ int rarch_main(int argc, char *argv[])
|
|||||||
g_extern.verbose = true;
|
g_extern.verbose = true;
|
||||||
|
|
||||||
get_environment_settings(argc, argv);
|
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();
|
config_load();
|
||||||
|
|
||||||
/* FIXME - when dummy loading becomes possible perhaps change this param */
|
/* FIXME - when dummy loading becomes possible perhaps change this param */
|
||||||
|
@ -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
|
#ifdef IS_SALAMANDER
|
||||||
|
|
||||||
static void find_and_set_first_file(void)
|
static void find_and_set_first_file(void)
|
||||||
@ -93,16 +82,7 @@ static void salamander_init_settings(void)
|
|||||||
char tmp_str[512] = {0};
|
char tmp_str[512] = {0};
|
||||||
bool config_file_exists;
|
bool config_file_exists;
|
||||||
|
|
||||||
if(!path_file_exists(default_paths.config_path))
|
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
|
|
||||||
config_file_exists = true;
|
config_file_exists = true;
|
||||||
|
|
||||||
//try to find CORE executable
|
//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.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.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);
|
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);
|
extern void __exception_setreload(int t);
|
||||||
|
@ -86,7 +86,7 @@ static void salamander_init_settings(void)
|
|||||||
char tmp_str[PATH_MAX];
|
char tmp_str[PATH_MAX];
|
||||||
bool config_file_exists = false;
|
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;
|
config_file_exists = true;
|
||||||
|
|
||||||
//try to find CORE executable
|
//try to find CORE executable
|
||||||
@ -101,7 +101,7 @@ static void salamander_init_settings(void)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(config_file_exists)
|
if (config_file_exists)
|
||||||
{
|
{
|
||||||
config_file_t * conf = config_file_new(default_paths.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_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);
|
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();
|
find_and_set_first_file();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user