mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
DatItems don't know about cleaning (nw)
This commit is contained in:
@@ -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
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name to use for a DatItem
|
||||
/// </summary>
|
||||
/// <returns>Name if available, null otherwise</returns>
|
||||
/// <inheritdoc/>
|
||||
public override string GetName()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetName(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
@@ -151,33 +153,6 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Filtering
|
||||
|
||||
/// <summary>
|
||||
/// Clean a DatItem according to the cleaner
|
||||
/// </summary>
|
||||
/// <param name="cleaner">Cleaner to implement</param>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
|
||||
@@ -3,7 +3,6 @@ using System.Linq;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
using SabreTools.Core;
|
||||
using SabreTools.Filtering;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace SabreTools.DatItems
|
||||
|
||||
@@ -28,15 +28,18 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Accessors
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name to use for a DatItem
|
||||
/// </summary>
|
||||
/// <returns>Name if available, null otherwise</returns>
|
||||
/// <inheritdoc/>
|
||||
public override string GetName()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetName(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
@@ -103,33 +106,6 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Filtering
|
||||
|
||||
/// <summary>
|
||||
/// Clean a DatItem according to the cleaner
|
||||
/// </summary>
|
||||
/// <param name="cleaner">Cleaner to implement</param>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
|
||||
@@ -46,15 +46,18 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Accessors
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name to use for a DatItem
|
||||
/// </summary>
|
||||
/// <returns>Name if available, null otherwise</returns>
|
||||
/// <inheritdoc/>
|
||||
public override string GetName()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetName(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
@@ -131,33 +134,6 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Filtering
|
||||
|
||||
/// <summary>
|
||||
/// Clean a DatItem according to the cleaner
|
||||
/// </summary>
|
||||
/// <param name="cleaner">Cleaner to implement</param>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
|
||||
@@ -59,15 +59,18 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Accessors
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name to use for a DatItem
|
||||
/// </summary>
|
||||
/// <returns>Name if available, null otherwise</returns>
|
||||
/// <inheritdoc/>
|
||||
public override string GetName()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetName(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
@@ -149,33 +152,6 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Filtering
|
||||
|
||||
/// <summary>
|
||||
/// Clean a DatItem according to the cleaner
|
||||
/// </summary>
|
||||
/// <param name="cleaner">Cleaner to implement</param>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
|
||||
@@ -72,15 +72,18 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Accessors
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name to use for a DatItem
|
||||
/// </summary>
|
||||
/// <returns>Name if available, null otherwise</returns>
|
||||
/// <inheritdoc/>
|
||||
public override string GetName()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetName(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
@@ -215,33 +218,6 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Filtering
|
||||
|
||||
/// <summary>
|
||||
/// Clean a DatItem according to the cleaner
|
||||
/// </summary>
|
||||
/// <param name="cleaner">Cleaner to implement</param>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the name to use for a DatItem
|
||||
/// </summary>
|
||||
/// <param name="name">Name to set for the item</param>
|
||||
public virtual void SetName(string name)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set fields with given values
|
||||
/// </summary>
|
||||
@@ -454,31 +460,6 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Filtering
|
||||
|
||||
/// <summary>
|
||||
/// Clean a DatItem according to the cleaner
|
||||
/// </summary>
|
||||
/// <param name="cleaner">Cleaner to implement</param>
|
||||
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 = "!";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check to see if a DatItem passes the filter
|
||||
/// </summary>
|
||||
@@ -523,23 +504,6 @@ namespace SabreTools.DatItems
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clean a game (or rom) name to the WoD standard
|
||||
/// </summary>
|
||||
/// <param name="game">Name of the game to be cleaned</param>
|
||||
/// <returns>The cleaned name</returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clean a CRC32 string and pad to the correct size
|
||||
/// </summary>
|
||||
@@ -612,16 +576,6 @@ namespace SabreTools.DatItems
|
||||
return CleanHashData(hash, Constants.SHA512Length);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove all unicode-specific chars from a string
|
||||
/// </summary>
|
||||
/// <param name="s">Input string to clean</param>
|
||||
/// <returns>Cleaned string</returns>
|
||||
protected string RemoveUnicodeCharacters(string s)
|
||||
{
|
||||
return new string(s.Where(c => c <= 255).ToArray());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clean a hash string and pad to the correct size
|
||||
/// </summary>
|
||||
@@ -665,135 +619,6 @@ namespace SabreTools.DatItems
|
||||
return hash;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Replace accented characters
|
||||
/// </summary>
|
||||
/// <param name="input">String to be parsed</param>
|
||||
/// <returns>String with characters replaced</returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert Cyrillic lettering to Latin lettering
|
||||
/// </summary>
|
||||
/// <param name="input">String to be parsed</param>
|
||||
/// <returns>String with characters replaced</returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Replace special characters and patterns
|
||||
/// </summary>
|
||||
/// <param name="input">String to be parsed</param>
|
||||
/// <returns>String with characters replaced</returns>
|
||||
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
|
||||
|
||||
@@ -61,15 +61,18 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Accessors
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name to use for a DatItem
|
||||
/// </summary>
|
||||
/// <returns>Name if available, null otherwise</returns>
|
||||
/// <inheritdoc/>
|
||||
public override string GetName()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetName(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
@@ -151,33 +154,6 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Filtering
|
||||
|
||||
/// <summary>
|
||||
/// Clean a DatItem according to the cleaner
|
||||
/// </summary>
|
||||
/// <param name="cleaner">Cleaner to implement</param>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
|
||||
@@ -28,15 +28,18 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Accessors
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name to use for a DatItem
|
||||
/// </summary>
|
||||
/// <returns>Name if available, null otherwise</returns>
|
||||
/// <inheritdoc/>
|
||||
public override string GetName()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetName(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
@@ -103,33 +106,6 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Filtering
|
||||
|
||||
/// <summary>
|
||||
/// Clean a DatItem according to the cleaner
|
||||
/// </summary>
|
||||
/// <param name="cleaner">Cleaner to implement</param>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
|
||||
@@ -98,15 +98,18 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Accessors
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name to use for a DatItem
|
||||
/// </summary>
|
||||
/// <returns>Name if available, null otherwise</returns>
|
||||
/// <inheritdoc/>
|
||||
public override string GetName()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetName(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
@@ -262,33 +265,6 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Filtering
|
||||
|
||||
/// <summary>
|
||||
/// Clean a DatItem according to the cleaner
|
||||
/// </summary>
|
||||
/// <param name="cleaner">Cleaner to implement</param>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
|
||||
@@ -155,15 +155,18 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Accessors
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name to use for a DatItem
|
||||
/// </summary>
|
||||
/// <returns>Name if available, null otherwise</returns>
|
||||
/// <inheritdoc/>
|
||||
public override string GetName()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetName(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
@@ -422,33 +425,6 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Filtering
|
||||
|
||||
/// <summary>
|
||||
/// Clean a DatItem according to the cleaner
|
||||
/// </summary>
|
||||
/// <param name="cleaner">Cleaner to implement</param>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
|
||||
@@ -30,15 +30,18 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Accessors
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name to use for a DatItem
|
||||
/// </summary>
|
||||
/// <returns>Name if available, null otherwise</returns>
|
||||
/// <inheritdoc/>
|
||||
public override string GetName()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetName(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
@@ -105,33 +108,6 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Filtering
|
||||
|
||||
/// <summary>
|
||||
/// Clean a DatItem according to the cleaner
|
||||
/// </summary>
|
||||
/// <param name="cleaner">Cleaner to implement</param>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
|
||||
@@ -28,15 +28,18 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Accessors
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name to use for a DatItem
|
||||
/// </summary>
|
||||
/// <returns>Name if available, null otherwise</returns>
|
||||
/// <inheritdoc/>
|
||||
public override string GetName()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetName(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
@@ -103,33 +106,6 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Filtering
|
||||
|
||||
/// <summary>
|
||||
/// Clean a DatItem according to the cleaner
|
||||
/// </summary>
|
||||
/// <param name="cleaner">Cleaner to implement</param>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
|
||||
@@ -35,15 +35,18 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Accessors
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name to use for a DatItem
|
||||
/// </summary>
|
||||
/// <returns>Name if available, null otherwise</returns>
|
||||
/// <inheritdoc/>
|
||||
public override string GetName()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetName(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
@@ -114,33 +117,6 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Filtering
|
||||
|
||||
/// <summary>
|
||||
/// Clean a DatItem according to the cleaner
|
||||
/// </summary>
|
||||
/// <param name="cleaner">Cleaner to implement</param>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
|
||||
@@ -35,15 +35,18 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Accessors
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name to use for a DatItem
|
||||
/// </summary>
|
||||
/// <returns>Name if available, null otherwise</returns>
|
||||
/// <inheritdoc/>
|
||||
public override string GetName()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetName(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
@@ -114,33 +117,6 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Filtering
|
||||
|
||||
/// <summary>
|
||||
/// Clean a DatItem according to the cleaner
|
||||
/// </summary>
|
||||
/// <param name="cleaner">Cleaner to implement</param>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
|
||||
@@ -49,15 +49,18 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Accessors
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name to use for a DatItem
|
||||
/// </summary>
|
||||
/// <returns>Name if available, null otherwise</returns>
|
||||
/// <inheritdoc/>
|
||||
public override string GetName()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetName(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
@@ -134,33 +137,6 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Filtering
|
||||
|
||||
/// <summary>
|
||||
/// Clean a DatItem according to the cleaner
|
||||
/// </summary>
|
||||
/// <param name="cleaner">Cleaner to implement</param>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
|
||||
@@ -84,15 +84,18 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Accessors
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name to use for a DatItem
|
||||
/// </summary>
|
||||
/// <returns>Name if available, null otherwise</returns>
|
||||
/// <inheritdoc/>
|
||||
public override string GetName()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetName(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
@@ -321,33 +324,6 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Filtering
|
||||
|
||||
/// <summary>
|
||||
/// Clean a DatItem according to the cleaner
|
||||
/// </summary>
|
||||
/// <param name="cleaner">Cleaner to implement</param>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
|
||||
@@ -38,15 +38,18 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Accessors
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name to use for a DatItem
|
||||
/// </summary>
|
||||
/// <returns>Name if available, null otherwise</returns>
|
||||
/// <inheritdoc/>
|
||||
public override string GetName()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetName(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
@@ -141,33 +144,6 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Filtering
|
||||
|
||||
/// <summary>
|
||||
/// Clean a DatItem according to the cleaner
|
||||
/// </summary>
|
||||
/// <param name="cleaner">Cleaner to implement</param>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
|
||||
@@ -35,15 +35,18 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Accessors
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name to use for a DatItem
|
||||
/// </summary>
|
||||
/// <returns>Name if available, null otherwise</returns>
|
||||
/// <inheritdoc/>
|
||||
public override string GetName()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetName(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
@@ -114,33 +117,6 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Filtering
|
||||
|
||||
/// <summary>
|
||||
/// Clean a DatItem according to the cleaner
|
||||
/// </summary>
|
||||
/// <param name="cleaner">Cleaner to implement</param>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
|
||||
@@ -46,15 +46,18 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Accessors
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name to use for a DatItem
|
||||
/// </summary>
|
||||
/// <returns>Name if available, null otherwise</returns>
|
||||
/// <inheritdoc/>
|
||||
public override string GetName()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetName(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
@@ -129,33 +132,6 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Filtering
|
||||
|
||||
/// <summary>
|
||||
/// Clean a DatItem according to the cleaner
|
||||
/// </summary>
|
||||
/// <param name="cleaner">Cleaner to implement</param>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
|
||||
@@ -60,15 +60,18 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Accessors
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name to use for a DatItem
|
||||
/// </summary>
|
||||
/// <returns>Name if available, null otherwise</returns>
|
||||
/// <inheritdoc/>
|
||||
public override string GetName()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetName(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
@@ -159,33 +162,6 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Filtering
|
||||
|
||||
/// <summary>
|
||||
/// Clean a DatItem according to the cleaner
|
||||
/// </summary>
|
||||
/// <param name="cleaner">Cleaner to implement</param>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
|
||||
@@ -343,15 +343,18 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Accessors
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name to use for a DatItem
|
||||
/// </summary>
|
||||
/// <returns>Name if available, null otherwise</returns>
|
||||
/// <inheritdoc/>
|
||||
public override string GetName()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetName(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
@@ -795,33 +798,6 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Filtering
|
||||
|
||||
/// <summary>
|
||||
/// Clean a DatItem according to the cleaner
|
||||
/// </summary>
|
||||
/// <param name="cleaner">Cleaner to implement</param>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\SabreTools.Core\SabreTools.Core.csproj" />
|
||||
<ProjectReference Include="..\SabreTools.FileTypes\SabreTools.FileTypes.csproj" />
|
||||
<ProjectReference Include="..\SabreTools.Filtering\SabreTools.Filtering.csproj" />
|
||||
<ProjectReference Include="..\SabreTools.Logging\SabreTools.Logging.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -28,15 +28,18 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Accessors
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name to use for a DatItem
|
||||
/// </summary>
|
||||
/// <returns>Name if available, null otherwise</returns>
|
||||
/// <inheritdoc/>
|
||||
public override string GetName()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetName(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
@@ -103,33 +106,6 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Filtering
|
||||
|
||||
/// <summary>
|
||||
/// Clean a DatItem according to the cleaner
|
||||
/// </summary>
|
||||
/// <param name="cleaner">Cleaner to implement</param>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
|
||||
@@ -56,15 +56,18 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Accessors
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name to use for a DatItem
|
||||
/// </summary>
|
||||
/// <returns>Name if available, null otherwise</returns>
|
||||
/// <inheritdoc/>
|
||||
public override string GetName()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetName(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
@@ -163,33 +166,6 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Filtering
|
||||
|
||||
/// <summary>
|
||||
/// Clean a DatItem according to the cleaner
|
||||
/// </summary>
|
||||
/// <param name="cleaner">Cleaner to implement</param>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
|
||||
@@ -35,15 +35,18 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Accessors
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name to use for a DatItem
|
||||
/// </summary>
|
||||
/// <returns>Name if available, null otherwise</returns>
|
||||
/// <inheritdoc/>
|
||||
public override string GetName()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetName(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
@@ -114,33 +117,6 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Filtering
|
||||
|
||||
/// <summary>
|
||||
/// Clean a DatItem according to the cleaner
|
||||
/// </summary>
|
||||
/// <param name="cleaner">Cleaner to implement</param>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
|
||||
@@ -38,15 +38,18 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Accessors
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name to use for a DatItem
|
||||
/// </summary>
|
||||
/// <returns>Name if available, null otherwise</returns>
|
||||
/// <inheritdoc/>
|
||||
public override string GetName()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetName(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
@@ -135,33 +138,6 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Filtering
|
||||
|
||||
/// <summary>
|
||||
/// Clean a DatItem according to the cleaner
|
||||
/// </summary>
|
||||
/// <param name="cleaner">Cleaner to implement</param>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
|
||||
@@ -46,15 +46,18 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Accessors
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name to use for a DatItem
|
||||
/// </summary>
|
||||
/// <returns>Name if available, null otherwise</returns>
|
||||
/// <inheritdoc/>
|
||||
public override string GetName()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetName(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
@@ -131,33 +134,6 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Filtering
|
||||
|
||||
/// <summary>
|
||||
/// Clean a DatItem according to the cleaner
|
||||
/// </summary>
|
||||
/// <param name="cleaner">Cleaner to implement</param>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
|
||||
@@ -48,15 +48,18 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Accessors
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name to use for a DatItem
|
||||
/// </summary>
|
||||
/// <returns>Name if available, null otherwise</returns>
|
||||
/// <inheritdoc/>
|
||||
public override string GetName()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetName(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void SetFields(
|
||||
Dictionary<DatItemField, string> datItemMappings,
|
||||
@@ -133,33 +136,6 @@ namespace SabreTools.DatItems
|
||||
|
||||
#region Filtering
|
||||
|
||||
/// <summary>
|
||||
/// Clean a DatItem according to the cleaner
|
||||
/// </summary>
|
||||
/// <param name="cleaner">Cleaner to implement</param>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool PassesFilter(Cleaner cleaner, bool sub = false)
|
||||
{
|
||||
|
||||
@@ -584,7 +584,7 @@ namespace SabreTools.DatTools
|
||||
continue;
|
||||
|
||||
// Run cleaning per item
|
||||
item.Clean(cleaner);
|
||||
cleaner.CleanDatItem(item);
|
||||
}
|
||||
|
||||
// Assign back for caution
|
||||
|
||||
@@ -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
|
||||
/// </summary>
|
||||
public class Cleaner
|
||||
{
|
||||
#region Exclusion Fields
|
||||
|
||||
/// <summary>
|
||||
/// Dictionary of DatHeader fields to exclude from writing
|
||||
/// </summary>
|
||||
public List<DatHeaderField> ExcludeDatHeaderFields { get; set; } = new List<DatHeaderField>();
|
||||
|
||||
/// <summary>
|
||||
/// Dictionary of DatItem fields to exclude from writing
|
||||
/// </summary>
|
||||
public List<DatItemField> ExcludeDatItemFields { get; set; } = new List<DatItemField>();
|
||||
|
||||
/// <summary>
|
||||
/// Dictionary of Machine fields to exclude from writing
|
||||
/// </summary>
|
||||
public List<MachineField> ExcludeMachineFields { get; set; } = new List<MachineField>();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Filter Fields
|
||||
|
||||
/// <summary>
|
||||
@@ -45,21 +68,6 @@ namespace SabreTools.Filtering
|
||||
/// </summary>
|
||||
public bool DescriptionAsName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Dictionary of DatHeader fields to exclude from writing
|
||||
/// </summary>
|
||||
public List<DatHeaderField> ExcludeDatHeaderFields { get; set; } = new List<DatHeaderField>();
|
||||
|
||||
/// <summary>
|
||||
/// Dictionary of DatItem fields to exclude from writing
|
||||
/// </summary>
|
||||
public List<DatItemField> ExcludeDatItemFields { get; set; } = new List<DatItemField>();
|
||||
|
||||
/// <summary>
|
||||
/// Dictionary of Machine fields to exclude from writing
|
||||
/// </summary>
|
||||
public List<MachineField> ExcludeMachineFields { get; set; } = new List<MachineField>();
|
||||
|
||||
/// <summary>
|
||||
/// Keep machines that don't contain any items
|
||||
/// </summary>
|
||||
@@ -105,6 +113,225 @@ namespace SabreTools.Filtering
|
||||
/// </summary>
|
||||
public bool Trim { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Cleaning
|
||||
|
||||
/// <summary>
|
||||
/// Clean a DatItem according to the cleaner
|
||||
/// </summary>
|
||||
/// <param name="datItem">DatItem to clean</param>
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clean a game (or rom) name to the WoD standard
|
||||
/// </summary>
|
||||
/// <param name="game">Name of the game to be cleaned</param>
|
||||
/// <returns>The cleaned name</returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Replace accented characters
|
||||
/// </summary>
|
||||
/// <param name="input">String to be parsed</param>
|
||||
/// <returns>String with characters replaced</returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove all unicode-specific chars from a string
|
||||
/// </summary>
|
||||
/// <param name="s">Input string to clean</param>
|
||||
/// <returns>Cleaned string</returns>
|
||||
private string RemoveUnicodeCharacters(string s)
|
||||
{
|
||||
if (s == null)
|
||||
return null;
|
||||
|
||||
return new string(s.Where(c => c <= 255).ToArray());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert Cyrillic lettering to Latin lettering
|
||||
/// </summary>
|
||||
/// <param name="input">String to be parsed</param>
|
||||
/// <returns>String with characters replaced</returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Replace special characters and patterns
|
||||
/// </summary>
|
||||
/// <param name="input">String to be parsed</param>
|
||||
/// <returns>String with characters replaced</returns>
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\SabreTools.Core\SabreTools.Core.csproj" />
|
||||
<ProjectReference Include="..\SabreTools.DatItems\SabreTools.DatItems.csproj" />
|
||||
<ProjectReference Include="..\SabreTools.IO\SabreTools.IO.csproj" />
|
||||
<ProjectReference Include="..\SabreTools.Logging\SabreTools.Logging.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user