diff --git a/SabreTools.Core/Tools/Sanitizer.cs b/SabreTools.Core/Tools/Sanitizer.cs deleted file mode 100644 index 8bfe4865..00000000 --- a/SabreTools.Core/Tools/Sanitizer.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; - -namespace SabreTools.Core.Tools -{ - public static class Sanitizer - { - /// - /// Get a sanitized size from an input string - /// - /// String to get value from - /// Size as a long?, if possible - public static long? CleanLong(string input) - { - long? size = null; - if (input != null && input.Contains("0x")) - size = Convert.ToInt64(input, 16); - - else if (input != null) - { - if (Int64.TryParse(input, out long longSize)) - size = longSize; - } - - return size; - } - - /// - /// Remove all chars that are considered path unsafe - /// - /// Input string to clean - /// Cleaned string - public static string RemovePathUnsafeCharacters(string s) - { - List invalidPath = Path.GetInvalidPathChars().ToList(); - return new string(s.Where(c => !invalidPath.Contains(c)).ToArray()); - } - } -} diff --git a/SabreTools.Core/Tools/Utilities.cs b/SabreTools.Core/Tools/Utilities.cs index bedd9dd6..5b5002b9 100644 --- a/SabreTools.Core/Tools/Utilities.cs +++ b/SabreTools.Core/Tools/Utilities.cs @@ -1,4 +1,7 @@ using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; namespace SabreTools.Core.Tools { @@ -59,6 +62,26 @@ namespace SabreTools.Core.Tools } } + /// + /// Get a sanitized size from an input string + /// + /// String to get value from + /// Size as a long?, if possible + public static long? CleanLong(string input) + { + long? size = null; + if (input != null && input.Contains("0x")) + size = Convert.ToInt64(input, 16); + + else if (input != null) + { + if (Int64.TryParse(input, out long longSize)) + size = longSize; + } + + return size; + } + /// /// Convert .NET DateTime to MS-DOS date format /// @@ -102,5 +125,16 @@ namespace SabreTools.Core.Tools { return (array == null || array.Length == 0); } + + /// + /// Remove all chars that are considered path unsafe + /// + /// Input string to clean + /// Cleaned string + public static string RemovePathUnsafeCharacters(string s) + { + List invalidPath = Path.GetInvalidPathChars().ToList(); + return new string(s.Where(c => !invalidPath.Contains(c)).ToArray()); + } } } diff --git a/SabreTools.DatFiles/Formats/ClrMamePro.cs b/SabreTools.DatFiles/Formats/ClrMamePro.cs index 903ae476..36405945 100644 --- a/SabreTools.DatFiles/Formats/ClrMamePro.cs +++ b/SabreTools.DatFiles/Formats/ClrMamePro.cs @@ -311,7 +311,7 @@ namespace SabreTools.DatFiles.Formats case "size": if (item.ItemType == ItemType.Rom) - (item as Rom).Size = Sanitizer.CleanLong(attrVal); + (item as Rom).Size = Utilities.CleanLong(attrVal); break; case "crc": diff --git a/SabreTools.DatFiles/Formats/DosCenter.cs b/SabreTools.DatFiles/Formats/DosCenter.cs index 868517dc..606e808c 100644 --- a/SabreTools.DatFiles/Formats/DosCenter.cs +++ b/SabreTools.DatFiles/Formats/DosCenter.cs @@ -224,7 +224,7 @@ namespace SabreTools.DatFiles.Formats break; case "size": - item.Size = Sanitizer.CleanLong(attrVal); + item.Size = Utilities.CleanLong(attrVal); break; case "crc": diff --git a/SabreTools.DatFiles/Formats/Listrom.cs b/SabreTools.DatFiles/Formats/Listrom.cs index b4796685..a83c07c7 100644 --- a/SabreTools.DatFiles/Formats/Listrom.cs +++ b/SabreTools.DatFiles/Formats/Listrom.cs @@ -151,7 +151,7 @@ namespace SabreTools.DatFiles.Formats Rom rom = new Rom() { Name = romname, - Size = Sanitizer.CleanLong(split[0]), + Size = Utilities.CleanLong(split[0]), CRC = CleanListromHashData(split[1]), SHA1 = CleanListromHashData(split[2]), @@ -199,7 +199,7 @@ namespace SabreTools.DatFiles.Formats Rom rom = new Rom() { Name = romname, - Size = Sanitizer.CleanLong(split[0]), + Size = Utilities.CleanLong(split[0]), CRC = CleanListromHashData(split[2]), SHA1 = CleanListromHashData(split[3]), ItemStatus = ItemStatus.BadDump, @@ -225,7 +225,7 @@ namespace SabreTools.DatFiles.Formats Rom rom = new Rom() { Name = romname, - Size = Sanitizer.CleanLong(split[0]), + Size = Utilities.CleanLong(split[0]), ItemStatus = ItemStatus.Nodump, Machine = new Machine diff --git a/SabreTools.DatFiles/Formats/Listxml.cs b/SabreTools.DatFiles/Formats/Listxml.cs index a3d4b2a5..fd204afc 100644 --- a/SabreTools.DatFiles/Formats/Listxml.cs +++ b/SabreTools.DatFiles/Formats/Listxml.cs @@ -393,7 +393,7 @@ namespace SabreTools.DatFiles.Formats Name = reader.GetAttribute("name"), Tag = reader.GetAttribute("tag"), ChipType = reader.GetAttribute("type").AsChipType(), - Clock = Sanitizer.CleanLong(reader.GetAttribute("clock")), + Clock = Utilities.CleanLong(reader.GetAttribute("clock")), Source = new Source { @@ -457,7 +457,7 @@ namespace SabreTools.DatFiles.Formats DeviceType = reader.GetAttribute("type").AsDeviceType(), Tag = reader.GetAttribute("tag"), FixedImage = reader.GetAttribute("fixed_image"), - Mandatory = Sanitizer.CleanLong(reader.GetAttribute("mandatory")), + Mandatory = Utilities.CleanLong(reader.GetAttribute("mandatory")), Interface = reader.GetAttribute("interface"), Source = new Source @@ -544,17 +544,17 @@ namespace SabreTools.DatFiles.Formats { Tag = reader.GetAttribute("tag"), DisplayType = reader.GetAttribute("type").AsDisplayType(), - Rotate = Sanitizer.CleanLong(reader.GetAttribute("rotate")), + Rotate = Utilities.CleanLong(reader.GetAttribute("rotate")), FlipX = reader.GetAttribute("flipx").AsYesNo(), - Width = Sanitizer.CleanLong(reader.GetAttribute("width")), - Height = Sanitizer.CleanLong(reader.GetAttribute("height")), - PixClock = Sanitizer.CleanLong(reader.GetAttribute("pixclock")), - HTotal = Sanitizer.CleanLong(reader.GetAttribute("htotal")), - HBEnd = Sanitizer.CleanLong(reader.GetAttribute("hbend")), - HBStart = Sanitizer.CleanLong(reader.GetAttribute("hbstart")), - VTotal = Sanitizer.CleanLong(reader.GetAttribute("vtotal")), - VBEnd = Sanitizer.CleanLong(reader.GetAttribute("vbend")), - VBStart = Sanitizer.CleanLong(reader.GetAttribute("vbstart")), + Width = Utilities.CleanLong(reader.GetAttribute("width")), + Height = Utilities.CleanLong(reader.GetAttribute("height")), + PixClock = Utilities.CleanLong(reader.GetAttribute("pixclock")), + HTotal = Utilities.CleanLong(reader.GetAttribute("htotal")), + HBEnd = Utilities.CleanLong(reader.GetAttribute("hbend")), + HBStart = Utilities.CleanLong(reader.GetAttribute("hbstart")), + VTotal = Utilities.CleanLong(reader.GetAttribute("vtotal")), + VBEnd = Utilities.CleanLong(reader.GetAttribute("vbend")), + VBStart = Utilities.CleanLong(reader.GetAttribute("vbstart")), Source = new Source { @@ -615,8 +615,8 @@ namespace SabreTools.DatFiles.Formats { Service = reader.GetAttribute("service").AsYesNo(), Tilt = reader.GetAttribute("tilt").AsYesNo(), - Players = Sanitizer.CleanLong(reader.GetAttribute("players")), - Coins = Sanitizer.CleanLong(reader.GetAttribute("coins")), + Players = Utilities.CleanLong(reader.GetAttribute("players")), + Coins = Utilities.CleanLong(reader.GetAttribute("coins")), Source = new Source { @@ -676,7 +676,7 @@ namespace SabreTools.DatFiles.Formats { Name = reader.GetAttribute("name"), Bios = reader.GetAttribute("bios"), - Size = Sanitizer.CleanLong(reader.GetAttribute("size")), + Size = Utilities.CleanLong(reader.GetAttribute("size")), CRC = reader.GetAttribute("crc"), SHA1 = reader.GetAttribute("sha1"), MergeTag = reader.GetAttribute("merge"), @@ -752,7 +752,7 @@ namespace SabreTools.DatFiles.Formats case "sound": var sound = new Sound { - Channels = Sanitizer.CleanLong(reader.GetAttribute("channels")), + Channels = Utilities.CleanLong(reader.GetAttribute("channels")), Source = new Source { @@ -883,13 +883,13 @@ namespace SabreTools.DatFiles.Formats var control = new Control { ControlType = reader.GetAttribute("type").AsControlType(), - Player = Sanitizer.CleanLong(reader.GetAttribute("player")), - Buttons = Sanitizer.CleanLong(reader.GetAttribute("buttons")), - RequiredButtons = Sanitizer.CleanLong(reader.GetAttribute("reqbuttons")), - Minimum = Sanitizer.CleanLong(reader.GetAttribute("minimum")), - Maximum = Sanitizer.CleanLong(reader.GetAttribute("maximum")), - Sensitivity = Sanitizer.CleanLong(reader.GetAttribute("sensitivity")), - KeyDelta = Sanitizer.CleanLong(reader.GetAttribute("keydelta")), + Player = Utilities.CleanLong(reader.GetAttribute("player")), + Buttons = Utilities.CleanLong(reader.GetAttribute("buttons")), + RequiredButtons = Utilities.CleanLong(reader.GetAttribute("reqbuttons")), + Minimum = Utilities.CleanLong(reader.GetAttribute("minimum")), + Maximum = Utilities.CleanLong(reader.GetAttribute("maximum")), + Sensitivity = Utilities.CleanLong(reader.GetAttribute("sensitivity")), + KeyDelta = Utilities.CleanLong(reader.GetAttribute("keydelta")), Reverse = reader.GetAttribute("reverse").AsYesNo(), Ways = reader.GetAttribute("ways"), Ways2 = reader.GetAttribute("ways2"), @@ -957,7 +957,7 @@ namespace SabreTools.DatFiles.Formats var dipLocation = new Location { Name = reader.GetAttribute("name"), - Number = Sanitizer.CleanLong(reader.GetAttribute("number")), + Number = Utilities.CleanLong(reader.GetAttribute("number")), Inverted = reader.GetAttribute("inverted").AsYesNo() }; @@ -1089,7 +1089,7 @@ namespace SabreTools.DatFiles.Formats var confLocation = new Location { Name = reader.GetAttribute("name"), - Number = Sanitizer.CleanLong(reader.GetAttribute("number")), + Number = Utilities.CleanLong(reader.GetAttribute("number")), Inverted = reader.GetAttribute("inverted").AsYesNo() }; diff --git a/SabreTools.DatFiles/Formats/Logiqx.cs b/SabreTools.DatFiles/Formats/Logiqx.cs index 484d2c14..f130c5d4 100644 --- a/SabreTools.DatFiles/Formats/Logiqx.cs +++ b/SabreTools.DatFiles/Formats/Logiqx.cs @@ -609,7 +609,7 @@ namespace SabreTools.DatFiles.Formats DatItem rom = new Rom { Name = reader.GetAttribute("name"), - Size = Sanitizer.CleanLong(reader.GetAttribute("size")), + Size = Utilities.CleanLong(reader.GetAttribute("size")), CRC = reader.GetAttribute("crc"), MD5 = reader.GetAttribute("md5"), #if NET_FRAMEWORK diff --git a/SabreTools.DatFiles/Formats/OfflineList.cs b/SabreTools.DatFiles/Formats/OfflineList.cs index 88ecc141..1a7299c4 100644 --- a/SabreTools.DatFiles/Formats/OfflineList.cs +++ b/SabreTools.DatFiles/Formats/OfflineList.cs @@ -526,7 +526,7 @@ namespace SabreTools.DatFiles.Formats break; case "romsize": - size = Sanitizer.CleanLong(reader.ReadElementContentAsString()); + size = Utilities.CleanLong(reader.ReadElementContentAsString()); break; case "publisher": diff --git a/SabreTools.DatFiles/Formats/RomCenter.cs b/SabreTools.DatFiles/Formats/RomCenter.cs index d295a852..cfe655ac 100644 --- a/SabreTools.DatFiles/Formats/RomCenter.cs +++ b/SabreTools.DatFiles/Formats/RomCenter.cs @@ -338,7 +338,7 @@ namespace SabreTools.DatFiles.Formats Rom rom = new Rom { Name = rominfo[5], - Size = Sanitizer.CleanLong(rominfo[7]), + Size = Utilities.CleanLong(rominfo[7]), CRC = rominfo[6], ItemStatus = ItemStatus.None, diff --git a/SabreTools.DatFiles/Formats/SoftwareList.cs b/SabreTools.DatFiles/Formats/SoftwareList.cs index 08960865..6ca8d0d0 100644 --- a/SabreTools.DatFiles/Formats/SoftwareList.cs +++ b/SabreTools.DatFiles/Formats/SoftwareList.cs @@ -337,8 +337,8 @@ namespace SabreTools.DatFiles.Formats var dataArea = new DataArea { Name = reader.GetAttribute("name"), - Size = Sanitizer.CleanLong(reader.GetAttribute("size")), - Width = Sanitizer.CleanLong(reader.GetAttribute("width")), + Size = Utilities.CleanLong(reader.GetAttribute("size")), + Width = Utilities.CleanLong(reader.GetAttribute("width")), Endianness = reader.GetAttribute("endianness").AsEndianness(), }; @@ -464,7 +464,7 @@ namespace SabreTools.DatFiles.Formats var rom = new Rom { Name = reader.GetAttribute("name"), - Size = Sanitizer.CleanLong(reader.GetAttribute("size")), + Size = Utilities.CleanLong(reader.GetAttribute("size")), CRC = reader.GetAttribute("crc"), SHA1 = reader.GetAttribute("sha1"), Offset = reader.GetAttribute("offset"), diff --git a/SabreTools.DatItems/Chip.cs b/SabreTools.DatItems/Chip.cs index 1d5f24d6..016cbf7a 100644 --- a/SabreTools.DatItems/Chip.cs +++ b/SabreTools.DatItems/Chip.cs @@ -88,7 +88,7 @@ namespace SabreTools.DatItems ChipType = mappings[Field.DatItem_ChipType].AsChipType(); if (mappings.Keys.Contains(Field.DatItem_Clock)) - Clock = Sanitizer.CleanLong(mappings[Field.DatItem_Clock]); + Clock = Utilities.CleanLong(mappings[Field.DatItem_Clock]); } #endregion diff --git a/SabreTools.DatItems/Control.cs b/SabreTools.DatItems/Control.cs index a031630f..5cf80b03 100644 --- a/SabreTools.DatItems/Control.cs +++ b/SabreTools.DatItems/Control.cs @@ -149,25 +149,25 @@ namespace SabreTools.DatItems ControlType = mappings[Field.DatItem_Control_Type].AsControlType(); if (mappings.Keys.Contains(Field.DatItem_Control_Player)) - Player = Sanitizer.CleanLong(mappings[Field.DatItem_Control_Player]); + Player = Utilities.CleanLong(mappings[Field.DatItem_Control_Player]); if (mappings.Keys.Contains(Field.DatItem_Control_Buttons)) - Buttons = Sanitizer.CleanLong(mappings[Field.DatItem_Control_Buttons]); + Buttons = Utilities.CleanLong(mappings[Field.DatItem_Control_Buttons]); if (mappings.Keys.Contains(Field.DatItem_Control_RequiredButtons)) - RequiredButtons = Sanitizer.CleanLong(mappings[Field.DatItem_Control_RequiredButtons]); + RequiredButtons = Utilities.CleanLong(mappings[Field.DatItem_Control_RequiredButtons]); if (mappings.Keys.Contains(Field.DatItem_Control_Minimum)) - Minimum = Sanitizer.CleanLong(mappings[Field.DatItem_Control_Minimum]); + Minimum = Utilities.CleanLong(mappings[Field.DatItem_Control_Minimum]); if (mappings.Keys.Contains(Field.DatItem_Control_Maximum)) - Maximum = Sanitizer.CleanLong(mappings[Field.DatItem_Control_Maximum]); + Maximum = Utilities.CleanLong(mappings[Field.DatItem_Control_Maximum]); if (mappings.Keys.Contains(Field.DatItem_Control_Sensitivity)) - Sensitivity = Sanitizer.CleanLong(mappings[Field.DatItem_Control_Sensitivity]); + Sensitivity = Utilities.CleanLong(mappings[Field.DatItem_Control_Sensitivity]); if (mappings.Keys.Contains(Field.DatItem_Control_KeyDelta)) - KeyDelta = Sanitizer.CleanLong(mappings[Field.DatItem_Control_KeyDelta]); + KeyDelta = Utilities.CleanLong(mappings[Field.DatItem_Control_KeyDelta]); if (mappings.Keys.Contains(Field.DatItem_Control_Reverse)) Reverse = mappings[Field.DatItem_Control_Reverse].AsYesNo(); diff --git a/SabreTools.DatItems/DatItem.cs b/SabreTools.DatItems/DatItem.cs index 9ae03651..71a48df8 100644 --- a/SabreTools.DatItems/DatItem.cs +++ b/SabreTools.DatItems/DatItem.cs @@ -1406,10 +1406,10 @@ namespace SabreTools.DatItems { if (x.ItemType == y.ItemType) { - if (Path.GetDirectoryName(Sanitizer.RemovePathUnsafeCharacters(x.GetName() ?? string.Empty)) == Path.GetDirectoryName(Sanitizer.RemovePathUnsafeCharacters(y.GetName() ?? string.Empty))) - return nc.Compare(Path.GetFileName(Sanitizer.RemovePathUnsafeCharacters(x.GetName() ?? string.Empty)), Path.GetFileName(Sanitizer.RemovePathUnsafeCharacters(y.GetName() ?? string.Empty))); + if (Path.GetDirectoryName(Utilities.RemovePathUnsafeCharacters(x.GetName() ?? string.Empty)) == Path.GetDirectoryName(Utilities.RemovePathUnsafeCharacters(y.GetName() ?? string.Empty))) + return nc.Compare(Path.GetFileName(Utilities.RemovePathUnsafeCharacters(x.GetName() ?? string.Empty)), Path.GetFileName(Utilities.RemovePathUnsafeCharacters(y.GetName() ?? string.Empty))); - return nc.Compare(Path.GetDirectoryName(Sanitizer.RemovePathUnsafeCharacters(x.GetName() ?? string.Empty)), Path.GetDirectoryName(Sanitizer.RemovePathUnsafeCharacters(y.GetName() ?? string.Empty))); + return nc.Compare(Path.GetDirectoryName(Utilities.RemovePathUnsafeCharacters(x.GetName() ?? string.Empty)), Path.GetDirectoryName(Utilities.RemovePathUnsafeCharacters(y.GetName() ?? string.Empty))); } return x.ItemType - y.ItemType; diff --git a/SabreTools.DatItems/DataArea.cs b/SabreTools.DatItems/DataArea.cs index 1b2418c5..0b45e52a 100644 --- a/SabreTools.DatItems/DataArea.cs +++ b/SabreTools.DatItems/DataArea.cs @@ -84,10 +84,10 @@ namespace SabreTools.DatItems Name = mappings[Field.DatItem_AreaName]; if (mappings.Keys.Contains(Field.DatItem_AreaSize)) - Size = Sanitizer.CleanLong(mappings[Field.DatItem_AreaSize]); + Size = Utilities.CleanLong(mappings[Field.DatItem_AreaSize]); if (mappings.Keys.Contains(Field.DatItem_AreaWidth)) - Width = Sanitizer.CleanLong(mappings[Field.DatItem_AreaWidth]); + Width = Utilities.CleanLong(mappings[Field.DatItem_AreaWidth]); if (mappings.Keys.Contains(Field.DatItem_AreaEndianness)) Endianness = mappings[Field.DatItem_AreaEndianness].AsEndianness(); diff --git a/SabreTools.DatItems/Device.cs b/SabreTools.DatItems/Device.cs index 2de4caca..4342eceb 100644 --- a/SabreTools.DatItems/Device.cs +++ b/SabreTools.DatItems/Device.cs @@ -105,7 +105,7 @@ namespace SabreTools.DatItems FixedImage = mappings[Field.DatItem_FixedImage]; if (mappings.Keys.Contains(Field.DatItem_Mandatory)) - Mandatory = Sanitizer.CleanLong(mappings[Field.DatItem_Mandatory]); + Mandatory = Utilities.CleanLong(mappings[Field.DatItem_Mandatory]); if (mappings.Keys.Contains(Field.DatItem_Interface)) Interface = mappings[Field.DatItem_Interface]; diff --git a/SabreTools.DatItems/Display.cs b/SabreTools.DatItems/Display.cs index 99d3b15a..82120621 100644 --- a/SabreTools.DatItems/Display.cs +++ b/SabreTools.DatItems/Display.cs @@ -178,16 +178,16 @@ namespace SabreTools.DatItems DisplayType = mappings[Field.DatItem_DisplayType].AsDisplayType(); if (mappings.Keys.Contains(Field.DatItem_Rotate)) - Rotate = Sanitizer.CleanLong(mappings[Field.DatItem_Rotate]); + Rotate = Utilities.CleanLong(mappings[Field.DatItem_Rotate]); if (mappings.Keys.Contains(Field.DatItem_FlipX)) FlipX = mappings[Field.DatItem_FlipX].AsYesNo(); if (mappings.Keys.Contains(Field.DatItem_Width)) - Width = Sanitizer.CleanLong(mappings[Field.DatItem_Width]); + Width = Utilities.CleanLong(mappings[Field.DatItem_Width]); if (mappings.Keys.Contains(Field.DatItem_Height)) - Height = Sanitizer.CleanLong(mappings[Field.DatItem_Height]); + Height = Utilities.CleanLong(mappings[Field.DatItem_Height]); if (mappings.Keys.Contains(Field.DatItem_Refresh)) { @@ -196,25 +196,25 @@ namespace SabreTools.DatItems } if (mappings.Keys.Contains(Field.DatItem_PixClock)) - PixClock = Sanitizer.CleanLong(mappings[Field.DatItem_PixClock]); + PixClock = Utilities.CleanLong(mappings[Field.DatItem_PixClock]); if (mappings.Keys.Contains(Field.DatItem_HTotal)) - HTotal = Sanitizer.CleanLong(mappings[Field.DatItem_HTotal]); + HTotal = Utilities.CleanLong(mappings[Field.DatItem_HTotal]); if (mappings.Keys.Contains(Field.DatItem_HBEnd)) - HBEnd = Sanitizer.CleanLong(mappings[Field.DatItem_HBEnd]); + HBEnd = Utilities.CleanLong(mappings[Field.DatItem_HBEnd]); if (mappings.Keys.Contains(Field.DatItem_HBStart)) - HBStart = Sanitizer.CleanLong(mappings[Field.DatItem_HBStart]); + HBStart = Utilities.CleanLong(mappings[Field.DatItem_HBStart]); if (mappings.Keys.Contains(Field.DatItem_VTotal)) - VTotal = Sanitizer.CleanLong(mappings[Field.DatItem_VTotal]); + VTotal = Utilities.CleanLong(mappings[Field.DatItem_VTotal]); if (mappings.Keys.Contains(Field.DatItem_VBEnd)) - VBEnd = Sanitizer.CleanLong(mappings[Field.DatItem_VBEnd]); + VBEnd = Utilities.CleanLong(mappings[Field.DatItem_VBEnd]); if (mappings.Keys.Contains(Field.DatItem_VBStart)) - VBStart = Sanitizer.CleanLong(mappings[Field.DatItem_VBStart]); + VBStart = Utilities.CleanLong(mappings[Field.DatItem_VBStart]); } #endregion diff --git a/SabreTools.DatItems/Input.cs b/SabreTools.DatItems/Input.cs index f51a1800..27fd96dc 100644 --- a/SabreTools.DatItems/Input.cs +++ b/SabreTools.DatItems/Input.cs @@ -89,10 +89,10 @@ namespace SabreTools.DatItems Tilt = mappings[Field.DatItem_Tilt].AsYesNo(); if (mappings.Keys.Contains(Field.DatItem_Players)) - Players = Sanitizer.CleanLong(mappings[Field.DatItem_Players]); + Players = Utilities.CleanLong(mappings[Field.DatItem_Players]); if (mappings.Keys.Contains(Field.DatItem_Coins)) - Coins = Sanitizer.CleanLong(mappings[Field.DatItem_Coins]); + Coins = Utilities.CleanLong(mappings[Field.DatItem_Coins]); if (ControlsSpecified) { diff --git a/SabreTools.DatItems/Location.cs b/SabreTools.DatItems/Location.cs index 66767127..23e6a456 100644 --- a/SabreTools.DatItems/Location.cs +++ b/SabreTools.DatItems/Location.cs @@ -72,7 +72,7 @@ namespace SabreTools.DatItems Name = mappings[Field.DatItem_Location_Name]; if (mappings.Keys.Contains(Field.DatItem_Location_Number)) - Number = Sanitizer.CleanLong(mappings[Field.DatItem_Location_Number]); + Number = Utilities.CleanLong(mappings[Field.DatItem_Location_Number]); if (mappings.Keys.Contains(Field.DatItem_Location_Inverted)) Inverted = mappings[Field.DatItem_Location_Inverted].AsYesNo(); diff --git a/SabreTools.DatItems/Rom.cs b/SabreTools.DatItems/Rom.cs index 12fb603b..8a818668 100644 --- a/SabreTools.DatItems/Rom.cs +++ b/SabreTools.DatItems/Rom.cs @@ -372,7 +372,7 @@ namespace SabreTools.DatItems Bios = mappings[Field.DatItem_Bios]; if (mappings.Keys.Contains(Field.DatItem_Size)) - Size = Sanitizer.CleanLong(mappings[Field.DatItem_Size]); + Size = Utilities.CleanLong(mappings[Field.DatItem_Size]); if (mappings.Keys.Contains(Field.DatItem_CRC)) CRC = mappings[Field.DatItem_CRC]; diff --git a/SabreTools.DatItems/Sound.cs b/SabreTools.DatItems/Sound.cs index fcf4eb85..6871359a 100644 --- a/SabreTools.DatItems/Sound.cs +++ b/SabreTools.DatItems/Sound.cs @@ -43,7 +43,7 @@ namespace SabreTools.DatItems // Handle Sound-specific fields if (mappings.Keys.Contains(Field.DatItem_Channels)) - Channels = Sanitizer.CleanLong(mappings[Field.DatItem_Channels]); + Channels = Utilities.CleanLong(mappings[Field.DatItem_Channels]); } #endregion diff --git a/SabreTools.FileTypes/Folder.cs b/SabreTools.FileTypes/Folder.cs index 869498c8..e8fea6a6 100644 --- a/SabreTools.FileTypes/Folder.cs +++ b/SabreTools.FileTypes/Folder.cs @@ -343,9 +343,9 @@ namespace SabreTools.FileTypes // Get the output folder name from the first rebuild rom string fileName; if (writeToParent) - fileName = Path.Combine(outDir, Sanitizer.RemovePathUnsafeCharacters(baseFile.Filename)); + fileName = Path.Combine(outDir, Utilities.RemovePathUnsafeCharacters(baseFile.Filename)); else - fileName = Path.Combine(outDir, Sanitizer.RemovePathUnsafeCharacters(baseFile.Parent), Sanitizer.RemovePathUnsafeCharacters(baseFile.Filename)); + fileName = Path.Combine(outDir, Utilities.RemovePathUnsafeCharacters(baseFile.Parent), Utilities.RemovePathUnsafeCharacters(baseFile.Filename)); try { diff --git a/SabreTools.FileTypes/SevenZipArchive.cs b/SabreTools.FileTypes/SevenZipArchive.cs index d5e7655d..f2e21e35 100644 --- a/SabreTools.FileTypes/SevenZipArchive.cs +++ b/SabreTools.FileTypes/SevenZipArchive.cs @@ -415,7 +415,7 @@ namespace SabreTools.FileTypes inputStream.Seek(0, SeekOrigin.Begin); // Get the output archive name from the first rebuild rom - string archiveFileName = Path.Combine(outDir, Sanitizer.RemovePathUnsafeCharacters(baseFile.Parent) + (baseFile.Parent.EndsWith(".7z") ? string.Empty : ".7z")); + string archiveFileName = Path.Combine(outDir, Utilities.RemovePathUnsafeCharacters(baseFile.Parent) + (baseFile.Parent.EndsWith(".7z") ? string.Empty : ".7z")); // Set internal variables Stream writeStream = null; @@ -610,7 +610,7 @@ namespace SabreTools.FileTypes } // Get the output archive name from the first rebuild rom - string archiveFileName = Path.Combine(outDir, Sanitizer.RemovePathUnsafeCharacters(baseFiles[0].Parent) + (baseFiles[0].Parent.EndsWith(".7z") ? string.Empty : ".7z")); + string archiveFileName = Path.Combine(outDir, Utilities.RemovePathUnsafeCharacters(baseFiles[0].Parent) + (baseFiles[0].Parent.EndsWith(".7z") ? string.Empty : ".7z")); // Set internal variables Stream writeStream = null; diff --git a/SabreTools.FileTypes/TapeArchive.cs b/SabreTools.FileTypes/TapeArchive.cs index cfacd353..7295eaea 100644 --- a/SabreTools.FileTypes/TapeArchive.cs +++ b/SabreTools.FileTypes/TapeArchive.cs @@ -276,7 +276,7 @@ namespace SabreTools.FileTypes return success; // Get the output archive name from the first rebuild rom - string archiveFileName = Path.Combine(outDir, Sanitizer.RemovePathUnsafeCharacters(baseFile.Parent) + (baseFile.Parent.EndsWith(".tar") ? string.Empty : ".tar")); + string archiveFileName = Path.Combine(outDir, Utilities.RemovePathUnsafeCharacters(baseFile.Parent) + (baseFile.Parent.EndsWith(".tar") ? string.Empty : ".tar")); // Set internal variables TarArchive oldTarFile = TarArchive.Create(); @@ -420,7 +420,7 @@ namespace SabreTools.FileTypes } // Get the output archive name from the first rebuild rom - string archiveFileName = Path.Combine(outDir, Sanitizer.RemovePathUnsafeCharacters(baseFiles[0].Parent) + (baseFiles[0].Parent.EndsWith(".tar") ? string.Empty : ".tar")); + string archiveFileName = Path.Combine(outDir, Utilities.RemovePathUnsafeCharacters(baseFiles[0].Parent) + (baseFiles[0].Parent.EndsWith(".tar") ? string.Empty : ".tar")); // Set internal variables TarArchive oldTarFile = TarArchive.Create(); diff --git a/SabreTools.FileTypes/ZipArchive.cs b/SabreTools.FileTypes/ZipArchive.cs index d8b2b6ee..c785660c 100644 --- a/SabreTools.FileTypes/ZipArchive.cs +++ b/SabreTools.FileTypes/ZipArchive.cs @@ -427,7 +427,7 @@ namespace SabreTools.FileTypes inputStream.Seek(0, SeekOrigin.Begin); // Get the output archive name from the first rebuild rom - string archiveFileName = Path.Combine(outDir, Sanitizer.RemovePathUnsafeCharacters(baseFile.Parent) + (baseFile.Parent.EndsWith(".zip") ? string.Empty : ".zip")); + string archiveFileName = Path.Combine(outDir, Utilities.RemovePathUnsafeCharacters(baseFile.Parent) + (baseFile.Parent.EndsWith(".zip") ? string.Empty : ".zip")); // Set internal variables Stream writeStream = null; @@ -621,7 +621,7 @@ namespace SabreTools.FileTypes } // Get the output archive name from the first rebuild rom - string archiveFileName = Path.Combine(outDir, Sanitizer.RemovePathUnsafeCharacters(baseFiles[0].Parent) + (baseFiles[0].Parent.EndsWith(".zip") ? string.Empty : ".zip")); + string archiveFileName = Path.Combine(outDir, Utilities.RemovePathUnsafeCharacters(baseFiles[0].Parent) + (baseFiles[0].Parent.EndsWith(".zip") ? string.Empty : ".zip")); // Set internal variables Stream writeStream = null;