mirror of https://github.com/OpenTTD/OpenTTD
(svn r9990) -Fix: MorphOS and AmigaOS do not like "//" in filenames as that means the same as "/../" in means in Unix.
parent
2bfc36c1ba
commit
b17a89c53d
|
@ -359,10 +359,10 @@ void DeterminePaths(const char *exe)
|
||||||
{
|
{
|
||||||
DetermineBasePaths(exe);
|
DetermineBasePaths(exe);
|
||||||
|
|
||||||
_paths.save_dir = str_fmt("%ssave", _paths.personal_dir);
|
_paths.save_dir = str_fmt("%ssave" PATHSEP, _paths.personal_dir);
|
||||||
_paths.autosave_dir = str_fmt("%s" PATHSEP "autosave", _paths.save_dir);
|
_paths.autosave_dir = str_fmt("%s" PATHSEP "autosave" PATHSEP, _paths.save_dir);
|
||||||
_paths.scenario_dir = str_fmt("%sscenario", _paths.personal_dir);
|
_paths.scenario_dir = str_fmt("%sscenario" PATHSEP, _paths.personal_dir);
|
||||||
_paths.heightmap_dir = str_fmt("%s" PATHSEP "heightmap", _paths.scenario_dir);
|
_paths.heightmap_dir = str_fmt("%s" PATHSEP "heightmap" PATHSEP, _paths.scenario_dir);
|
||||||
_paths.gm_dir = str_fmt("%sgm" PATHSEP, _paths.game_data_dir);
|
_paths.gm_dir = str_fmt("%sgm" PATHSEP, _paths.game_data_dir);
|
||||||
_paths.data_dir = str_fmt("%sdata" PATHSEP, _paths.game_data_dir);
|
_paths.data_dir = str_fmt("%sdata" PATHSEP, _paths.game_data_dir);
|
||||||
#if defined(CUSTOM_LANG_DIR)
|
#if defined(CUSTOM_LANG_DIR)
|
||||||
|
|
15
src/fios.cpp
15
src/fios.cpp
|
@ -114,9 +114,10 @@ char *FiosBrowseTo(const FiosItem *item)
|
||||||
|
|
||||||
case FIOS_TYPE_PARENT:
|
case FIOS_TYPE_PARENT:
|
||||||
/* Check for possible NULL ptr (not required for UNIXes, but AmigaOS-alikes) */
|
/* Check for possible NULL ptr (not required for UNIXes, but AmigaOS-alikes) */
|
||||||
if ((s = strrchr(path, PATHSEPCHAR)) != NULL) {
|
if ((s = strrchr(path, PATHSEPCHAR)) != path) {
|
||||||
s[1] = '\0'; // go up a directory
|
s[0] = '\0'; // Remove last path separator character, so we can go up one level.
|
||||||
if (!FiosIsRoot(path)) s[0] = '\0';
|
s = strrchr(path, PATHSEPCHAR);
|
||||||
|
if (s != NULL) s[1] = '\0'; // go up a directory
|
||||||
}
|
}
|
||||||
#if defined(__MORPHOS__) || defined(__AMIGAOS__)
|
#if defined(__MORPHOS__) || defined(__AMIGAOS__)
|
||||||
/* On MorphOS or AmigaOS paths look like: "Volume:directory/subdirectory" */
|
/* On MorphOS or AmigaOS paths look like: "Volume:directory/subdirectory" */
|
||||||
|
@ -125,14 +126,12 @@ char *FiosBrowseTo(const FiosItem *item)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FIOS_TYPE_DIR:
|
case FIOS_TYPE_DIR:
|
||||||
if (!FiosIsRoot(path)) strcat(path, PATHSEP);
|
|
||||||
strcat(path, item->name);
|
strcat(path, item->name);
|
||||||
|
strcat(path, PATHSEP);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FIOS_TYPE_DIRECT:
|
case FIOS_TYPE_DIRECT:
|
||||||
sprintf(path, "%s" PATHSEP, item->name);
|
sprintf(path, "%s", item->name);
|
||||||
s = strrchr(path, PATHSEPCHAR);
|
|
||||||
if (s != NULL && s[1] == '\0') s[0] = '\0'; // strip trailing slash
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FIOS_TYPE_FILE:
|
case FIOS_TYPE_FILE:
|
||||||
|
@ -150,7 +149,7 @@ char *FiosBrowseTo(const FiosItem *item)
|
||||||
snprintf(str_buffr, lengthof(str_buffr), "%s:%s", path, item->name);
|
snprintf(str_buffr, lengthof(str_buffr), "%s:%s", path, item->name);
|
||||||
} else // XXX - only next line!
|
} else // XXX - only next line!
|
||||||
#endif
|
#endif
|
||||||
snprintf(str_buffr, lengthof(str_buffr), "%s" PATHSEP "%s", path, item->name);
|
snprintf(str_buffr, lengthof(str_buffr), "%s%s", path, item->name);
|
||||||
|
|
||||||
return str_buffr;
|
return str_buffr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,8 +87,11 @@ bool FiosIsValidFile(const char *path, const struct dirent *ent, struct stat *sb
|
||||||
if (FiosIsRoot(path)) {
|
if (FiosIsRoot(path)) {
|
||||||
snprintf(filename, lengthof(filename), "%s:%s", path, ent->d_name);
|
snprintf(filename, lengthof(filename), "%s:%s", path, ent->d_name);
|
||||||
} else // XXX - only next line!
|
} else // XXX - only next line!
|
||||||
|
#else
|
||||||
|
assert(path[strlen(path) - 1] == PATHSEPCHAR);
|
||||||
|
if (strlen(path) > 2) assert(path[strlen(path) - 2] != PATHSEPCHAR);
|
||||||
#endif
|
#endif
|
||||||
snprintf(filename, lengthof(filename), "%s" PATHSEP "%s", path, ent->d_name);
|
snprintf(filename, lengthof(filename), "%s%s", path, ent->d_name);
|
||||||
|
|
||||||
return stat(filename, sb) == 0;
|
return stat(filename, sb) == 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue