From ccba9635b6a8b430fd1b92693e63d0af9a7c9f79 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 23 May 2017 19:43:58 +0200 Subject: [PATCH] Update the way default directories are handled --- configuration.c | 124 ++++++----- defaults.h | 61 +++--- dirs.c | 57 +----- frontend/drivers/platform_ctr.c | 58 +++--- frontend/drivers/platform_darwin.m | 97 +++++---- frontend/drivers/platform_emscripten.c | 106 +++++----- frontend/drivers/platform_gx.c | 52 ++--- frontend/drivers/platform_linux.c | 271 ++++++++++++------------- frontend/drivers/platform_ps3.c | 71 ++++--- frontend/drivers/platform_psp.c | 170 +++++++--------- frontend/drivers/platform_qnx.c | 188 +++++++++-------- frontend/drivers/platform_wiiu.c | 66 +++--- frontend/drivers/platform_win32.c | 126 ++++++------ frontend/drivers/platform_xdk.cpp | 62 +++--- frontend/frontend_salamander.c | 4 +- menu/menu_setting.c | 8 +- 16 files changed, 750 insertions(+), 771 deletions(-) diff --git a/configuration.c b/configuration.c index 29e5d6aabd..d747f1774c 100644 --- a/configuration.c +++ b/configuration.c @@ -1657,62 +1657,79 @@ static void config_set_defaults(void) video_driver_default_settings(); - if (!string_is_empty(g_defaults.dir.wallpapers)) + if (!string_is_empty(g_defaults.dirs[DEFAULT_DIR_WALLPAPERS])) strlcpy(settings->paths.directory_dynamic_wallpapers, - g_defaults.dir.wallpapers, sizeof(settings->paths.directory_dynamic_wallpapers)); - if (!string_is_empty(g_defaults.dir.thumbnails)) + g_defaults.dirs[DEFAULT_DIR_WALLPAPERS], + sizeof(settings->paths.directory_dynamic_wallpapers)); + if (!string_is_empty(g_defaults.dirs[DEFAULT_DIR_THUMBNAILS])) strlcpy(settings->paths.directory_thumbnails, - g_defaults.dir.thumbnails, sizeof(settings->paths.directory_thumbnails)); - if (!string_is_empty(g_defaults.dir.remap)) + g_defaults.dirs[DEFAULT_DIR_THUMBNAILS], + sizeof(settings->paths.directory_thumbnails)); + if (!string_is_empty(g_defaults.dirs[DEFAULT_DIR_REMAP])) strlcpy(settings->paths.directory_input_remapping, - g_defaults.dir.remap, sizeof(settings->paths.directory_input_remapping)); - if (!string_is_empty(g_defaults.dir.cache)) + g_defaults.dirs[DEFAULT_DIR_REMAP], + sizeof(settings->paths.directory_input_remapping)); + if (!string_is_empty(g_defaults.dirs[DEFAULT_DIR_CACHE])) strlcpy(settings->paths.directory_cache, - g_defaults.dir.cache, sizeof(settings->paths.directory_cache)); - if (!string_is_empty(g_defaults.dir.assets)) + g_defaults.dirs[DEFAULT_DIR_CACHE], + sizeof(settings->paths.directory_cache)); + if (!string_is_empty(g_defaults.dirs[DEFAULT_DIR_ASSETS])) strlcpy(settings->paths.directory_assets, - g_defaults.dir.assets, sizeof(settings->paths.directory_assets)); - if (!string_is_empty(g_defaults.dir.core_assets)) + g_defaults.dirs[DEFAULT_DIR_ASSETS], + sizeof(settings->paths.directory_assets)); + if (!string_is_empty(g_defaults.dirs[DEFAULT_DIR_CORE_ASSETS])) strlcpy(settings->paths.directory_core_assets, - g_defaults.dir.core_assets, sizeof(settings->paths.directory_core_assets)); - if (!string_is_empty(g_defaults.dir.playlist)) + g_defaults.dirs[DEFAULT_DIR_CORE_ASSETS], + sizeof(settings->paths.directory_core_assets)); + if (!string_is_empty(g_defaults.dirs[DEFAULT_DIR_PLAYLIST])) strlcpy(settings->paths.directory_playlist, - g_defaults.dir.playlist, sizeof(settings->paths.directory_playlist)); - if (!string_is_empty(g_defaults.dir.core)) + g_defaults.dirs[DEFAULT_DIR_PLAYLIST], + sizeof(settings->paths.directory_playlist)); + if (!string_is_empty(g_defaults.dirs[DEFAULT_DIR_CORE])) fill_pathname_expand_special(settings->paths.directory_libretro, - g_defaults.dir.core, sizeof(settings->paths.directory_libretro)); - if (!string_is_empty(g_defaults.dir.audio_filter)) + g_defaults.dirs[DEFAULT_DIR_CORE], + sizeof(settings->paths.directory_libretro)); + if (!string_is_empty(g_defaults.dirs[DEFAULT_DIR_AUDIO_FILTER])) strlcpy(settings->paths.directory_audio_filter, - g_defaults.dir.audio_filter, sizeof(settings->paths.directory_audio_filter)); - if (!string_is_empty(g_defaults.dir.video_filter)) + g_defaults.dirs[DEFAULT_DIR_AUDIO_FILTER], + sizeof(settings->paths.directory_audio_filter)); + if (!string_is_empty(g_defaults.dirs[DEFAULT_DIR_VIDEO_FILTER])) strlcpy(settings->paths.directory_video_filter, - g_defaults.dir.video_filter, sizeof(settings->paths.directory_video_filter)); - if (!string_is_empty(g_defaults.dir.shader)) + g_defaults.dirs[DEFAULT_DIR_VIDEO_FILTER], + sizeof(settings->paths.directory_video_filter)); + if (!string_is_empty(g_defaults.dirs[DEFAULT_DIR_SHADER])) fill_pathname_expand_special(settings->paths.directory_video_shader, - g_defaults.dir.shader, sizeof(settings->paths.directory_video_shader)); + g_defaults.dirs[DEFAULT_DIR_SHADER], + sizeof(settings->paths.directory_video_shader)); if (!string_is_empty(g_defaults.path.buildbot_server_url)) strlcpy(settings->paths.network_buildbot_url, - g_defaults.path.buildbot_server_url, sizeof(settings->paths.network_buildbot_url)); + g_defaults.path.buildbot_server_url, + sizeof(settings->paths.network_buildbot_url)); if (!string_is_empty(g_defaults.path.core)) rarch_ctl(RARCH_CTL_SET_LIBRETRO_PATH, g_defaults.path.core); - if (!string_is_empty(g_defaults.dir.database)) - strlcpy(settings->paths.path_content_database, g_defaults.dir.database, + if (!string_is_empty(g_defaults.dirs[DEFAULT_DIR_DATABASE])) + strlcpy(settings->paths.path_content_database, + g_defaults.dirs[DEFAULT_DIR_DATABASE], sizeof(settings->paths.path_content_database)); - if (!string_is_empty(g_defaults.dir.cursor)) - strlcpy(settings->paths.directory_cursor, g_defaults.dir.cursor, + if (!string_is_empty(g_defaults.dirs[DEFAULT_DIR_CURSOR])) + strlcpy(settings->paths.directory_cursor, + g_defaults.dirs[DEFAULT_DIR_CURSOR], sizeof(settings->paths.directory_cursor)); - if (!string_is_empty(g_defaults.dir.cheats)) - strlcpy(settings->paths.path_cheat_database, g_defaults.dir.cheats, + if (!string_is_empty(g_defaults.dirs[DEFAULT_DIR_CHEATS])) + strlcpy(settings->paths.path_cheat_database, + g_defaults.dirs[DEFAULT_DIR_CHEATS], sizeof(settings->paths.path_cheat_database)); - if (!string_is_empty(g_defaults.dir.core_info)) + if (!string_is_empty(g_defaults.dirs[DEFAULT_DIR_CORE_INFO])) fill_pathname_expand_special(settings->paths.path_libretro_info, - g_defaults.dir.core_info, sizeof(settings->paths.path_libretro_info)); + g_defaults.dirs[DEFAULT_DIR_CORE_INFO], + sizeof(settings->paths.path_libretro_info)); #ifdef HAVE_OVERLAY - if (!string_is_empty(g_defaults.dir.overlay)) + if (!string_is_empty(g_defaults.dirs[DEFAULT_DIR_OVERLAY])) { fill_pathname_expand_special(settings->paths.directory_overlay, - g_defaults.dir.overlay, sizeof(settings->paths.directory_overlay)); + g_defaults.dirs[DEFAULT_DIR_OVERLAY], + sizeof(settings->paths.directory_overlay)); #ifdef RARCH_MOBILE if (string_is_empty(settings->paths.path_overlay)) fill_pathname_join(settings->paths.path_overlay, @@ -1724,10 +1741,10 @@ static void config_set_defaults(void) #endif #ifdef HAVE_MENU - if (!string_is_empty(g_defaults.dir.menu_config)) + if (!string_is_empty(g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG])) { strlcpy(settings->paths.directory_menu_config, - g_defaults.dir.menu_config, + g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG], sizeof(settings->paths.directory_menu_config)); #if TARGET_OS_IPHONE path_set(RARCH_PATH_CONFIG, @@ -1735,38 +1752,39 @@ static void config_set_defaults(void) #endif } - if (!string_is_empty(g_defaults.dir.menu_content)) + if (!string_is_empty(g_defaults.dirs[DEFAULT_DIR_MENU_CONTENT])) strlcpy(settings->paths.directory_menu_content, - g_defaults.dir.menu_content, + g_defaults.dirs[DEFAULT_DIR_MENU_CONTENT], sizeof(settings->paths.directory_menu_content)); #endif - if (!string_is_empty(g_defaults.dir.autoconfig)) + if (!string_is_empty(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG])) strlcpy(settings->paths.directory_autoconfig, - g_defaults.dir.autoconfig, + g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG], sizeof(settings->paths.directory_autoconfig)); if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_STATE_PATH, NULL) && - !string_is_empty(g_defaults.dir.savestate)) - dir_set(RARCH_DIR_SAVESTATE, g_defaults.dir.savestate); + !string_is_empty(g_defaults.dirs[DEFAULT_DIR_SAVESTATE])) + dir_set(RARCH_DIR_SAVESTATE, g_defaults.dirs[DEFAULT_DIR_SAVESTATE]); if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_SAVE_PATH, NULL) && - !string_is_empty(g_defaults.dir.sram)) - dir_set(RARCH_DIR_SAVEFILE, g_defaults.dir.sram); + !string_is_empty(g_defaults.dirs[DEFAULT_DIR_SRAM])) + dir_set(RARCH_DIR_SAVEFILE, g_defaults.dirs[DEFAULT_DIR_SRAM]); - if (!string_is_empty(g_defaults.dir.system)) + if (!string_is_empty(g_defaults.dirs[DEFAULT_DIR_SYSTEM])) strlcpy(settings->paths.directory_system, - g_defaults.dir.system, sizeof(settings->paths.directory_system)); - if (!string_is_empty(g_defaults.dir.screenshot)) + g_defaults.dirs[DEFAULT_DIR_SYSTEM], + sizeof(settings->paths.directory_system)); + if (!string_is_empty(g_defaults.dirs[DEFAULT_DIR_SCREENSHOT])) strlcpy(settings->paths.directory_screenshot, - g_defaults.dir.screenshot, + g_defaults.dirs[DEFAULT_DIR_SCREENSHOT], sizeof(settings->paths.directory_screenshot)); - if (!string_is_empty(g_defaults.dir.resampler)) + if (!string_is_empty(g_defaults.dirs[DEFAULT_DIR_RESAMPLER])) strlcpy(settings->paths.directory_resampler, - g_defaults.dir.resampler, + g_defaults.dirs[DEFAULT_DIR_RESAMPLER], sizeof(settings->paths.directory_resampler)); - if (!string_is_empty(g_defaults.dir.content_history)) + if (!string_is_empty(g_defaults.dirs[DEFAULT_DIR_CONTENT_HISTORY])) strlcpy(settings->paths.directory_content_history, - g_defaults.dir.content_history, + g_defaults.dirs[DEFAULT_DIR_CONTENT_HISTORY], sizeof(settings->paths.directory_content_history)); if (!string_is_empty(g_defaults.path.config)) @@ -2574,7 +2592,7 @@ static bool config_load_file(const char *path, bool set_defaults, config_get_path(conf, "savefile_directory", tmp_str, sizeof(tmp_str))) { if (string_is_equal_fast(tmp_str, "default", 7)) - dir_set(RARCH_DIR_SAVEFILE, g_defaults.dir.sram); + dir_set(RARCH_DIR_SAVEFILE, g_defaults.dirs[DEFAULT_DIR_SRAM]); else if (path_is_directory(tmp_str)) { @@ -2600,7 +2618,7 @@ static bool config_load_file(const char *path, bool set_defaults, config_get_path(conf, "savestate_directory", tmp_str, sizeof(tmp_str))) { if (string_is_equal_fast(tmp_str, "default", 7)) - dir_set(RARCH_DIR_SAVESTATE, g_defaults.dir.savestate); + dir_set(RARCH_DIR_SAVESTATE, g_defaults.dirs[DEFAULT_DIR_SAVESTATE]); else if (path_is_directory(tmp_str)) { global_t *global = global_get_ptr(); diff --git a/defaults.h b/defaults.h index f249f10069..845fda3723 100644 --- a/defaults.h +++ b/defaults.h @@ -24,6 +24,37 @@ #include "playlist.h" #endif +enum default_dirs +{ + DEFAULT_DIR_MENU_CONTENT = 0, + DEFAULT_DIR_CORE_ASSETS, + DEFAULT_DIR_MENU_CONFIG, + DEFAULT_DIR_AUTOCONFIG, + DEFAULT_DIR_AUDIO_FILTER, + DEFAULT_DIR_VIDEO_FILTER, + DEFAULT_DIR_ASSETS, + DEFAULT_DIR_CORE, + DEFAULT_DIR_CORE_INFO, + DEFAULT_DIR_OVERLAY, + DEFAULT_DIR_PORT, + DEFAULT_DIR_SHADER, + DEFAULT_DIR_SAVESTATE, + DEFAULT_DIR_RESAMPLER, + DEFAULT_DIR_SRAM, + DEFAULT_DIR_SCREENSHOT, + DEFAULT_DIR_SYSTEM, + DEFAULT_DIR_PLAYLIST, + DEFAULT_DIR_CONTENT_HISTORY, + DEFAULT_DIR_REMAP, + DEFAULT_DIR_CACHE, + DEFAULT_DIR_WALLPAPERS, + DEFAULT_DIR_THUMBNAILS, + DEFAULT_DIR_DATABASE, + DEFAULT_DIR_CURSOR, + DEFAULT_DIR_CHEATS, + DEFAULT_DIR_LAST +}; + struct defaults { #ifdef HAVE_MENU @@ -50,35 +81,7 @@ struct defaults bool enable; } overlay; - struct - { - char menu_content[PATH_MAX_LENGTH]; - char core_assets[PATH_MAX_LENGTH]; - char menu_config[PATH_MAX_LENGTH]; - char autoconfig[PATH_MAX_LENGTH]; - char audio_filter[PATH_MAX_LENGTH]; - char video_filter[PATH_MAX_LENGTH]; - char assets[PATH_MAX_LENGTH]; - char core[PATH_MAX_LENGTH]; - char core_info[PATH_MAX_LENGTH]; - char overlay[PATH_MAX_LENGTH]; - char port[PATH_MAX_LENGTH]; - char shader[PATH_MAX_LENGTH]; - char savestate[PATH_MAX_LENGTH]; - char resampler[PATH_MAX_LENGTH]; - char sram[PATH_MAX_LENGTH]; - char screenshot[PATH_MAX_LENGTH]; - char system[PATH_MAX_LENGTH]; - char playlist[PATH_MAX_LENGTH]; - char content_history[PATH_MAX_LENGTH]; - char remap[PATH_MAX_LENGTH]; - char cache[PATH_MAX_LENGTH]; - char wallpapers[PATH_MAX_LENGTH]; - char thumbnails[PATH_MAX_LENGTH]; - char database[PATH_MAX_LENGTH]; - char cursor[PATH_MAX_LENGTH]; - char cheats[PATH_MAX_LENGTH]; - } dir; + char dirs [DEFAULT_DIR_LAST + 1][PATH_MAX_LENGTH]; struct { diff --git a/dirs.c b/dirs.c index 6e0b22c680..ce484e86b5 100644 --- a/dirs.c +++ b/dirs.c @@ -297,60 +297,17 @@ static void check_defaults_dir_create_dir(const char *path) void dir_check_defaults(void) { + unsigned i; /* early return for people with a custom folder setup so it doesn't create unnecessary directories */ if (path_file_exists("custom.ini")) return; - if (!string_is_empty(g_defaults.dir.core_assets)) - check_defaults_dir_create_dir(g_defaults.dir.core_assets); - if (!string_is_empty(g_defaults.dir.remap)) - check_defaults_dir_create_dir(g_defaults.dir.remap); - if (!string_is_empty(g_defaults.dir.screenshot)) - check_defaults_dir_create_dir(g_defaults.dir.screenshot); - if (!string_is_empty(g_defaults.dir.core)) - check_defaults_dir_create_dir(g_defaults.dir.core); - if (!string_is_empty(g_defaults.dir.autoconfig)) - check_defaults_dir_create_dir(g_defaults.dir.autoconfig); - if (!string_is_empty(g_defaults.dir.audio_filter)) - check_defaults_dir_create_dir(g_defaults.dir.audio_filter); - if (!string_is_empty(g_defaults.dir.video_filter)) - check_defaults_dir_create_dir(g_defaults.dir.video_filter); - if (!string_is_empty(g_defaults.dir.assets)) - check_defaults_dir_create_dir(g_defaults.dir.assets); - if (!string_is_empty(g_defaults.dir.playlist)) - check_defaults_dir_create_dir(g_defaults.dir.playlist); - if (!string_is_empty(g_defaults.dir.core)) - check_defaults_dir_create_dir(g_defaults.dir.core); - if (!string_is_empty(g_defaults.dir.core_info)) - check_defaults_dir_create_dir(g_defaults.dir.core_info); - if (!string_is_empty(g_defaults.dir.overlay)) - check_defaults_dir_create_dir(g_defaults.dir.overlay); - if (!string_is_empty(g_defaults.dir.port)) - check_defaults_dir_create_dir(g_defaults.dir.port); - if (!string_is_empty(g_defaults.dir.shader)) - check_defaults_dir_create_dir(g_defaults.dir.shader); - if (!string_is_empty(g_defaults.dir.savestate)) - check_defaults_dir_create_dir(g_defaults.dir.savestate); - if (!string_is_empty(g_defaults.dir.sram)) - check_defaults_dir_create_dir(g_defaults.dir.sram); - if (!string_is_empty(g_defaults.dir.system)) - check_defaults_dir_create_dir(g_defaults.dir.system); - if (!string_is_empty(g_defaults.dir.resampler)) - check_defaults_dir_create_dir(g_defaults.dir.resampler); - if (!string_is_empty(g_defaults.dir.menu_config)) - check_defaults_dir_create_dir(g_defaults.dir.menu_config); - if (!string_is_empty(g_defaults.dir.content_history)) - check_defaults_dir_create_dir(g_defaults.dir.content_history); - if (!string_is_empty(g_defaults.dir.cache)) - check_defaults_dir_create_dir(g_defaults.dir.cache); - if (!string_is_empty(g_defaults.dir.database)) - check_defaults_dir_create_dir(g_defaults.dir.database); - if (!string_is_empty(g_defaults.dir.cursor)) - check_defaults_dir_create_dir(g_defaults.dir.cursor); - if (!string_is_empty(g_defaults.dir.cheats)) - check_defaults_dir_create_dir(g_defaults.dir.cheats); - if (!string_is_empty(g_defaults.dir.thumbnails)) - check_defaults_dir_create_dir(g_defaults.dir.thumbnails); + for (i = 0; i < DEFAULT_DIR_LAST; i++) + { + const char *dir_path = g_defaults.dirs[i]; + if (!string_is_empty(dir_path)) + check_defaults_dir_create_dir(dir_path); + } } diff --git a/frontend/drivers/platform_ctr.c b/frontend/drivers/platform_ctr.c index 59370f8edf..52da6795b3 100644 --- a/frontend/drivers/platform_ctr.c +++ b/frontend/drivers/platform_ctr.c @@ -64,36 +64,36 @@ static void frontend_ctr_get_environment_settings(int *argc, char *argv[], #endif #endif - fill_pathname_basedir(g_defaults.dir.port, elf_path_cst, sizeof(g_defaults.dir.port)); - RARCH_LOG("port dir: [%s]\n", g_defaults.dir.port); + 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]); - fill_pathname_join(g_defaults.dir.core_assets, g_defaults.dir.port, - "downloads", sizeof(g_defaults.dir.core_assets)); - fill_pathname_join(g_defaults.dir.assets, g_defaults.dir.port, - "media", sizeof(g_defaults.dir.assets)); - fill_pathname_join(g_defaults.dir.core, g_defaults.dir.port, - "cores", sizeof(g_defaults.dir.core)); - fill_pathname_join(g_defaults.dir.core_info, g_defaults.dir.core, - "info", sizeof(g_defaults.dir.core_info)); - fill_pathname_join(g_defaults.dir.savestate, g_defaults.dir.core, - "savestates", sizeof(g_defaults.dir.savestate)); - fill_pathname_join(g_defaults.dir.sram, g_defaults.dir.core, - "savefiles", sizeof(g_defaults.dir.sram)); - fill_pathname_join(g_defaults.dir.system, g_defaults.dir.core, - "system", sizeof(g_defaults.dir.system)); - fill_pathname_join(g_defaults.dir.playlist, g_defaults.dir.core, - "playlists", sizeof(g_defaults.dir.playlist)); - fill_pathname_join(g_defaults.dir.menu_config, g_defaults.dir.port, - "config", sizeof(g_defaults.dir.menu_config)); - fill_pathname_join(g_defaults.dir.remap, g_defaults.dir.port, - "config/remaps", sizeof(g_defaults.dir.remap)); - fill_pathname_join(g_defaults.dir.video_filter, g_defaults.dir.port, - "filters", sizeof(g_defaults.dir.remap)); - fill_pathname_join(g_defaults.dir.database, g_defaults.dir.port, - "database/rdb", sizeof(g_defaults.dir.database)); - fill_pathname_join(g_defaults.dir.cursor, g_defaults.dir.port, - "database/cursors", sizeof(g_defaults.dir.cursor)); - fill_pathname_join(g_defaults.path.config, g_defaults.dir.port, + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_ASSETS], g_defaults.dirs[DEFAULT_DIR_PORT], + "downloads", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_ASSETS])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_ASSETS], g_defaults.dirs[DEFAULT_DIR_PORT], + "media", sizeof(g_defaults.dirs[DEFAULT_DIR_ASSETS])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE], g_defaults.dirs[DEFAULT_DIR_PORT], + "cores", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_INFO], g_defaults.dirs[DEFAULT_DIR_CORE], + "info", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_INFO])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SAVESTATE], g_defaults.dirs[DEFAULT_DIR_CORE], + "savestates", sizeof(g_defaults.dirs[DEFAULT_DIR_SAVESTATE])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SRAM], g_defaults.dirs[DEFAULT_DIR_CORE], + "savefiles", sizeof(g_defaults.dirs[DEFAULT_DIR_SRAM])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SYSTEM], g_defaults.dirs[DEFAULT_DIR_CORE], + "system", sizeof(g_defaults.dirs[DEFAULT_DIR_SYSTEM])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_PLAYLIST], g_defaults.dirs[DEFAULT_DIR_CORE], + "playlists", sizeof(g_defaults.dirs[DEFAULT_DIR_PLAYLIST])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG], g_defaults.dirs[DEFAULT_DIR_PORT], + "config", sizeof(g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_REMAP], g_defaults.dirs[DEFAULT_DIR_PORT], + "config/remaps", sizeof(g_defaults.dirs[DEFAULT_DIR_REMAP])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_VIDEO_FILTER], g_defaults.dirs[DEFAULT_DIR_PORT], + "filters", sizeof(g_defaults.dirs[DEFAULT_DIR_REMAP])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_DATABASE], g_defaults.dirs[DEFAULT_DIR_PORT], + "database/rdb", sizeof(g_defaults.dirs[DEFAULT_DIR_DATABASE])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CURSOR], g_defaults.dirs[DEFAULT_DIR_PORT], + "database/cursors", sizeof(g_defaults.dirs[DEFAULT_DIR_CURSOR])); + fill_pathname_join(g_defaults.path.config, g_defaults.dirs[DEFAULT_DIR_PORT], file_path_str(FILE_PATH_MAIN_CONFIG), sizeof(g_defaults.path.config)); } diff --git a/frontend/drivers/platform_darwin.m b/frontend/drivers/platform_darwin.m index a0787d967c..4be6360f82 100644 --- a/frontend/drivers/platform_darwin.m +++ b/frontend/drivers/platform_darwin.m @@ -332,37 +332,41 @@ static void frontend_darwin_get_environment_settings(int *argc, char *argv[], CFStringGetCString(bundle_path, bundle_path_buf, sizeof(bundle_path_buf), kCFStringEncodingUTF8); (void)home_dir_buf; - CFSearchPathForDirectoriesInDomains(CFDocumentDirectory, CFUserDomainMask, 1, home_dir_buf, sizeof(home_dir_buf)); + CFSearchPathForDirectoriesInDomains(CFDocumentDirectory, + CFUserDomainMask, 1, home_dir_buf, sizeof(home_dir_buf)); strlcat(home_dir_buf, "/RetroArch", sizeof(home_dir_buf)); - fill_pathname_join(g_defaults.dir.shader, home_dir_buf, "shaders_glsl", sizeof(g_defaults.dir.shader)); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SHADER], + home_dir_buf, "shaders_glsl", + sizeof(g_defaults.dirs[DEFAULT_DIR_SHADER])); #if TARGET_OS_IPHONE int major, minor; get_ios_version(&major, &minor); - if (major >= 10 ) { - fill_pathname_join(g_defaults.dir.core, bundle_path_buf, "modules", sizeof(g_defaults.dir.core)); - } else { - fill_pathname_join(g_defaults.dir.core, home_dir_buf, "cores", sizeof(g_defaults.dir.core)); - } + if (major >= 10 ) + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE], + bundle_path_buf, "modules", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE])); + else + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE], + home_dir_buf, "cores", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE])); #else - fill_pathname_join(g_defaults.dir.core, home_dir_buf, "cores", sizeof(g_defaults.dir.core)); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE], home_dir_buf, "cores", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE])); #endif - fill_pathname_join(g_defaults.dir.core_info, home_dir_buf, "info", sizeof(g_defaults.dir.core_info)); - fill_pathname_join(g_defaults.dir.overlay, home_dir_buf, "overlays", sizeof(g_defaults.dir.overlay)); - fill_pathname_join(g_defaults.dir.autoconfig, home_dir_buf, "autoconfig", sizeof(g_defaults.dir.autoconfig)); - fill_pathname_join(g_defaults.dir.core_assets, home_dir_buf, "downloads", sizeof(g_defaults.dir.core_assets)); - fill_pathname_join(g_defaults.dir.assets, home_dir_buf, "assets", sizeof(g_defaults.dir.assets)); - fill_pathname_join(g_defaults.dir.system, home_dir_buf, "system", sizeof(g_defaults.dir.system)); - fill_pathname_join(g_defaults.dir.menu_config, home_dir_buf, "config", sizeof(g_defaults.dir.menu_config)); - fill_pathname_join(g_defaults.dir.remap, g_defaults.dir.menu_config, "remaps", sizeof(g_defaults.dir.remap)); - fill_pathname_join(g_defaults.dir.database, home_dir_buf, "database/rdb", sizeof(g_defaults.dir.database)); - fill_pathname_join(g_defaults.dir.cursor, home_dir_buf, "database/cursors", sizeof(g_defaults.dir.cursor)); - fill_pathname_join(g_defaults.dir.cheats, home_dir_buf, "cht", sizeof(g_defaults.dir.cheats)); - fill_pathname_join(g_defaults.dir.thumbnails, home_dir_buf, "thumbnails", sizeof(g_defaults.dir.thumbnails)); - fill_pathname_join(g_defaults.dir.sram, home_dir_buf, "saves", sizeof(g_defaults.dir.sram)); - fill_pathname_join(g_defaults.dir.savestate, home_dir_buf, "states", sizeof(g_defaults.dir.savestate)); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_INFO], home_dir_buf, "info", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_INFO])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_OVERLAY], home_dir_buf, "overlays", sizeof(g_defaults.dirs[DEFAULT_DIR_OVERLAY])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG], home_dir_buf, "autoconfig", sizeof(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_ASSETS], home_dir_buf, "downloads", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_ASSETS])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_ASSETS], home_dir_buf, "assets", sizeof(g_defaults.dirs[DEFAULT_DIR_ASSETS])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SYSTEM], home_dir_buf, "system", sizeof(g_defaults.dirs[DEFAULT_DIR_SYSTEM])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG], home_dir_buf, "config", sizeof(g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_REMAP], g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG], "remaps", sizeof(g_defaults.dirs[DEFAULT_DIR_REMAP])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_DATABASE], home_dir_buf, "database/rdb", sizeof(g_defaults.dirs[DEFAULT_DIR_DATABASE])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CURSOR], home_dir_buf, "database/cursors", sizeof(g_defaults.dirs[DEFAULT_DIR_CURSOR])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CHEATS], home_dir_buf, "cht", sizeof(g_defaults.dirs[DEFAULT_DIR_CHEATS])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_THUMBNAILS], home_dir_buf, "thumbnails", sizeof(g_defaults.dirs[DEFAULT_DIR_THUMBNAILS])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SRAM], home_dir_buf, "saves", sizeof(g_defaults.dirs[DEFAULT_DIR_SRAM])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SAVESTATE], home_dir_buf, "states", sizeof(g_defaults.dirs[DEFAULT_DIR_SAVESTATE])); #if defined(IOS) - fill_pathname_join(g_defaults.dir.playlist, home_dir_buf, "playlists", sizeof(g_defaults.dir.playlist)); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_PLAYLIST], home_dir_buf, "playlists", sizeof(g_defaults.dirs[DEFAULT_DIR_PLAYLIST])); #endif #if defined(OSX) char application_data[PATH_MAX_LENGTH]; @@ -370,26 +374,26 @@ static void frontend_darwin_get_environment_settings(int *argc, char *argv[], fill_pathname_application_data(application_data, sizeof(application_data)); #ifdef HAVE_CG - fill_pathname_join(g_defaults.dir.shader, home_dir_buf, "shaders_cg", sizeof(g_defaults.dir.shader)); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SHADER], home_dir_buf, "shaders_cg", sizeof(g_defaults.dirs[DEFAULT_DIR_SHADER])); #endif - fill_pathname_join(g_defaults.dir.audio_filter, home_dir_buf, "audio_filters", sizeof(g_defaults.dir.audio_filter)); - fill_pathname_join(g_defaults.dir.video_filter, home_dir_buf, "video_filters", sizeof(g_defaults.dir.video_filter)); - fill_pathname_join(g_defaults.dir.playlist, application_data, "playlists", sizeof(g_defaults.dir.playlist)); - fill_pathname_join(g_defaults.dir.thumbnails, application_data, "thumbnails", sizeof(g_defaults.dir.thumbnails)); - fill_pathname_join(g_defaults.dir.menu_config, application_data, "config", sizeof(g_defaults.dir.menu_config)); - fill_pathname_join(g_defaults.dir.remap, g_defaults.dir.menu_config, "remaps", sizeof(g_defaults.dir.remap)); - fill_pathname_join(g_defaults.dir.core_assets, application_data, "downloads", sizeof(g_defaults.dir.core_assets)); - fill_pathname_join(g_defaults.dir.screenshot, application_data, "screenshots", sizeof(g_defaults.dir.screenshot)); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_AUDIO_FILTER], home_dir_buf, "audio_filters", sizeof(g_defaults.dirs[DEFAULT_DIR_AUDIO_FILTER])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_VIDEO_FILTER], home_dir_buf, "video_filters", sizeof(g_defaults.dirs[DEFAULT_DIR_VIDEO_FILTER])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_PLAYLIST], application_data, "playlists", sizeof(g_defaults.dirs[DEFAULT_DIR_PLAYLIST])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_THUMBNAILS], application_data, "thumbnails", sizeof(g_defaults.dirs[DEFAULT_DIR_THUMBNAILS])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG], application_data, "config", sizeof(g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_REMAP], g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG], "remaps", sizeof(g_defaults.dirs[DEFAULT_DIR_REMAP])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE]_assets, application_data, "downloads", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE]_assets)); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SCREENSHOT], application_data, "screenshots", sizeof(g_defaults.dirs[DEFAULT_DIR_SCREENSHOT])); #if defined(RELEASE_BUILD) - fill_pathname_join(g_defaults.dir.shader, bundle_path_buf, "Contents/Resources/shaders", sizeof(g_defaults.dir.shader)); - fill_pathname_join(g_defaults.dir.core, bundle_path_buf, "Contents/Resources/cores", sizeof(g_defaults.dir.core)); - fill_pathname_join(g_defaults.dir.core_info, bundle_path_buf, "Contents/Resources/info", sizeof(g_defaults.dir.core_info)); - fill_pathname_join(g_defaults.dir.overlay, bundle_path_buf, "Contents/Resources/overlays", sizeof(g_defaults.dir.overlay)); - fill_pathname_join(g_defaults.dir.autoconfig, bundle_path_buf, "Contents/Resources/autoconfig", sizeof(g_defaults.dir.autoconfig)); - fill_pathname_join(g_defaults.dir.assets, bundle_path_buf, "Contents/Resources/assets", sizeof(g_defaults.dir.assets)); - fill_pathname_join(g_defaults.dir.database, bundle_path_buf, "Contents/Resources/database/rdb", sizeof(g_defaults.dir.database)); - fill_pathname_join(g_defaults.dir.cursor, bundle_path_buf, "Contents/Resources/database/cursors", sizeof(g_defaults.dir.cursor)); - fill_pathname_join(g_defaults.dir.cheats, bundle_path_buf, "Contents/Resources/cht", sizeof(g_defaults.dir.cheats)); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SHADER], bundle_path_buf, "Contents/Resources/shaders", sizeof(g_defaults.dirs[DEFAULT_DIR_SHADER])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE], bundle_path_buf, "Contents/Resources/cores", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_INFO], bundle_path_buf, "Contents/Resources/info", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_INFO])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_OVERLAY], bundle_path_buf, "Contents/Resources/overlays", sizeof(g_defaults.dirs[DEFAULT_DIR_OVERLAY])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG], bundle_path_buf, "Contents/Resources/autoconfig", sizeof(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_ASSETS], bundle_path_buf, "Contents/Resources/assets", sizeof(g_defaults.dirs[DEFAULT_DIR_ASSETS])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_DATABASE], bundle_path_buf, "Contents/Resources/database/rdb", sizeof(g_defaults.dirs[DEFAULT_DIR_DATABASE])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CURSOR], bundle_path_buf, "Contents/Resources/database/cursors", sizeof(g_defaults.dirs[DEFAULT_DIR_CURSOR])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CHEATS], bundle_path_buf, "Contents/Resources/cht", sizeof(g_defaults.dirs[DEFAULT_DIR_CHEATS])); #endif #endif @@ -413,7 +417,9 @@ static void frontend_darwin_get_environment_settings(int *argc, char *argv[], #endif CFTemporaryDirectory(temp_dir, sizeof(temp_dir)); - strlcpy(g_defaults.dir.cache, temp_dir, sizeof(g_defaults.dir.cache)); + strlcpy(g_defaults.dirs[DEFAULT_DIR_CACHE], + temp_dir, + sizeof(g_defaults.dirs[DEFAULT_DIR_CACHE])); path_mkdir(bundle_path_buf); @@ -421,12 +427,13 @@ static void frontend_darwin_get_environment_settings(int *argc, char *argv[], RARCH_ERR("Failed to create or access base directory: %s\n", bundle_path_buf); else { - path_mkdir(g_defaults.dir.system); + path_mkdir(g_defaults.dirs[DEFAULT_DIR_SYSTEM]); - if (access(g_defaults.dir.system, 0755) != 0) - RARCH_ERR("Failed to create or access system directory: %s.\n", g_defaults.dir.system); + if (access(g_defaults.dirs[DEFAULT_DIR_SYSTEM], 0755) != 0) + RARCH_ERR("Failed to create or access system directory: %s.\n", g_defaults.dirs[DEFAULT_DIR_SYSTEM]); } + CFRelease(bundle_path); CFRelease(bundle_url); } diff --git a/frontend/drivers/platform_emscripten.c b/frontend/drivers/platform_emscripten.c index 2bd3500e99..0ebc2d6ac6 100644 --- a/frontend/drivers/platform_emscripten.c +++ b/frontend/drivers/platform_emscripten.c @@ -83,6 +83,7 @@ static void frontend_emscripten_get_env(int *argc, char *argv[], { (void)args; + unsigned i; char base_path[PATH_MAX] = {0}; char user_path[PATH_MAX] = {0}; const char *home = getenv("HOME"); @@ -100,74 +101,65 @@ static void frontend_emscripten_get_env(int *argc, char *argv[], snprintf(user_path, sizeof(user_path), "retroarch/userdata"); } - fill_pathname_join(g_defaults.dir.core, base_path, - "cores", sizeof(g_defaults.dir.core)); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE], base_path, + "cores", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE])); /* bundle data */ - fill_pathname_join(g_defaults.dir.assets, base_path, - "bundle/assets", sizeof(g_defaults.dir.assets)); - fill_pathname_join(g_defaults.dir.autoconfig, base_path, - "bundle/autoconfig", sizeof(g_defaults.dir.autoconfig)); - fill_pathname_join(g_defaults.dir.cursor, base_path, - "bundle/database/cursors", sizeof(g_defaults.dir.cursor)); - fill_pathname_join(g_defaults.dir.database, base_path, - "bundle/database/rdb", sizeof(g_defaults.dir.database)); - fill_pathname_join(g_defaults.dir.core_info, base_path, - "bundle/info", sizeof(g_defaults.dir.core_info)); - fill_pathname_join(g_defaults.dir.overlay, base_path, - "bundle/overlays", sizeof(g_defaults.dir.overlay)); - fill_pathname_join(g_defaults.dir.shader, base_path, - "bundle/shaders", sizeof(g_defaults.dir.shader)); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_ASSETS], base_path, + "bundle/assets", sizeof(g_defaults.dirs[DEFAULT_DIR_ASSETS])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG], base_path, + "bundle/autoconfig", sizeof(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CURSOR], base_path, + "bundle/database/cursors", sizeof(g_defaults.dirs[DEFAULT_DIR_CURSOR])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_DATABASE], base_path, + "bundle/database/rdb", sizeof(g_defaults.dirs[DEFAULT_DIR_DATABASE])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_INFO], base_path, + "bundle/info", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_INFO])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_OVERLAY], base_path, + "bundle/overlays", sizeof(g_defaults.dirs[DEFAULT_DIR_OVERLAY])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SHADER], base_path, + "bundle/shaders", sizeof(g_defaults.dirs[DEFAULT_DIR_SHADER])); /* user data dirs */ - fill_pathname_join(g_defaults.dir.cheats, user_path, - "cheats", sizeof(g_defaults.dir.cheats)); - fill_pathname_join(g_defaults.dir.menu_config, user_path, - "config", sizeof(g_defaults.dir.menu_config)); - fill_pathname_join(g_defaults.dir.menu_content, user_path, - "content", sizeof(g_defaults.dir.menu_content)); - fill_pathname_join(g_defaults.dir.core_assets, user_path, - "content/downloads", sizeof(g_defaults.dir.core_assets)); - fill_pathname_join(g_defaults.dir.playlist, user_path, - "playlists", sizeof(g_defaults.dir.playlist)); - fill_pathname_join(g_defaults.dir.remap, g_defaults.dir.menu_config, - "remaps", sizeof(g_defaults.dir.remap)); - fill_pathname_join(g_defaults.dir.sram, user_path, - "saves", sizeof(g_defaults.dir.sram)); - fill_pathname_join(g_defaults.dir.screenshot, user_path, - "screenshots", sizeof(g_defaults.dir.screenshot)); - fill_pathname_join(g_defaults.dir.savestate, user_path, - "states", sizeof(g_defaults.dir.savestate)); - fill_pathname_join(g_defaults.dir.system, user_path, - "system", sizeof(g_defaults.dir.system)); - fill_pathname_join(g_defaults.dir.thumbnails, user_path, - "thumbnails", sizeof(g_defaults.dir.thumbnails)); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CHEATS], user_path, + "cheats", sizeof(g_defaults.dirs[DEFAULT_DIR_CHEATS])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG], user_path, + "config", sizeof(g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_MENU_CONTENT], user_path, + "content", sizeof(g_defaults.dirs[DEFAULT_DIR_MENU_CONTENT])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_ASSETS], user_path, + "content/downloads", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_ASSETS])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_PLAYLIST], user_path, + "playlists", sizeof(g_defaults.dirs[DEFAULT_DIR_PLAYLIST])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_REMAP], g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG], + "remaps", sizeof(g_defaults.dirs[DEFAULT_DIR_REMAP])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SRAM], user_path, + "saves", sizeof(g_defaults.dirs[DEFAULT_DIR_SRAM])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SCREENSHOT], user_path, + "screenshots", sizeof(g_defaults.dirs[DEFAULT_DIR_SCREENSHOT])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SAVESTATE], user_path, + "states", sizeof(g_defaults.dirs[DEFAULT_DIR_SAVESTATE])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SYSTEM], user_path, + "system", sizeof(g_defaults.dirs[DEFAULT_DIR_SYSTEM])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_THUMBNAILS], user_path, + "thumbnails", sizeof(g_defaults.dirs[DEFAULT_DIR_THUMBNAILS])); /* cache dir */ - fill_pathname_join(g_defaults.dir.cache, "/tmp/", - "retroarch", sizeof(g_defaults.dir.cache)); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CACHE], "/tmp/", + "retroarch", sizeof(g_defaults.dirs[DEFAULT_DIR_CACHE])); /* history and main config */ - strlcpy(g_defaults.dir.content_history, - user_path, sizeof(g_defaults.dir.content_history)); + strlcpy(g_defaults.dirs[DEFAULT_DIR_CONTENT_HISTORY], + user_path, sizeof(g_defaults.dirs[DEFAULT_DIR_CONTENT_HISTORY])); fill_pathname_join(g_defaults.path.config, user_path, file_path_str(FILE_PATH_MAIN_CONFIG), sizeof(g_defaults.path.config)); - /* create user data dirs */ - path_mkdir(g_defaults.dir.cheats); - path_mkdir(g_defaults.dir.core_assets); - path_mkdir(g_defaults.dir.menu_config); - path_mkdir(g_defaults.dir.menu_content); - path_mkdir(g_defaults.dir.playlist); - path_mkdir(g_defaults.dir.remap); - path_mkdir(g_defaults.dir.savestate); - path_mkdir(g_defaults.dir.screenshot); - path_mkdir(g_defaults.dir.sram); - path_mkdir(g_defaults.dir.system); - path_mkdir(g_defaults.dir.thumbnails); - - /* create cache dir */ - path_mkdir(g_defaults.dir.cache); + for (i = 0; i < DEFAULT_DIR_LAST; i++) + { + const char *dir_path = g_defaults.dirs[i]; + if (!string_is_empty(dir_path)) + check_defaults_dir_create_dir(dir_path); + } snprintf(g_defaults.settings.menu, sizeof(g_defaults.settings.menu), "rgui"); } diff --git a/frontend/drivers/platform_gx.c b/frontend/drivers/platform_gx.c index c2002bb338..d2934bd6ab 100644 --- a/frontend/drivers/platform_gx.c +++ b/frontend/drivers/platform_gx.c @@ -207,37 +207,37 @@ static void frontend_gx_get_environment_settings( #ifdef HW_DOL chdir("carda:/retroarch"); #endif - getcwd(g_defaults.dir.core, PATH_MAX_LENGTH); + getcwd(g_defaults.dirs[DEFAULT_DIR_CORE], PATH_MAX_LENGTH); - last_slash = strrchr(g_defaults.dir.core, '/'); + last_slash = strrchr(g_defaults.dirs[DEFAULT_DIR_CORE], '/'); if (last_slash) *last_slash = 0; - device_end = strchr(g_defaults.dir.core, '/'); + device_end = strchr(g_defaults.dirs[DEFAULT_DIR_CORE], '/'); if (device_end) - snprintf(g_defaults.dir.port, sizeof(g_defaults.dir.port), - "%.*s/retroarch", device_end - g_defaults.dir.core, - g_defaults.dir.core); + snprintf(g_defaults.dirs[DEFAULT_DIR_PORT], sizeof(g_defaults.dirs[DEFAULT_DIR_PORT]), + "%.*s/retroarch", device_end - g_defaults.dirs[DEFAULT_DIR_CORE], + g_defaults.dirs[DEFAULT_DIR_CORE]); else - fill_pathname_join(g_defaults.dir.port, g_defaults.dir.port, - "retroarch", sizeof(g_defaults.dir.port)); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_PORT], g_defaults.dirs[DEFAULT_DIR_PORT], + "retroarch", sizeof(g_defaults.dirs[DEFAULT_DIR_PORT])); - fill_pathname_join(g_defaults.dir.core_info, g_defaults.dir.core, - "info", sizeof(g_defaults.dir.core_info)); - fill_pathname_join(g_defaults.dir.autoconfig, - g_defaults.dir.core, "autoconfig", - sizeof(g_defaults.dir.autoconfig)); - fill_pathname_join(g_defaults.dir.overlay, g_defaults.dir.core, - "overlays", sizeof(g_defaults.dir.overlay)); - fill_pathname_join(g_defaults.path.config, g_defaults.dir.port, + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_INFO], g_defaults.dirs[DEFAULT_DIR_CORE], + "info", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_INFO])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG], + g_defaults.dirs[DEFAULT_DIR_CORE], "autoconfig", + sizeof(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_OVERLAY], g_defaults.dirs[DEFAULT_DIR_CORE], + "overlays", sizeof(g_defaults.dirs[DEFAULT_DIR_OVERLAY])); + fill_pathname_join(g_defaults.path.config, g_defaults.dirs[DEFAULT_DIR_PORT], "retroarch.cfg", sizeof(g_defaults.path.config)); - fill_pathname_join(g_defaults.dir.system, g_defaults.dir.port, - "system", sizeof(g_defaults.dir.system)); - fill_pathname_join(g_defaults.dir.sram, g_defaults.dir.port, - "savefiles", sizeof(g_defaults.dir.sram)); - fill_pathname_join(g_defaults.dir.savestate, g_defaults.dir.port, - "savefiles", sizeof(g_defaults.dir.savestate)); - fill_pathname_join(g_defaults.dir.playlist, g_defaults.dir.port, - "playlists", sizeof(g_defaults.dir.playlist)); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SYSTEM], g_defaults.dirs[DEFAULT_DIR_PORT], + "system", sizeof(g_defaults.dirs[DEFAULT_DIR_SYSTEM])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SRAM], g_defaults.dirs[DEFAULT_DIR_PORT], + "savefiles", sizeof(g_defaults.dirs[DEFAULT_DIR_SRAM])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SAVESTATE], g_defaults.dirs[DEFAULT_DIR_PORT], + "savefiles", sizeof(g_defaults.dirs[DEFAULT_DIR_SAVESTATE])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_PLAYLIST], g_defaults.dirs[DEFAULT_DIR_PORT], + "playlists", sizeof(g_defaults.dirs[DEFAULT_DIR_PLAYLIST])); #ifdef IS_SALAMANDER if (*argc > 2 && argv[1] != NULL && argv[2] != NULL) @@ -387,7 +387,7 @@ static void frontend_gx_exitspawn(char *s, size_t len) if (frontend_driver_get_salamander_basename(salamander_name, sizeof(salamander_name))) { - fill_pathname_join(new_path, g_defaults.dir.core, + fill_pathname_join(new_path, g_defaults.dirs[DEFAULT_DIR_CORE], salamander_name, sizeof(new_path)); path_set(RARCH_PATH_CONTENT, new_path); } @@ -406,7 +406,7 @@ static void frontend_gx_exitspawn(char *s, size_t len) * direct loading failed (out of memory), * try to jump to Salamander, * then load the correct core */ - fill_pathname_join(s, g_defaults.dir.core, + fill_pathname_join(s, g_defaults.dirs[DEFAULT_DIR_CORE], salamander_basename, len); #endif frontend_gx_exec(s, should_load_game); diff --git a/frontend/drivers/platform_linux.c b/frontend/drivers/platform_linux.c index 8a65b1a6dd..dc109da83f 100644 --- a/frontend/drivers/platform_linux.c +++ b/frontend/drivers/platform_linux.c @@ -1235,6 +1235,7 @@ static void frontend_linux_get_lakka_version(char *s, static void frontend_linux_get_env(int *argc, char *argv[], void *data, void *params_data) { + unsigned i; #ifdef ANDROID int32_t major, minor, rel; char device_model[PROP_VALUE_MAX] = {0}; @@ -1518,158 +1519,147 @@ static void frontend_linux_get_env(int *argc, "RetroArch", "[ENV]: application location: [%s]\n", app_dir); if (args && *app_dir) { - fill_pathname_join(g_defaults.dir.assets, app_dir, - "assets", sizeof(g_defaults.dir.assets)); - fill_pathname_join(g_defaults.dir.cache, app_dir, - "tmp", sizeof(g_defaults.dir.cache)); - fill_pathname_join(g_defaults.dir.shader, app_dir, - "shaders", sizeof(g_defaults.dir.shader)); - fill_pathname_join(g_defaults.dir.overlay, app_dir, - "overlays", sizeof(g_defaults.dir.overlay)); - fill_pathname_join(g_defaults.dir.core, app_dir, - "cores", sizeof(g_defaults.dir.core)); - fill_pathname_join(g_defaults.dir.core_info, - app_dir, "info", sizeof(g_defaults.dir.core_info)); - fill_pathname_join(g_defaults.dir.autoconfig, - app_dir, "autoconfig", sizeof(g_defaults.dir.autoconfig)); - fill_pathname_join(g_defaults.dir.audio_filter, - app_dir, "filters/audio", sizeof(g_defaults.dir.audio_filter)); - fill_pathname_join(g_defaults.dir.video_filter, - app_dir, "filters/video", sizeof(g_defaults.dir.video_filter)); - strlcpy(g_defaults.dir.content_history, - app_dir, sizeof(g_defaults.dir.content_history)); - fill_pathname_join(g_defaults.dir.database, - app_dir, "database/rdb", sizeof(g_defaults.dir.database)); - fill_pathname_join(g_defaults.dir.cursor, - app_dir, "database/cursors", sizeof(g_defaults.dir.cursor)); - fill_pathname_join(g_defaults.dir.wallpapers, - app_dir, "assets/wallpapers", sizeof(g_defaults.dir.wallpapers)); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_ASSETS], app_dir, + "assets", sizeof(g_defaults.dirs[DEFAULT_DIR_ASSETS])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CACHE], app_dir, + "tmp", sizeof(g_defaults.dirs[DEFAULT_DIR_CACHE])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SHADER], app_dir, + "shaders", sizeof(g_defaults.dirs[DEFAULT_DIR_SHADER])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_OVERLAY], app_dir, + "overlays", sizeof(g_defaults.dirs[DEFAULT_DIR_OVERLAY])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE], app_dir, + "cores", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_INFO], + app_dir, "info", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_INFO])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG], + app_dir, "autoconfig", sizeof(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_AUDIO_FILTER], + app_dir, "filters/audio", sizeof(g_defaults.dirs[DEFAULT_DIR_AUDIO_FILTER])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_VIDEO_FILTER], + app_dir, "filters/video", sizeof(g_defaults.dirs[DEFAULT_DIR_VIDEO_FILTER])); + strlcpy(g_defualts.dirs[DEFAULT_DIR_CONTENT_HISTORY], + app_dir, sizeof(g_defualts.dirs[DEFAULT_DIR_CONTENT_HISTORY])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_DATABASE], + app_dir, "database/rdb", sizeof(g_defaults.dirs[DEFAULT_DIR_DATABASE])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CURSOR], + app_dir, "database/cursors", sizeof(g_defaults.dirs[DEFAULT_DIR_CURSOR])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_WALLPAPERS], + app_dir, "assets/wallpapers", sizeof(g_defaults.dirs[DEFAULT_DIR_WALLPAPERS])); if(!string_is_empty(downloads_dir) && test_permissions(downloads_dir)) { - fill_pathname_join(g_defaults.dir.core_assets, - downloads_dir, "", sizeof(g_defaults.dir.core_assets)); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_ASSETS], + downloads_dir, "", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_ASSETS])); } else { - fill_pathname_join(g_defaults.dir.core_assets, - app_dir, "downloads", sizeof(g_defaults.dir.core_assets)); - path_mkdir(g_defaults.dir.core_assets); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_ASSETS], + app_dir, "downloads", + sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_ASSETS])); } __android_log_print(ANDROID_LOG_INFO, "RetroArch", "[ENV]: default download folder: [%s]", - g_defaults.dir.core_assets); + g_defaults.dirs[DEFAULT_DIR_CORE_ASSETS]); switch (perms) { /* Set defaults for this since we can't guarantee saving on content dir will work in this case */ case INTERNAL_STORAGE_APPDIR_WRITABLE: - fill_pathname_join(g_defaults.dir.sram, - internal_storage_app_path, "saves", sizeof(g_defaults.dir.sram)); - fill_pathname_join(g_defaults.dir.savestate, - internal_storage_app_path, "states", sizeof(g_defaults.dir.savestate)); - fill_pathname_join(g_defaults.dir.system, - internal_storage_app_path, "system", sizeof(g_defaults.dir.system)); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SRAM], + internal_storage_app_path, "saves", sizeof(g_defaults.dirs[DEFAULT_DIR_SRAM])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SAVESTATE], + internal_storage_app_path, "states", sizeof(g_defaults.dirs[DEFAULT_DIR_SAVESTATE])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SYSTEM], + internal_storage_app_path, "system", sizeof(g_defaults.dirs[DEFAULT_DIR_SYSTEM])); - fill_pathname_join(g_defaults.dir.menu_config, - internal_storage_app_path, "config", sizeof(g_defaults.dir.menu_config)); - fill_pathname_join(g_defaults.dir.remap, - g_defaults.dir.menu_config, "remaps", sizeof(g_defaults.dir.remap)); - fill_pathname_join(g_defaults.dir.thumbnails, - internal_storage_app_path, "thumbnails", sizeof(g_defaults.dir.thumbnails)); - fill_pathname_join(g_defaults.dir.playlist, - internal_storage_app_path, "playlists", sizeof(g_defaults.dir.playlist)); - fill_pathname_join(g_defaults.dir.cheats, - internal_storage_app_path, "cheats", sizeof(g_defaults.dir.cheats)); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG], + internal_storage_app_path, "config", sizeof(g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_REMAP], + g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG], "remaps", sizeof(g_defaults.dirs[DEFAULT_DIR_REMAP])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_THUMBNAILS], + internal_storage_app_path, "thumbnails", sizeof(g_defaults.dirs[DEFAULT_DIR_THUMBNAILS])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_PLAYLIST], + internal_storage_app_path, "playlists", sizeof(g_defaults.dirs[DEFAULT_DIR_PLAYLIST])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CHEATS], + internal_storage_app_path, "cheats", sizeof(g_defaults.dirs[DEFAULT_DIR_CHEATS])); if(!string_is_empty(screenshot_dir) && test_permissions(screenshot_dir)) { - fill_pathname_join(g_defaults.dir.screenshot, - screenshot_dir, "", sizeof(g_defaults.dir.screenshot)); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SCREENSHOT], + screenshot_dir, "", sizeof(g_defaults.dirs[DEFAULT_DIR_SCREENSHOT])); } else { - fill_pathname_join(g_defaults.dir.screenshot, - internal_storage_app_path, "screenshots", sizeof(g_defaults.dir.screenshot)); - path_mkdir(g_defaults.dir.screenshot); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SCREENSHOT], + internal_storage_app_path, "screenshots", + sizeof(g_defaults.dirs[DEFAULT_DIR_SCREENSHOT])); } - path_mkdir(g_defaults.dir.sram); - path_mkdir(g_defaults.dir.savestate); - path_mkdir(g_defaults.dir.system); break; case INTERNAL_STORAGE_NOT_WRITABLE: /* Set defaults for this since we can't guarantee saving on content dir will work in this case */ - fill_pathname_join(g_defaults.dir.sram, - app_dir, "saves", sizeof(g_defaults.dir.sram)); - fill_pathname_join(g_defaults.dir.savestate, - app_dir, "states", sizeof(g_defaults.dir.savestate)); - fill_pathname_join(g_defaults.dir.system, - app_dir, "system", sizeof(g_defaults.dir.system)); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SRAM], + app_dir, "saves", sizeof(g_defaults.dirs[DEFAULT_DIR_SRAM])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SAVESTATE], + app_dir, "states", sizeof(g_defaults.dirs[DEFAULT_DIR_SAVESTATE])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SYSTEM], + app_dir, "system", sizeof(g_defaults.dirs[DEFAULT_DIR_SYSTEM])); - fill_pathname_join(g_defaults.dir.menu_config, - app_dir, "config", sizeof(g_defaults.dir.menu_config)); - fill_pathname_join(g_defaults.dir.remap, - g_defaults.dir.menu_config, "remaps", sizeof(g_defaults.dir.remap)); - fill_pathname_join(g_defaults.dir.thumbnails, - app_dir, "thumbnails", sizeof(g_defaults.dir.thumbnails)); - fill_pathname_join(g_defaults.dir.playlist, - app_dir, "playlists", sizeof(g_defaults.dir.playlist)); - fill_pathname_join(g_defaults.dir.cheats, - app_dir, "cheats", sizeof(g_defaults.dir.cheats)); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG], + app_dir, "config", sizeof(g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_REMAP], + g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG], "remaps", sizeof(g_defaults.dirs[DEFAULT_DIR_REMAP])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_THUMBNAILS], + app_dir, "thumbnails", sizeof(g_defaults.dirs[DEFAULT_DIR_THUMBNAILS])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_PLAYLIST], + app_dir, "playlists", sizeof(g_defaults.dirs[DEFAULT_DIR_PLAYLIST])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CHEATS], + app_dir, "cheats", sizeof(g_defaults.dirs[DEFAULT_DIR_CHEATS])); if(!string_is_empty(screenshot_dir) && test_permissions(screenshot_dir)) { - fill_pathname_join(g_defaults.dir.screenshot, - screenshot_dir, "", sizeof(g_defaults.dir.screenshot)); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SCREENSHOT], + screenshot_dir, "", sizeof(g_defaults.dirs[DEFAULT_DIR_SCREENSHOT])); } else { - fill_pathname_join(g_defaults.dir.screenshot, - app_dir, "screenshots", sizeof(g_defaults.dir.screenshot)); - path_mkdir(g_defaults.dir.screenshot); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SCREENSHOT], + app_dir, "screenshots", + sizeof(g_defaults.dirs[DEFAULT_DIR_SCREENSHOT])); } - path_mkdir(g_defaults.dir.sram); - path_mkdir(g_defaults.dir.savestate); - path_mkdir(g_defaults.dir.system); break; case INTERNAL_STORAGE_WRITABLE: /* Don't set defaults for saves, states, system or screenshots in this case to be able to honour saving on content dir */ - fill_pathname_join(g_defaults.dir.menu_config, - internal_storage_path, "RetroArch/config", sizeof(g_defaults.dir.menu_config)); - fill_pathname_join(g_defaults.dir.remap, - g_defaults.dir.menu_config, "remaps", sizeof(g_defaults.dir.remap)); - fill_pathname_join(g_defaults.dir.thumbnails, - internal_storage_path, "RetroArch/thumbnails", sizeof(g_defaults.dir.thumbnails)); - fill_pathname_join(g_defaults.dir.playlist, - internal_storage_path, "RetroArch/playlists", sizeof(g_defaults.dir.playlist)); - fill_pathname_join(g_defaults.dir.cheats, - internal_storage_path, "RetroArch/cheats", sizeof(g_defaults.dir.cheats)); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG], + internal_storage_path, "RetroArch/config", sizeof(g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_REMAP], + g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG], "remaps", sizeof(g_defaults.dirs[DEFAULT_DIR_REMAP])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_THUMBNAILS], + internal_storage_path, "RetroArch/thumbnails", sizeof(g_defaults.dirs[DEFAULT_DIR_THUMBNAILS])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_PLAYLIST], + internal_storage_path, "RetroArch/playlists", sizeof(g_defaults.dirs[DEFAULT_DIR_PLAYLIST])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CHEATS], + internal_storage_path, "RetroArch/cheats", sizeof(g_defaults.dirs[DEFAULT_DIR_CHEATS])); default: break; } - path_mkdir(g_defaults.dir.menu_config); - path_mkdir(g_defaults.dir.remap); - path_mkdir(g_defaults.dir.thumbnails); - path_mkdir(g_defaults.dir.playlist); - path_mkdir(g_defaults.dir.cheats); __android_log_print(ANDROID_LOG_INFO, "RetroArch", "[ENV]: default savefile folder: [%s]", - g_defaults.dir.sram); + g_defaults.dirs[DEFAULT_DIR_SRAM]); __android_log_print(ANDROID_LOG_INFO, "RetroArch", "[ENV]: default savestate folder: [%s]", - g_defaults.dir.savestate); + g_defaults.dirs[DEFAULT_DIR_SAVESTATE]); __android_log_print(ANDROID_LOG_INFO, "RetroArch", "[ENV]: default system folder: [%s]", - g_defaults.dir.system); + g_defaults.dirs[DEFAULT_DIR_SYSTEM]); __android_log_print(ANDROID_LOG_INFO, "RetroArch", "[ENV]: default screenshot folder: [%s]", - g_defaults.dir.screenshot); + g_defaults.dirs[DEFAULT_DIR_SCREENSHOT]); } } } @@ -1746,52 +1736,59 @@ static void frontend_linux_get_env(int *argc, else snprintf(base_path, sizeof(base_path), "retroarch"); - fill_pathname_join(g_defaults.dir.core, base_path, - "cores", sizeof(g_defaults.dir.core)); - fill_pathname_join(g_defaults.dir.core_info, base_path, - "cores", sizeof(g_defaults.dir.core_info)); - fill_pathname_join(g_defaults.dir.autoconfig, base_path, - "autoconfig", sizeof(g_defaults.dir.autoconfig)); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE], base_path, + "cores", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_INFO], base_path, + "cores", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_INFO])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG], base_path, + "autoconfig", sizeof(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG])); if (path_is_directory("/usr/local/share/retroarch/assets")) - fill_pathname_join(g_defaults.dir.assets, "/usr/local/share/retroarch", - "assets", sizeof(g_defaults.dir.assets)); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_ASSETS], "/usr/local/share/retroarch", + "assets", sizeof(g_defaults.dirs[DEFAULT_DIR_ASSETS])); else if (path_is_directory("/usr/share/retroarch/assets")) - fill_pathname_join(g_defaults.dir.assets, "/usr/share/retroarch", - "assets", sizeof(g_defaults.dir.assets)); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_ASSETS], "/usr/share/retroarch", + "assets", sizeof(g_defaults.dirs[DEFAULT_DIR_ASSETS])); else if (path_is_directory("/usr/local/share/games/retroarch/assets")) - fill_pathname_join(g_defaults.dir.assets, "/usr/local/share/games/retroarch", - "assets", sizeof(g_defaults.dir.assets)); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_ASSETS], "/usr/local/share/games/retroarch", + "assets", sizeof(g_defaults.dirs[DEFAULT_DIR_ASSETS])); else if (path_is_directory("/usr/share/games/retroarch/assets")) - fill_pathname_join(g_defaults.dir.assets, "/usr/share/games/retroarch", - "assets", sizeof(g_defaults.dir.assets)); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_ASSETS], "/usr/share/games/retroarch", + "assets", sizeof(g_defaults.dirs[DEFAULT_DIR_ASSETS])); else - fill_pathname_join(g_defaults.dir.assets, base_path, - "assets", sizeof(g_defaults.dir.assets)); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_ASSETS], base_path, + "assets", sizeof(g_defaults.dirs[DEFAULT_DIR_ASSETS])); - fill_pathname_join(g_defaults.dir.menu_config, base_path, - "config", sizeof(g_defaults.dir.menu_config)); - fill_pathname_join(g_defaults.dir.remap, g_defaults.dir.menu_config, - "remaps", sizeof(g_defaults.dir.remap)); - fill_pathname_join(g_defaults.dir.playlist, base_path, - "playlists", sizeof(g_defaults.dir.playlist)); - fill_pathname_join(g_defaults.dir.cursor, base_path, - "database/cursors", sizeof(g_defaults.dir.cursor)); - fill_pathname_join(g_defaults.dir.database, base_path, - "database/rdb", sizeof(g_defaults.dir.database)); - fill_pathname_join(g_defaults.dir.shader, base_path, - "shaders", sizeof(g_defaults.dir.shader)); - fill_pathname_join(g_defaults.dir.cheats, base_path, - "cheats", sizeof(g_defaults.dir.cheats)); - fill_pathname_join(g_defaults.dir.overlay, base_path, - "overlay", sizeof(g_defaults.dir.overlay)); - fill_pathname_join(g_defaults.dir.core_assets, base_path, - "downloads", sizeof(g_defaults.dir.core_assets)); - fill_pathname_join(g_defaults.dir.screenshot, base_path, - "screenshots", sizeof(g_defaults.dir.screenshot)); - fill_pathname_join(g_defaults.dir.thumbnails, base_path, - "thumbnails", sizeof(g_defaults.dir.thumbnails)); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG], base_path, + "config", sizeof(g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_REMAP], g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG], + "remaps", sizeof(g_defaults.dirs[DEFAULT_DIR_REMAP])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_PLAYLIST], base_path, + "playlists", sizeof(g_defaults.dirs[DEFAULT_DIR_PLAYLIST])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CURSOR], base_path, + "database/cursors", sizeof(g_defaults.dirs[DEFAULT_DIR_CURSOR])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_DATABASE], base_path, + "database/rdb", sizeof(g_defaults.dirs[DEFAULT_DIR_DATABASE])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SHADER], base_path, + "shaders", sizeof(g_defaults.dirs[DEFAULT_DIR_SHADER])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CHEATS], base_path, + "cheats", sizeof(g_defaults.dirs[DEFAULT_DIR_CHEATS])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_OVERLAY], base_path, + "overlay", sizeof(g_defaults.dirs[DEFAULT_DIR_OVERLAY])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_ASSETS], base_path, + "downloads", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_ASSETS])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SCREENSHOT], base_path, + "screenshots", sizeof(g_defaults.dirs[DEFAULT_DIR_SCREENSHOT])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_THUMBNAILS], base_path, + "thumbnails", sizeof(g_defaults.dirs[DEFAULT_DIR_THUMBNAILS])); #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); + } } #ifdef ANDROID diff --git a/frontend/drivers/platform_ps3.c b/frontend/drivers/platform_ps3.c index 98584b86e8..980361d14e 100644 --- a/frontend/drivers/platform_ps3.c +++ b/frontend/drivers/platform_ps3.c @@ -193,15 +193,15 @@ static void frontend_ps3_get_environment_settings(int *argc, char *argv[], == CELL_GAME_ATTRIBUTE_APP_HOME) RARCH_LOG("RetroArch was launched from host machine (APP_HOME).\n"); - ret = cellGameContentPermit(content_info_path, g_defaults.dir.port); + ret = cellGameContentPermit(content_info_path, g_defaults.dirs[DEFAULT_DIR_PORT]); #ifdef HAVE_MULTIMAN if (multiman_detected) { fill_pathname_join(content_info_path, "/dev_hdd0/game/", EMULATOR_CONTENT_DIR, sizeof(content_info_path)); - fill_pathname_join(g_defaults.dir.port, content_info_path, - "USRDIR", sizeof(g_defaults.dir.port)); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_PORT], content_info_path, + "USRDIR", sizeof(g_defaults.dirs[DEFAULT_DIR_PORT])); } #endif @@ -211,35 +211,48 @@ static void frontend_ps3_get_environment_settings(int *argc, char *argv[], { RARCH_LOG("cellGameContentPermit() OK.\n"); RARCH_LOG("content_info_path : [%s].\n", content_info_path); - RARCH_LOG("usrDirPath : [%s].\n", g_defaults.dir.port); + RARCH_LOG("usrDirPath : [%s].\n", g_defaults.dirs[DEFAULT_DIR_PORT]); } - strlcpy(g_defaults.dir.content_history, - g_defaults.dir.port, sizeof(g_defaults.dir.content_history)); - fill_pathname_join(g_defaults.dir.core, g_defaults.dir.port, - "cores", sizeof(g_defaults.dir.core)); - fill_pathname_join(g_defaults.dir.core_info, g_defaults.dir.core, - "info", sizeof(g_defaults.dir.core_info)); - fill_pathname_join(g_defaults.dir.savestate, g_defaults.dir.core, - "savestates", sizeof(g_defaults.dir.savestate)); - fill_pathname_join(g_defaults.dir.sram, g_defaults.dir.core, - "savefiles", sizeof(g_defaults.dir.sram)); - fill_pathname_join(g_defaults.dir.system, g_defaults.dir.core, - "system", sizeof(g_defaults.dir.system)); - fill_pathname_join(g_defaults.dir.shader, g_defaults.dir.core, - "shaders_cg", sizeof(g_defaults.dir.shader)); - fill_pathname_join(g_defaults.path.config, g_defaults.dir.port, + strlcpy(g_defaults.dirs[DEFAULT_DIR_CONTENT_HISTORY], + g_defaults.dirs[DEFAULT_DIR_PORT], + sizeof(g_defaults.dirs[DEFAULT_DIR_CONTENT_HISTORY])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE], + g_defaults.dirs[DEFAULT_DIR_PORT], + "cores", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_INFO], + g_defaults.dirs[DEFAULT_DIR_CORE], + "info", + sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_INFO])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SAVESTATE], + g_defaults.dirs[DEFAULT_DIR_CORE], + "savestates", sizeof(g_defaults.dirs[DEFAULT_DIR_SAVESTATE])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SRAM], + g_defaults.dirs[DEFAULT_DIR_CORE], + "savefiles", sizeof(g_defaults.dirs[DEFAULT_DIR_SRAM])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SYSTEM], + g_defaults.dirs[DEFAULT_DIR_CORE], + "system", sizeof(g_defaults.dirs[DEFAULT_DIR_SYSTEM])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SHADER], + g_defaults.dirs[DEFAULT_DIR_CORE], + "shaders_cg", sizeof(g_defaults.dirs[DEFAULT_DIR_SHADER])); + fill_pathname_join(g_defaults.path.config, g_defaults.dirs[DEFAULT_DIR_PORT], file_path_str(FILE_PATH_MAIN_CONFIG), sizeof(g_defaults.path.config)); - fill_pathname_join(g_defaults.dir.overlay, g_defaults.dir.core, - "overlays", sizeof(g_defaults.dir.overlay)); - fill_pathname_join(g_defaults.dir.assets, g_defaults.dir.core, - "assets", sizeof(g_defaults.dir.assets)); - fill_pathname_join(g_defaults.dir.cursor, g_defaults.dir.core, - "database/cursors", sizeof(g_defaults.dir.cursor)); - fill_pathname_join(g_defaults.dir.database, g_defaults.dir.core, - "database/rdb", sizeof(g_defaults.dir.database)); - fill_pathname_join(g_defaults.dir.playlist, g_defaults.dir.core, - "playlists", sizeof(g_defaults.dir.playlist)); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_OVERLAY], + g_defaults.dirs[DEFAULT_DIR_CORE], + "overlays", sizeof(g_defaults.dirs[DEFAULT_DIR_OVERLAY])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_ASSETS], + g_defaults.dirs[DEFAULT_DIR_CORE], + "assets", sizeof(g_defaults.dirs[DEFAULT_DIR_ASSETS])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CURSOR], + g_defaults.dirs[DEFAULT_DIR_CORE], + "database/cursors", sizeof(g_defaults.dirs[DEFAULT_DIR_CURSOR])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_DATABASE], + g_defaults.dirs[DEFAULT_DIR_CORE], + "database/rdb", sizeof(g_defaults.dirs[DEFAULT_DIR_DATABASE])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_PLAYLIST], + g_defaults.dirs[DEFAULT_DIR_CORE], + "playlists", sizeof(g_defaults.dirs[DEFAULT_DIR_PLAYLIST])); } #ifndef IS_SALAMANDER diff --git a/frontend/drivers/platform_psp.c b/frontend/drivers/platform_psp.c index 012f403fcd..d9f4fb1776 100644 --- a/frontend/drivers/platform_psp.c +++ b/frontend/drivers/platform_psp.c @@ -81,6 +81,7 @@ static enum frontend_fork psp_fork_mode = FRONTEND_FORK_NONE; static void frontend_psp_get_environment_settings(int *argc, char *argv[], void *args, void *params_data) { + unsigned i; struct rarch_main_wrap *params = NULL; (void)args; @@ -99,129 +100,93 @@ static void frontend_psp_get_environment_settings(int *argc, char *argv[], #ifdef VITA strlcpy(eboot_path, "app0:/", sizeof(eboot_path)); - strlcpy(g_defaults.dir.port, eboot_path, sizeof(g_defaults.dir.port)); + strlcpy(g_defaults.dirs[DEFAULT_DIR_PORT], eboot_path, sizeof(g_defaults.dirs[DEFAULT_DIR_PORT])); strlcpy(user_path, "ux0:/data/retroarch/", sizeof(user_path)); #else strlcpy(eboot_path, argv[0], sizeof(eboot_path)); /* for PSP, use uppercase directories, and no trailing slashes otherwise mkdir fails */ strlcpy(user_path, "ms0:/PSP/RETROARCH", sizeof(user_path)); - fill_pathname_basedir(g_defaults.dir.port, argv[0], sizeof(g_defaults.dir.port)); + fill_pathname_basedir(g_defaults.dirs[DEFAULT_DIR_PORT], argv[0], sizeof(g_defaults.dirs[DEFAULT_DIR_PORT])); #endif - RARCH_LOG("port dir: [%s]\n", g_defaults.dir.port); + RARCH_LOG("port dir: [%s]\n", g_defaults.dirs[DEFAULT_DIR_PORT]); #ifdef VITA /* bundle data*/ - fill_pathname_join(g_defaults.dir.core, g_defaults.dir.port, - "", sizeof(g_defaults.dir.core)); - fill_pathname_join(g_defaults.dir.assets, g_defaults.dir.port, - "assets", sizeof(g_defaults.dir.assets)); - fill_pathname_join(g_defaults.dir.core_info, g_defaults.dir.core, - "info", sizeof(g_defaults.dir.core_info)); - fill_pathname_join(g_defaults.dir.database, g_defaults.dir.port, - "database/rdb", sizeof(g_defaults.dir.database)); - fill_pathname_join(g_defaults.dir.cursor, g_defaults.dir.port, - "database/cursors", sizeof(g_defaults.dir.cursor)); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE], g_defaults.dirs[DEFAULT_DIR_PORT], + "", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_ASSETS], g_defaults.dirs[DEFAULT_DIR_PORT], + "assets", sizeof(g_defaults.dirs[DEFAULT_DIR_ASSETS])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_INFO], g_defaults.dirs[DEFAULT_DIR_CORE], + "info", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_INFO])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_DATABASE], g_defaults.dirs[DEFAULT_DIR_PORT], + "database/rdb", sizeof(g_defaults.dirs[DEFAULT_DIR_DATABASE])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CURSOR], g_defaults.dirs[DEFAULT_DIR_PORT], + "database/cursors", sizeof(g_defaults.dirs[DEFAULT_DIR_CURSOR])); /* user data*/ - fill_pathname_join(g_defaults.dir.cheats, user_path, - "cheats", sizeof(g_defaults.dir.cheats)); - fill_pathname_join(g_defaults.dir.menu_config, user_path, - "config", sizeof(g_defaults.dir.menu_config)); - fill_pathname_join(g_defaults.dir.core_assets, user_path, - "downloads", sizeof(g_defaults.dir.core_assets)); - fill_pathname_join(g_defaults.dir.playlist, user_path, - "playlists", sizeof(g_defaults.dir.playlist)); - fill_pathname_join(g_defaults.dir.remap, user_path, - "remaps", sizeof(g_defaults.dir.remap)); - fill_pathname_join(g_defaults.dir.sram, user_path, - "savefiles", sizeof(g_defaults.dir.sram)); - fill_pathname_join(g_defaults.dir.savestate, user_path, - "savestates", sizeof(g_defaults.dir.savestate)); - fill_pathname_join(g_defaults.dir.system, user_path, - "system", sizeof(g_defaults.dir.system)); - fill_pathname_join(g_defaults.dir.cache, user_path, - "temp", sizeof(g_defaults.dir.cache)); - fill_pathname_join(g_defaults.dir.overlay, user_path, - "overlays", sizeof(g_defaults.dir.overlay)); - fill_pathname_join(g_defaults.dir.thumbnails, user_path, - "thumbnails", sizeof(g_defaults.dir.thumbnails)); - strlcpy(g_defaults.dir.content_history, - user_path, sizeof(g_defaults.dir.content_history)); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CHEATS], user_path, + "cheats", sizeof(g_defaults.dirs[DEFAULT_DIR_CHEATS])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG], user_path, + "config", sizeof(g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_ASSETS], user_path, + "downloads", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_ASSETS])); + fill_pathname_join(g_default.dirs[DEFAULT_DIR_PLAYLIST], user_path, + "playlists", sizeof(g_default.dirs[DEFAULT_DIR_PLAYLIST])); + fill_pathname_join(g_default.dirs[DEFAULT_DIR_REMAP], user_path, + "remaps", sizeof(g_default.dirs[DEFAULT_DIR_REMAP])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SRAM], user_path, + "savefiles", sizeof(g_defaults.dirs[DEFAULT_DIR_SRAM])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SAVESTATE], user_path, + "savestates", sizeof(g_defaults.dirs[DEFAULT_DIR_SAVESTATE])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SYSTEM], user_path, + "system", sizeof(g_defaults.dirs[DEFAULT_DIR_SYSTEM])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CACHE], user_path, + "temp", sizeof(g_defaults.dirs[DEFAULT_DIR_CACHE])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_OVERLAY], user_path, + "overlays", sizeof(g_defaults.dirs[DEFAULT_DIR_OVERLAY])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_THUMBNAILS], user_path, + "thumbnails", sizeof(g_defaults.dirs[DEFAULT_DIR_THUMBNAILS])); + strlcpy(g_defaults.dirs[DEFAULT_DIR_CONTENT_HISTORY], + user_path, sizeof(g_defaults.dirs[DEFAULT_DIR_CONTENT_HISTORY])); fill_pathname_join(g_defaults.path.config, user_path, file_path_str(FILE_PATH_MAIN_CONFIG), sizeof(g_defaults.path.config)); #else - fill_pathname_join(g_defaults.dir.core, g_defaults.dir.port, - "CORES", sizeof(g_defaults.dir.core)); - fill_pathname_join(g_defaults.dir.core_info, g_defaults.dir.port, - "INFO", sizeof(g_defaults.dir.core_info)); - - /* bundle data */ - /* - fill_pathname_join(g_defaults.dir.assets, g_defaults.dir.port, - "BUNDLE/ASSETS", sizeof(g_defaults.dir.assets)); - fill_pathname_join(g_defaults.dir.autoconfig, g_defaults.dir.port, - "BUNDLE/AUTOCONFIG", sizeof(g_defaults.dir.autoconfig)); - fill_pathname_join(g_defaults.dir.cursor, base_path, - "BUNDLE/DATABASE/CURSORS", sizeof(g_defaults.dir.cursor)); - fill_pathname_join(g_defaults.dir.database, base_path, - "BUNDLE/DATABASE/RDB", sizeof(g_defaults.dir.database)); - fill_pathname_join(g_defaults.dir.overlay, base_path, - "BUNDLE/OVERLAYS", sizeof(g_defaults.dir.overlay)); - fill_pathname_join(g_defaults.dir.shader, base_path, - "BUNDLE/SHADERS", sizeof(g_defaults.dir.shader)); - */ + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE], g_defaults.dirs[DEFAULT_DIR_PORT], + "CORES", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_INFO], g_defaults.dirs[DEFAULT_DIR_PORT], + "INFO", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_INFO])); /* user data */ - fill_pathname_join(g_defaults.dir.cheats, user_path, - "CHEATS", sizeof(g_defaults.dir.cheats)); - fill_pathname_join(g_defaults.dir.menu_config, user_path, - "CONFIG", sizeof(g_defaults.dir.menu_config)); - fill_pathname_join(g_defaults.dir.core_assets, user_path, - "DOWNLOADS", sizeof(g_defaults.dir.core_assets)); - fill_pathname_join(g_defaults.dir.playlist, user_path, - "PLAYLISTS", sizeof(g_defaults.dir.playlist)); - fill_pathname_join(g_defaults.dir.remap, g_defaults.dir.menu_config, - "REMAPS", sizeof(g_defaults.dir.remap)); - fill_pathname_join(g_defaults.dir.sram, user_path, - "SAVEFILES", sizeof(g_defaults.dir.sram)); - fill_pathname_join(g_defaults.dir.savestate, user_path, - "SAVESTATES", sizeof(g_defaults.dir.savestate)); - fill_pathname_join(g_defaults.dir.screenshot, user_path, - "SCREENSHOTS", sizeof(g_defaults.dir.screenshot)); - fill_pathname_join(g_defaults.dir.system, user_path, - "SYSTEM", sizeof(g_defaults.dir.system)); - /* fill_pathname_join(g_defaults.dir.thumbnails, user_path, - "THUMBNAILS", sizeof(g_defaults.dir.thumbnails)); */ + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CHEATS], user_path, + "CHEATS", sizeof(g_defaults.dirs[DEFAULT_DIR_CHEATS])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG], user_path, + "CONFIG", sizeof(g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_ASSETS], user_path, + "DOWNLOADS", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_ASSETS])); + fill_pathname_join(g_default.dirs[DEFAULT_DIR_PLAYLIST], user_path, + "PLAYLISTS", sizeof(g_default.dirs[DEFAULT_DIR_PLAYLIST])); + fill_pathname_join(g_default.dirs[DEFAULT_DIR_REMAP], g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG], + "REMAPS", sizeof(g_default.dirs[DEFAULT_DIR_REMAP])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SRAM], user_path, + "SAVEFILES", sizeof(g_defaults.dirs[DEFAULT_DIR_SRAM])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SAVESTATE], user_path, + "SAVESTATES", sizeof(g_defaults.dirs[DEFAULT_DIR_SAVESTATE])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SCREENSHOT], user_path, + "SCREENSHOTS", sizeof(g_defaults.dirs[DEFAULT_DIR_SCREENSHOT])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SYSTEM], user_path, + "SYSTEM", sizeof(g_defaults.dirs[DEFAULT_DIR_SYSTEM])); /* cache dir */ - fill_pathname_join(g_defaults.dir.cache, user_path, - "TEMP", sizeof(g_defaults.dir.cache)); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CACHE], user_path, + "TEMP", sizeof(g_defaults.dirs[DEFAULT_DIR_CACHE])); /* history and main config */ - strlcpy(g_defaults.dir.content_history, - user_path, sizeof(g_defaults.dir.content_history)); + strlcpy(g_defaults.dirs[DEFAULT_DIR_CONTENT_HISTORY], + user_path, sizeof(g_defaults.dirs[DEFAULT_DIR_CONTENT_HISTORY])); fill_pathname_join(g_defaults.path.config, user_path, file_path_str(FILE_PATH_MAIN_CONFIG), sizeof(g_defaults.path.config)); #endif - /* create user data dirs */ - path_mkdir(g_defaults.dir.cheats); - path_mkdir(g_defaults.dir.core_assets); - path_mkdir(g_defaults.dir.playlist); - path_mkdir(g_defaults.dir.menu_config); - path_mkdir(g_defaults.dir.playlist); - path_mkdir(g_defaults.dir.remap); - path_mkdir(g_defaults.dir.savestate); - path_mkdir(g_defaults.dir.screenshot); - path_mkdir(g_defaults.dir.sram); - path_mkdir(g_defaults.dir.system); -#ifdef VITA - path_mkdir(g_defaults.dir.thumbnails); -#endif - /* create cache dir */ - path_mkdir(g_defaults.dir.cache); - - #ifndef IS_SALAMANDER #ifdef VITA @@ -255,6 +220,13 @@ static void frontend_psp_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)) + check_defaults_dir_create_dir(dir_path); + } } static void frontend_psp_deinit(void *data) diff --git a/frontend/drivers/platform_qnx.c b/frontend/drivers/platform_qnx.c index a12bd0d18c..64ab2bc4c1 100644 --- a/frontend/drivers/platform_qnx.c +++ b/frontend/drivers/platform_qnx.c @@ -52,121 +52,117 @@ static int frontend_qnx_get_rating(void) static void frontend_qnx_get_environment_settings(int *argc, char *argv[], void *data, void *params_data) { - char assets_path[PATH_MAX] = {0}; - char data_path[PATH_MAX] = {0}; - char user_path[PATH_MAX] = {0}; - char tmp_path[PATH_MAX] = {0}; + unsigned i; + char assets_path[PATH_MAX] = {0}; + char data_path[PATH_MAX] = {0}; + char user_path[PATH_MAX] = {0}; + char tmp_path[PATH_MAX] = {0}; - char workdir[PATH_MAX] = {0}; - getcwd(workdir, sizeof(workdir)); + char workdir[PATH_MAX] = {0}; + getcwd(workdir, sizeof(workdir)); - if(!string_is_empty(workdir)) - { - snprintf(assets_path, sizeof(data_path), - "%s/app/native/assets", workdir); - snprintf(data_path, sizeof(data_path), - "%s/data", workdir); - snprintf(user_path, sizeof(user_path), - "%s/shared/misc/retroarch", workdir); - snprintf(tmp_path, sizeof(user_path), - "%s/tmp", workdir); - } - else - { - snprintf(assets_path, sizeof(data_path), "app/native/assets"); - snprintf(data_path, sizeof(data_path), "data"); - snprintf(user_path, sizeof(user_path), "shared/misc/retroarch"); - snprintf(tmp_path, sizeof(user_path), "tmp"); - } + if(!string_is_empty(workdir)) + { + snprintf(assets_path, sizeof(data_path), + "%s/app/native/assets", workdir); + snprintf(data_path, sizeof(data_path), + "%s/data", workdir); + snprintf(user_path, sizeof(user_path), + "%s/shared/misc/retroarch", workdir); + snprintf(tmp_path, sizeof(user_path), + "%s/tmp", workdir); + } + else + { + snprintf(assets_path, sizeof(data_path), "app/native/assets"); + snprintf(data_path, sizeof(data_path), "data"); + snprintf(user_path, sizeof(user_path), "shared/misc/retroarch"); + snprintf(tmp_path, sizeof(user_path), "tmp"); + } - // app data - fill_pathname_join(g_defaults.dir.core, data_path, - "cores", sizeof(g_defaults.dir.core)); - fill_pathname_join(g_defaults.dir.assets, data_path, - "assets", sizeof(g_defaults.dir.assets)); - fill_pathname_join(g_defaults.dir.autoconfig, data_path, - "autoconfig", sizeof(g_defaults.dir.autoconfig)); - fill_pathname_join(g_defaults.dir.cursor, data_path, - "database/cursors", sizeof(g_defaults.dir.cursor)); - fill_pathname_join(g_defaults.dir.database, data_path, - "database/rdb", sizeof(g_defaults.dir.database)); - fill_pathname_join(g_defaults.dir.core_info, data_path, - "info", sizeof(g_defaults.dir.core_info)); - fill_pathname_join(g_defaults.dir.overlay, data_path, - "overlays", sizeof(g_defaults.dir.overlay)); - fill_pathname_join(g_defaults.dir.shader, data_path, - "shaders", sizeof(g_defaults.dir.shader)); + /* app data */ + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE], data_path, + "cores", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_ASSETS], data_path, + "assets", sizeof(g_defaults.dirs[DEFAULT_DIR_ASSETS])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG], data_path, + "autoconfig", sizeof(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CURSOR], data_path, + "database/cursors", sizeof(g_defaults.dirs[DEFAULT_DIR_CURSOR])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_DATABASE], data_path, + "database/rdb", sizeof(g_defaults.dirs[DEFAULT_DIR_DATABASE])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_INFO], data_path, + "info", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_INFO])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_OVERLAY], data_path, + "overlays", sizeof(g_defaults.dirs[DEFAULT_DIR_OVERLAY])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SHADERS], data_path, + "shaders", sizeof(g_defaults.dirs[DEFAULT_DIR_SHADERS])); - // user data - fill_pathname_join(g_defaults.dir.cheats, user_path, - "cheats", sizeof(g_defaults.dir.cheats)); - fill_pathname_join(g_defaults.dir.menu_config, user_path, - "config", sizeof(g_defaults.dir.menu_config)); - fill_pathname_join(g_defaults.dir.menu_content, user_path, - "content", sizeof(g_defaults.dir.menu_content)); - fill_pathname_join(g_defaults.dir.core_assets, user_path, - "downloads", sizeof(g_defaults.dir.core_assets)); - fill_pathname_join(g_defaults.dir.audio_filter, user_path, - "filters/audio", sizeof(g_defaults.dir.audio_filter)); - fill_pathname_join(g_defaults.dir.video_filter, user_path, - "filters/video", sizeof(g_defaults.dir.video_filter)); - fill_pathname_join(g_defaults.dir.playlist, user_path, - "playlists", sizeof(g_defaults.dir.playlist)); - fill_pathname_join(g_defaults.dir.remap, user_path, - "remaps", sizeof(g_defaults.dir.remap)); - fill_pathname_join(g_defaults.dir.sram, user_path, - "saves", sizeof(g_defaults.dir.sram)); - fill_pathname_join(g_defaults.dir.screenshot, user_path, - "screenshots", sizeof(g_defaults.dir.screenshot)); - fill_pathname_join(g_defaults.dir.savestate, user_path, - "states", sizeof(g_defaults.dir.savestate)); - fill_pathname_join(g_defaults.dir.system, user_path, - "system", sizeof(g_defaults.dir.system)); - fill_pathname_join(g_defaults.dir.thumbnails, user_path, - "thumbnails", sizeof(g_defaults.dir.thumbnails)); - fill_pathname_join(g_defaults.dir.wallpapers, user_path, - "wallpapers", sizeof(g_defaults.dir.wallpapers)); + /* user data */ + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CHEATS], user_path, + "cheats", sizeof(g_defaults.dirs[DEFAULT_DIR_CHEATS])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG], user_path, + "config", sizeof(g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_MENU_CONTENT], user_path, + "content", sizeof(g_defaults.dirs[DEFAULT_DIR_MENU_CONTENT])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_ASSETS], user_path, + "downloads", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_ASSETS])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_AUDIO_FILTER], user_path, + "filters/audio", sizeof(g_defaults.dirs[DEFAULT_DIR_AUDIO_FILTER])); + fill_pathname_join(g_defaults.dirs[DEFAULT_VIDEO_FILTER], user_path, + "filters/video", sizeof(g_defaults.dirs[DEFAULT_VIDEO_FILTER])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_PLAYLIST], user_path, + "playlists", sizeof(g_defaults.dirs[DEFAULT_DIR_PLAYLIST])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_REMAP], user_path, + "remaps", sizeof(g_defaults.dirs[DEFAULT_DIR_REMAP])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SRAM], user_path, + "saves", sizeof(g_defaults.dirs[DEFAULT_DIR_SRAM])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SCREENSHOT], user_path, + "screenshots", sizeof(g_defaults.dirs[DEFAULT_DIR_SCREENSHOT])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SAVESTATE], user_path, + "states", sizeof(g_defaults.dirs[DEFAULT_DIR_SAVESTATE])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SYSTEM], user_path, + "system", sizeof(g_defaults.dirs[DEFAULT_DIR_SYSTEM])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_THUMBNAIL], user_path, + "thumbnails", sizeof(g_defaults.dirs[DEFAULT_DIR_THUMBNAIL])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_WALLPAPERS], user_path, + "wallpapers", sizeof(g_defaults.dirs[DEFAULT_DIR_WALLPAPERS])); - // tmp - strlcpy(g_defaults.dir.cache, tmp_path, sizeof(g_defaults.dir.cache)); + /* tmp */ + strlcpy(g_defaults.dirs[DEFAULT_DIR_CACHE], + tmp_path, sizeof(g_defaults.dirs[DEFAULT_DIR_CACHE])); - // history and main config - strlcpy(g_defaults.dir.content_history, - user_path, sizeof(g_defaults.dir.content_history)); + /* history and main config */ + strlcpy(g_defaults.dirs[DEFAULT_DIR_CONTENT_HISTORY], + user_path, sizeof(g_defaults.dirs[DEFAULT_DIR_CONTENT_HISTORY])); fill_pathname_join(g_defaults.path.config, user_path, file_path_str(FILE_PATH_MAIN_CONFIG), sizeof(g_defaults.path.config)); - // bundle copy + /* bundle copy */ char data_assets_path[PATH_MAX] = {0}; sprintf(data_assets_path, "%s/%s", data_path, "assets"); if(!path_file_exists(data_assets_path)) { - RARCH_LOG( "Copying application assets to data directory...\n" ); + RARCH_LOG( "Copying application assets to data directory...\n" ); - char copy_command[PATH_MAX] = {0}; - sprintf(copy_command, "cp -r %s/. %s", assets_path, data_path); + char copy_command[PATH_MAX] = {0}; + sprintf(copy_command, "cp -r %s/. %s", assets_path, data_path); - if(system(copy_command) == -1) { + if(system(copy_command) == -1) { RARCH_LOG( "Asset copy failed: Shell could not be run.\n" ); - } else { - RARCH_LOG( "Asset copy successful.\n"); - } + } else { + RARCH_LOG( "Asset copy successful.\n"); + } } - // create user data dirs - path_mkdir(g_defaults.dir.cheats); - path_mkdir(g_defaults.dir.menu_config); - path_mkdir(g_defaults.dir.menu_content); - path_mkdir(g_defaults.dir.core_assets); - path_mkdir(g_defaults.dir.playlist); - path_mkdir(g_defaults.dir.remap); - path_mkdir(g_defaults.dir.savestate); - path_mkdir(g_defaults.dir.screenshot); - path_mkdir(g_defaults.dir.sram); - path_mkdir(g_defaults.dir.system); - path_mkdir(g_defaults.dir.thumbnails); + for (i = 0; i < DEFAULT_DIR_LAST; i++) + { + const char *dir_path = g_defaults.dirs[i]; + if (!string_is_empty(dir_path)) + check_defaults_dir_create_dir(dir_path); + } - // set glui as default menu + /* set glui as default menu */ snprintf(g_defaults.settings.menu, sizeof(g_defaults.settings.menu), "glui"); } diff --git a/frontend/drivers/platform_wiiu.c b/frontend/drivers/platform_wiiu.c index 2a666970df..caef3c2b5d 100644 --- a/frontend/drivers/platform_wiiu.c +++ b/frontend/drivers/platform_wiiu.c @@ -80,40 +80,46 @@ static const char *elf_path_cst = WIIU_SD_PATH "retroarch/retroarch.elf"; static void frontend_wiiu_get_environment_settings(int *argc, char *argv[], void *args, void *params_data) { + unsigned i; (void)args; - fill_pathname_basedir(g_defaults.dir.port, elf_path_cst, sizeof(g_defaults.dir.port)); + 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.dir.port); - - fill_pathname_join(g_defaults.dir.core_assets, g_defaults.dir.port, - "downloads", sizeof(g_defaults.dir.core_assets)); - fill_pathname_join(g_defaults.dir.assets, g_defaults.dir.port, - "media", sizeof(g_defaults.dir.assets)); - fill_pathname_join(g_defaults.dir.core, g_defaults.dir.port, - "cores", sizeof(g_defaults.dir.core)); - fill_pathname_join(g_defaults.dir.core_info, g_defaults.dir.core, - "info", sizeof(g_defaults.dir.core_info)); - fill_pathname_join(g_defaults.dir.savestate, g_defaults.dir.core, - "savestates", sizeof(g_defaults.dir.savestate)); - fill_pathname_join(g_defaults.dir.sram, g_defaults.dir.core, - "savefiles", sizeof(g_defaults.dir.sram)); - fill_pathname_join(g_defaults.dir.system, g_defaults.dir.core, - "system", sizeof(g_defaults.dir.system)); - fill_pathname_join(g_defaults.dir.playlist, g_defaults.dir.core, - "playlists", sizeof(g_defaults.dir.playlist)); - fill_pathname_join(g_defaults.dir.menu_config, g_defaults.dir.port, - "config", sizeof(g_defaults.dir.menu_config)); - fill_pathname_join(g_defaults.dir.remap, g_defaults.dir.port, - "config/remaps", sizeof(g_defaults.dir.remap)); - fill_pathname_join(g_defaults.dir.video_filter, g_defaults.dir.port, - "filters", sizeof(g_defaults.dir.remap)); - fill_pathname_join(g_defaults.dir.database, g_defaults.dir.port, - "database/rdb", sizeof(g_defaults.dir.database)); - fill_pathname_join(g_defaults.dir.cursor, g_defaults.dir.port, - "database/cursors", sizeof(g_defaults.dir.cursor)); - fill_pathname_join(g_defaults.path.config, g_defaults.dir.port, + fill_pathname_join(g_defaults.dir[DEFAULT_DIR_CORE_ASSETS], g_defaults.dirs[DEFAULT_DIR_PORT], + "downloads", sizeof(g_defaults.dir[DEFAULT_DIR_CORE_ASSETS])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_ASSETS], g_defaults.dirs[DEFAULT_DIR_PORT], + "media", sizeof(g_defaults.dirs[DEFAULT_DIR_ASSETS])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE], g_defaults.dirs[DEFAULT_DIR_PORT], + "cores", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_INFO], g_defaults.dirs[DEFAULT_DIR_CORE], + "info", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_INFO])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SAVESTATE], g_defaults.dirs[DEFAULT_DIR_CORE], + "savestates", sizeof(g_defaults.dirs[DEFAULT_DIR_SAVESTATE])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SRAM], g_defaults.dirs[DEFAULT_DIR_CORE], + "savefiles", sizeof(g_defaults.dirs[DEFAULT_DIR_SRAM])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SYSTEM], g_defaults.dirs[DEFAULT_DIR_CORE], + "system", sizeof(g_defaults.dirs[DEFAULT_DIR_SYSTEM])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_PLAYLIST], g_defaults.dirs[DEFAULT_DIR_CORE], + "playlists", sizeof(g_defaults.dirs[DEFAULT_DIR_PLAYLIST])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG], g_defaults.dirs[DEFAULT_DIR_PORT], + "config", sizeof(g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_REMAP], g_defaults.dirs[DEFAULT_DIR_PORT], + "config/remaps", sizeof(g_defaults.dirs[DEFAULT_DIR_REMAP])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_VIDEO_FILTER], g_defaults.dirs[DEFAULT_DIR_PORT], + "filters", sizeof(g_defaults.dirs[DEFAULT_DIR_VIDEO_FILTER])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_DATABASE], g_defaults.dirs[DEFAULT_DIR_PORT], + "database/rdb", sizeof(g_defaults.dirs[DEFAULT_DIR_DATABASE])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CURSOR], g_defaults.dirs[DEFAULT_DIR_PORT], + "database/cursors", sizeof(g_defaults.dirs[DEFAULT_DIR_CURSOR])); + fill_pathname_join(g_defaults.path.config, g_defaults.dirs[DEFAULT_DIR_PORT], file_path_str(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)) + check_defaults_dir_create_dir(dir_path); + } } static void frontend_wiiu_deinit(void *data) diff --git a/frontend/drivers/platform_win32.c b/frontend/drivers/platform_win32.c index f294186ceb..bafc462c68 100644 --- a/frontend/drivers/platform_win32.c +++ b/frontend/drivers/platform_win32.c @@ -179,9 +179,12 @@ static void frontend_win32_init(void *data) { typedef BOOL (WINAPI *isProcessDPIAwareProc)(); typedef BOOL (WINAPI *setProcessDPIAwareProc)(); - HMODULE handle = GetModuleHandle("User32.dll"); - isProcessDPIAwareProc isDPIAwareProc = (isProcessDPIAwareProc)dylib_proc(handle, "IsProcessDPIAware"); - setProcessDPIAwareProc setDPIAwareProc = (setProcessDPIAwareProc)dylib_proc(handle, "SetProcessDPIAware"); + HMODULE handle = + GetModuleHandle("User32.dll"); + isProcessDPIAwareProc isDPIAwareProc = + (isProcessDPIAwareProc)dylib_proc(handle, "IsProcessDPIAware"); + setProcessDPIAwareProc setDPIAwareProc = + (setProcessDPIAwareProc)dylib_proc(handle, "SetProcessDPIAware"); if (isDPIAwareProc) { @@ -257,63 +260,55 @@ static void frontend_win32_environment_get(int *argc, char *argv[], { gfx_set_dwm(); - fill_pathname_expand_special(g_defaults.dir.assets, - ":\\assets", sizeof(g_defaults.dir.assets)); - fill_pathname_expand_special(g_defaults.dir.audio_filter, - ":\\filters\\audio", sizeof(g_defaults.dir.audio_filter)); - fill_pathname_expand_special(g_defaults.dir.video_filter, - ":\\filters\\video", sizeof(g_defaults.dir.video_filter)); - fill_pathname_expand_special(g_defaults.dir.cheats, - ":\\cheats", sizeof(g_defaults.dir.cheats)); - fill_pathname_expand_special(g_defaults.dir.database, - ":\\database\\rdb", sizeof(g_defaults.dir.database)); - fill_pathname_expand_special(g_defaults.dir.cursor, - ":\\database\\cursors", sizeof(g_defaults.dir.cursor)); - fill_pathname_expand_special(g_defaults.dir.playlist, - ":\\playlists", sizeof(g_defaults.dir.assets)); - fill_pathname_expand_special(g_defaults.dir.menu_config, - ":\\config", sizeof(g_defaults.dir.menu_config)); - fill_pathname_expand_special(g_defaults.dir.remap, - ":\\config\\remaps", sizeof(g_defaults.dir.remap)); - fill_pathname_expand_special(g_defaults.dir.wallpapers, - ":\\assets\\wallpapers", sizeof(g_defaults.dir.wallpapers)); - fill_pathname_expand_special(g_defaults.dir.thumbnails, - ":\\thumbnails", sizeof(g_defaults.dir.thumbnails)); - fill_pathname_expand_special(g_defaults.dir.overlay, - ":\\overlays", sizeof(g_defaults.dir.overlay)); - fill_pathname_expand_special(g_defaults.dir.core, - ":\\cores", sizeof(g_defaults.dir.core)); - fill_pathname_expand_special(g_defaults.dir.core_info, - ":\\info", sizeof(g_defaults.dir.core_info)); - fill_pathname_expand_special(g_defaults.dir.autoconfig, - ":\\autoconfig", sizeof(g_defaults.dir.autoconfig)); - fill_pathname_expand_special(g_defaults.dir.shader, - ":\\shaders", sizeof(g_defaults.dir.shader)); - fill_pathname_expand_special(g_defaults.dir.core_assets, - ":\\downloads", sizeof(g_defaults.dir.core_assets)); - fill_pathname_expand_special(g_defaults.dir.screenshot, - ":\\screenshots", sizeof(g_defaults.dir.screenshot)); + fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_ASSETS], + ":\\assets", sizeof(g_defaults.dirs[DEFAULT_DIR_ASSETS])); + fill_pathname_expand_special(g_defaults.dirs[DEFAULT_AUDIO_FILTER], + ":\\filters\\audio", sizeof(g_defaults.dirs[DEFAULT_AUDIO_FILTER])); + fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_VIDEO_FILTER], + ":\\filters\\video", sizeof(g_defaults.dirs[DEFAULT_DIR_VIDEO_FILTER])); + fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_CHEATS], + ":\\cheats", sizeof(g_defaults.dirs[DEFAULT_DIR_CHEATS])); + fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_DATABASE], + ":\\database\\rdb", sizeof(g_defaults.dirs[DEFAULT_DIR_DATABASE])); + fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_CURSOR], + ":\\database\\cursors", sizeof(g_defaults.dirs[DEFAULT_DIR_CURSOR])); + fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_PLAYLIST], + ":\\playlists", sizeof(g_defaults.dirs[DEFAULT_DIR_ASSETS])); + fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG], + ":\\config", sizeof(g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG])); + fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_REMAP], + ":\\config\\remaps", sizeof(g_defaults.dirs[DEFAULT_DIR_REMAP])); + fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_WALLPAPERS], + ":\\assets\\wallpapers", sizeof(g_defaults.dirs[DEFAULT_DIR_WALLPAPERS])); + fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_THUMBNAIL], + ":\\thumbnails", sizeof(g_defaults.dirs[DEFAULT_DIR_THUMBNAIL])); + fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_OVERLAY], + ":\\overlays", sizeof(g_defaults.dirs[DEFAULT_DIR_OVERLAY])); + fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_CORE], + ":\\cores", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE])); + fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_CORE_INFO], + ":\\info", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_INFO])); + fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG], + ":\\autoconfig", sizeof(g_defaults.dirs[DEFAULT_DIR_AUTOCONFIG])); + fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_SHADER], + ":\\shaders", sizeof(g_defaults.dirs[DEFAULT_DIR_SHADER])); + fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_CORE]_assets, + ":\\downloads", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE]_assets)); + fill_pathname_expand_special(g_defaults.dirs[DEFAULT_DIR_SCREENSHOT], + ":\\screenshots", sizeof(g_defaults.dirs[DEFAULT_DIR_SCREENSHOT])); -/* don't force this in the driver anymore, these will be handled by - a dummy config file so they can be reset to content dir - - fill_pathname_expand_special(g_defaults.dir.sram, - ":\\saves", sizeof(g_defaults.dir.sram)); - fill_pathname_expand_special(g_defaults.dir.savestate, - ":\\states", sizeof(g_defaults.dir.savestate)); - fill_pathname_expand_special(g_defaults.dir.system, - ":\\system", sizeof(g_defaults.dir.system)); -*/ #ifdef HAVE_MENU #if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) - snprintf(g_defaults.settings.menu, sizeof(g_defaults.settings.menu), "xmb"); + snprintf(g_defaults.settings.menu, + sizeof(g_defaults.settings.menu), "xmb"); #endif #endif } static uint64_t frontend_win32_get_mem_total(void) { - /* OSes below 2000 don't have the Ex version, and non-Ex cannot work with >4GB RAM */ + /* OSes below 2000 don't have the Ex version, + * and non-Ex cannot work with >4GB RAM */ #if _WIN32_WINNT > 0x0400 MEMORYSTATUSEX mem_info; mem_info.dwLength = sizeof(MEMORYSTATUSEX); @@ -329,7 +324,8 @@ static uint64_t frontend_win32_get_mem_total(void) static uint64_t frontend_win32_get_mem_used(void) { - /* OSes below 2000 don't have the Ex version, and non-Ex cannot work with >4GB RAM */ + /* OSes below 2000 don't have the Ex version, + * and non-Ex cannot work with >4GB RAM */ #if _WIN32_WINNT > 0x0400 MEMORYSTATUSEX mem_info; mem_info.dwLength = sizeof(MEMORYSTATUSEX); @@ -349,25 +345,30 @@ static void frontend_win32_attach_console(void) #ifdef _WIN32_WINNT_WINXP /* msys will start the process with FILE_TYPE_PIPE connected. - * cmd will start the process with FILE_TYPE_UNKNOWN connected (since this is subsystem windows application - * ... UNLESS stdout/stderr were redirected (then FILE_TYPE_DISK will be connected most likely) + * cmd will start the process with FILE_TYPE_UNKNOWN connected + * (since this is subsystem windows application + * ... UNLESS stdout/stderr were redirected (then FILE_TYPE_DISK + * will be connected most likely) * explorer will start the process with NOTHING connected. * * Now, let's not reconnect anything that's already connected. * If any are disconnected, open a console, and connect to them. - * In case we're launched from msys or cmd, try attaching to the parent process console first. - * Take care to leave a record of what we did, so we can undo it precisely + * In case we're launched from msys or cmd, try attaching to the + * parent process console first. + * + * Take care to leave a record of what we did, so we can + * undo it precisely. */ - bool need_stdout = (GetFileType(GetStdHandle(STD_OUTPUT_HANDLE)) == FILE_TYPE_UNKNOWN); - bool need_stderr = (GetFileType(GetStdHandle(STD_ERROR_HANDLE)) == FILE_TYPE_UNKNOWN); + bool need_stdout = (GetFileType(GetStdHandle(STD_OUTPUT_HANDLE)) + == FILE_TYPE_UNKNOWN); + bool need_stderr = (GetFileType(GetStdHandle(STD_ERROR_HANDLE)) + == FILE_TYPE_UNKNOWN); if(need_stdout || need_stderr) { if(!AttachConsole( ATTACH_PARENT_PROCESS)) - { AllocConsole(); - } if(need_stdout) freopen( "CONOUT$", "w", stdout ); if(need_stderr) freopen( "CONOUT$", "w", stderr ); @@ -386,8 +387,9 @@ static void frontend_win32_detach_console(void) if(console_needs_free) { - /* we don't reconnect stdout/stderr to anything here, because by definition, they weren't connected to anything in the first place. */ - + /* we don't reconnect stdout/stderr to anything here, + * because by definition, they weren't connected to + * anything in the first place. */ FreeConsole(); console_needs_free = false; } diff --git a/frontend/drivers/platform_xdk.cpp b/frontend/drivers/platform_xdk.cpp index 02896f6c00..9268fb6df4 100644 --- a/frontend/drivers/platform_xdk.cpp +++ b/frontend/drivers/platform_xdk.cpp @@ -1135,34 +1135,50 @@ static void frontend_xdk_get_environment_settings(int *argc, char *argv[], #endif #if defined(_XBOX1) - strlcpy(g_defaults.dir.core, "D:", sizeof(g_defaults.dir.core)); - fill_pathname_join(g_defaults.path.config, g_defaults.dir.core, + strlcpy(g_defaults.dirs[DEFAULT_DIR_CORE], + "D:", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE])); + fill_pathname_join(g_defaults.path.config, g_defaults.dirs[DEFAULT_DIR_CORE], file_path_str(FILE_PATH_MAIN_CONFIG), sizeof(g_defaults.path.config)); - fill_pathname_join(g_defaults.dir.savestate, g_defaults.dir.core, - "savestates", sizeof(g_defaults.dir.savestate)); - fill_pathname_join(g_defaults.dir.sram, g_defaults.dir.core, - "savefiles", sizeof(g_defaults.dir.sram)); - fill_pathname_join(g_defaults.dir.system, g_defaults.dir.core, - "system", sizeof(g_defaults.dir.system)); - fill_pathname_join(g_defaults.dir.screenshot, g_defaults.dir.core, - "screenshots", sizeof(g_defaults.dir.screenshot)); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SAVESTATE], + g_defaults.dirs[DEFAULT_DIR_CORE], + "savestates", + sizeof(g_defaults.dirs[DEFAULT_DIR_SAVESTATE])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SRAM], + g_defaults.dirs[DEFAULT_DIR_CORE], + "savefiles", + sizeof(g_defaults.dirs[DEFAULT_DIR_SRAM])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SYSTEM], + g_defaults.dirs[DEFAULT_DIR_CORE], + "system", + sizeof(g_defaults.dirs[DEFAULT_DIR_SYSTEM])); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SCREENSHOT], + g_defaults.dirs[DEFAULT_DIR_CORE], + "screenshots", + sizeof(g_defaults.dirs[DEFAULT_DIR_SCREENSHOT])); #elif defined(_XBOX360) - strlcpy(g_defaults.dir.core, "game:", sizeof(g_defaults.dir.core)); + strlcpy(g_defaults.dirs[DEFAULT_DIR_CORE], + "game:", + sizeof(g_defaults.dirs[DEFAULT_DIR_CORE])); strlcpy(g_defaults.path.config, "game:\\retroarch.cfg", sizeof(g_defaults.path.config)); - strlcpy(g_defaults.dir.screenshot, - "game:", sizeof(g_defaults.dir.screenshot)); - strlcpy(g_defaults.dir.savestate, - "game:\\savestates", sizeof(g_defaults.dir.savestate)); - strlcpy(g_defaults.dir.playlist, - "game:\\playlists", sizeof(g_defaults.dir.playlist)); - strlcpy(g_defaults.dir.sram, - "game:\\savefiles", sizeof(g_defaults.dir.sram)); - strlcpy(g_defaults.dir.system, - "game:\\system", sizeof(g_defaults.dir.system)); + strlcpy(g_defaults.dirs[DEFAULT_DIR_SCREENSHOT], + "game:", + sizeof(g_defaults.dirs[DEFAULT_DIR_SCREENSHOT])); + strlcpy(g_defaults.dirs[DEFAULT_DIR_SAVESTATE], + "game:\\savestates", + sizeof(g_defaults.dirs[DEFAULT_DIR_SAVESTATE])); + strlcpy(g_defaults.dirs[DEFAULT_DIR_PLAYLIST], + "game:\\playlists", + sizeof(g_defaults.dirs[DEFAULT_DIR_PLAYLIST])); + strlcpy(g_defaults.dirs[DEFAULT_DIR_SRAM], + "game:\\savefiles", + sizeof(g_defaults.dirs[DEFAULT_DIR_SRAM])); + strlcpy(g_defaults.dirs[DEFAULT_DIR_SYSTEM], + "game:\\system", sizeof(g_defaults.dirs[DEFAULT_DIR_SYSTEM])); #endif - fill_pathname_join(g_defaults.dir.core_info, g_defaults.dir.core, - "info", sizeof(g_defaults.dir.core_info)); + fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_INFO], + g_defaults.dirs[DEFAULT_DIR_CORE], + "info", sizeof(g_defaults.dirs[DEFAULT_DIR_CORE_INFO])); #ifndef IS_SALAMANDER static char path[PATH_MAX_LENGTH] = {0}; diff --git a/frontend/frontend_salamander.c b/frontend/frontend_salamander.c index 27dffef654..e8c2441e29 100644 --- a/frontend/frontend_salamander.c +++ b/frontend/frontend_salamander.c @@ -103,7 +103,7 @@ static void find_and_set_first_file(char *s, size_t len, char first_file[PATH_MAX_LENGTH] = {0}; find_first_libretro_core(first_file, sizeof(first_file), - g_defaults.dir.core, ext); + g_defaults.dirs[DEFAULT_DIR_CORE], ext); if (string_is_empty(first_file)) { @@ -111,7 +111,7 @@ static void find_and_set_first_file(char *s, size_t len, return; } - fill_pathname_join(s, g_defaults.dir.core, first_file, len); + fill_pathname_join(s, g_defaults.dirs[DEFAULT_DIR_CORE], first_file, len); RARCH_LOG("libretro_path now set to: %s.\n", s); } diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 08982b2e13..89def46225 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -6422,7 +6422,7 @@ static bool setting_append_list( sizeof(settings->paths.directory_libretro), MENU_ENUM_LABEL_LIBRETRO_DIR_PATH, MENU_ENUM_LABEL_VALUE_LIBRETRO_DIR_PATH, - g_defaults.dir.core, + g_defaults.dirs[DEFAULT_DIR_CORE], MENU_ENUM_LABEL_VALUE_DIRECTORY_NONE, &group_info, &subgroup_info, @@ -6437,7 +6437,7 @@ static bool setting_append_list( sizeof(settings->paths.path_libretro_info), MENU_ENUM_LABEL_LIBRETRO_INFO_PATH, MENU_ENUM_LABEL_VALUE_LIBRETRO_INFO_PATH, - g_defaults.dir.core_info, + g_defaults.dirs[DEFAULT_DIR_CORE_INFO], MENU_ENUM_LABEL_VALUE_DIRECTORY_NONE, &group_info, &subgroup_info, @@ -6524,7 +6524,7 @@ static bool setting_append_list( sizeof(settings->paths.directory_video_shader), MENU_ENUM_LABEL_VIDEO_SHADER_DIR, MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_DIR, - g_defaults.dir.shader, + g_defaults.dirs[DEFAULT_DIR_SHADER], MENU_ENUM_LABEL_VALUE_DIRECTORY_DEFAULT, &group_info, &subgroup_info, @@ -6569,7 +6569,7 @@ static bool setting_append_list( sizeof(settings->paths.directory_overlay), MENU_ENUM_LABEL_OVERLAY_DIRECTORY, MENU_ENUM_LABEL_VALUE_OVERLAY_DIRECTORY, - g_defaults.dir.overlay, + g_defaults.dirs[DEFAULT_DIR_OVERLAY], MENU_ENUM_LABEL_VALUE_DIRECTORY_DEFAULT, &group_info, &subgroup_info,