mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Empty the rest of Santizer into Utilities
This commit is contained in:
@@ -1,41 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace SabreTools.Core.Tools
|
|
||||||
{
|
|
||||||
public static class Sanitizer
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Get a sanitized size from an input string
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="input">String to get value from</param>
|
|
||||||
/// <returns>Size as a long?, if possible</returns>
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Remove all chars that are considered path unsafe
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="s">Input string to clean</param>
|
|
||||||
/// <returns>Cleaned string</returns>
|
|
||||||
public static string RemovePathUnsafeCharacters(string s)
|
|
||||||
{
|
|
||||||
List<char> invalidPath = Path.GetInvalidPathChars().ToList();
|
|
||||||
return new string(s.Where(c => !invalidPath.Contains(c)).ToArray());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace SabreTools.Core.Tools
|
namespace SabreTools.Core.Tools
|
||||||
{
|
{
|
||||||
@@ -59,6 +62,26 @@ namespace SabreTools.Core.Tools
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get a sanitized size from an input string
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input">String to get value from</param>
|
||||||
|
/// <returns>Size as a long?, if possible</returns>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Convert .NET DateTime to MS-DOS date format
|
/// Convert .NET DateTime to MS-DOS date format
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -102,5 +125,16 @@ namespace SabreTools.Core.Tools
|
|||||||
{
|
{
|
||||||
return (array == null || array.Length == 0);
|
return (array == null || array.Length == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remove all chars that are considered path unsafe
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="s">Input string to clean</param>
|
||||||
|
/// <returns>Cleaned string</returns>
|
||||||
|
public static string RemovePathUnsafeCharacters(string s)
|
||||||
|
{
|
||||||
|
List<char> invalidPath = Path.GetInvalidPathChars().ToList();
|
||||||
|
return new string(s.Where(c => !invalidPath.Contains(c)).ToArray());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -311,7 +311,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
|
|
||||||
case "size":
|
case "size":
|
||||||
if (item.ItemType == ItemType.Rom)
|
if (item.ItemType == ItemType.Rom)
|
||||||
(item as Rom).Size = Sanitizer.CleanLong(attrVal);
|
(item as Rom).Size = Utilities.CleanLong(attrVal);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case "crc":
|
case "crc":
|
||||||
|
|||||||
@@ -224,7 +224,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "size":
|
case "size":
|
||||||
item.Size = Sanitizer.CleanLong(attrVal);
|
item.Size = Utilities.CleanLong(attrVal);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "crc":
|
case "crc":
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
Rom rom = new Rom()
|
Rom rom = new Rom()
|
||||||
{
|
{
|
||||||
Name = romname,
|
Name = romname,
|
||||||
Size = Sanitizer.CleanLong(split[0]),
|
Size = Utilities.CleanLong(split[0]),
|
||||||
CRC = CleanListromHashData(split[1]),
|
CRC = CleanListromHashData(split[1]),
|
||||||
SHA1 = CleanListromHashData(split[2]),
|
SHA1 = CleanListromHashData(split[2]),
|
||||||
|
|
||||||
@@ -199,7 +199,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
Rom rom = new Rom()
|
Rom rom = new Rom()
|
||||||
{
|
{
|
||||||
Name = romname,
|
Name = romname,
|
||||||
Size = Sanitizer.CleanLong(split[0]),
|
Size = Utilities.CleanLong(split[0]),
|
||||||
CRC = CleanListromHashData(split[2]),
|
CRC = CleanListromHashData(split[2]),
|
||||||
SHA1 = CleanListromHashData(split[3]),
|
SHA1 = CleanListromHashData(split[3]),
|
||||||
ItemStatus = ItemStatus.BadDump,
|
ItemStatus = ItemStatus.BadDump,
|
||||||
@@ -225,7 +225,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
Rom rom = new Rom()
|
Rom rom = new Rom()
|
||||||
{
|
{
|
||||||
Name = romname,
|
Name = romname,
|
||||||
Size = Sanitizer.CleanLong(split[0]),
|
Size = Utilities.CleanLong(split[0]),
|
||||||
ItemStatus = ItemStatus.Nodump,
|
ItemStatus = ItemStatus.Nodump,
|
||||||
|
|
||||||
Machine = new Machine
|
Machine = new Machine
|
||||||
|
|||||||
@@ -393,7 +393,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
Name = reader.GetAttribute("name"),
|
Name = reader.GetAttribute("name"),
|
||||||
Tag = reader.GetAttribute("tag"),
|
Tag = reader.GetAttribute("tag"),
|
||||||
ChipType = reader.GetAttribute("type").AsChipType(),
|
ChipType = reader.GetAttribute("type").AsChipType(),
|
||||||
Clock = Sanitizer.CleanLong(reader.GetAttribute("clock")),
|
Clock = Utilities.CleanLong(reader.GetAttribute("clock")),
|
||||||
|
|
||||||
Source = new Source
|
Source = new Source
|
||||||
{
|
{
|
||||||
@@ -457,7 +457,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
DeviceType = reader.GetAttribute("type").AsDeviceType(),
|
DeviceType = reader.GetAttribute("type").AsDeviceType(),
|
||||||
Tag = reader.GetAttribute("tag"),
|
Tag = reader.GetAttribute("tag"),
|
||||||
FixedImage = reader.GetAttribute("fixed_image"),
|
FixedImage = reader.GetAttribute("fixed_image"),
|
||||||
Mandatory = Sanitizer.CleanLong(reader.GetAttribute("mandatory")),
|
Mandatory = Utilities.CleanLong(reader.GetAttribute("mandatory")),
|
||||||
Interface = reader.GetAttribute("interface"),
|
Interface = reader.GetAttribute("interface"),
|
||||||
|
|
||||||
Source = new Source
|
Source = new Source
|
||||||
@@ -544,17 +544,17 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
{
|
{
|
||||||
Tag = reader.GetAttribute("tag"),
|
Tag = reader.GetAttribute("tag"),
|
||||||
DisplayType = reader.GetAttribute("type").AsDisplayType(),
|
DisplayType = reader.GetAttribute("type").AsDisplayType(),
|
||||||
Rotate = Sanitizer.CleanLong(reader.GetAttribute("rotate")),
|
Rotate = Utilities.CleanLong(reader.GetAttribute("rotate")),
|
||||||
FlipX = reader.GetAttribute("flipx").AsYesNo(),
|
FlipX = reader.GetAttribute("flipx").AsYesNo(),
|
||||||
Width = Sanitizer.CleanLong(reader.GetAttribute("width")),
|
Width = Utilities.CleanLong(reader.GetAttribute("width")),
|
||||||
Height = Sanitizer.CleanLong(reader.GetAttribute("height")),
|
Height = Utilities.CleanLong(reader.GetAttribute("height")),
|
||||||
PixClock = Sanitizer.CleanLong(reader.GetAttribute("pixclock")),
|
PixClock = Utilities.CleanLong(reader.GetAttribute("pixclock")),
|
||||||
HTotal = Sanitizer.CleanLong(reader.GetAttribute("htotal")),
|
HTotal = Utilities.CleanLong(reader.GetAttribute("htotal")),
|
||||||
HBEnd = Sanitizer.CleanLong(reader.GetAttribute("hbend")),
|
HBEnd = Utilities.CleanLong(reader.GetAttribute("hbend")),
|
||||||
HBStart = Sanitizer.CleanLong(reader.GetAttribute("hbstart")),
|
HBStart = Utilities.CleanLong(reader.GetAttribute("hbstart")),
|
||||||
VTotal = Sanitizer.CleanLong(reader.GetAttribute("vtotal")),
|
VTotal = Utilities.CleanLong(reader.GetAttribute("vtotal")),
|
||||||
VBEnd = Sanitizer.CleanLong(reader.GetAttribute("vbend")),
|
VBEnd = Utilities.CleanLong(reader.GetAttribute("vbend")),
|
||||||
VBStart = Sanitizer.CleanLong(reader.GetAttribute("vbstart")),
|
VBStart = Utilities.CleanLong(reader.GetAttribute("vbstart")),
|
||||||
|
|
||||||
Source = new Source
|
Source = new Source
|
||||||
{
|
{
|
||||||
@@ -615,8 +615,8 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
{
|
{
|
||||||
Service = reader.GetAttribute("service").AsYesNo(),
|
Service = reader.GetAttribute("service").AsYesNo(),
|
||||||
Tilt = reader.GetAttribute("tilt").AsYesNo(),
|
Tilt = reader.GetAttribute("tilt").AsYesNo(),
|
||||||
Players = Sanitizer.CleanLong(reader.GetAttribute("players")),
|
Players = Utilities.CleanLong(reader.GetAttribute("players")),
|
||||||
Coins = Sanitizer.CleanLong(reader.GetAttribute("coins")),
|
Coins = Utilities.CleanLong(reader.GetAttribute("coins")),
|
||||||
|
|
||||||
Source = new Source
|
Source = new Source
|
||||||
{
|
{
|
||||||
@@ -676,7 +676,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
{
|
{
|
||||||
Name = reader.GetAttribute("name"),
|
Name = reader.GetAttribute("name"),
|
||||||
Bios = reader.GetAttribute("bios"),
|
Bios = reader.GetAttribute("bios"),
|
||||||
Size = Sanitizer.CleanLong(reader.GetAttribute("size")),
|
Size = Utilities.CleanLong(reader.GetAttribute("size")),
|
||||||
CRC = reader.GetAttribute("crc"),
|
CRC = reader.GetAttribute("crc"),
|
||||||
SHA1 = reader.GetAttribute("sha1"),
|
SHA1 = reader.GetAttribute("sha1"),
|
||||||
MergeTag = reader.GetAttribute("merge"),
|
MergeTag = reader.GetAttribute("merge"),
|
||||||
@@ -752,7 +752,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
case "sound":
|
case "sound":
|
||||||
var sound = new Sound
|
var sound = new Sound
|
||||||
{
|
{
|
||||||
Channels = Sanitizer.CleanLong(reader.GetAttribute("channels")),
|
Channels = Utilities.CleanLong(reader.GetAttribute("channels")),
|
||||||
|
|
||||||
Source = new Source
|
Source = new Source
|
||||||
{
|
{
|
||||||
@@ -883,13 +883,13 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
var control = new Control
|
var control = new Control
|
||||||
{
|
{
|
||||||
ControlType = reader.GetAttribute("type").AsControlType(),
|
ControlType = reader.GetAttribute("type").AsControlType(),
|
||||||
Player = Sanitizer.CleanLong(reader.GetAttribute("player")),
|
Player = Utilities.CleanLong(reader.GetAttribute("player")),
|
||||||
Buttons = Sanitizer.CleanLong(reader.GetAttribute("buttons")),
|
Buttons = Utilities.CleanLong(reader.GetAttribute("buttons")),
|
||||||
RequiredButtons = Sanitizer.CleanLong(reader.GetAttribute("reqbuttons")),
|
RequiredButtons = Utilities.CleanLong(reader.GetAttribute("reqbuttons")),
|
||||||
Minimum = Sanitizer.CleanLong(reader.GetAttribute("minimum")),
|
Minimum = Utilities.CleanLong(reader.GetAttribute("minimum")),
|
||||||
Maximum = Sanitizer.CleanLong(reader.GetAttribute("maximum")),
|
Maximum = Utilities.CleanLong(reader.GetAttribute("maximum")),
|
||||||
Sensitivity = Sanitizer.CleanLong(reader.GetAttribute("sensitivity")),
|
Sensitivity = Utilities.CleanLong(reader.GetAttribute("sensitivity")),
|
||||||
KeyDelta = Sanitizer.CleanLong(reader.GetAttribute("keydelta")),
|
KeyDelta = Utilities.CleanLong(reader.GetAttribute("keydelta")),
|
||||||
Reverse = reader.GetAttribute("reverse").AsYesNo(),
|
Reverse = reader.GetAttribute("reverse").AsYesNo(),
|
||||||
Ways = reader.GetAttribute("ways"),
|
Ways = reader.GetAttribute("ways"),
|
||||||
Ways2 = reader.GetAttribute("ways2"),
|
Ways2 = reader.GetAttribute("ways2"),
|
||||||
@@ -957,7 +957,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
var dipLocation = new Location
|
var dipLocation = new Location
|
||||||
{
|
{
|
||||||
Name = reader.GetAttribute("name"),
|
Name = reader.GetAttribute("name"),
|
||||||
Number = Sanitizer.CleanLong(reader.GetAttribute("number")),
|
Number = Utilities.CleanLong(reader.GetAttribute("number")),
|
||||||
Inverted = reader.GetAttribute("inverted").AsYesNo()
|
Inverted = reader.GetAttribute("inverted").AsYesNo()
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1089,7 +1089,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
var confLocation = new Location
|
var confLocation = new Location
|
||||||
{
|
{
|
||||||
Name = reader.GetAttribute("name"),
|
Name = reader.GetAttribute("name"),
|
||||||
Number = Sanitizer.CleanLong(reader.GetAttribute("number")),
|
Number = Utilities.CleanLong(reader.GetAttribute("number")),
|
||||||
Inverted = reader.GetAttribute("inverted").AsYesNo()
|
Inverted = reader.GetAttribute("inverted").AsYesNo()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -609,7 +609,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
DatItem rom = new Rom
|
DatItem rom = new Rom
|
||||||
{
|
{
|
||||||
Name = reader.GetAttribute("name"),
|
Name = reader.GetAttribute("name"),
|
||||||
Size = Sanitizer.CleanLong(reader.GetAttribute("size")),
|
Size = Utilities.CleanLong(reader.GetAttribute("size")),
|
||||||
CRC = reader.GetAttribute("crc"),
|
CRC = reader.GetAttribute("crc"),
|
||||||
MD5 = reader.GetAttribute("md5"),
|
MD5 = reader.GetAttribute("md5"),
|
||||||
#if NET_FRAMEWORK
|
#if NET_FRAMEWORK
|
||||||
|
|||||||
@@ -526,7 +526,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "romsize":
|
case "romsize":
|
||||||
size = Sanitizer.CleanLong(reader.ReadElementContentAsString());
|
size = Utilities.CleanLong(reader.ReadElementContentAsString());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "publisher":
|
case "publisher":
|
||||||
|
|||||||
@@ -338,7 +338,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
Rom rom = new Rom
|
Rom rom = new Rom
|
||||||
{
|
{
|
||||||
Name = rominfo[5],
|
Name = rominfo[5],
|
||||||
Size = Sanitizer.CleanLong(rominfo[7]),
|
Size = Utilities.CleanLong(rominfo[7]),
|
||||||
CRC = rominfo[6],
|
CRC = rominfo[6],
|
||||||
ItemStatus = ItemStatus.None,
|
ItemStatus = ItemStatus.None,
|
||||||
|
|
||||||
|
|||||||
@@ -337,8 +337,8 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
var dataArea = new DataArea
|
var dataArea = new DataArea
|
||||||
{
|
{
|
||||||
Name = reader.GetAttribute("name"),
|
Name = reader.GetAttribute("name"),
|
||||||
Size = Sanitizer.CleanLong(reader.GetAttribute("size")),
|
Size = Utilities.CleanLong(reader.GetAttribute("size")),
|
||||||
Width = Sanitizer.CleanLong(reader.GetAttribute("width")),
|
Width = Utilities.CleanLong(reader.GetAttribute("width")),
|
||||||
Endianness = reader.GetAttribute("endianness").AsEndianness(),
|
Endianness = reader.GetAttribute("endianness").AsEndianness(),
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -464,7 +464,7 @@ namespace SabreTools.DatFiles.Formats
|
|||||||
var rom = new Rom
|
var rom = new Rom
|
||||||
{
|
{
|
||||||
Name = reader.GetAttribute("name"),
|
Name = reader.GetAttribute("name"),
|
||||||
Size = Sanitizer.CleanLong(reader.GetAttribute("size")),
|
Size = Utilities.CleanLong(reader.GetAttribute("size")),
|
||||||
CRC = reader.GetAttribute("crc"),
|
CRC = reader.GetAttribute("crc"),
|
||||||
SHA1 = reader.GetAttribute("sha1"),
|
SHA1 = reader.GetAttribute("sha1"),
|
||||||
Offset = reader.GetAttribute("offset"),
|
Offset = reader.GetAttribute("offset"),
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ namespace SabreTools.DatItems
|
|||||||
ChipType = mappings[Field.DatItem_ChipType].AsChipType();
|
ChipType = mappings[Field.DatItem_ChipType].AsChipType();
|
||||||
|
|
||||||
if (mappings.Keys.Contains(Field.DatItem_Clock))
|
if (mappings.Keys.Contains(Field.DatItem_Clock))
|
||||||
Clock = Sanitizer.CleanLong(mappings[Field.DatItem_Clock]);
|
Clock = Utilities.CleanLong(mappings[Field.DatItem_Clock]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -149,25 +149,25 @@ namespace SabreTools.DatItems
|
|||||||
ControlType = mappings[Field.DatItem_Control_Type].AsControlType();
|
ControlType = mappings[Field.DatItem_Control_Type].AsControlType();
|
||||||
|
|
||||||
if (mappings.Keys.Contains(Field.DatItem_Control_Player))
|
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))
|
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))
|
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))
|
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))
|
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))
|
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))
|
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))
|
if (mappings.Keys.Contains(Field.DatItem_Control_Reverse))
|
||||||
Reverse = mappings[Field.DatItem_Control_Reverse].AsYesNo();
|
Reverse = mappings[Field.DatItem_Control_Reverse].AsYesNo();
|
||||||
|
|||||||
@@ -1406,10 +1406,10 @@ namespace SabreTools.DatItems
|
|||||||
{
|
{
|
||||||
if (x.ItemType == y.ItemType)
|
if (x.ItemType == y.ItemType)
|
||||||
{
|
{
|
||||||
if (Path.GetDirectoryName(Sanitizer.RemovePathUnsafeCharacters(x.GetName() ?? string.Empty)) == Path.GetDirectoryName(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(Sanitizer.RemovePathUnsafeCharacters(x.GetName() ?? string.Empty)), Path.GetFileName(Sanitizer.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;
|
return x.ItemType - y.ItemType;
|
||||||
|
|||||||
@@ -84,10 +84,10 @@ namespace SabreTools.DatItems
|
|||||||
Name = mappings[Field.DatItem_AreaName];
|
Name = mappings[Field.DatItem_AreaName];
|
||||||
|
|
||||||
if (mappings.Keys.Contains(Field.DatItem_AreaSize))
|
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))
|
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))
|
if (mappings.Keys.Contains(Field.DatItem_AreaEndianness))
|
||||||
Endianness = mappings[Field.DatItem_AreaEndianness].AsEndianness();
|
Endianness = mappings[Field.DatItem_AreaEndianness].AsEndianness();
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ namespace SabreTools.DatItems
|
|||||||
FixedImage = mappings[Field.DatItem_FixedImage];
|
FixedImage = mappings[Field.DatItem_FixedImage];
|
||||||
|
|
||||||
if (mappings.Keys.Contains(Field.DatItem_Mandatory))
|
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))
|
if (mappings.Keys.Contains(Field.DatItem_Interface))
|
||||||
Interface = mappings[Field.DatItem_Interface];
|
Interface = mappings[Field.DatItem_Interface];
|
||||||
|
|||||||
@@ -178,16 +178,16 @@ namespace SabreTools.DatItems
|
|||||||
DisplayType = mappings[Field.DatItem_DisplayType].AsDisplayType();
|
DisplayType = mappings[Field.DatItem_DisplayType].AsDisplayType();
|
||||||
|
|
||||||
if (mappings.Keys.Contains(Field.DatItem_Rotate))
|
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))
|
if (mappings.Keys.Contains(Field.DatItem_FlipX))
|
||||||
FlipX = mappings[Field.DatItem_FlipX].AsYesNo();
|
FlipX = mappings[Field.DatItem_FlipX].AsYesNo();
|
||||||
|
|
||||||
if (mappings.Keys.Contains(Field.DatItem_Width))
|
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))
|
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))
|
if (mappings.Keys.Contains(Field.DatItem_Refresh))
|
||||||
{
|
{
|
||||||
@@ -196,25 +196,25 @@ namespace SabreTools.DatItems
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mappings.Keys.Contains(Field.DatItem_PixClock))
|
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))
|
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))
|
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))
|
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))
|
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))
|
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))
|
if (mappings.Keys.Contains(Field.DatItem_VBStart))
|
||||||
VBStart = Sanitizer.CleanLong(mappings[Field.DatItem_VBStart]);
|
VBStart = Utilities.CleanLong(mappings[Field.DatItem_VBStart]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -89,10 +89,10 @@ namespace SabreTools.DatItems
|
|||||||
Tilt = mappings[Field.DatItem_Tilt].AsYesNo();
|
Tilt = mappings[Field.DatItem_Tilt].AsYesNo();
|
||||||
|
|
||||||
if (mappings.Keys.Contains(Field.DatItem_Players))
|
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))
|
if (mappings.Keys.Contains(Field.DatItem_Coins))
|
||||||
Coins = Sanitizer.CleanLong(mappings[Field.DatItem_Coins]);
|
Coins = Utilities.CleanLong(mappings[Field.DatItem_Coins]);
|
||||||
|
|
||||||
if (ControlsSpecified)
|
if (ControlsSpecified)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ namespace SabreTools.DatItems
|
|||||||
Name = mappings[Field.DatItem_Location_Name];
|
Name = mappings[Field.DatItem_Location_Name];
|
||||||
|
|
||||||
if (mappings.Keys.Contains(Field.DatItem_Location_Number))
|
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))
|
if (mappings.Keys.Contains(Field.DatItem_Location_Inverted))
|
||||||
Inverted = mappings[Field.DatItem_Location_Inverted].AsYesNo();
|
Inverted = mappings[Field.DatItem_Location_Inverted].AsYesNo();
|
||||||
|
|||||||
@@ -372,7 +372,7 @@ namespace SabreTools.DatItems
|
|||||||
Bios = mappings[Field.DatItem_Bios];
|
Bios = mappings[Field.DatItem_Bios];
|
||||||
|
|
||||||
if (mappings.Keys.Contains(Field.DatItem_Size))
|
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))
|
if (mappings.Keys.Contains(Field.DatItem_CRC))
|
||||||
CRC = mappings[Field.DatItem_CRC];
|
CRC = mappings[Field.DatItem_CRC];
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ namespace SabreTools.DatItems
|
|||||||
|
|
||||||
// Handle Sound-specific fields
|
// Handle Sound-specific fields
|
||||||
if (mappings.Keys.Contains(Field.DatItem_Channels))
|
if (mappings.Keys.Contains(Field.DatItem_Channels))
|
||||||
Channels = Sanitizer.CleanLong(mappings[Field.DatItem_Channels]);
|
Channels = Utilities.CleanLong(mappings[Field.DatItem_Channels]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -343,9 +343,9 @@ namespace SabreTools.FileTypes
|
|||||||
// Get the output folder name from the first rebuild rom
|
// Get the output folder name from the first rebuild rom
|
||||||
string fileName;
|
string fileName;
|
||||||
if (writeToParent)
|
if (writeToParent)
|
||||||
fileName = Path.Combine(outDir, Sanitizer.RemovePathUnsafeCharacters(baseFile.Filename));
|
fileName = Path.Combine(outDir, Utilities.RemovePathUnsafeCharacters(baseFile.Filename));
|
||||||
else
|
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
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -415,7 +415,7 @@ namespace SabreTools.FileTypes
|
|||||||
inputStream.Seek(0, SeekOrigin.Begin);
|
inputStream.Seek(0, SeekOrigin.Begin);
|
||||||
|
|
||||||
// Get the output archive name from the first rebuild rom
|
// 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
|
// Set internal variables
|
||||||
Stream writeStream = null;
|
Stream writeStream = null;
|
||||||
@@ -610,7 +610,7 @@ namespace SabreTools.FileTypes
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get the output archive name from the first rebuild rom
|
// 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
|
// Set internal variables
|
||||||
Stream writeStream = null;
|
Stream writeStream = null;
|
||||||
|
|||||||
@@ -276,7 +276,7 @@ namespace SabreTools.FileTypes
|
|||||||
return success;
|
return success;
|
||||||
|
|
||||||
// Get the output archive name from the first rebuild rom
|
// 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
|
// Set internal variables
|
||||||
TarArchive oldTarFile = TarArchive.Create();
|
TarArchive oldTarFile = TarArchive.Create();
|
||||||
@@ -420,7 +420,7 @@ namespace SabreTools.FileTypes
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get the output archive name from the first rebuild rom
|
// 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
|
// Set internal variables
|
||||||
TarArchive oldTarFile = TarArchive.Create();
|
TarArchive oldTarFile = TarArchive.Create();
|
||||||
|
|||||||
@@ -427,7 +427,7 @@ namespace SabreTools.FileTypes
|
|||||||
inputStream.Seek(0, SeekOrigin.Begin);
|
inputStream.Seek(0, SeekOrigin.Begin);
|
||||||
|
|
||||||
// Get the output archive name from the first rebuild rom
|
// 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
|
// Set internal variables
|
||||||
Stream writeStream = null;
|
Stream writeStream = null;
|
||||||
@@ -621,7 +621,7 @@ namespace SabreTools.FileTypes
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get the output archive name from the first rebuild rom
|
// 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
|
// Set internal variables
|
||||||
Stream writeStream = null;
|
Stream writeStream = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user