summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-03-04 14:25:53 +0000
committerrubidium <rubidium@openttd.org>2009-03-04 14:25:53 +0000
commita52d50c62fc5431e03a9fec53a4a5d9eb5597a87 (patch)
tree2d9370d65b75cd16f77704535b7ddee0121cab3e
parent6cbf131318a5687182373c487ed01ad6b6a549c0 (diff)
downloadopenttd-a52d50c62fc5431e03a9fec53a4a5d9eb5597a87.tar.xz
(svn r15612) -Codechange: unduplicate directory creation
-rw-r--r--src/fileio.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/fileio.cpp b/src/fileio.cpp
index 3ad29b6f2..2c177f648 100644
--- a/src/fileio.cpp
+++ b/src/fileio.cpp
@@ -935,19 +935,20 @@ void DeterminePaths(const char *exe)
_highscore_file = str_fmt("%shs.dat", _personal_dir);
_log_file = str_fmt("%sopenttd.log", _personal_dir);
- char *save_dir = str_fmt("%s%s", _personal_dir, FioGetSubdirectory(SAVE_DIR));
- char *autosave_dir = str_fmt("%s%s", _personal_dir, FioGetSubdirectory(AUTOSAVE_DIR));
-
/* Make the necessary folders */
#if !defined(__MORPHOS__) && !defined(__AMIGA__) && defined(WITH_PERSONAL_DIR)
FioCreateDirectory(_personal_dir);
#endif
- FioCreateDirectory(save_dir);
- FioCreateDirectory(autosave_dir);
+ static const Subdirectory default_subdirs[] = {
+ SAVE_DIR, AUTOSAVE_DIR
+ };
- free(save_dir);
- free(autosave_dir);
+ for (uint i = 0; i < lengthof(default_subdirs); i++) {
+ char *dir = str_fmt("%s%s", _personal_dir, FioGetSubdirectory(default_subdirs[i]));
+ FioCreateDirectory(dir);
+ free(dir);
+ }
/* If we have network we make a directory for the autodownloading of content */
_searchpaths[SP_AUTODOWNLOAD_DIR] = str_fmt("%s%s", _personal_dir, "content_download" PATHSEP);