Add sanitize method
This commit is contained in:
parent
2505a1abcd
commit
d977d40ff7
1 changed files with 8 additions and 0 deletions
|
@ -1,4 +1,6 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace Ryujinx.Common.Utilities
|
||||
{
|
||||
|
@ -44,5 +46,11 @@ namespace Ryujinx.Common.Utilities
|
|||
CopyDirectory(sourceDir, destinationDir, true);
|
||||
Directory.Delete(sourceDir, true);
|
||||
}
|
||||
|
||||
public static string SanitizeFileName(string fileName)
|
||||
{
|
||||
var reservedChars = new HashSet<char>(Path.GetInvalidFileNameChars());
|
||||
return string.Concat(fileName.Select(c => reservedChars.Contains(c) ? '_' : c));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue