mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Remove .NET Framework 4.6.2/4.7.2 (#24)
* Remove < .NET 4.8, general cleanup * Abstract * Tango * Banner * Scan no more * Common * Application * Access * Filter-feeder * Graffiti * Paint-over * Law and Order * XOR-o * Unused staircase * Maybe * Maybe not * Delete this * The word is "no" * Emit * Improper * Aye aye * Fence * Barrier * Monkey * Pail * Lines
This commit is contained in:
@@ -14,7 +14,6 @@ namespace SabreTools.Library.DatFiles
|
||||
/// <summary>
|
||||
/// Represents parsing and writing of a SofwareList, M1, or MAME XML DAT
|
||||
/// </summary>
|
||||
/// TODO: Verify that all write for this DatFile type is correct
|
||||
internal class SoftwareList : DatFile
|
||||
{
|
||||
/// <summary>
|
||||
@@ -22,7 +21,7 @@ namespace SabreTools.Library.DatFiles
|
||||
/// </summary>
|
||||
/// <param name="datFile">Parent DatFile to copy from</param>
|
||||
public SoftwareList(DatFile datFile)
|
||||
: base(datFile, cloneHeader: false)
|
||||
: base(datFile)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -30,25 +29,18 @@ namespace SabreTools.Library.DatFiles
|
||||
/// Parse an SofwareList XML DAT and return all found games and roms within
|
||||
/// </summary>
|
||||
/// <param name="filename">Name of the file to be parsed</param>
|
||||
/// <param name="sysid">System ID for the DAT</param>
|
||||
/// <param name="srcid">Source ID for the DAT</param>
|
||||
/// <param name="indexId">Index ID for the DAT</param>
|
||||
/// <param name="keep">True if full pathnames are to be kept, false otherwise (default)</param>
|
||||
/// <param name="clean">True if game names are sanitized, false otherwise (default)</param>
|
||||
/// <param name="remUnicode">True if we should remove non-ASCII characters from output, false otherwise (default)</param>
|
||||
public override void ParseFile(
|
||||
protected override void ParseFile(
|
||||
// Standard Dat parsing
|
||||
string filename,
|
||||
int sysid,
|
||||
int srcid,
|
||||
int indexId,
|
||||
|
||||
// Miscellaneous
|
||||
bool keep,
|
||||
bool clean,
|
||||
bool remUnicode)
|
||||
bool keep)
|
||||
{
|
||||
// Prepare all internal variables
|
||||
Encoding enc = Utilities.GetEncoding(filename);
|
||||
XmlReader xtr = Utilities.GetXmlTextReader(filename);
|
||||
XmlReader xtr = filename.GetXmlTextReader();
|
||||
|
||||
// If we got a null reader, just return
|
||||
if (xtr == null)
|
||||
@@ -70,23 +62,23 @@ namespace SabreTools.Library.DatFiles
|
||||
switch (xtr.Name)
|
||||
{
|
||||
case "softwarelist":
|
||||
Name = (string.IsNullOrWhiteSpace(Name) ? xtr.GetAttribute("name") ?? string.Empty : Name);
|
||||
Description = (string.IsNullOrWhiteSpace(Description) ? xtr.GetAttribute("description") ?? string.Empty : Description);
|
||||
if (ForceMerging == ForceMerging.None)
|
||||
ForceMerging = Utilities.GetForceMerging(xtr.GetAttribute("forcemerging"));
|
||||
DatHeader.Name = (string.IsNullOrWhiteSpace(DatHeader.Name) ? xtr.GetAttribute("name") ?? string.Empty : DatHeader.Name);
|
||||
DatHeader.Description = (string.IsNullOrWhiteSpace(DatHeader.Description) ? xtr.GetAttribute("description") ?? string.Empty : DatHeader.Description);
|
||||
if (DatHeader.ForceMerging == ForceMerging.None)
|
||||
DatHeader.ForceMerging = xtr.GetAttribute("forcemerging").AsForceMerging();
|
||||
|
||||
if (ForceNodump == ForceNodump.None)
|
||||
ForceNodump = Utilities.GetForceNodump(xtr.GetAttribute("forcenodump"));
|
||||
if (DatHeader.ForceNodump == ForceNodump.None)
|
||||
DatHeader.ForceNodump = xtr.GetAttribute("forcenodump").AsForceNodump();
|
||||
|
||||
if (ForcePacking == ForcePacking.None)
|
||||
ForcePacking = Utilities.GetForcePacking(xtr.GetAttribute("forcepacking"));
|
||||
if (DatHeader.ForcePacking == ForcePacking.None)
|
||||
DatHeader.ForcePacking = xtr.GetAttribute("forcepacking").AsForcePacking();
|
||||
|
||||
xtr.Read();
|
||||
break;
|
||||
|
||||
// We want to process the entire subtree of the machine
|
||||
case "software":
|
||||
ReadSoftware(xtr.ReadSubtree(), filename, sysid, srcid, keep, clean, remUnicode);
|
||||
ReadSoftware(xtr.ReadSubtree(), filename, indexId, keep);
|
||||
|
||||
// Skip the software now that we've processed it
|
||||
xtr.Skip();
|
||||
@@ -114,23 +106,17 @@ namespace SabreTools.Library.DatFiles
|
||||
/// </summary>
|
||||
/// <param name="reader">XmlReader representing a software block</param>
|
||||
/// <param name="filename">Name of the file to be parsed</param>
|
||||
/// <param name="sysid">System ID for the DAT</param>
|
||||
/// <param name="srcid">Source ID for the DAT</param>
|
||||
/// <param name="indexId">Index ID for the DAT</param>
|
||||
/// <param name="keep">True if full pathnames are to be kept, false otherwise (default)</param>
|
||||
/// <param name="clean">True if game names are sanitized, false otherwise (default)</param>
|
||||
/// <param name="remUnicode">True if we should remove non-ASCII characters from output, false otherwise (default)</param>
|
||||
private void ReadSoftware(
|
||||
XmlReader reader,
|
||||
|
||||
// Standard Dat parsing
|
||||
string filename,
|
||||
int sysid,
|
||||
int srcid,
|
||||
int indexId,
|
||||
|
||||
// Miscellaneous
|
||||
bool keep,
|
||||
bool clean,
|
||||
bool remUnicode)
|
||||
bool keep)
|
||||
{
|
||||
// If we have an empty software, skip it
|
||||
if (reader == null)
|
||||
@@ -139,26 +125,24 @@ namespace SabreTools.Library.DatFiles
|
||||
// Otherwise, add what is possible
|
||||
reader.MoveToContent();
|
||||
|
||||
string key = string.Empty;
|
||||
string temptype = reader.Name;
|
||||
bool containsItems = false;
|
||||
|
||||
// Create a new machine
|
||||
MachineType machineType = MachineType.NULL;
|
||||
if (Utilities.GetYesNo(reader.GetAttribute("isbios")) == true)
|
||||
if (reader.GetAttribute("isbios").AsYesNo() == true)
|
||||
machineType |= MachineType.Bios;
|
||||
|
||||
if (Utilities.GetYesNo(reader.GetAttribute("isdevice")) == true)
|
||||
if (reader.GetAttribute("isdevice").AsYesNo() == true)
|
||||
machineType |= MachineType.Device;
|
||||
|
||||
if (Utilities.GetYesNo(reader.GetAttribute("ismechanical")) == true)
|
||||
if (reader.GetAttribute("ismechanical").AsYesNo() == true)
|
||||
machineType |= MachineType.Mechanical;
|
||||
|
||||
Machine machine = new Machine
|
||||
{
|
||||
Name = reader.GetAttribute("name"),
|
||||
Description = reader.GetAttribute("name"),
|
||||
Supported = Utilities.GetYesNo(reader.GetAttribute("supported")), // (yes|partial|no) "yes"
|
||||
Supported = reader.GetAttribute("supported").AsYesNo(), // (yes|partial|no) "yes"
|
||||
|
||||
CloneOf = reader.GetAttribute("cloneof") ?? string.Empty,
|
||||
Infos = new List<KeyValuePair<string, string>>(),
|
||||
@@ -202,7 +186,7 @@ namespace SabreTools.Library.DatFiles
|
||||
break;
|
||||
|
||||
case "part": // Contains all rom and disk information
|
||||
containsItems = ReadPart(reader.ReadSubtree(), machine, filename, sysid, srcid, keep, clean, remUnicode);
|
||||
containsItems = ReadPart(reader.ReadSubtree(), machine, filename, indexId, keep);
|
||||
|
||||
// Skip the part now that we've processed it
|
||||
reader.Skip();
|
||||
@@ -219,14 +203,13 @@ namespace SabreTools.Library.DatFiles
|
||||
{
|
||||
Blank blank = new Blank()
|
||||
{
|
||||
SystemID = sysid,
|
||||
System = filename,
|
||||
SourceID = srcid,
|
||||
IndexId = indexId,
|
||||
IndexSource = filename,
|
||||
};
|
||||
blank.CopyMachineInformation(machine);
|
||||
|
||||
// Now process and add the rom
|
||||
ParseAddHelper(blank, clean, remUnicode);
|
||||
ParseAddHelper(blank);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,27 +219,20 @@ namespace SabreTools.Library.DatFiles
|
||||
/// <param name="reader">XmlReader representing a part block</param>
|
||||
/// <param name="machine">Machine information to pass to contained items</param>
|
||||
/// <param name="filename">Name of the file to be parsed</param>
|
||||
/// <param name="sysid">System ID for the DAT</param>
|
||||
/// <param name="srcid">Source ID for the DAT</param>
|
||||
/// <param name="indexId">Index ID for the DAT</param>
|
||||
/// <param name="keep">True if full pathnames are to be kept, false otherwise (default)</param>
|
||||
/// <param name="clean">True if game names are sanitized, false otherwise (default)</param>
|
||||
/// <param name="remUnicode">True if we should remove non-ASCII characters from output, false otherwise (default)</param>
|
||||
private bool ReadPart(
|
||||
XmlReader reader,
|
||||
Machine machine,
|
||||
|
||||
// Standard Dat parsing
|
||||
string filename,
|
||||
int sysid,
|
||||
int srcid,
|
||||
int indexId,
|
||||
|
||||
// Miscellaneous
|
||||
bool keep,
|
||||
bool clean,
|
||||
bool remUnicode)
|
||||
bool keep)
|
||||
{
|
||||
string key = string.Empty, areaname = string.Empty, partname = string.Empty, partinterface = string.Empty;
|
||||
string temptype = reader.Name;
|
||||
string key, areaname, partname = string.Empty, partinterface = string.Empty;
|
||||
long? areasize = null;
|
||||
var features = new List<KeyValuePair<string, string>>();
|
||||
bool containsItems = false;
|
||||
@@ -274,10 +250,7 @@ namespace SabreTools.Library.DatFiles
|
||||
}
|
||||
|
||||
if (reader.NodeType == XmlNodeType.EndElement && (reader.Name == "dataarea" || reader.Name == "diskarea"))
|
||||
{
|
||||
areaname = string.Empty;
|
||||
areasize = null;
|
||||
}
|
||||
|
||||
reader.Read();
|
||||
continue;
|
||||
@@ -308,8 +281,8 @@ namespace SabreTools.Library.DatFiles
|
||||
// string dataarea_width = reader.GetAttribute("width"); // (8|16|32|64) "8"
|
||||
// string dataarea_endianness = reader.GetAttribute("endianness"); // endianness (big|little) "little"
|
||||
|
||||
containsItems = ReadDataArea(reader.ReadSubtree(), machine, features, areaname, areasize,
|
||||
partname, partinterface, filename, sysid, srcid, keep, clean, remUnicode);
|
||||
containsItems = ReadDataArea(reader.ReadSubtree(), machine, features, areaname, areasize,
|
||||
partname, partinterface, filename, indexId, keep);
|
||||
|
||||
// Skip the dataarea now that we've processed it
|
||||
reader.Skip();
|
||||
@@ -319,7 +292,7 @@ namespace SabreTools.Library.DatFiles
|
||||
areaname = reader.GetAttribute("name");
|
||||
|
||||
containsItems = ReadDiskArea(reader.ReadSubtree(), machine, features, areaname, areasize,
|
||||
partname, partinterface, filename, sysid, srcid, keep, clean, remUnicode);
|
||||
partname, partinterface, filename, indexId, keep);
|
||||
|
||||
// Skip the diskarea now that we've processed it
|
||||
reader.Skip();
|
||||
@@ -358,11 +331,8 @@ namespace SabreTools.Library.DatFiles
|
||||
/// <param name="partname">Name of the containing part</param>
|
||||
/// <param name="partinterface">Interface of the containing part</param>
|
||||
/// <param name="filename">Name of the file to be parsed</param>
|
||||
/// <param name="sysid">System ID for the DAT</param>
|
||||
/// <param name="srcid">Source ID for the DAT</param>
|
||||
/// <param name="indexId">Index ID for the DAT</param>
|
||||
/// <param name="keep">True if full pathnames are to be kept, false otherwise (default)</param>
|
||||
/// <param name="clean">True if game names are sanitized, false otherwise (default)</param>
|
||||
/// <param name="remUnicode">True if we should remove non-ASCII characters from output, false otherwise (default)</param>
|
||||
private bool ReadDataArea(
|
||||
XmlReader reader,
|
||||
Machine machine,
|
||||
@@ -374,13 +344,10 @@ namespace SabreTools.Library.DatFiles
|
||||
|
||||
// Standard Dat parsing
|
||||
string filename,
|
||||
int sysid,
|
||||
int srcid,
|
||||
int indexId,
|
||||
|
||||
// Miscellaneous
|
||||
bool keep,
|
||||
bool clean,
|
||||
bool remUnicode)
|
||||
bool keep)
|
||||
{
|
||||
string key = string.Empty;
|
||||
string temptype = reader.Name;
|
||||
@@ -408,7 +375,7 @@ namespace SabreTools.Library.DatFiles
|
||||
DatItem lastrom = this[key][index];
|
||||
if (lastrom.ItemType == ItemType.Rom)
|
||||
{
|
||||
((Rom)lastrom).Size += Utilities.GetSize(reader.GetAttribute("size"));
|
||||
((Rom)lastrom).Size += Sanitizer.CleanSize(reader.GetAttribute("size"));
|
||||
}
|
||||
this[key].RemoveAt(index);
|
||||
this[key].Add(lastrom);
|
||||
@@ -419,17 +386,19 @@ namespace SabreTools.Library.DatFiles
|
||||
DatItem rom = new Rom
|
||||
{
|
||||
Name = reader.GetAttribute("name"),
|
||||
Size = Utilities.GetSize(reader.GetAttribute("size")),
|
||||
CRC = Utilities.CleanHashData(reader.GetAttribute("crc"), Constants.CRCLength),
|
||||
MD5 = Utilities.CleanHashData(reader.GetAttribute("md5"), Constants.MD5Length),
|
||||
RIPEMD160 = Utilities.CleanHashData(reader.GetAttribute("ripemd160"), Constants.RIPEMD160Length),
|
||||
SHA1 = Utilities.CleanHashData(reader.GetAttribute("sha1"), Constants.SHA1Length),
|
||||
SHA256 = Utilities.CleanHashData(reader.GetAttribute("sha256"), Constants.SHA256Length),
|
||||
SHA384 = Utilities.CleanHashData(reader.GetAttribute("sha384"), Constants.SHA384Length),
|
||||
SHA512 = Utilities.CleanHashData(reader.GetAttribute("sha512"), Constants.SHA512Length),
|
||||
Size = Sanitizer.CleanSize(reader.GetAttribute("size")),
|
||||
CRC = reader.GetAttribute("crc"),
|
||||
MD5 = reader.GetAttribute("md5"),
|
||||
#if NET_FRAMEWORK
|
||||
RIPEMD160 = reader.GetAttribute("ripemd160"),
|
||||
#endif
|
||||
SHA1 = reader.GetAttribute("sha1"),
|
||||
SHA256 = reader.GetAttribute("sha256"),
|
||||
SHA384 = reader.GetAttribute("sha384"),
|
||||
SHA512 = reader.GetAttribute("sha512"),
|
||||
Offset = reader.GetAttribute("offset"),
|
||||
// Value = reader.GetAttribute("value");
|
||||
ItemStatus = Utilities.GetItemStatus(reader.GetAttribute("status")),
|
||||
ItemStatus = reader.GetAttribute("status").AsItemStatus(),
|
||||
// LoadFlag = reader.GetAttribute("loadflag"), // (load16_byte|load16_word|load16_word_swap|load32_byte|load32_word|load32_word_swap|load32_dword|load64_word|load64_word_swap|reload|fill|continue|reload_plain|ignore)
|
||||
|
||||
AreaName = areaname,
|
||||
@@ -438,15 +407,14 @@ namespace SabreTools.Library.DatFiles
|
||||
PartName = partname,
|
||||
PartInterface = partinterface,
|
||||
|
||||
SystemID = sysid,
|
||||
System = filename,
|
||||
SourceID = srcid,
|
||||
IndexId = indexId,
|
||||
IndexSource = filename,
|
||||
};
|
||||
|
||||
rom.CopyMachineInformation(machine);
|
||||
|
||||
// Now process and add the rom
|
||||
key = ParseAddHelper(rom, clean, remUnicode);
|
||||
key = ParseAddHelper(rom);
|
||||
|
||||
reader.Read();
|
||||
break;
|
||||
@@ -471,11 +439,8 @@ namespace SabreTools.Library.DatFiles
|
||||
/// <param name="partname">Name of the containing part</param>
|
||||
/// <param name="partinterface">Interface of the containing part</param>
|
||||
/// <param name="filename">Name of the file to be parsed</param>
|
||||
/// <param name="sysid">System ID for the DAT</param>
|
||||
/// <param name="srcid">Source ID for the DAT</param>
|
||||
/// <param name="indexId">Index ID for the DAT</param>
|
||||
/// <param name="keep">True if full pathnames are to be kept, false otherwise (default)</param>
|
||||
/// <param name="clean">True if game names are sanitized, false otherwise (default)</param>
|
||||
/// <param name="remUnicode">True if we should remove non-ASCII characters from output, false otherwise (default)</param>
|
||||
private bool ReadDiskArea(
|
||||
XmlReader reader,
|
||||
Machine machine,
|
||||
@@ -487,13 +452,10 @@ namespace SabreTools.Library.DatFiles
|
||||
|
||||
// Standard Dat parsing
|
||||
string filename,
|
||||
int sysid,
|
||||
int srcid,
|
||||
int indexId,
|
||||
|
||||
// Miscellaneous
|
||||
bool keep,
|
||||
bool clean,
|
||||
bool remUnicode)
|
||||
bool keep)
|
||||
{
|
||||
string key = string.Empty;
|
||||
string temptype = reader.Name;
|
||||
@@ -517,14 +479,16 @@ namespace SabreTools.Library.DatFiles
|
||||
DatItem disk = new Disk
|
||||
{
|
||||
Name = reader.GetAttribute("name"),
|
||||
MD5 = Utilities.CleanHashData(reader.GetAttribute("md5"), Constants.MD5Length),
|
||||
RIPEMD160 = Utilities.CleanHashData(reader.GetAttribute("ripemd160"), Constants.RIPEMD160Length),
|
||||
SHA1 = Utilities.CleanHashData(reader.GetAttribute("sha1"), Constants.SHA1Length),
|
||||
SHA256 = Utilities.CleanHashData(reader.GetAttribute("sha256"), Constants.SHA256Length),
|
||||
SHA384 = Utilities.CleanHashData(reader.GetAttribute("sha384"), Constants.SHA384Length),
|
||||
SHA512 = Utilities.CleanHashData(reader.GetAttribute("sha512"), Constants.SHA512Length),
|
||||
ItemStatus = Utilities.GetItemStatus(reader.GetAttribute("status")),
|
||||
Writable = Utilities.GetYesNo(reader.GetAttribute("writable")),
|
||||
MD5 = reader.GetAttribute("md5"),
|
||||
#if NET_FRAMEWORK
|
||||
RIPEMD160 = reader.GetAttribute("ripemd160"),
|
||||
#endif
|
||||
SHA1 = reader.GetAttribute("sha1"),
|
||||
SHA256 = reader.GetAttribute("sha256"),
|
||||
SHA384 = reader.GetAttribute("sha384"),
|
||||
SHA512 = reader.GetAttribute("sha512"),
|
||||
ItemStatus = reader.GetAttribute("status").AsItemStatus(),
|
||||
Writable = reader.GetAttribute("writable").AsYesNo(),
|
||||
|
||||
AreaName = areaname,
|
||||
AreaSize = areasize,
|
||||
@@ -532,15 +496,14 @@ namespace SabreTools.Library.DatFiles
|
||||
PartName = partname,
|
||||
PartInterface = partinterface,
|
||||
|
||||
SystemID = sysid,
|
||||
System = filename,
|
||||
SourceID = srcid,
|
||||
IndexId = indexId,
|
||||
IndexSource = filename,
|
||||
};
|
||||
|
||||
disk.CopyMachineInformation(machine);
|
||||
|
||||
// Now process and add the rom
|
||||
key = ParseAddHelper(disk, clean, remUnicode);
|
||||
key = ParseAddHelper(disk);
|
||||
|
||||
reader.Read();
|
||||
break;
|
||||
@@ -565,7 +528,7 @@ namespace SabreTools.Library.DatFiles
|
||||
try
|
||||
{
|
||||
Globals.Logger.User($"Opening file for writing: {outfile}");
|
||||
FileStream fs = Utilities.TryCreate(outfile);
|
||||
FileStream fs = FileExtensions.TryCreate(outfile);
|
||||
|
||||
// If we get back null for some reason, just log and return
|
||||
if (fs == null)
|
||||
@@ -574,10 +537,12 @@ namespace SabreTools.Library.DatFiles
|
||||
return false;
|
||||
}
|
||||
|
||||
XmlTextWriter xtw = new XmlTextWriter(fs, new UTF8Encoding(false));
|
||||
xtw.Formatting = Formatting.Indented;
|
||||
xtw.IndentChar = '\t';
|
||||
xtw.Indentation = 1;
|
||||
XmlTextWriter xtw = new XmlTextWriter(fs, new UTF8Encoding(false))
|
||||
{
|
||||
Formatting = Formatting.Indented,
|
||||
IndentChar = '\t',
|
||||
Indentation = 1
|
||||
};
|
||||
|
||||
// Write out the header
|
||||
WriteHeader(xtw);
|
||||
@@ -663,10 +628,10 @@ namespace SabreTools.Library.DatFiles
|
||||
xtw.WriteDocType("softwarelist", null, "softwarelist.dtd", null);
|
||||
|
||||
xtw.WriteStartElement("softwarelist");
|
||||
xtw.WriteAttributeString("name", Name);
|
||||
xtw.WriteAttributeString("description", Description);
|
||||
xtw.WriteAttributeString("name", DatHeader.Name);
|
||||
xtw.WriteAttributeString("description", DatHeader.Description);
|
||||
|
||||
switch (ForcePacking)
|
||||
switch (DatHeader.ForcePacking)
|
||||
{
|
||||
case ForcePacking.Unzip:
|
||||
xtw.WriteAttributeString("forcepacking", "unzip");
|
||||
@@ -676,7 +641,7 @@ namespace SabreTools.Library.DatFiles
|
||||
break;
|
||||
}
|
||||
|
||||
switch (ForceMerging)
|
||||
switch (DatHeader.ForceMerging)
|
||||
{
|
||||
case ForceMerging.Full:
|
||||
xtw.WriteAttributeString("forcemerging", "full");
|
||||
@@ -692,7 +657,7 @@ namespace SabreTools.Library.DatFiles
|
||||
break;
|
||||
}
|
||||
|
||||
switch (ForceNodump)
|
||||
switch (DatHeader.ForceNodump)
|
||||
{
|
||||
case ForceNodump.Ignore:
|
||||
xtw.WriteAttributeString("forcenodump", "ignore");
|
||||
@@ -731,12 +696,12 @@ namespace SabreTools.Library.DatFiles
|
||||
|
||||
// Build the state based on excluded fields
|
||||
xtw.WriteStartElement("software");
|
||||
xtw.WriteAttributeString("name", datItem.GetField(Field.MachineName, ExcludeFields));
|
||||
xtw.WriteAttributeString("name", datItem.GetField(Field.MachineName, DatHeader.ExcludeFields));
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.CloneOf, ExcludeFields)) && !string.Equals(datItem.MachineName, datItem.CloneOf, StringComparison.OrdinalIgnoreCase))
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.CloneOf, DatHeader.ExcludeFields)) && !string.Equals(datItem.MachineName, datItem.CloneOf, StringComparison.OrdinalIgnoreCase))
|
||||
xtw.WriteAttributeString("cloneof", datItem.CloneOf);
|
||||
|
||||
if (!ExcludeFields[(int)Field.Supported])
|
||||
|
||||
if (!DatHeader.ExcludeFields[(int)Field.Supported])
|
||||
{
|
||||
if (datItem.Supported == true)
|
||||
xtw.WriteAttributeString("supported", "yes");
|
||||
@@ -746,14 +711,14 @@ namespace SabreTools.Library.DatFiles
|
||||
xtw.WriteAttributeString("supported", "partial");
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Description, ExcludeFields)))
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Description, DatHeader.ExcludeFields)))
|
||||
xtw.WriteElementString("description", datItem.MachineDescription);
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Year, ExcludeFields)))
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Year, DatHeader.ExcludeFields)))
|
||||
xtw.WriteElementString("year", datItem.Year);
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Publisher, ExcludeFields)))
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Publisher, DatHeader.ExcludeFields)))
|
||||
xtw.WriteElementString("publisher", datItem.Publisher);
|
||||
|
||||
if (!ExcludeFields[(int)Field.Infos] && datItem.Infos != null && datItem.Infos.Count > 0)
|
||||
if (!DatHeader.ExcludeFields[(int)Field.Infos] && datItem.Infos != null && datItem.Infos.Count > 0)
|
||||
{
|
||||
foreach (KeyValuePair<string, string> kvp in datItem.Infos)
|
||||
{
|
||||
@@ -818,10 +783,10 @@ namespace SabreTools.Library.DatFiles
|
||||
|
||||
// Build the state based on excluded fields
|
||||
xtw.WriteStartElement("part");
|
||||
xtw.WriteAttributeString("name", datItem.GetField(Field.PartName, ExcludeFields));
|
||||
xtw.WriteAttributeString("interface", datItem.GetField(Field.PartInterface, ExcludeFields));
|
||||
xtw.WriteAttributeString("name", datItem.GetField(Field.PartName, DatHeader.ExcludeFields));
|
||||
xtw.WriteAttributeString("interface", datItem.GetField(Field.PartInterface, DatHeader.ExcludeFields));
|
||||
|
||||
if (!ExcludeFields[(int)Field.Features] && datItem.Features != null && datItem.Features.Count > 0)
|
||||
if (!DatHeader.ExcludeFields[(int)Field.Features] && datItem.Features != null && datItem.Features.Count > 0)
|
||||
{
|
||||
foreach (KeyValuePair<string, string> kvp in datItem.Features)
|
||||
{
|
||||
@@ -832,36 +797,38 @@ namespace SabreTools.Library.DatFiles
|
||||
}
|
||||
}
|
||||
|
||||
string areaName = datItem.GetField(Field.AreaName, ExcludeFields);
|
||||
string areaName = datItem.GetField(Field.AreaName, DatHeader.ExcludeFields);
|
||||
switch (datItem.ItemType)
|
||||
{
|
||||
case ItemType.Disk:
|
||||
var disk = datItem as Disk;
|
||||
if (!ExcludeFields[(int)Field.AreaName] && string.IsNullOrWhiteSpace(areaName))
|
||||
if (!DatHeader.ExcludeFields[(int)Field.AreaName] && string.IsNullOrWhiteSpace(areaName))
|
||||
areaName = "cdrom";
|
||||
|
||||
xtw.WriteStartElement("diskarea");
|
||||
xtw.WriteAttributeString("name", areaName);
|
||||
if (!ExcludeFields[(int)Field.AreaSize] && disk.AreaSize != null)
|
||||
if (!DatHeader.ExcludeFields[(int)Field.AreaSize] && disk.AreaSize != null)
|
||||
xtw.WriteAttributeString("size", disk.AreaSize.ToString());
|
||||
|
||||
xtw.WriteStartElement("disk");
|
||||
xtw.WriteAttributeString("name", disk.GetField(Field.Name, ExcludeFields));
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.MD5, ExcludeFields)))
|
||||
xtw.WriteAttributeString("name", disk.GetField(Field.Name, DatHeader.ExcludeFields));
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.MD5, DatHeader.ExcludeFields)))
|
||||
xtw.WriteAttributeString("md5", disk.MD5.ToLowerInvariant());
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.RIPEMD160, ExcludeFields)))
|
||||
#if NET_FRAMEWORK
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.RIPEMD160, DatHeader.ExcludeFields)))
|
||||
xtw.WriteAttributeString("ripemd160", disk.RIPEMD160.ToLowerInvariant());
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA1, ExcludeFields)))
|
||||
#endif
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA1, DatHeader.ExcludeFields)))
|
||||
xtw.WriteAttributeString("sha1", disk.SHA1.ToLowerInvariant());
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA256, ExcludeFields)))
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA256, DatHeader.ExcludeFields)))
|
||||
xtw.WriteAttributeString("sha256", disk.SHA256.ToLowerInvariant());
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA384, ExcludeFields)))
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA384, DatHeader.ExcludeFields)))
|
||||
xtw.WriteAttributeString("sha384", disk.SHA384.ToLowerInvariant());
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA512, ExcludeFields)))
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA512, DatHeader.ExcludeFields)))
|
||||
xtw.WriteAttributeString("sha512", disk.SHA512.ToLowerInvariant());
|
||||
if (!ExcludeFields[(int)Field.Status] && disk.ItemStatus != ItemStatus.None)
|
||||
if (!DatHeader.ExcludeFields[(int)Field.Status] && disk.ItemStatus != ItemStatus.None)
|
||||
xtw.WriteAttributeString("status", disk.ItemStatus.ToString().ToLowerInvariant());
|
||||
if (!ExcludeFields[(int)Field.Writable] && disk.Writable != null)
|
||||
if (!DatHeader.ExcludeFields[(int)Field.Writable] && disk.Writable != null)
|
||||
xtw.WriteAttributeString("writable", disk.Writable == true ? "yes" : "no");
|
||||
xtw.WriteEndElement();
|
||||
|
||||
@@ -871,39 +838,41 @@ namespace SabreTools.Library.DatFiles
|
||||
|
||||
case ItemType.Rom:
|
||||
var rom = datItem as Rom;
|
||||
if (!ExcludeFields[(int)Field.AreaName] && string.IsNullOrWhiteSpace(areaName))
|
||||
if (!DatHeader.ExcludeFields[(int)Field.AreaName] && string.IsNullOrWhiteSpace(areaName))
|
||||
areaName = "rom";
|
||||
|
||||
xtw.WriteStartElement("dataarea");
|
||||
xtw.WriteAttributeString("name", areaName);
|
||||
if (!ExcludeFields[(int)Field.AreaSize] && rom.AreaSize != null)
|
||||
if (!DatHeader.ExcludeFields[(int)Field.AreaSize] && rom.AreaSize != null)
|
||||
xtw.WriteAttributeString("size", rom.AreaSize.ToString());
|
||||
|
||||
xtw.WriteStartElement("rom");
|
||||
xtw.WriteAttributeString("name", rom.GetField(Field.Name, ExcludeFields));
|
||||
if (!ExcludeFields[(int)Field.Size] && rom.Size != -1)
|
||||
xtw.WriteAttributeString("name", rom.GetField(Field.Name, DatHeader.ExcludeFields));
|
||||
if (!DatHeader.ExcludeFields[(int)Field.Size] && rom.Size != -1)
|
||||
xtw.WriteAttributeString("size", rom.Size.ToString());
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.CRC, ExcludeFields)))
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.CRC, DatHeader.ExcludeFields)))
|
||||
xtw.WriteAttributeString("crc", rom.CRC.ToLowerInvariant());
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.MD5, ExcludeFields)))
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.MD5, DatHeader.ExcludeFields)))
|
||||
xtw.WriteAttributeString("md5", rom.MD5.ToLowerInvariant());
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.RIPEMD160, ExcludeFields)))
|
||||
#if NET_FRAMEWORK
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.RIPEMD160, DatHeader.ExcludeFields)))
|
||||
xtw.WriteAttributeString("ripemd160", rom.RIPEMD160.ToLowerInvariant());
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA1, ExcludeFields)))
|
||||
#endif
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA1, DatHeader.ExcludeFields)))
|
||||
xtw.WriteAttributeString("sha1", rom.SHA1.ToLowerInvariant());
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA256, ExcludeFields)))
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA256, DatHeader.ExcludeFields)))
|
||||
xtw.WriteAttributeString("sha256", rom.SHA256.ToLowerInvariant());
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA384, ExcludeFields)))
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA384, DatHeader.ExcludeFields)))
|
||||
xtw.WriteAttributeString("sha384", rom.SHA384.ToLowerInvariant());
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA512, ExcludeFields)))
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA512, DatHeader.ExcludeFields)))
|
||||
xtw.WriteAttributeString("sha512", rom.SHA512.ToLowerInvariant());
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Offset, ExcludeFields)))
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Offset, DatHeader.ExcludeFields)))
|
||||
xtw.WriteAttributeString("offset", rom.Offset);
|
||||
//if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Value, ExcludeFields)))
|
||||
//if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Value, DatHeader.ExcludeFields)))
|
||||
// xtw.WriteAttributeString("value", rom.Value);
|
||||
if (!ExcludeFields[(int)Field.Status] && rom.ItemStatus != ItemStatus.None)
|
||||
if (!DatHeader.ExcludeFields[(int)Field.Status] && rom.ItemStatus != ItemStatus.None)
|
||||
xtw.WriteAttributeString("status", rom.ItemStatus.ToString().ToLowerInvariant());
|
||||
//if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Loadflag, ExcludeFields)))
|
||||
//if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Loadflag, DatHeader.ExcludeFields)))
|
||||
// xtw.WriteAttributeString("loadflag", rom.Loadflag);
|
||||
xtw.WriteEndElement();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user