From 0d7018c964a02b7103c22b4f26b4e9e0818b3ec0 Mon Sep 17 00:00:00 2001 From: PopSlime Date: Mon, 7 Nov 2022 12:19:31 +0800 Subject: [PATCH] Fix import error due to invalid file name. (Amend) --- Assets/Cryville/Common/StringUtils.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Assets/Cryville/Common/StringUtils.cs b/Assets/Cryville/Common/StringUtils.cs index a25dc67..b230bc8 100644 --- a/Assets/Cryville/Common/StringUtils.cs +++ b/Assets/Cryville/Common/StringUtils.cs @@ -1,5 +1,6 @@ using System; using System.Text; +using System.Text.RegularExpressions; namespace Cryville.Common { /// @@ -33,5 +34,13 @@ namespace Cryville.Common { b.Append((timeSpan.TotalSeconds % 60).ToString("00." + new string('0', digits))); return b.ToString(); } + /// + /// Escapes special characters in a file name. + /// + /// The file name excluding the extension. + /// The escaped file name. + public static string EscapeFileName(string name) { + return Regex.Replace(name, @"[\/\\\<\>\:\x22\|\?\*\p{Cc}\.\s]", "_"); + } } }