PathManager - Make FilesystemSafeName remove all invalid chars (for filesystems) from a game name

This commit is contained in:
andres.delikat 2011-09-04 19:24:40 +00:00
parent 772737f579
commit d7c267cbbe
1 changed files with 12 additions and 0 deletions

View File

@ -261,9 +261,21 @@ namespace BizHawk.MultiClient
return path;
}
public static string RemoveInvalidFileSystemChars(string name)
{
string newStr = name;
char[] chars = Path.GetInvalidFileNameChars();
foreach (char c in chars)
{
newStr = newStr.Replace(c.ToString(), "");
}
return newStr;
}
public static string FilesystemSafeName(GameInfo game)
{
string filesystemSafeName = game.Name.Replace("|", "+");
filesystemSafeName = RemoveInvalidFileSystemChars(filesystemSafeName);
return Path.Combine(Path.GetDirectoryName(filesystemSafeName), Path.GetFileNameWithoutExtension(filesystemSafeName));
}