src/fileio.cpp
changeset 7371 b86b05214afe
parent 7330 577e92774f23
child 7392 a716551b0c7f
--- a/src/fileio.cpp	Tue Jun 12 14:22:28 2007 +0000
+++ b/src/fileio.cpp	Tue Jun 12 15:46:34 2007 +0000
@@ -394,3 +394,20 @@
 	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;
+		}
+	}
+}