mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[DatFile] Make the code a little cleaner
This commit is contained in:
@@ -2066,8 +2066,14 @@ namespace SabreTools.Helper
|
||||
List<string> parent = new List<string>();
|
||||
|
||||
XmlTextReader xtr = FileTools.GetXmlTextReader(filename, logger);
|
||||
if (xtr != null)
|
||||
|
||||
// If we got a null reader, just return
|
||||
if (xtr == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Otherwise, read the file to the end
|
||||
xtr.MoveToContent();
|
||||
while (!xtr.EOF)
|
||||
{
|
||||
@@ -2190,8 +2196,14 @@ namespace SabreTools.Helper
|
||||
case "header":
|
||||
headreader = xtr.ReadSubtree();
|
||||
|
||||
if (headreader != null)
|
||||
// If there's no subtree to the header, skip it
|
||||
if (headreader == null)
|
||||
{
|
||||
xtr.Skip();
|
||||
continue;
|
||||
}
|
||||
|
||||
// Otherwise, read what we can from the header
|
||||
while (!headreader.EOF)
|
||||
{
|
||||
// We only want elements
|
||||
@@ -2323,8 +2335,14 @@ namespace SabreTools.Helper
|
||||
break;
|
||||
case "flags":
|
||||
flagreader = xtr.ReadSubtree();
|
||||
if (flagreader != null)
|
||||
|
||||
// If we somehow have a null flag section, skip it
|
||||
if (flagreader == null)
|
||||
{
|
||||
xtr.Skip();
|
||||
continue;
|
||||
}
|
||||
|
||||
while (!flagreader.EOF)
|
||||
{
|
||||
// We only want elements
|
||||
@@ -2394,7 +2412,6 @@ namespace SabreTools.Helper
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
headreader.Skip();
|
||||
break;
|
||||
default:
|
||||
@@ -2402,7 +2419,6 @@ namespace SabreTools.Helper
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Skip the header node now that we've processed it
|
||||
xtr.Skip();
|
||||
@@ -2420,9 +2436,14 @@ namespace SabreTools.Helper
|
||||
// Safeguard for interesting case of "software" without anything except roms
|
||||
bool software = false;
|
||||
|
||||
// If we have a subtree, add what is possible
|
||||
if (subreader != null)
|
||||
// If we have an empty machine, skip it
|
||||
if (subreader == null)
|
||||
{
|
||||
xtr.Skip();
|
||||
continue;
|
||||
}
|
||||
|
||||
// Otherwise, add what is possible
|
||||
subreader.MoveToContent();
|
||||
if (!softlist && temptype == "software" && subreader.ReadToFollowing("description"))
|
||||
{
|
||||
@@ -2644,7 +2665,6 @@ namespace SabreTools.Helper
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If we didn't find any items in the folder, make sure to add the blank rom
|
||||
if (empty)
|
||||
@@ -2687,8 +2707,14 @@ namespace SabreTools.Helper
|
||||
// If the rom is itemStatus, flag it
|
||||
its = ItemStatus.None;
|
||||
flagreader = xtr.ReadSubtree();
|
||||
if (flagreader != null)
|
||||
|
||||
// If the subtree is empty, skip it
|
||||
if (flagreader == null)
|
||||
{
|
||||
xtr.Skip();
|
||||
continue;
|
||||
}
|
||||
|
||||
while (!flagreader.EOF)
|
||||
{
|
||||
// We only want elements
|
||||
@@ -2730,7 +2756,6 @@ namespace SabreTools.Helper
|
||||
|
||||
flagreader.Read();
|
||||
}
|
||||
}
|
||||
|
||||
// If the rom has a Date attached, read it in and then sanitize it
|
||||
date = "";
|
||||
@@ -2807,7 +2832,6 @@ namespace SabreTools.Helper
|
||||
|
||||
xtr.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add a rom to the Dat after checking
|
||||
|
||||
Reference in New Issue
Block a user