diff --git a/frontend/drivers/platform_ctr.c b/frontend/drivers/platform_ctr.c index 7a3de7f8f6..6874549680 100644 --- a/frontend/drivers/platform_ctr.c +++ b/frontend/drivers/platform_ctr.c @@ -94,8 +94,6 @@ static void get_first_valid_core(char* path_return, size_t len) static void frontend_ctr_get_environment_settings(int* argc, char* argv[], void* args, void* params_data) { - (void)args; - fill_pathname_basedir(g_defaults.dirs[DEFAULT_DIR_PORT], elf_path_cst, sizeof(g_defaults.dirs[DEFAULT_DIR_PORT])); RARCH_LOG("port dir: [%s]\n", g_defaults.dirs[DEFAULT_DIR_PORT]); @@ -129,6 +127,10 @@ static void frontend_ctr_get_environment_settings(int* argc, char* argv[], "logs", sizeof(g_defaults.dirs[DEFAULT_DIR_LOGS])); fill_pathname_join(g_defaults.path_config, g_defaults.dirs[DEFAULT_DIR_PORT], FILE_PATH_MAIN_CONFIG, sizeof(g_defaults.path_config)); + +#ifndef IS_SALAMANDER + dir_check_defaults("custom.ini"); +#endif } static void frontend_ctr_deinit(void* data) diff --git a/frontend/drivers/platform_darwin.m b/frontend/drivers/platform_darwin.m index 2751effa51..f5c4178250 100644 --- a/frontend/drivers/platform_darwin.m +++ b/frontend/drivers/platform_darwin.m @@ -67,6 +67,7 @@ #include "../../verbosity.h" #include "../../msg_hash.h" #include "../../ui/ui_companion_driver.h" +#include "../../paths.h" #if 1 #define RELEASE_BUILD @@ -500,6 +501,10 @@ static void frontend_darwin_get_environment_settings(int *argc, char *argv[], CFRelease(bundle_path); CFRelease(bundle_url); + +#ifndef IS_SALAMANDER + dir_check_defaults("custom.ini"); +#endif } static void frontend_darwin_load_content(void) diff --git a/frontend/drivers/platform_dos.c b/frontend/drivers/platform_dos.c index 7f3c81a0be..aa3031e88f 100644 --- a/frontend/drivers/platform_dos.c +++ b/frontend/drivers/platform_dos.c @@ -22,6 +22,7 @@ #include "../frontend_driver.h" #include "../../defaults.h" +#include "../../paths.h" static enum frontend_fork dos_fork_mode = FRONTEND_FORK_NONE; @@ -105,12 +106,9 @@ static void frontend_dos_get_env_settings(int *argc, char *argv[], fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_LOGS], base_path, "logs", sizeof(g_defaults.dirs[DEFAULT_DIR_LOGS])); - for (i = 0; i < DEFAULT_DIR_LAST; i++) - { - const char *dir_path = g_defaults.dirs[i]; - if (!string_is_empty(dir_path)) - path_mkdir(dir_path); - } +#ifndef IS_SALAMANDER + dir_check_defaults("custom.ini"); +#endif } static void frontend_dos_exec(const char *path, bool should_load_game) diff --git a/frontend/drivers/platform_emscripten.c b/frontend/drivers/platform_emscripten.c index e7d24e35a5..a35041eb8e 100644 --- a/frontend/drivers/platform_emscripten.c +++ b/frontend/drivers/platform_emscripten.c @@ -45,6 +45,7 @@ #include "../../command.h" #include "../../tasks/tasks_internal.h" #include "../../file_path_special.h" +#include "../../paths.h" void dummyErrnoCodes(void); void emscripten_mainloop(void); @@ -151,12 +152,9 @@ static void frontend_emscripten_get_env(int *argc, char *argv[], fill_pathname_join(g_defaults.path_config, user_path, FILE_PATH_MAIN_CONFIG, sizeof(g_defaults.path_config)); - for (i = 0; i < DEFAULT_DIR_LAST; i++) - { - const char *dir_path = g_defaults.dirs[i]; - if (!string_is_empty(dir_path)) - path_mkdir(dir_path); - } +#ifndef IS_SALAMANDER + dir_check_defaults("custom.ini"); +#endif } int main(int argc, char *argv[]) diff --git a/frontend/drivers/platform_gx.c b/frontend/drivers/platform_gx.c index b6a2e565e7..a75c2ea4a8 100644 --- a/frontend/drivers/platform_gx.c +++ b/frontend/drivers/platform_gx.c @@ -283,6 +283,7 @@ static void frontend_gx_get_environment_settings( } } #endif + dir_check_defaults("custom.ini"); #endif } diff --git a/frontend/drivers/platform_orbis.c b/frontend/drivers/platform_orbis.c index 3d2196703d..42fb3b4c5e 100644 --- a/frontend/drivers/platform_orbis.c +++ b/frontend/drivers/platform_orbis.c @@ -210,14 +210,9 @@ static void frontend_orbis_get_environment_settings(int *argc, char *argv[], RARCH_LOG("Auto-start game %s.\n", argv[2]); } } -#endif - for (i = 0; i < DEFAULT_DIR_LAST; i++) - { - const char *dir_path = g_defaults.dirs[i]; - if (!string_is_empty(dir_path)) - path_mkdir(dir_path); - } + dir_check_defaults("host0:app/custom.ini"); +#endif } static void frontend_orbis_deinit(void *data) diff --git a/frontend/drivers/platform_ps2.c b/frontend/drivers/platform_ps2.c index ccb5420265..cea7fca00d 100644 --- a/frontend/drivers/platform_ps2.c +++ b/frontend/drivers/platform_ps2.c @@ -33,6 +33,7 @@ #include "../../defaults.h" #include "../../file_path_special.h" #include "../../verbosity.h" +#include "../../paths.h" #include @@ -140,12 +141,10 @@ static void frontend_ps2_get_environment_settings(int *argc, char *argv[], } } #endif - for (i = 0; i < DEFAULT_DIR_LAST; i++) - { - const char *dir_path = g_defaults.dirs[i]; - if (!string_is_empty(dir_path)) - path_mkdir(dir_path); - } + +#ifndef IS_SALAMANDER + dir_check_defaults("custom.ini"); +#endif } static void frontend_ps2_init(void *data) diff --git a/frontend/drivers/platform_ps3.c b/frontend/drivers/platform_ps3.c index 077e20a7ef..deeea666e3 100644 --- a/frontend/drivers/platform_ps3.c +++ b/frontend/drivers/platform_ps3.c @@ -49,6 +49,7 @@ #include "../../defines/ps3_defines.h" #include "../../defaults.h" #include "../../verbosity.h" +#include "../../paths.h" #ifdef __PSL1GHT__ #define EMULATOR_CONTENT_DIR "SSNE10001" @@ -206,6 +207,8 @@ static void frontend_ps3_get_environment_settings(int *argc, char *argv[], verbosity_enable(); else verbosity_disable(); + + dir_check_defaults("custom.ini"); #endif } @@ -329,6 +332,7 @@ static void frontend_ps3_get_environment_settings(int *argc, char *argv[], verbosity_enable(); else verbosity_disable(); + ps3_dir_check_defaults(); #endif } #endif diff --git a/frontend/drivers/platform_psp.c b/frontend/drivers/platform_psp.c index 649e5d1900..38f65f2b2f 100644 --- a/frontend/drivers/platform_psp.c +++ b/frontend/drivers/platform_psp.c @@ -217,14 +217,9 @@ static void frontend_psp_get_environment_settings(int *argc, char *argv[], RARCH_LOG("Auto-start game %s.\n", argv[1]); } } -#endif - for (i = 0; i < DEFAULT_DIR_LAST; i++) - { - const char *dir_path = g_defaults.dirs[i]; - if (!string_is_empty(dir_path)) - path_mkdir(dir_path); - } + dir_check_defaults("custom.ini"); +#endif } static void frontend_psp_deinit(void *data) diff --git a/frontend/drivers/platform_qnx.c b/frontend/drivers/platform_qnx.c index 3145cca490..4af6fc24e7 100644 --- a/frontend/drivers/platform_qnx.c +++ b/frontend/drivers/platform_qnx.c @@ -30,6 +30,7 @@ #include "../../defaults.h" #include "../../dynamic.h" #include "../../verbosity.h" +#include "../../paths.h" static void frontend_qnx_init(void *data) { @@ -162,15 +163,12 @@ static void frontend_qnx_get_environment_settings(int *argc, char *argv[], RARCH_LOG( "Asset copy successful.\n"); } - for (i = 0; i < DEFAULT_DIR_LAST; i++) - { - const char *dir_path = g_defaults.dirs[i]; - if (!string_is_empty(dir_path)) - path_mkdir(dir_path); - } - - /* set glui as default menu */ + /* set GLUI as default menu */ snprintf(g_defaults.settings_menu, sizeof(g_defaults.settings_menu), "glui"); + +#ifndef IS_SALAMANDER + dir_check_defaults("custom.ini"); +#endif } enum frontend_architecture frontend_qnx_get_architecture(void) diff --git a/frontend/drivers/platform_switch.c b/frontend/drivers/platform_switch.c index 40d0145863..6c83c1b3b6 100644 --- a/frontend/drivers/platform_switch.c +++ b/frontend/drivers/platform_switch.c @@ -276,6 +276,10 @@ static void frontend_switch_get_environment_settings( g_defaults.dirs[DEFAULT_DIR_PORT], FILE_PATH_MAIN_CONFIG, sizeof(g_defaults.path_config)); + +#ifndef IS_SALAMANDER + dir_check_defaults("custom.ini"); +#endif } static void frontend_switch_deinit(void *data) diff --git a/frontend/drivers/platform_unix.c b/frontend/drivers/platform_unix.c index ec17dea7aa..0eb8636963 100644 --- a/frontend/drivers/platform_unix.c +++ b/frontend/drivers/platform_unix.c @@ -1853,12 +1853,13 @@ static void frontend_unix_get_env(int *argc, "system", sizeof(g_defaults.dirs[DEFAULT_DIR_SYSTEM])); #endif - for (i = 0; i < DEFAULT_DIR_LAST; i++) - { - const char *dir_path = g_defaults.dirs[i]; - if (!string_is_empty(dir_path)) - path_mkdir(dir_path); - } +#ifndef IS_SALAMANDER +#if defined(ANDROID) + dir_check_defaults("host0:app/custom.ini"); +#else + dir_check_defaults("custom.ini"); +#endif +#endif } #ifdef ANDROID diff --git a/frontend/drivers/platform_uwp.c b/frontend/drivers/platform_uwp.c index 041ab2658a..1ba9ea3fb5 100644 --- a/frontend/drivers/platform_uwp.c +++ b/frontend/drivers/platform_uwp.c @@ -42,6 +42,7 @@ #include "../../retroarch.h" #include "../../verbosity.h" #include "../../ui/drivers/ui_win32.h" +#include "../../paths.h" #include "../../uwp/uwp_func.h" @@ -390,6 +391,15 @@ static void frontend_uwp_environment_get(int *argc, char *argv[], strcpy_literal(g_defaults.settings_menu, "glui"); #endif #endif + +#ifndef IS_SALAMANDER + { + char custom_ini_path[PATH_MAX_LENGTH]; + fill_pathname_expand_special(custom_ini_path, + "~\\custom.ini", sizeof(custom_ini_path)); + dir_check_defaults(custom_ini_path); + } +#endif } static uint64_t frontend_uwp_get_mem_total(void) diff --git a/frontend/drivers/platform_wiiu.c b/frontend/drivers/platform_wiiu.c index 1dab67518a..4f04268644 100644 --- a/frontend/drivers/platform_wiiu.c +++ b/frontend/drivers/platform_wiiu.c @@ -136,12 +136,9 @@ static void frontend_wiiu_get_environment_settings(int *argc, char *argv[], fill_pathname_join(g_defaults.path_config, g_defaults.dirs[DEFAULT_DIR_PORT], FILE_PATH_MAIN_CONFIG, sizeof(g_defaults.path_config)); - for (i = 0; i < DEFAULT_DIR_LAST; i++) - { - const char *dir_path = g_defaults.dirs[i]; - if (!string_is_empty(dir_path)) - path_mkdir(dir_path); - } +#ifndef IS_SALAMANDER + dir_check_defaults("custom.ini"); +#endif } static void frontend_wiiu_deinit(void *data) diff --git a/frontend/drivers/platform_win32.c b/frontend/drivers/platform_win32.c index 6414a8e021..008a2be78e 100644 --- a/frontend/drivers/platform_win32.c +++ b/frontend/drivers/platform_win32.c @@ -627,6 +627,10 @@ static void frontend_win32_environment_get(int *argc, char *argv[], ":\\system", sizeof(g_defaults.dirs[DEFAULT_DIR_SYSTEM])); fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_LOGS], ":\\logs", sizeof(g_defaults.dirs[DEFAULT_DIR_LOGS])); + +#ifndef IS_SALAMANDER + dir_check_defaults("custom.ini"); +#endif } static uint64_t frontend_win32_get_total_mem(void) diff --git a/frontend/drivers/platform_xdk.c b/frontend/drivers/platform_xdk.c index 6805035c01..e32b2f9efe 100644 --- a/frontend/drivers/platform_xdk.c +++ b/frontend/drivers/platform_xdk.c @@ -227,6 +227,8 @@ exit: else verbosity_disable(); #endif + + dir_check_defaults("custom.ini"); #endif } diff --git a/frontend/drivers/platform_xenon.c b/frontend/drivers/platform_xenon.c index a5e3cca662..a6fb9b4277 100644 --- a/frontend/drivers/platform_xenon.c +++ b/frontend/drivers/platform_xenon.c @@ -33,6 +33,7 @@ #include #include "../../dynamic.h" +#include "../../paths.h" static void frontend_xenon_init(void *data) { diff --git a/frontend/frontend_salamander.c b/frontend/frontend_salamander.c index ad0f6264d7..94d0e28b59 100644 --- a/frontend/frontend_salamander.c +++ b/frontend/frontend_salamander.c @@ -123,8 +123,10 @@ static void salamander_init(char *s, size_t len) const char *rarch_config_path = g_defaults.path_config; bool config_valid = false; char config_path[PATH_MAX_LENGTH]; + char config_dir[PATH_MAX_LENGTH]; config_path[0] = '\0'; + config_dir[0] = '\0'; /* Get salamander config file path */ if (!string_is_empty(rarch_config_path)) @@ -135,6 +137,12 @@ static void salamander_init(char *s, size_t len) else strcpy_literal(config_path, FILE_PATH_SALAMANDER_CONFIG); + /* Ensure that config directory exists */ + fill_pathname_parent_dir(config_dir, config_path, sizeof(config_dir)); + if (!string_is_empty(config_dir) && + !path_is_directory(config_dir)) + path_mkdir(config_dir); + /* Attempt to open config file */ config = config_file_new_from_path_to_string(config_path); diff --git a/paths.h b/paths.h index bee6fe5f53..3e0134e701 100644 --- a/paths.h +++ b/paths.h @@ -65,7 +65,7 @@ char *dir_get_ptr(enum rarch_dir_type type); void dir_set(enum rarch_dir_type type, const char *path); -void dir_check_defaults(void); +void dir_check_defaults(const char *custom_ini_path); void path_deinit_savefile(void); diff --git a/retroarch.c b/retroarch.c index 16da847606..25f3429168 100644 --- a/retroarch.c +++ b/retroarch.c @@ -9424,28 +9424,20 @@ void dir_set(enum rarch_dir_type type, const char *path) } } -void dir_check_defaults(void) +void dir_check_defaults(const char *custom_ini_path) { - unsigned i; - char path[PATH_MAX_LENGTH]; + size_t i; - /* early return for people with a custom folder setup - so it doesn't create unnecessary directories - */ -#if defined(ORBIS) || defined(ANDROID) - strcpy_literal(path, "host0:app/custom.ini"); -#elif defined(__WINRT__) - fill_pathname_expand_special(path, "~\\custom.ini", MAX_PATH); -#else - strcpy_literal(path, "custom.ini"); -#endif - if (path_is_valid(path)) + /* Early return for people with a custom folder setup + * so it doesn't create unnecessary directories */ + if (!string_is_empty(custom_ini_path) && + path_is_valid(custom_ini_path)) return; for (i = 0; i < DEFAULT_DIR_LAST; i++) { - char new_path[PATH_MAX_LENGTH]; const char *dir_path = g_defaults.dirs[i]; + char new_path[PATH_MAX_LENGTH]; if (string_is_empty(dir_path)) continue; diff --git a/tasks/task_content.c b/tasks/task_content.c index c7aaf0df01..e41ae9da53 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -648,8 +648,6 @@ static bool content_load(content_ctx_info_t *info, command_event(CMD_EVENT_RESUME, NULL); command_event(CMD_EVENT_VIDEO_SET_ASPECT_RATIO, NULL); - dir_check_defaults(); - frontend_driver_process_args(rarch_argc_ptr, rarch_argv_ptr); frontend_driver_content_loaded();