mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[RomTools] Try to make sort more safe
This commit is contained in:
@@ -225,6 +225,8 @@ namespace SabreTools.Helper
|
||||
/// <param name="norename">True if files are not renamed, false otherwise</param>
|
||||
/// <returns>True if it sorted correctly, false otherwise</returns>
|
||||
public static bool Sort(List<Rom> roms, bool norename)
|
||||
{
|
||||
try
|
||||
{
|
||||
roms.Sort(delegate (Rom x, Rom y)
|
||||
{
|
||||
@@ -248,6 +250,12 @@ namespace SabreTools.Helper
|
||||
});
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -514,6 +514,17 @@ namespace SabreTools.Helper
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// http://stackoverflow.com/questions/146134/how-to-remove-illegal-characters-from-path-and-filenames
|
||||
/// </summary>
|
||||
public static string StripInvalidPathChars(string s)
|
||||
{
|
||||
string regexSearch = new string(Path.GetInvalidFileNameChars()) + new string(Path.GetInvalidPathChars());
|
||||
Regex r = new Regex(string.Format("[{0}]", Regex.Escape(regexSearch)));
|
||||
s = r.Replace(s, "");
|
||||
return s;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user