Skip to content

Commit

Permalink
hardcode invalid chars in file name to get same file names in differe…
Browse files Browse the repository at this point in the history
…nt platforms
  • Loading branch information
goojal committed Feb 16, 2024
1 parent c620aa6 commit 6b92335
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions engine/Tools.MSBuildProjectBuilder.Shared/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,21 @@ namespace JustDecompile.Tools.MSBuildProjectBuilder
public static class Utilities
{
public const int MaxPathLength = 259; // 259 + NULL == 260

public static string GetLegalFileName(string legalName)
public static readonly char[] InvalidChars = new char[41] // Hardcoding invalid chars to get same result in different platforms
{
'"', '<', '>', '|', '\0', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005',
'\u0006', '\a', '\b', '\t', '\n', '\v', '\f', '\r', '\u000e', '\u000f',
'\u0010', '\u0011', '\u0012', '\u0013', '\u0014', '\u0015', '\u0016', '\u0017', '\u0018', '\u0019',
'\u001a', '\u001b', '\u001c', '\u001d', '\u001e', '\u001f', ':', '*', '?', '\\',
'/'
};
public static string GetLegalFileName(string legalName)
{
if (legalName.Length == 0)
{
return string.Empty;
}
string regexSearch = new string(Path.GetInvalidFileNameChars()) + new string(Path.GetInvalidPathChars());
string regexSearch = new string(InvalidChars);

Regex r = new Regex(string.Format("[{0}]", Regex.Escape(regexSearch)));

Expand All @@ -41,7 +48,7 @@ public static string GetLegalFolderName(string nameSpace)
{
return string.Empty;
}
string regexSearch = new string(Path.GetInvalidPathChars());
string regexSearch = new string(InvalidChars);

Regex r = new Regex(string.Format("[{0}]", Regex.Escape(regexSearch)));

Expand Down

0 comments on commit 6b92335

Please sign in to comment.