Create directories after the config is read (#16093)

This commit is contained in:
Eric Warmenhoven 2024-01-11 16:16:27 -05:00 committed by GitHub
parent 6c57b31ce5
commit 286e31dc7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 67 additions and 6 deletions

View File

@ -480,6 +480,9 @@ static void frontend_darwin_get_env(int *argc, char *argv[],
strlcpy(g_defaults.dirs[DEFAULT_DIR_CACHE],
temp_dir,
sizeof(g_defaults.dirs[DEFAULT_DIR_CACHE]));
if (!path_is_directory(g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG]))
path_mkdir(g_defaults.dirs[DEFAULT_DIR_MENU_CONFIG]);
}
static int frontend_darwin_get_rating(void)

View File

@ -1676,7 +1676,6 @@ void playlist_write_file(playlist_t *playlist)
size_t i, len;
intfstream_t *file = NULL;
bool compressed = false;
char dir_path[PATH_MAX_LENGTH];
/* Playlist will be written if any of the
* following are true:
@ -1693,11 +1692,6 @@ void playlist_write_file(playlist_t *playlist)
(playlist->old_format != playlist->config.old_format)))
return;
fill_pathname_basedir(dir_path, playlist->config.path, sizeof(dir_path));
if (!path_is_directory(dir_path))
if (!path_mkdir(dir_path))
return;
#if defined(HAVE_ZLIB)
if (playlist->config.compress)
file = intfstream_open_rzip_file(playlist->config.path,

View File

@ -3000,6 +3000,59 @@ void dir_check_defaults(const char *custom_ini_path)
}
}
#ifdef __APPLE__
static void dir_check_config(void)
{
settings_t *settings = config_get_ptr();
#define ENSURE_DIRECTORY(DIRPATH) \
if (!string_is_empty(DIRPATH)) \
if (!path_is_directory(DIRPATH)) \
path_mkdir(DIRPATH)
/* the order here mimics the order of enum default_dirs */
/* TODO: not all of these are necessary/used and many are created on demand, make fewer */
ENSURE_DIRECTORY(settings->paths.directory_menu_content);
ENSURE_DIRECTORY(settings->paths.directory_core_assets);
ENSURE_DIRECTORY(settings->paths.directory_menu_config);
ENSURE_DIRECTORY(settings->paths.directory_autoconfig);
ENSURE_DIRECTORY(settings->paths.directory_audio_filter);
ENSURE_DIRECTORY(settings->paths.directory_video_filter);
ENSURE_DIRECTORY(settings->paths.directory_assets);
#ifdef _3DS
ENSURE_DIRECTORY(settings->paths.directory_bottom_assets);
#endif
ENSURE_DIRECTORY(settings->paths.directory_libretro);
ENSURE_DIRECTORY(settings->paths.path_libretro_info);
ENSURE_DIRECTORY(settings->paths.directory_overlay);
ENSURE_DIRECTORY(settings->paths.directory_osk_overlay);
/* PORT */
ENSURE_DIRECTORY(settings->paths.directory_video_shader);
ENSURE_DIRECTORY(dir_get_ptr(RARCH_DIR_SAVESTATE));
ENSURE_DIRECTORY(settings->paths.directory_resampler);
ENSURE_DIRECTORY(dir_get_ptr(RARCH_DIR_SAVEFILE));
ENSURE_DIRECTORY(settings->paths.directory_screenshot);
ENSURE_DIRECTORY(settings->paths.directory_system);
ENSURE_DIRECTORY(settings->paths.directory_playlist);
ENSURE_DIRECTORY(settings->paths.directory_content_favorites);
ENSURE_DIRECTORY(settings->paths.directory_content_history);
ENSURE_DIRECTORY(settings->paths.directory_content_image_history);
ENSURE_DIRECTORY(settings->paths.directory_content_music_history);
ENSURE_DIRECTORY(settings->paths.directory_content_video_history);
ENSURE_DIRECTORY(settings->paths.directory_input_remapping);
ENSURE_DIRECTORY(settings->paths.directory_cache);
ENSURE_DIRECTORY(settings->paths.directory_dynamic_wallpapers);
ENSURE_DIRECTORY(settings->paths.directory_thumbnails);
ENSURE_DIRECTORY(settings->paths.path_content_database);
ENSURE_DIRECTORY(settings->paths.path_cheat_database);
/* RECORD_CONFIG */
/* RECORD_OUTPUT */
ENSURE_DIRECTORY(settings->paths.log_dir);
#undef ENSURE_DIRECTORY
}
#endif
#ifdef HAVE_ACCESSIBILITY
bool is_accessibility_enabled(bool accessibility_enable, bool accessibility_enabled)
{
@ -7313,6 +7366,17 @@ bool retroarch_main_init(int argc, char *argv[])
verbosity_enabled = retroarch_parse_input_and_config(p_rarch,
global_get_ptr(), argc, argv);
#ifdef __APPLE__
/* This doesn't have to be apple specific but it's currently the only
* platform that doesn't call dir_check_defaults(). This does exactly the
* same thing as dir_check_defaults() except that it makes the directories
* pointed at by the config file rather than the defaults, which is why it
* comes right after parsing the config. osx users seem to be more likely to
* want to do change the default directories.
*/
dir_check_config();
#endif
#ifdef HAVE_ACCESSIBILITY
accessibility_enable = settings->bools.accessibility_enable;
accessibility_narrator_speech_speed = settings->uints.accessibility_narrator_speech_speed;