(svn r10116) -Fix [FS#850]: remove invalid characters (for the file system) from savegame names. Based on a patch by TheJosh.

This commit is contained in:
rubidium
2007-06-12 15:46:34 +00:00
parent 443db4bb2e
commit 60d738f23a
4 changed files with 22 additions and 0 deletions

View File

@@ -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;
}
}
}