-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move pattern formatter to the common dumper code and use it in linux …
…build also add explicit invalid character filter for the resulting name that should fix #20
- Loading branch information
1 parent
2d4884a
commit 84d7e21
Showing
6 changed files
with
46 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System; | ||
using System.Collections.Specialized; | ||
using System.IO; | ||
using System.Linq; | ||
|
||
namespace Ps3DiscDumper.Utils | ||
{ | ||
public static class PatternFormatter | ||
{ | ||
public static string Format(string pattern, NameValueCollection items) | ||
{ | ||
if (string.IsNullOrEmpty(pattern)) | ||
return pattern; | ||
|
||
foreach (var k in items.AllKeys) | ||
pattern = pattern.Replace($"%{k}%", items[k]); | ||
pattern = pattern.Replace("®", "") | ||
.Replace("™", "") | ||
.Replace("(TM)", "") | ||
.Replace("(R)", ""); | ||
pattern = ReplaceInvalidChars(pattern); | ||
if (string.IsNullOrEmpty(pattern)) | ||
pattern = ReplaceInvalidChars($"{DateTime.Now:s}"); | ||
return pattern; | ||
} | ||
|
||
private static string ReplaceInvalidChars(string dirName) | ||
{ | ||
foreach (var invalidChar in Path.GetInvalidFileNameChars().Concat(Path.GetInvalidPathChars()).Distinct()) | ||
dirName = dirName.Replace(invalidChar, '_'); | ||
return dirName; | ||
} | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
UI.WinForms.Msil/Patterns.cs → Ps3DiscDumper/Utils/Patterns.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters