From d7c267cbbe21edd484b5cbfab873cf634ab04fc5 Mon Sep 17 00:00:00 2001 From: "andres.delikat" Date: Sun, 4 Sep 2011 19:24:40 +0000 Subject: [PATCH] PathManager - Make FilesystemSafeName remove all invalid chars (for filesystems) from a game name --- BizHawk.MultiClient/config/PathManager.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/BizHawk.MultiClient/config/PathManager.cs b/BizHawk.MultiClient/config/PathManager.cs index f1c53be69d..53acb9b16f 100644 --- a/BizHawk.MultiClient/config/PathManager.cs +++ b/BizHawk.MultiClient/config/PathManager.cs @@ -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)); }