diff --git a/SabreTools.DatItems/Adjuster.cs b/SabreTools.DatItems/Adjuster.cs
index 2ae87cfe..54756857 100644
--- a/SabreTools.DatItems/Adjuster.cs
+++ b/SabreTools.DatItems/Adjuster.cs
@@ -5,7 +5,6 @@ using System.Xml.Serialization;
using SabreTools.Core;
using SabreTools.Core.Tools;
-using SabreTools.Filtering;
using Newtonsoft.Json;
namespace SabreTools.DatItems
@@ -49,15 +48,18 @@ namespace SabreTools.DatItems
#region Accessors
- ///
- /// Gets the name to use for a DatItem
- ///
- /// Name if available, null otherwise
+ ///
public override string GetName()
{
return Name;
}
+ ///
+ public override void SetName(string name)
+ {
+ Name = name;
+ }
+
///
public override void SetFields(
Dictionary datItemMappings,
@@ -151,33 +153,6 @@ namespace SabreTools.DatItems
#region Filtering
- ///
- /// Clean a DatItem according to the cleaner
- ///
- /// Cleaner to implement
- public override void Clean(Cleaner cleaner)
- {
- // Clean common items first
- base.Clean(cleaner);
-
- // If we're stripping unicode characters, strip item name
- if (cleaner?.RemoveUnicode == true)
- Name = RemoveUnicodeCharacters(Name);
-
- // If we are in NTFS trim mode, trim the game name
- if (cleaner?.Trim == true)
- {
- // Windows max name length is 260
- int usableLength = 260 - Machine.Name.Length - (cleaner.Root?.Length ?? 0);
- if (Name.Length > usableLength)
- {
- string ext = Path.GetExtension(Name);
- Name = Name.Substring(0, usableLength - ext.Length);
- Name += ext;
- }
- }
- }
-
///
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
{
diff --git a/SabreTools.DatItems/Analog.cs b/SabreTools.DatItems/Analog.cs
index 9f8e9c36..3b8bc1c6 100644
--- a/SabreTools.DatItems/Analog.cs
+++ b/SabreTools.DatItems/Analog.cs
@@ -3,7 +3,6 @@ using System.Linq;
using System.Xml.Serialization;
using SabreTools.Core;
-using SabreTools.Filtering;
using Newtonsoft.Json;
namespace SabreTools.DatItems
diff --git a/SabreTools.DatItems/Archive.cs b/SabreTools.DatItems/Archive.cs
index 0a853711..7b840589 100644
--- a/SabreTools.DatItems/Archive.cs
+++ b/SabreTools.DatItems/Archive.cs
@@ -28,15 +28,18 @@ namespace SabreTools.DatItems
#region Accessors
- ///
- /// Gets the name to use for a DatItem
- ///
- /// Name if available, null otherwise
+ ///
public override string GetName()
{
return Name;
}
+ ///
+ public override void SetName(string name)
+ {
+ Name = name;
+ }
+
///
public override void SetFields(
Dictionary datItemMappings,
@@ -103,33 +106,6 @@ namespace SabreTools.DatItems
#region Filtering
- ///
- /// Clean a DatItem according to the cleaner
- ///
- /// Cleaner to implement
- public override void Clean(Cleaner cleaner)
- {
- // Clean common items first
- base.Clean(cleaner);
-
- // If we're stripping unicode characters, strip item name
- if (cleaner?.RemoveUnicode == true)
- Name = RemoveUnicodeCharacters(Name);
-
- // If we are in NTFS trim mode, trim the game name
- if (cleaner?.Trim == true)
- {
- // Windows max name length is 260
- int usableLength = 260 - Machine.Name.Length - (cleaner.Root?.Length ?? 0);
- if (Name.Length > usableLength)
- {
- string ext = Path.GetExtension(Name);
- Name = Name.Substring(0, usableLength - ext.Length);
- Name += ext;
- }
- }
- }
-
///
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
{
diff --git a/SabreTools.DatItems/BiosSet.cs b/SabreTools.DatItems/BiosSet.cs
index 8b162dd7..a9a42db2 100644
--- a/SabreTools.DatItems/BiosSet.cs
+++ b/SabreTools.DatItems/BiosSet.cs
@@ -46,15 +46,18 @@ namespace SabreTools.DatItems
#region Accessors
- ///
- /// Gets the name to use for a DatItem
- ///
- /// Name if available, null otherwise
+ ///
public override string GetName()
{
return Name;
}
+ ///
+ public override void SetName(string name)
+ {
+ Name = name;
+ }
+
///
public override void SetFields(
Dictionary datItemMappings,
@@ -131,33 +134,6 @@ namespace SabreTools.DatItems
#region Filtering
- ///
- /// Clean a DatItem according to the cleaner
- ///
- /// Cleaner to implement
- public override void Clean(Cleaner cleaner)
- {
- // Clean common items first
- base.Clean(cleaner);
-
- // If we're stripping unicode characters, strip item name
- if (cleaner?.RemoveUnicode == true)
- Name = RemoveUnicodeCharacters(Name);
-
- // If we are in NTFS trim mode, trim the game name
- if (cleaner?.Trim == true)
- {
- // Windows max name length is 260
- int usableLength = 260 - Machine.Name.Length - (cleaner.Root?.Length ?? 0);
- if (Name.Length > usableLength)
- {
- string ext = Path.GetExtension(Name);
- Name = Name.Substring(0, usableLength - ext.Length);
- Name += ext;
- }
- }
- }
-
///
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
{
diff --git a/SabreTools.DatItems/Chip.cs b/SabreTools.DatItems/Chip.cs
index a681ece4..a5400197 100644
--- a/SabreTools.DatItems/Chip.cs
+++ b/SabreTools.DatItems/Chip.cs
@@ -59,15 +59,18 @@ namespace SabreTools.DatItems
#region Accessors
- ///
- /// Gets the name to use for a DatItem
- ///
- /// Name if available, null otherwise
+ ///
public override string GetName()
{
return Name;
}
+ ///
+ public override void SetName(string name)
+ {
+ Name = name;
+ }
+
///
public override void SetFields(
Dictionary datItemMappings,
@@ -149,33 +152,6 @@ namespace SabreTools.DatItems
#region Filtering
- ///
- /// Clean a DatItem according to the cleaner
- ///
- /// Cleaner to implement
- public override void Clean(Cleaner cleaner)
- {
- // Clean common items first
- base.Clean(cleaner);
-
- // If we're stripping unicode characters, strip item name
- if (cleaner?.RemoveUnicode == true)
- Name = RemoveUnicodeCharacters(Name);
-
- // If we are in NTFS trim mode, trim the game name
- if (cleaner?.Trim == true)
- {
- // Windows max name length is 260
- int usableLength = 260 - Machine.Name.Length - (cleaner.Root?.Length ?? 0);
- if (Name.Length > usableLength)
- {
- string ext = Path.GetExtension(Name);
- Name = Name.Substring(0, usableLength - ext.Length);
- Name += ext;
- }
- }
- }
-
///
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
{
diff --git a/SabreTools.DatItems/Configuration.cs b/SabreTools.DatItems/Configuration.cs
index 3b084bcd..d9da6a77 100644
--- a/SabreTools.DatItems/Configuration.cs
+++ b/SabreTools.DatItems/Configuration.cs
@@ -72,15 +72,18 @@ namespace SabreTools.DatItems
#region Accessors
- ///
- /// Gets the name to use for a DatItem
- ///
- /// Name if available, null otherwise
+ ///
public override string GetName()
{
return Name;
}
+ ///
+ public override void SetName(string name)
+ {
+ Name = name;
+ }
+
///
public override void SetFields(
Dictionary datItemMappings,
@@ -215,33 +218,6 @@ namespace SabreTools.DatItems
#region Filtering
- ///
- /// Clean a DatItem according to the cleaner
- ///
- /// Cleaner to implement
- public override void Clean(Cleaner cleaner)
- {
- // Clean common items first
- base.Clean(cleaner);
-
- // If we're stripping unicode characters, strip item name
- if (cleaner?.RemoveUnicode == true)
- Name = RemoveUnicodeCharacters(Name);
-
- // If we are in NTFS trim mode, trim the game name
- if (cleaner?.Trim == true)
- {
- // Windows max name length is 260
- int usableLength = 260 - Machine.Name.Length - (cleaner.Root?.Length ?? 0);
- if (Name.Length > usableLength)
- {
- string ext = Path.GetExtension(Name);
- Name = Name.Substring(0, usableLength - ext.Length);
- Name += ext;
- }
- }
- }
-
///
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
{
diff --git a/SabreTools.DatItems/DatItem.cs b/SabreTools.DatItems/DatItem.cs
index d8b2d156..7e32c507 100644
--- a/SabreTools.DatItems/DatItem.cs
+++ b/SabreTools.DatItems/DatItem.cs
@@ -2,13 +2,11 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
-using System.Text.RegularExpressions;
using System.Xml.Serialization;
using SabreTools.Core;
using SabreTools.Core.Tools;
using SabreTools.FileTypes;
-using SabreTools.Filtering;
using SabreTools.Logging;
using NaturalSort;
using Newtonsoft.Json;
@@ -136,6 +134,14 @@ namespace SabreTools.DatItems
return null;
}
+ ///
+ /// Sets the name to use for a DatItem
+ ///
+ /// Name to set for the item
+ public virtual void SetName(string name)
+ {
+ }
+
///
/// Set fields with given values
///
@@ -454,31 +460,6 @@ namespace SabreTools.DatItems
#region Filtering
- ///
- /// Clean a DatItem according to the cleaner
- ///
- /// Cleaner to implement
- public virtual void Clean(Cleaner cleaner)
- {
- // If we're stripping unicode characters, strip machine name and description
- if (cleaner?.RemoveUnicode == true)
- {
- Machine.Name = RemoveUnicodeCharacters(Machine.Name);
- Machine.Description = RemoveUnicodeCharacters(Machine.Description);
- }
-
- // If we're in cleaning mode, sanitize machine name and description
- if (cleaner?.Clean == true)
- {
- Machine.Name = CleanGameName(Machine.Name);
- Machine.Description = CleanGameName(Machine.Description);
- }
-
- // If we are in single game mode, rename the machine
- if (cleaner?.Single == true)
- Machine.Name = "!";
- }
-
///
/// Check to see if a DatItem passes the filter
///
@@ -523,23 +504,6 @@ namespace SabreTools.DatItems
{
}
- ///
- /// Clean a game (or rom) name to the WoD standard
- ///
- /// Name of the game to be cleaned
- /// The cleaned name
- protected string CleanGameName(string game)
- {
- ///Run the name through the filters to make sure that it's correct
- game = NormalizeChars(game);
- game = RussianToLatin(game);
- game = SearchPattern(game);
-
- game = new Regex(@"(([[(].*[\)\]] )?([^([]+))").Match(game).Groups[1].Value;
- game = game.TrimStart().TrimEnd();
- return game;
- }
-
///
/// Clean a CRC32 string and pad to the correct size
///
@@ -612,16 +576,6 @@ namespace SabreTools.DatItems
return CleanHashData(hash, Constants.SHA512Length);
}
- ///
- /// Remove all unicode-specific chars from a string
- ///
- /// Input string to clean
- /// Cleaned string
- protected string RemoveUnicodeCharacters(string s)
- {
- return new string(s.Where(c => c <= 255).ToArray());
- }
-
///
/// Clean a hash string and pad to the correct size
///
@@ -665,135 +619,6 @@ namespace SabreTools.DatItems
return hash;
}
- ///
- /// Replace accented characters
- ///
- /// String to be parsed
- /// String with characters replaced
- private string NormalizeChars(string input)
- {
- string[,] charmap = {
- { "Á", "A" }, { "á", "a" },
- { "À", "A" }, { "à", "a" },
- { "Â", "A" }, { "â", "a" },
- { "Ä", "Ae" }, { "ä", "ae" },
- { "Ã", "A" }, { "ã", "a" },
- { "Å", "A" }, { "å", "a" },
- { "Æ", "Ae" }, { "æ", "ae" },
- { "Ç", "C" }, { "ç", "c" },
- { "Ð", "D" }, { "ð", "d" },
- { "É", "E" }, { "é", "e" },
- { "È", "E" }, { "è", "e" },
- { "Ê", "E" }, { "ê", "e" },
- { "Ë", "E" }, { "ë", "e" },
- { "ƒ", "f" },
- { "Í", "I" }, { "í", "i" },
- { "Ì", "I" }, { "ì", "i" },
- { "Î", "I" }, { "î", "i" },
- { "Ï", "I" }, { "ï", "i" },
- { "Ñ", "N" }, { "ñ", "n" },
- { "Ó", "O" }, { "ó", "o" },
- { "Ò", "O" }, { "ò", "o" },
- { "Ô", "O" }, { "ô", "o" },
- { "Ö", "Oe" }, { "ö", "oe" },
- { "Õ", "O" }, { "õ", "o" },
- { "Ø", "O" }, { "ø", "o" },
- { "Š", "S" }, { "š", "s" },
- { "ß", "ss" },
- { "Þ", "B" }, { "þ", "b" },
- { "Ú", "U" }, { "ú", "u" },
- { "Ù", "U" }, { "ù", "u" },
- { "Û", "U" }, { "û", "u" },
- { "Ü", "Ue" }, { "ü", "ue" },
- { "ÿ", "y" },
- { "Ý", "Y" }, { "ý", "y" },
- { "Ž", "Z" }, { "ž", "z" },
- };
-
- for (int i = 0; i < charmap.GetLength(0); i++)
- {
- input = input.Replace(charmap[i, 0], charmap[i, 1]);
- }
-
- return input;
- }
-
- ///
- /// Convert Cyrillic lettering to Latin lettering
- ///
- /// String to be parsed
- /// String with characters replaced
- private string RussianToLatin(string input)
- {
- string[,] charmap = {
- { "А", "A" }, { "Б", "B" }, { "В", "V" }, { "Г", "G" }, { "Д", "D" },
- { "Е", "E" }, { "Ё", "Yo" }, { "Ж", "Zh" }, { "З", "Z" }, { "И", "I" },
- { "Й", "J" }, { "К", "K" }, { "Л", "L" }, { "М", "M" }, { "Н", "N" },
- { "О", "O" }, { "П", "P" }, { "Р", "R" }, { "С", "S" }, { "Т", "T" },
- { "У", "U" }, { "Ф", "f" }, { "Х", "Kh" }, { "Ц", "Ts" }, { "Ч", "Ch" },
- { "Ш", "Sh" }, { "Щ", "Sch" }, { "Ъ", string.Empty }, { "Ы", "y" }, { "Ь", string.Empty },
- { "Э", "e" }, { "Ю", "yu" }, { "Я", "ya" }, { "а", "a" }, { "б", "b" },
- { "в", "v" }, { "г", "g" }, { "д", "d" }, { "е", "e" }, { "ё", "yo" },
- { "ж", "zh" }, { "з", "z" }, { "и", "i" }, { "й", "j" }, { "к", "k" },
- { "л", "l" }, { "м", "m" }, { "н", "n" }, { "о", "o" }, { "п", "p" },
- { "р", "r" }, { "с", "s" }, { "т", "t" }, { "у", "u" }, { "ф", "f" },
- { "х", "kh" }, { "ц", "ts" }, { "ч", "ch" }, { "ш", "sh" }, { "щ", "sch" },
- { "ъ", string.Empty }, { "ы", "y" }, { "ь", string.Empty }, { "э", "e" }, { "ю", "yu" },
- { "я", "ya" },
- };
-
- for (int i = 0; i < charmap.GetLength(0); i++)
- {
- input = input.Replace(charmap[i, 0], charmap[i, 1]);
- }
-
- return input;
- }
-
- ///
- /// Replace special characters and patterns
- ///
- /// String to be parsed
- /// String with characters replaced
- private string SearchPattern(string input)
- {
- string[,] charmap = {
- { @"~", " - " },
- { @"_", " " },
- { @":", " " },
- { @">", ")" },
- { @"<", "(" },
- { @"\|", "-" },
- { "\"", "'" },
- { @"\*", "." },
- { @"\\", "-" },
- { @"/", "-" },
- { @"\?", " " },
- { @"\(([^)(]*)\(([^)]*)\)([^)(]*)\)", " " },
- { @"\(([^)]+)\)", " " },
- { @"\[([^]]+)\]", " " },
- { @"\{([^}]+)\}", " " },
- { @"(ZZZJUNK|ZZZ-UNK-|ZZZ-UNK |zzz unknow |zzz unk |Copy of |[.][a-z]{3}[.][a-z]{3}[.]|[.][a-z]{3}[.])", " " },
- { @" (r|rev|v|ver)\s*[\d\.]+[^\s]*", " " },
- { @"(( )|(\A))(\d{6}|\d{8})(( )|(\Z))", " " },
- { @"(( )|(\A))(\d{1,2})-(\d{1,2})-(\d{4}|\d{2})", " " },
- { @"(( )|(\A))(\d{4}|\d{2})-(\d{1,2})-(\d{1,2})", " " },
- { @"[-]+", "-" },
- { @"\A\s*\)", " " },
- { @"\A\s*(,|-)", " " },
- { @"\s+", " " },
- { @"\s+,", "," },
- { @"\s*(,|-)\s*\Z", " " },
- };
-
- for (int i = 0; i < charmap.GetLength(0); i++)
- {
- input = Regex.Replace(input, charmap[i, 0], charmap[i, 1]);
- }
-
- return input;
- }
-
#endregion
#region Sorting and Merging
diff --git a/SabreTools.DatItems/DataArea.cs b/SabreTools.DatItems/DataArea.cs
index d72ff926..5dc98b8a 100644
--- a/SabreTools.DatItems/DataArea.cs
+++ b/SabreTools.DatItems/DataArea.cs
@@ -61,15 +61,18 @@ namespace SabreTools.DatItems
#region Accessors
- ///
- /// Gets the name to use for a DatItem
- ///
- /// Name if available, null otherwise
+ ///
public override string GetName()
{
return Name;
}
+ ///
+ public override void SetName(string name)
+ {
+ Name = name;
+ }
+
///
public override void SetFields(
Dictionary datItemMappings,
@@ -151,33 +154,6 @@ namespace SabreTools.DatItems
#region Filtering
- ///
- /// Clean a DatItem according to the cleaner
- ///
- /// Cleaner to implement
- public override void Clean(Cleaner cleaner)
- {
- // Clean common items first
- base.Clean(cleaner);
-
- // If we're stripping unicode characters, strip item name
- if (cleaner?.RemoveUnicode == true)
- Name = RemoveUnicodeCharacters(Name);
-
- // If we are in NTFS trim mode, trim the game name
- if (cleaner?.Trim == true)
- {
- // Windows max name length is 260
- int usableLength = 260 - Machine.Name.Length - (cleaner.Root?.Length ?? 0);
- if (Name.Length > usableLength)
- {
- string ext = Path.GetExtension(Name);
- Name = Name.Substring(0, usableLength - ext.Length);
- Name += ext;
- }
- }
- }
-
///
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
{
diff --git a/SabreTools.DatItems/DeviceReference.cs b/SabreTools.DatItems/DeviceReference.cs
index 878035fc..a15fbe02 100644
--- a/SabreTools.DatItems/DeviceReference.cs
+++ b/SabreTools.DatItems/DeviceReference.cs
@@ -28,15 +28,18 @@ namespace SabreTools.DatItems
#region Accessors
- ///
- /// Gets the name to use for a DatItem
- ///
- /// Name if available, null otherwise
+ ///
public override string GetName()
{
return Name;
}
+ ///
+ public override void SetName(string name)
+ {
+ Name = name;
+ }
+
///
public override void SetFields(
Dictionary datItemMappings,
@@ -103,33 +106,6 @@ namespace SabreTools.DatItems
#region Filtering
- ///
- /// Clean a DatItem according to the cleaner
- ///
- /// Cleaner to implement
- public override void Clean(Cleaner cleaner)
- {
- // Clean common items first
- base.Clean(cleaner);
-
- // If we're stripping unicode characters, strip item name
- if (cleaner?.RemoveUnicode == true)
- Name = RemoveUnicodeCharacters(Name);
-
- // If we are in NTFS trim mode, trim the game name
- if (cleaner?.Trim == true)
- {
- // Windows max name length is 260
- int usableLength = 260 - Machine.Name.Length - (cleaner.Root?.Length ?? 0);
- if (Name.Length > usableLength)
- {
- string ext = Path.GetExtension(Name);
- Name = Name.Substring(0, usableLength - ext.Length);
- Name += ext;
- }
- }
- }
-
///
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
{
diff --git a/SabreTools.DatItems/DipSwitch.cs b/SabreTools.DatItems/DipSwitch.cs
index 573f0bbd..c7d4da6b 100644
--- a/SabreTools.DatItems/DipSwitch.cs
+++ b/SabreTools.DatItems/DipSwitch.cs
@@ -98,15 +98,18 @@ namespace SabreTools.DatItems
#region Accessors
- ///
- /// Gets the name to use for a DatItem
- ///
- /// Name if available, null otherwise
+ ///
public override string GetName()
{
return Name;
}
+ ///
+ public override void SetName(string name)
+ {
+ Name = name;
+ }
+
///
public override void SetFields(
Dictionary datItemMappings,
@@ -262,33 +265,6 @@ namespace SabreTools.DatItems
#region Filtering
- ///
- /// Clean a DatItem according to the cleaner
- ///
- /// Cleaner to implement
- public override void Clean(Cleaner cleaner)
- {
- // Clean common items first
- base.Clean(cleaner);
-
- // If we're stripping unicode characters, strip item name
- if (cleaner?.RemoveUnicode == true)
- Name = RemoveUnicodeCharacters(Name);
-
- // If we are in NTFS trim mode, trim the game name
- if (cleaner?.Trim == true)
- {
- // Windows max name length is 260
- int usableLength = 260 - Machine.Name.Length - (cleaner.Root?.Length ?? 0);
- if (Name.Length > usableLength)
- {
- string ext = Path.GetExtension(Name);
- Name = Name.Substring(0, usableLength - ext.Length);
- Name += ext;
- }
- }
- }
-
///
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
{
diff --git a/SabreTools.DatItems/Disk.cs b/SabreTools.DatItems/Disk.cs
index ef5c3291..57af3662 100644
--- a/SabreTools.DatItems/Disk.cs
+++ b/SabreTools.DatItems/Disk.cs
@@ -155,15 +155,18 @@ namespace SabreTools.DatItems
#region Accessors
- ///
- /// Gets the name to use for a DatItem
- ///
- /// Name if available, null otherwise
+ ///
public override string GetName()
{
return Name;
}
+ ///
+ public override void SetName(string name)
+ {
+ Name = name;
+ }
+
///
public override void SetFields(
Dictionary datItemMappings,
@@ -422,33 +425,6 @@ namespace SabreTools.DatItems
#region Filtering
- ///
- /// Clean a DatItem according to the cleaner
- ///
- /// Cleaner to implement
- public override void Clean(Cleaner cleaner)
- {
- // Clean common items first
- base.Clean(cleaner);
-
- // If we're stripping unicode characters, strip item name
- if (cleaner?.RemoveUnicode == true)
- Name = RemoveUnicodeCharacters(Name);
-
- // If we are in NTFS trim mode, trim the game name
- if (cleaner?.Trim == true)
- {
- // Windows max name length is 260
- int usableLength = 260 - Machine.Name.Length - (cleaner.Root?.Length ?? 0);
- if (Name.Length > usableLength)
- {
- string ext = Path.GetExtension(Name);
- Name = Name.Substring(0, usableLength - ext.Length);
- Name += ext;
- }
- }
- }
-
///
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
{
diff --git a/SabreTools.DatItems/DiskArea.cs b/SabreTools.DatItems/DiskArea.cs
index 22d4136d..b8b09d55 100644
--- a/SabreTools.DatItems/DiskArea.cs
+++ b/SabreTools.DatItems/DiskArea.cs
@@ -30,15 +30,18 @@ namespace SabreTools.DatItems
#region Accessors
- ///
- /// Gets the name to use for a DatItem
- ///
- /// Name if available, null otherwise
+ ///
public override string GetName()
{
return Name;
}
+ ///
+ public override void SetName(string name)
+ {
+ Name = name;
+ }
+
///
public override void SetFields(
Dictionary datItemMappings,
@@ -105,33 +108,6 @@ namespace SabreTools.DatItems
#region Filtering
- ///
- /// Clean a DatItem according to the cleaner
- ///
- /// Cleaner to implement
- public override void Clean(Cleaner cleaner)
- {
- // Clean common items first
- base.Clean(cleaner);
-
- // If we're stripping unicode characters, strip item name
- if (cleaner?.RemoveUnicode == true)
- Name = RemoveUnicodeCharacters(Name);
-
- // If we are in NTFS trim mode, trim the game name
- if (cleaner?.Trim == true)
- {
- // Windows max name length is 260
- int usableLength = 260 - Machine.Name.Length - (cleaner.Root?.Length ?? 0);
- if (Name.Length > usableLength)
- {
- string ext = Path.GetExtension(Name);
- Name = Name.Substring(0, usableLength - ext.Length);
- Name += ext;
- }
- }
- }
-
///
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
{
diff --git a/SabreTools.DatItems/Extension.cs b/SabreTools.DatItems/Extension.cs
index 4086ebff..d17de568 100644
--- a/SabreTools.DatItems/Extension.cs
+++ b/SabreTools.DatItems/Extension.cs
@@ -28,15 +28,18 @@ namespace SabreTools.DatItems
#region Accessors
- ///
- /// Gets the name to use for a DatItem
- ///
- /// Name if available, null otherwise
+ ///
public override string GetName()
{
return Name;
}
+ ///
+ public override void SetName(string name)
+ {
+ Name = name;
+ }
+
///
public override void SetFields(
Dictionary datItemMappings,
@@ -103,33 +106,6 @@ namespace SabreTools.DatItems
#region Filtering
- ///
- /// Clean a DatItem according to the cleaner
- ///
- /// Cleaner to implement
- public override void Clean(Cleaner cleaner)
- {
- // Clean common items first
- base.Clean(cleaner);
-
- // If we're stripping unicode characters, strip item name
- if (cleaner?.RemoveUnicode == true)
- Name = RemoveUnicodeCharacters(Name);
-
- // If we are in NTFS trim mode, trim the game name
- if (cleaner?.Trim == true)
- {
- // Windows max name length is 260
- int usableLength = 260 - Machine.Name.Length - (cleaner.Root?.Length ?? 0);
- if (Name.Length > usableLength)
- {
- string ext = Path.GetExtension(Name);
- Name = Name.Substring(0, usableLength - ext.Length);
- Name += ext;
- }
- }
- }
-
///
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
{
diff --git a/SabreTools.DatItems/Info.cs b/SabreTools.DatItems/Info.cs
index 99d0f5f8..b44cf3bb 100644
--- a/SabreTools.DatItems/Info.cs
+++ b/SabreTools.DatItems/Info.cs
@@ -35,15 +35,18 @@ namespace SabreTools.DatItems
#region Accessors
- ///
- /// Gets the name to use for a DatItem
- ///
- /// Name if available, null otherwise
+ ///
public override string GetName()
{
return Name;
}
+ ///
+ public override void SetName(string name)
+ {
+ Name = name;
+ }
+
///
public override void SetFields(
Dictionary datItemMappings,
@@ -114,33 +117,6 @@ namespace SabreTools.DatItems
#region Filtering
- ///
- /// Clean a DatItem according to the cleaner
- ///
- /// Cleaner to implement
- public override void Clean(Cleaner cleaner)
- {
- // Clean common items first
- base.Clean(cleaner);
-
- // If we're stripping unicode characters, strip item name
- if (cleaner?.RemoveUnicode == true)
- Name = RemoveUnicodeCharacters(Name);
-
- // If we are in NTFS trim mode, trim the game name
- if (cleaner?.Trim == true)
- {
- // Windows max name length is 260
- int usableLength = 260 - Machine.Name.Length - (cleaner.Root?.Length ?? 0);
- if (Name.Length > usableLength)
- {
- string ext = Path.GetExtension(Name);
- Name = Name.Substring(0, usableLength - ext.Length);
- Name += ext;
- }
- }
- }
-
///
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
{
diff --git a/SabreTools.DatItems/Instance.cs b/SabreTools.DatItems/Instance.cs
index e2d5d5c7..2b6593ce 100644
--- a/SabreTools.DatItems/Instance.cs
+++ b/SabreTools.DatItems/Instance.cs
@@ -35,15 +35,18 @@ namespace SabreTools.DatItems
#region Accessors
- ///
- /// Gets the name to use for a DatItem
- ///
- /// Name if available, null otherwise
+ ///
public override string GetName()
{
return Name;
}
+ ///
+ public override void SetName(string name)
+ {
+ Name = name;
+ }
+
///
public override void SetFields(
Dictionary datItemMappings,
@@ -114,33 +117,6 @@ namespace SabreTools.DatItems
#region Filtering
- ///
- /// Clean a DatItem according to the cleaner
- ///
- /// Cleaner to implement
- public override void Clean(Cleaner cleaner)
- {
- // Clean common items first
- base.Clean(cleaner);
-
- // If we're stripping unicode characters, strip item name
- if (cleaner?.RemoveUnicode == true)
- Name = RemoveUnicodeCharacters(Name);
-
- // If we are in NTFS trim mode, trim the game name
- if (cleaner?.Trim == true)
- {
- // Windows max name length is 260
- int usableLength = 260 - Machine.Name.Length - (cleaner.Root?.Length ?? 0);
- if (Name.Length > usableLength)
- {
- string ext = Path.GetExtension(Name);
- Name = Name.Substring(0, usableLength - ext.Length);
- Name += ext;
- }
- }
- }
-
///
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
{
diff --git a/SabreTools.DatItems/Location.cs b/SabreTools.DatItems/Location.cs
index 5fa34df3..ec54e155 100644
--- a/SabreTools.DatItems/Location.cs
+++ b/SabreTools.DatItems/Location.cs
@@ -49,15 +49,18 @@ namespace SabreTools.DatItems
#region Accessors
- ///
- /// Gets the name to use for a DatItem
- ///
- /// Name if available, null otherwise
+ ///
public override string GetName()
{
return Name;
}
+ ///
+ public override void SetName(string name)
+ {
+ Name = name;
+ }
+
///
public override void SetFields(
Dictionary datItemMappings,
@@ -134,33 +137,6 @@ namespace SabreTools.DatItems
#region Filtering
- ///
- /// Clean a DatItem according to the cleaner
- ///
- /// Cleaner to implement
- public override void Clean(Cleaner cleaner)
- {
- // Clean common items first
- base.Clean(cleaner);
-
- // If we're stripping unicode characters, strip item name
- if (cleaner?.RemoveUnicode == true)
- Name = RemoveUnicodeCharacters(Name);
-
- // If we are in NTFS trim mode, trim the game name
- if (cleaner?.Trim == true)
- {
- // Windows max name length is 260
- int usableLength = 260 - Machine.Name.Length - (cleaner.Root?.Length ?? 0);
- if (Name.Length > usableLength)
- {
- string ext = Path.GetExtension(Name);
- Name = Name.Substring(0, usableLength - ext.Length);
- Name += ext;
- }
- }
- }
-
///
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
{
diff --git a/SabreTools.DatItems/Media.cs b/SabreTools.DatItems/Media.cs
index 7cb28bb0..f38d75b1 100644
--- a/SabreTools.DatItems/Media.cs
+++ b/SabreTools.DatItems/Media.cs
@@ -84,15 +84,18 @@ namespace SabreTools.DatItems
#region Accessors
- ///
- /// Gets the name to use for a DatItem
- ///
- /// Name if available, null otherwise
+ ///
public override string GetName()
{
return Name;
}
+ ///
+ public override void SetName(string name)
+ {
+ Name = name;
+ }
+
///
public override void SetFields(
Dictionary datItemMappings,
@@ -321,33 +324,6 @@ namespace SabreTools.DatItems
#region Filtering
- ///
- /// Clean a DatItem according to the cleaner
- ///
- /// Cleaner to implement
- public override void Clean(Cleaner cleaner)
- {
- // Clean common items first
- base.Clean(cleaner);
-
- // If we're stripping unicode characters, strip item name
- if (cleaner?.RemoveUnicode == true)
- Name = RemoveUnicodeCharacters(Name);
-
- // If we are in NTFS trim mode, trim the game name
- if (cleaner?.Trim == true)
- {
- // Windows max name length is 260
- int usableLength = 260 - Machine.Name.Length - (cleaner.Root?.Length ?? 0);
- if (Name.Length > usableLength)
- {
- string ext = Path.GetExtension(Name);
- Name = Name.Substring(0, usableLength - ext.Length);
- Name += ext;
- }
- }
- }
-
///
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
{
diff --git a/SabreTools.DatItems/Part.cs b/SabreTools.DatItems/Part.cs
index 49b78a37..166ed481 100644
--- a/SabreTools.DatItems/Part.cs
+++ b/SabreTools.DatItems/Part.cs
@@ -38,15 +38,18 @@ namespace SabreTools.DatItems
#region Accessors
- ///
- /// Gets the name to use for a DatItem
- ///
- /// Name if available, null otherwise
+ ///
public override string GetName()
{
return Name;
}
+ ///
+ public override void SetName(string name)
+ {
+ Name = name;
+ }
+
///
public override void SetFields(
Dictionary datItemMappings,
@@ -141,33 +144,6 @@ namespace SabreTools.DatItems
#region Filtering
- ///
- /// Clean a DatItem according to the cleaner
- ///
- /// Cleaner to implement
- public override void Clean(Cleaner cleaner)
- {
- // Clean common items first
- base.Clean(cleaner);
-
- // If we're stripping unicode characters, strip item name
- if (cleaner?.RemoveUnicode == true)
- Name = RemoveUnicodeCharacters(Name);
-
- // If we are in NTFS trim mode, trim the game name
- if (cleaner?.Trim == true)
- {
- // Windows max name length is 260
- int usableLength = 260 - Machine.Name.Length - (cleaner.Root?.Length ?? 0);
- if (Name.Length > usableLength)
- {
- string ext = Path.GetExtension(Name);
- Name = Name.Substring(0, usableLength - ext.Length);
- Name += ext;
- }
- }
- }
-
///
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
{
diff --git a/SabreTools.DatItems/PartFeature.cs b/SabreTools.DatItems/PartFeature.cs
index f214c8bd..d88ce9d3 100644
--- a/SabreTools.DatItems/PartFeature.cs
+++ b/SabreTools.DatItems/PartFeature.cs
@@ -35,15 +35,18 @@ namespace SabreTools.DatItems
#region Accessors
- ///
- /// Gets the name to use for a DatItem
- ///
- /// Name if available, null otherwise
+ ///
public override string GetName()
{
return Name;
}
+ ///
+ public override void SetName(string name)
+ {
+ Name = name;
+ }
+
///
public override void SetFields(
Dictionary datItemMappings,
@@ -114,33 +117,6 @@ namespace SabreTools.DatItems
#region Filtering
- ///
- /// Clean a DatItem according to the cleaner
- ///
- /// Cleaner to implement
- public override void Clean(Cleaner cleaner)
- {
- // Clean common items first
- base.Clean(cleaner);
-
- // If we're stripping unicode characters, strip item name
- if (cleaner?.RemoveUnicode == true)
- Name = RemoveUnicodeCharacters(Name);
-
- // If we are in NTFS trim mode, trim the game name
- if (cleaner?.Trim == true)
- {
- // Windows max name length is 260
- int usableLength = 260 - Machine.Name.Length - (cleaner.Root?.Length ?? 0);
- if (Name.Length > usableLength)
- {
- string ext = Path.GetExtension(Name);
- Name = Name.Substring(0, usableLength - ext.Length);
- Name += ext;
- }
- }
- }
-
///
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
{
diff --git a/SabreTools.DatItems/RamOption.cs b/SabreTools.DatItems/RamOption.cs
index 590b6e51..5d0798ae 100644
--- a/SabreTools.DatItems/RamOption.cs
+++ b/SabreTools.DatItems/RamOption.cs
@@ -46,15 +46,18 @@ namespace SabreTools.DatItems
#region Accessors
- ///
- /// Gets the name to use for a DatItem
- ///
- /// Name if available, null otherwise
+ ///
public override string GetName()
{
return Name;
}
+ ///
+ public override void SetName(string name)
+ {
+ Name = name;
+ }
+
///
public override void SetFields(
Dictionary datItemMappings,
@@ -129,33 +132,6 @@ namespace SabreTools.DatItems
#region Filtering
- ///
- /// Clean a DatItem according to the cleaner
- ///
- /// Cleaner to implement
- public override void Clean(Cleaner cleaner)
- {
- // Clean common items first
- base.Clean(cleaner);
-
- // If we're stripping unicode characters, strip item name
- if (cleaner?.RemoveUnicode == true)
- Name = RemoveUnicodeCharacters(Name);
-
- // If we are in NTFS trim mode, trim the game name
- if (cleaner?.Trim == true)
- {
- // Windows max name length is 260
- int usableLength = 260 - Machine.Name.Length - (cleaner.Root?.Length ?? 0);
- if (Name.Length > usableLength)
- {
- string ext = Path.GetExtension(Name);
- Name = Name.Substring(0, usableLength - ext.Length);
- Name += ext;
- }
- }
- }
-
///
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
{
diff --git a/SabreTools.DatItems/Release.cs b/SabreTools.DatItems/Release.cs
index 4e45f6c3..eac72d9c 100644
--- a/SabreTools.DatItems/Release.cs
+++ b/SabreTools.DatItems/Release.cs
@@ -60,15 +60,18 @@ namespace SabreTools.DatItems
#region Accessors
- ///
- /// Gets the name to use for a DatItem
- ///
- /// Name if available, null otherwise
+ ///
public override string GetName()
{
return Name;
}
+ ///
+ public override void SetName(string name)
+ {
+ Name = name;
+ }
+
///
public override void SetFields(
Dictionary datItemMappings,
@@ -159,33 +162,6 @@ namespace SabreTools.DatItems
#region Filtering
- ///
- /// Clean a DatItem according to the cleaner
- ///
- /// Cleaner to implement
- public override void Clean(Cleaner cleaner)
- {
- // Clean common items first
- base.Clean(cleaner);
-
- // If we're stripping unicode characters, strip item name
- if (cleaner?.RemoveUnicode == true)
- Name = RemoveUnicodeCharacters(Name);
-
- // If we are in NTFS trim mode, trim the game name
- if (cleaner?.Trim == true)
- {
- // Windows max name length is 260
- int usableLength = 260 - Machine.Name.Length - (cleaner.Root?.Length ?? 0);
- if (Name.Length > usableLength)
- {
- string ext = Path.GetExtension(Name);
- Name = Name.Substring(0, usableLength - ext.Length);
- Name += ext;
- }
- }
- }
-
///
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
{
diff --git a/SabreTools.DatItems/Rom.cs b/SabreTools.DatItems/Rom.cs
index 355e95a8..fc12b397 100644
--- a/SabreTools.DatItems/Rom.cs
+++ b/SabreTools.DatItems/Rom.cs
@@ -343,15 +343,18 @@ namespace SabreTools.DatItems
#region Accessors
- ///
- /// Gets the name to use for a DatItem
- ///
- /// Name if available, null otherwise
+ ///
public override string GetName()
{
return Name;
}
+ ///
+ public override void SetName(string name)
+ {
+ Name = name;
+ }
+
///
public override void SetFields(
Dictionary datItemMappings,
@@ -795,33 +798,6 @@ namespace SabreTools.DatItems
#region Filtering
- ///
- /// Clean a DatItem according to the cleaner
- ///
- /// Cleaner to implement
- public override void Clean(Cleaner cleaner)
- {
- // Clean common items first
- base.Clean(cleaner);
-
- // If we're stripping unicode characters, strip item name
- if (cleaner?.RemoveUnicode == true)
- Name = RemoveUnicodeCharacters(Name);
-
- // If we are in NTFS trim mode, trim the game name
- if (cleaner?.Trim == true)
- {
- // Windows max name length is 260
- int usableLength = 260 - Machine.Name.Length - (cleaner.Root?.Length ?? 0);
- if (Name.Length > usableLength)
- {
- string ext = Path.GetExtension(Name);
- Name = Name.Substring(0, usableLength - ext.Length);
- Name += ext;
- }
- }
- }
-
///
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
{
diff --git a/SabreTools.DatItems/SabreTools.DatItems.csproj b/SabreTools.DatItems/SabreTools.DatItems.csproj
index a27b27b9..99d50ee2 100644
--- a/SabreTools.DatItems/SabreTools.DatItems.csproj
+++ b/SabreTools.DatItems/SabreTools.DatItems.csproj
@@ -14,7 +14,6 @@
-
diff --git a/SabreTools.DatItems/Sample.cs b/SabreTools.DatItems/Sample.cs
index 28392417..00bfc904 100644
--- a/SabreTools.DatItems/Sample.cs
+++ b/SabreTools.DatItems/Sample.cs
@@ -28,15 +28,18 @@ namespace SabreTools.DatItems
#region Accessors
- ///
- /// Gets the name to use for a DatItem
- ///
- /// Name if available, null otherwise
+ ///
public override string GetName()
{
return Name;
}
+ ///
+ public override void SetName(string name)
+ {
+ Name = name;
+ }
+
///
public override void SetFields(
Dictionary datItemMappings,
@@ -103,33 +106,6 @@ namespace SabreTools.DatItems
#region Filtering
- ///
- /// Clean a DatItem according to the cleaner
- ///
- /// Cleaner to implement
- public override void Clean(Cleaner cleaner)
- {
- // Clean common items first
- base.Clean(cleaner);
-
- // If we're stripping unicode characters, strip item name
- if (cleaner?.RemoveUnicode == true)
- Name = RemoveUnicodeCharacters(Name);
-
- // If we are in NTFS trim mode, trim the game name
- if (cleaner?.Trim == true)
- {
- // Windows max name length is 260
- int usableLength = 260 - Machine.Name.Length - (cleaner.Root?.Length ?? 0);
- if (Name.Length > usableLength)
- {
- string ext = Path.GetExtension(Name);
- Name = Name.Substring(0, usableLength - ext.Length);
- Name += ext;
- }
- }
- }
-
///
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
{
diff --git a/SabreTools.DatItems/Setting.cs b/SabreTools.DatItems/Setting.cs
index 252f0743..9d061722 100644
--- a/SabreTools.DatItems/Setting.cs
+++ b/SabreTools.DatItems/Setting.cs
@@ -56,15 +56,18 @@ namespace SabreTools.DatItems
#region Accessors
- ///
- /// Gets the name to use for a DatItem
- ///
- /// Name if available, null otherwise
+ ///
public override string GetName()
{
return Name;
}
+ ///
+ public override void SetName(string name)
+ {
+ Name = name;
+ }
+
///
public override void SetFields(
Dictionary datItemMappings,
@@ -163,33 +166,6 @@ namespace SabreTools.DatItems
#region Filtering
- ///
- /// Clean a DatItem according to the cleaner
- ///
- /// Cleaner to implement
- public override void Clean(Cleaner cleaner)
- {
- // Clean common items first
- base.Clean(cleaner);
-
- // If we're stripping unicode characters, strip item name
- if (cleaner?.RemoveUnicode == true)
- Name = RemoveUnicodeCharacters(Name);
-
- // If we are in NTFS trim mode, trim the game name
- if (cleaner?.Trim == true)
- {
- // Windows max name length is 260
- int usableLength = 260 - Machine.Name.Length - (cleaner.Root?.Length ?? 0);
- if (Name.Length > usableLength)
- {
- string ext = Path.GetExtension(Name);
- Name = Name.Substring(0, usableLength - ext.Length);
- Name += ext;
- }
- }
- }
-
///
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
{
diff --git a/SabreTools.DatItems/SharedFeature.cs b/SabreTools.DatItems/SharedFeature.cs
index 0a259f76..25dfd7db 100644
--- a/SabreTools.DatItems/SharedFeature.cs
+++ b/SabreTools.DatItems/SharedFeature.cs
@@ -35,15 +35,18 @@ namespace SabreTools.DatItems
#region Accessors
- ///
- /// Gets the name to use for a DatItem
- ///
- /// Name if available, null otherwise
+ ///
public override string GetName()
{
return Name;
}
+ ///
+ public override void SetName(string name)
+ {
+ Name = name;
+ }
+
///
public override void SetFields(
Dictionary datItemMappings,
@@ -114,33 +117,6 @@ namespace SabreTools.DatItems
#region Filtering
- ///
- /// Clean a DatItem according to the cleaner
- ///
- /// Cleaner to implement
- public override void Clean(Cleaner cleaner)
- {
- // Clean common items first
- base.Clean(cleaner);
-
- // If we're stripping unicode characters, strip item name
- if (cleaner?.RemoveUnicode == true)
- Name = RemoveUnicodeCharacters(Name);
-
- // If we are in NTFS trim mode, trim the game name
- if (cleaner?.Trim == true)
- {
- // Windows max name length is 260
- int usableLength = 260 - Machine.Name.Length - (cleaner.Root?.Length ?? 0);
- if (Name.Length > usableLength)
- {
- string ext = Path.GetExtension(Name);
- Name = Name.Substring(0, usableLength - ext.Length);
- Name += ext;
- }
- }
- }
-
///
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
{
diff --git a/SabreTools.DatItems/Slot.cs b/SabreTools.DatItems/Slot.cs
index 4ce19980..5ac25d9f 100644
--- a/SabreTools.DatItems/Slot.cs
+++ b/SabreTools.DatItems/Slot.cs
@@ -38,15 +38,18 @@ namespace SabreTools.DatItems
#region Accessors
- ///
- /// Gets the name to use for a DatItem
- ///
- /// Name if available, null otherwise
+ ///
public override string GetName()
{
return Name;
}
+ ///
+ public override void SetName(string name)
+ {
+ Name = name;
+ }
+
///
public override void SetFields(
Dictionary datItemMappings,
@@ -135,33 +138,6 @@ namespace SabreTools.DatItems
#region Filtering
- ///
- /// Clean a DatItem according to the cleaner
- ///
- /// Cleaner to implement
- public override void Clean(Cleaner cleaner)
- {
- // Clean common items first
- base.Clean(cleaner);
-
- // If we're stripping unicode characters, strip item name
- if (cleaner?.RemoveUnicode == true)
- Name = RemoveUnicodeCharacters(Name);
-
- // If we are in NTFS trim mode, trim the game name
- if (cleaner?.Trim == true)
- {
- // Windows max name length is 260
- int usableLength = 260 - Machine.Name.Length - (cleaner.Root?.Length ?? 0);
- if (Name.Length > usableLength)
- {
- string ext = Path.GetExtension(Name);
- Name = Name.Substring(0, usableLength - ext.Length);
- Name += ext;
- }
- }
- }
-
///
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
{
diff --git a/SabreTools.DatItems/SlotOption.cs b/SabreTools.DatItems/SlotOption.cs
index 4ed751d5..5d4973bc 100644
--- a/SabreTools.DatItems/SlotOption.cs
+++ b/SabreTools.DatItems/SlotOption.cs
@@ -46,15 +46,18 @@ namespace SabreTools.DatItems
#region Accessors
- ///
- /// Gets the name to use for a DatItem
- ///
- /// Name if available, null otherwise
+ ///
public override string GetName()
{
return Name;
}
+ ///
+ public override void SetName(string name)
+ {
+ Name = name;
+ }
+
///
public override void SetFields(
Dictionary datItemMappings,
@@ -131,33 +134,6 @@ namespace SabreTools.DatItems
#region Filtering
- ///
- /// Clean a DatItem according to the cleaner
- ///
- /// Cleaner to implement
- public override void Clean(Cleaner cleaner)
- {
- // Clean common items first
- base.Clean(cleaner);
-
- // If we're stripping unicode characters, strip item name
- if (cleaner?.RemoveUnicode == true)
- Name = RemoveUnicodeCharacters(Name);
-
- // If we are in NTFS trim mode, trim the game name
- if (cleaner?.Trim == true)
- {
- // Windows max name length is 260
- int usableLength = 260 - Machine.Name.Length - (cleaner.Root?.Length ?? 0);
- if (Name.Length > usableLength)
- {
- string ext = Path.GetExtension(Name);
- Name = Name.Substring(0, usableLength - ext.Length);
- Name += ext;
- }
- }
- }
-
///
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
{
diff --git a/SabreTools.DatItems/SoftwareList.cs b/SabreTools.DatItems/SoftwareList.cs
index 88d6abf4..92d24a3e 100644
--- a/SabreTools.DatItems/SoftwareList.cs
+++ b/SabreTools.DatItems/SoftwareList.cs
@@ -48,15 +48,18 @@ namespace SabreTools.DatItems
#region Accessors
- ///
- /// Gets the name to use for a DatItem
- ///
- /// Name if available, null otherwise
+ ///
public override string GetName()
{
return Name;
}
+ ///
+ public override void SetName(string name)
+ {
+ Name = name;
+ }
+
///
public override void SetFields(
Dictionary datItemMappings,
@@ -133,33 +136,6 @@ namespace SabreTools.DatItems
#region Filtering
- ///
- /// Clean a DatItem according to the cleaner
- ///
- /// Cleaner to implement
- public override void Clean(Cleaner cleaner)
- {
- // Clean common items first
- base.Clean(cleaner);
-
- // If we're stripping unicode characters, strip item name
- if (cleaner?.RemoveUnicode == true)
- Name = RemoveUnicodeCharacters(Name);
-
- // If we are in NTFS trim mode, trim the game name
- if (cleaner?.Trim == true)
- {
- // Windows max name length is 260
- int usableLength = 260 - Machine.Name.Length - (cleaner.Root?.Length ?? 0);
- if (Name.Length > usableLength)
- {
- string ext = Path.GetExtension(Name);
- Name = Name.Substring(0, usableLength - ext.Length);
- Name += ext;
- }
- }
- }
-
///
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
{
diff --git a/SabreTools.DatTools/Modification.cs b/SabreTools.DatTools/Modification.cs
index 1e5634c0..17c030ad 100644
--- a/SabreTools.DatTools/Modification.cs
+++ b/SabreTools.DatTools/Modification.cs
@@ -584,7 +584,7 @@ namespace SabreTools.DatTools
continue;
// Run cleaning per item
- item.Clean(cleaner);
+ cleaner.CleanDatItem(item);
}
// Assign back for caution
diff --git a/SabreTools.Filtering/Cleaner.cs b/SabreTools.Filtering/Cleaner.cs
index 98e1536f..c1aaca03 100644
--- a/SabreTools.Filtering/Cleaner.cs
+++ b/SabreTools.Filtering/Cleaner.cs
@@ -1,6 +1,10 @@
using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text.RegularExpressions;
using SabreTools.Core;
+using SabreTools.DatItems;
namespace SabreTools.Filtering
{
@@ -9,6 +13,25 @@ namespace SabreTools.Filtering
///
public class Cleaner
{
+ #region Exclusion Fields
+
+ ///
+ /// Dictionary of DatHeader fields to exclude from writing
+ ///
+ public List ExcludeDatHeaderFields { get; set; } = new List();
+
+ ///
+ /// Dictionary of DatItem fields to exclude from writing
+ ///
+ public List ExcludeDatItemFields { get; set; } = new List();
+
+ ///
+ /// Dictionary of Machine fields to exclude from writing
+ ///
+ public List ExcludeMachineFields { get; set; } = new List();
+
+ #endregion
+
#region Filter Fields
///
@@ -45,21 +68,6 @@ namespace SabreTools.Filtering
///
public bool DescriptionAsName { get; set; }
- ///
- /// Dictionary of DatHeader fields to exclude from writing
- ///
- public List ExcludeDatHeaderFields { get; set; } = new List();
-
- ///
- /// Dictionary of DatItem fields to exclude from writing
- ///
- public List ExcludeDatItemFields { get; set; } = new List();
-
- ///
- /// Dictionary of Machine fields to exclude from writing
- ///
- public List ExcludeMachineFields { get; set; } = new List();
-
///
/// Keep machines that don't contain any items
///
@@ -105,6 +113,225 @@ namespace SabreTools.Filtering
///
public bool Trim { get; set; }
+ #endregion
+
+ #region Cleaning
+
+ ///
+ /// Clean a DatItem according to the cleaner
+ ///
+ /// DatItem to clean
+ public void CleanDatItem(DatItem datItem)
+ {
+ // If we're stripping unicode characters, strip machine name and description
+ if (RemoveUnicode == true)
+ {
+ datItem.Machine.Name = RemoveUnicodeCharacters(datItem.Machine.Name);
+ datItem.Machine.Description = RemoveUnicodeCharacters(datItem.Machine.Description);
+ datItem.SetName(RemoveUnicodeCharacters(datItem.GetName()));
+ }
+
+ // If we're in cleaning mode, sanitize machine name and description
+ if (Clean == true)
+ {
+ datItem.Machine.Name = CleanGameName(datItem.Machine.Name);
+ datItem.Machine.Description = CleanGameName(datItem.Machine.Description);
+ }
+
+ // If we are in single game mode, rename the machine
+ if (Single == true)
+ datItem.Machine.Name = "!";
+
+ // If we are in NTFS trim mode, trim the item name
+ if (Trim == true && datItem.GetName() != null)
+ {
+ // Windows max name length is 260
+ int usableLength = 260 - datItem.Machine.Name.Length - (Root?.Length ?? 0);
+ if (datItem.GetName().Length > usableLength)
+ {
+ string ext = Path.GetExtension(datItem.GetName());
+ datItem.SetName(datItem.GetName().Substring(0, usableLength - ext.Length) + ext);
+ }
+ }
+ }
+
+ ///
+ /// Clean a game (or rom) name to the WoD standard
+ ///
+ /// Name of the game to be cleaned
+ /// The cleaned name
+ private string CleanGameName(string game)
+ {
+ if (game == null)
+ return null;
+
+ ///Run the name through the filters to make sure that it's correct
+ game = NormalizeChars(game);
+ game = RussianToLatin(game);
+ game = SearchPattern(game);
+
+ game = new Regex(@"(([[(].*[\)\]] )?([^([]+))").Match(game).Groups[1].Value;
+ game = game.TrimStart().TrimEnd();
+ return game;
+ }
+
+ ///
+ /// Replace accented characters
+ ///
+ /// String to be parsed
+ /// String with characters replaced
+ private string NormalizeChars(string input)
+ {
+ if (input == null)
+ return null;
+
+ string[,] charmap = {
+ { "Á", "A" }, { "á", "a" },
+ { "À", "A" }, { "à", "a" },
+ { "Â", "A" }, { "â", "a" },
+ { "Ä", "Ae" }, { "ä", "ae" },
+ { "Ã", "A" }, { "ã", "a" },
+ { "Å", "A" }, { "å", "a" },
+ { "Æ", "Ae" }, { "æ", "ae" },
+ { "Ç", "C" }, { "ç", "c" },
+ { "Ð", "D" }, { "ð", "d" },
+ { "É", "E" }, { "é", "e" },
+ { "È", "E" }, { "è", "e" },
+ { "Ê", "E" }, { "ê", "e" },
+ { "Ë", "E" }, { "ë", "e" },
+ { "ƒ", "f" },
+ { "Í", "I" }, { "í", "i" },
+ { "Ì", "I" }, { "ì", "i" },
+ { "Î", "I" }, { "î", "i" },
+ { "Ï", "I" }, { "ï", "i" },
+ { "Ñ", "N" }, { "ñ", "n" },
+ { "Ó", "O" }, { "ó", "o" },
+ { "Ò", "O" }, { "ò", "o" },
+ { "Ô", "O" }, { "ô", "o" },
+ { "Ö", "Oe" }, { "ö", "oe" },
+ { "Õ", "O" }, { "õ", "o" },
+ { "Ø", "O" }, { "ø", "o" },
+ { "Š", "S" }, { "š", "s" },
+ { "ß", "ss" },
+ { "Þ", "B" }, { "þ", "b" },
+ { "Ú", "U" }, { "ú", "u" },
+ { "Ù", "U" }, { "ù", "u" },
+ { "Û", "U" }, { "û", "u" },
+ { "Ü", "Ue" }, { "ü", "ue" },
+ { "ÿ", "y" },
+ { "Ý", "Y" }, { "ý", "y" },
+ { "Ž", "Z" }, { "ž", "z" },
+ };
+
+ for (int i = 0; i < charmap.GetLength(0); i++)
+ {
+ input = input.Replace(charmap[i, 0], charmap[i, 1]);
+ }
+
+ return input;
+ }
+
+ ///
+ /// Remove all unicode-specific chars from a string
+ ///
+ /// Input string to clean
+ /// Cleaned string
+ private string RemoveUnicodeCharacters(string s)
+ {
+ if (s == null)
+ return null;
+
+ return new string(s.Where(c => c <= 255).ToArray());
+ }
+
+ ///
+ /// Convert Cyrillic lettering to Latin lettering
+ ///
+ /// String to be parsed
+ /// String with characters replaced
+ private string RussianToLatin(string input)
+ {
+ if (input == null)
+ return null;
+
+ string[,] charmap = {
+ { "А", "A" }, { "Б", "B" }, { "В", "V" }, { "Г", "G" }, { "Д", "D" },
+ { "Е", "E" }, { "Ё", "Yo" }, { "Ж", "Zh" }, { "З", "Z" }, { "И", "I" },
+ { "Й", "J" }, { "К", "K" }, { "Л", "L" }, { "М", "M" }, { "Н", "N" },
+ { "О", "O" }, { "П", "P" }, { "Р", "R" }, { "С", "S" }, { "Т", "T" },
+ { "У", "U" }, { "Ф", "f" }, { "Х", "Kh" }, { "Ц", "Ts" }, { "Ч", "Ch" },
+ { "Ш", "Sh" }, { "Щ", "Sch" }, { "Ъ", string.Empty }, { "Ы", "y" }, { "Ь", string.Empty },
+ { "Э", "e" }, { "Ю", "yu" }, { "Я", "ya" }, { "а", "a" }, { "б", "b" },
+ { "в", "v" }, { "г", "g" }, { "д", "d" }, { "е", "e" }, { "ё", "yo" },
+ { "ж", "zh" }, { "з", "z" }, { "и", "i" }, { "й", "j" }, { "к", "k" },
+ { "л", "l" }, { "м", "m" }, { "н", "n" }, { "о", "o" }, { "п", "p" },
+ { "р", "r" }, { "с", "s" }, { "т", "t" }, { "у", "u" }, { "ф", "f" },
+ { "х", "kh" }, { "ц", "ts" }, { "ч", "ch" }, { "ш", "sh" }, { "щ", "sch" },
+ { "ъ", string.Empty }, { "ы", "y" }, { "ь", string.Empty }, { "э", "e" }, { "ю", "yu" },
+ { "я", "ya" },
+ };
+
+ for (int i = 0; i < charmap.GetLength(0); i++)
+ {
+ input = input.Replace(charmap[i, 0], charmap[i, 1]);
+ }
+
+ return input;
+ }
+
+ ///
+ /// Replace special characters and patterns
+ ///
+ /// String to be parsed
+ /// String with characters replaced
+ private string SearchPattern(string input)
+ {
+ if (input == null)
+ return null;
+
+ string[,] charmap = {
+ { @"~", " - " },
+ { @"_", " " },
+ { @":", " " },
+ { @">", ")" },
+ { @"<", "(" },
+ { @"\|", "-" },
+ { "\"", "'" },
+ { @"\*", "." },
+ { @"\\", "-" },
+ { @"/", "-" },
+ { @"\?", " " },
+ { @"\(([^)(]*)\(([^)]*)\)([^)(]*)\)", " " },
+ { @"\(([^)]+)\)", " " },
+ { @"\[([^]]+)\]", " " },
+ { @"\{([^}]+)\}", " " },
+ { @"(ZZZJUNK|ZZZ-UNK-|ZZZ-UNK |zzz unknow |zzz unk |Copy of |[.][a-z]{3}[.][a-z]{3}[.]|[.][a-z]{3}[.])", " " },
+ { @" (r|rev|v|ver)\s*[\d\.]+[^\s]*", " " },
+ { @"(( )|(\A))(\d{6}|\d{8})(( )|(\Z))", " " },
+ { @"(( )|(\A))(\d{1,2})-(\d{1,2})-(\d{4}|\d{2})", " " },
+ { @"(( )|(\A))(\d{4}|\d{2})-(\d{1,2})-(\d{1,2})", " " },
+ { @"[-]+", "-" },
+ { @"\A\s*\)", " " },
+ { @"\A\s*(,|-)", " " },
+ { @"\s+", " " },
+ { @"\s+,", "," },
+ { @"\s*(,|-)\s*\Z", " " },
+ };
+
+ for (int i = 0; i < charmap.GetLength(0); i++)
+ {
+ input = Regex.Replace(input, charmap[i, 0], charmap[i, 1]);
+ }
+
+ return input;
+ }
+
+ #endregion
+
+ #region Filtering
+
+
+
#endregion
}
}
diff --git a/SabreTools.Filtering/SabreTools.Filtering.csproj b/SabreTools.Filtering/SabreTools.Filtering.csproj
index d1eae1b2..39cb3f4f 100644
--- a/SabreTools.Filtering/SabreTools.Filtering.csproj
+++ b/SabreTools.Filtering/SabreTools.Filtering.csproj
@@ -13,6 +13,7 @@
+