diff options
Diffstat (limited to 'src/fileio.cpp')
-rw-r--r-- | src/fileio.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/fileio.cpp b/src/fileio.cpp index ba3abb21a..171f6bfcd 100644 --- a/src/fileio.cpp +++ b/src/fileio.cpp @@ -394,3 +394,20 @@ void DeterminePaths(const char *exe) FioCreateDirectory(_paths.scenario_dir); FioCreateDirectory(_paths.heightmap_dir); } + +/** + * Sanitizes a filename, i.e. removes all illegal characters from it. + * @param filename the "\0" terminated filename + */ +void SanitizeFilename(char *filename) +{ + for (; *filename != '\0'; filename++) { + switch (*filename) { + /* The following characters are not allowed in filenames + * on at least one of the supported operating systems: */ + case ':': case '\\': case '*': case '?': case '/': + *filename = '_'; + break; + } + } +} |