diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/fileio.cpp | 13 | ||||
-rw-r--r-- | src/fios.cpp | 23 |
2 files changed, 27 insertions, 9 deletions
diff --git a/src/fileio.cpp b/src/fileio.cpp index f33c8e0c1..f92a7f6ab 100644 --- a/src/fileio.cpp +++ b/src/fileio.cpp @@ -363,6 +363,16 @@ void FioCreateDirectory(const char *name) CreateDirectory(OTTD2FS(name), NULL); #elif defined(OS2) && !defined(__INNOTEK_LIBC__) mkdir(OTTD2FS(name)); +#elif defined(__MORPHOS__) || defined(__AMIGAOS__) + char buf[MAX_PATH]; + ttd_strlcpy(buf, name, MAX_PATH); + + size_t len = strlen(name) - 1; + if (buf[len] == '/') { + buf[len] = '\0'; // Kill pathsep, so mkdir() will not fail + } + + mkdir(OTTD2FS(buf), 0755); #else mkdir(OTTD2FS(name), 0755); #endif @@ -720,7 +730,10 @@ void DeterminePaths(const char *exe) 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); diff --git a/src/fios.cpp b/src/fios.cpp index 31c3d8390..2dc10002c 100644 --- a/src/fios.cpp +++ b/src/fios.cpp @@ -145,15 +145,7 @@ char *FiosBrowseTo(const FiosItem *item) case FIOS_TYPE_BMP: { static char str_buffr[512]; - -#if defined(__MORPHOS__) || defined(__AMIGAOS__) - /* On MorphOS or AmigaOS paths look like: "Volume:directory/subdirectory" */ - if (FiosIsRoot(path)) { - snprintf(str_buffr, lengthof(str_buffr), "%s:%s", path, item->name); - } else // XXX - only next line! -#endif snprintf(str_buffr, lengthof(str_buffr), "%s%s", path, item->name); - return str_buffr; } } @@ -170,8 +162,21 @@ void FiosMakeSavegameName(char *buf, const char *name, size_t size) /* Don't append the extension if it is already there */ period = strrchr(name, '.'); if (period != NULL && strcasecmp(period, extension) == 0) extension = ""; - +#if defined(__MORPHOS__) || defined(__AMIGAOS__) + if (_fios_path != NULL) { + unsigned char sepchar = _fios_path[(strlen(_fios_path) - 1)]; + + if (sepchar != ':' && sepchar != '/') { + snprintf(buf, size, "%s" PATHSEP "%s%s", _fios_path, name, extension); + } else { + snprintf(buf, size, "%s%s%s", _fios_path, name, extension); + } + } else { + snprintf(buf, size, "%s%s", name, extension); + } +#else snprintf(buf, size, "%s" PATHSEP "%s%s", _fios_path, name, extension); +#endif } #if defined(WIN32) |