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>();
|
List<string> parent = new List<string>();
|
||||||
|
|
||||||
XmlTextReader xtr = FileTools.GetXmlTextReader(filename, logger);
|
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();
|
xtr.MoveToContent();
|
||||||
while (!xtr.EOF)
|
while (!xtr.EOF)
|
||||||
{
|
{
|
||||||
@@ -2190,8 +2196,14 @@ namespace SabreTools.Helper
|
|||||||
case "header":
|
case "header":
|
||||||
headreader = xtr.ReadSubtree();
|
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)
|
while (!headreader.EOF)
|
||||||
{
|
{
|
||||||
// We only want elements
|
// We only want elements
|
||||||
@@ -2323,8 +2335,14 @@ namespace SabreTools.Helper
|
|||||||
break;
|
break;
|
||||||
case "flags":
|
case "flags":
|
||||||
flagreader = xtr.ReadSubtree();
|
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)
|
while (!flagreader.EOF)
|
||||||
{
|
{
|
||||||
// We only want elements
|
// We only want elements
|
||||||
@@ -2394,7 +2412,6 @@ namespace SabreTools.Helper
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
headreader.Skip();
|
headreader.Skip();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -2402,7 +2419,6 @@ namespace SabreTools.Helper
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Skip the header node now that we've processed it
|
// Skip the header node now that we've processed it
|
||||||
xtr.Skip();
|
xtr.Skip();
|
||||||
@@ -2420,9 +2436,14 @@ namespace SabreTools.Helper
|
|||||||
// Safeguard for interesting case of "software" without anything except roms
|
// Safeguard for interesting case of "software" without anything except roms
|
||||||
bool software = false;
|
bool software = false;
|
||||||
|
|
||||||
// If we have a subtree, add what is possible
|
// If we have an empty machine, skip it
|
||||||
if (subreader != null)
|
if (subreader == null)
|
||||||
{
|
{
|
||||||
|
xtr.Skip();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise, add what is possible
|
||||||
subreader.MoveToContent();
|
subreader.MoveToContent();
|
||||||
if (!softlist && temptype == "software" && subreader.ReadToFollowing("description"))
|
if (!softlist && temptype == "software" && subreader.ReadToFollowing("description"))
|
||||||
{
|
{
|
||||||
@@ -2644,7 +2665,6 @@ namespace SabreTools.Helper
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// If we didn't find any items in the folder, make sure to add the blank rom
|
// If we didn't find any items in the folder, make sure to add the blank rom
|
||||||
if (empty)
|
if (empty)
|
||||||
@@ -2687,8 +2707,14 @@ namespace SabreTools.Helper
|
|||||||
// If the rom is itemStatus, flag it
|
// If the rom is itemStatus, flag it
|
||||||
its = ItemStatus.None;
|
its = ItemStatus.None;
|
||||||
flagreader = xtr.ReadSubtree();
|
flagreader = xtr.ReadSubtree();
|
||||||
if (flagreader != null)
|
|
||||||
|
// If the subtree is empty, skip it
|
||||||
|
if (flagreader == null)
|
||||||
{
|
{
|
||||||
|
xtr.Skip();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
while (!flagreader.EOF)
|
while (!flagreader.EOF)
|
||||||
{
|
{
|
||||||
// We only want elements
|
// We only want elements
|
||||||
@@ -2730,7 +2756,6 @@ namespace SabreTools.Helper
|
|||||||
|
|
||||||
flagreader.Read();
|
flagreader.Read();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// If the rom has a Date attached, read it in and then sanitize it
|
// If the rom has a Date attached, read it in and then sanitize it
|
||||||
date = "";
|
date = "";
|
||||||
@@ -2807,7 +2832,6 @@ namespace SabreTools.Helper
|
|||||||
|
|
||||||
xtr.Dispose();
|
xtr.Dispose();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add a rom to the Dat after checking
|
/// Add a rom to the Dat after checking
|
||||||
|
|||||||
Reference in New Issue
Block a user