[DatTools, RomTools] Fix type-split output, make parsing for MAME listxml better

This commit is contained in:
Matt Nadareski
2016-09-13 11:24:02 -07:00
parent 3cef665b2b
commit ed1676cd35
3 changed files with 34 additions and 5 deletions

View File

@@ -900,6 +900,15 @@ namespace SabreTools.Helper
switch (xtr.Name) switch (xtr.Name)
{ {
// Handle MAME listxml since they're halfway between a SL and a Logiqx XML
case "mame":
if (xtr.GetAttribute("build") != null)
{
datdata.Name = (String.IsNullOrEmpty(datdata.Name) ? xtr.GetAttribute("build") : datdata.Name);
datdata.Description = (String.IsNullOrEmpty(datdata.Description) ? datdata.Name : datdata.Name);
}
xtr.Read();
break;
// New software lists have this behavior // New software lists have this behavior
case "softwarelist": case "softwarelist":
if (xtr.GetAttribute("name") != null) if (xtr.GetAttribute("name") != null)
@@ -920,6 +929,7 @@ namespace SabreTools.Helper
{ {
datdata.Version = (String.IsNullOrEmpty(datdata.Version) ? xtr.GetAttribute("version") : datdata.Version); datdata.Version = (String.IsNullOrEmpty(datdata.Version) ? xtr.GetAttribute("version") : datdata.Version);
} }
xtr.Read();
break; break;
// We want to process the entire subtree of the header // We want to process the entire subtree of the header
case "header": case "header":

View File

@@ -235,6 +235,8 @@ namespace SabreTools.Helper
if (x.Metadata.SourceID == y.Metadata.SourceID) if (x.Metadata.SourceID == y.Metadata.SourceID)
{ {
if (x.Machine.Name == y.Machine.Name) if (x.Machine.Name == y.Machine.Name)
{
if ((x.Type == ItemType.Rom || x.Type == ItemType.Disk) && (y.Type == ItemType.Rom || y.Type == ItemType.Disk))
{ {
if (Path.GetDirectoryName(x.Name) == Path.GetDirectoryName(y.Name)) if (Path.GetDirectoryName(x.Name) == Path.GetDirectoryName(y.Name))
{ {
@@ -242,6 +244,23 @@ namespace SabreTools.Helper
} }
return Style.CompareNumeric(Path.GetDirectoryName(x.Name), Path.GetDirectoryName(y.Name)); return Style.CompareNumeric(Path.GetDirectoryName(x.Name), Path.GetDirectoryName(y.Name));
} }
else if ((x.Type == ItemType.Rom || x.Type == ItemType.Disk) && (y.Type != ItemType.Rom && y.Type != ItemType.Disk))
{
return -1;
}
else if ((x.Type != ItemType.Rom && x.Type != ItemType.Disk) && (y.Type == ItemType.Rom || y.Type == ItemType.Disk))
{
return 1;
}
else
{
if (Path.GetDirectoryName(x.Name) == Path.GetDirectoryName(y.Name))
{
return Style.CompareNumeric(Path.GetFileName(x.Name), Path.GetFileName(y.Name));
}
return Style.CompareNumeric(Path.GetDirectoryName(x.Name), Path.GetDirectoryName(y.Name));
}
}
return Style.CompareNumeric(x.Machine.Name, y.Machine.Name); return Style.CompareNumeric(x.Machine.Name, y.Machine.Name);
} }
return (norename ? String.Compare(x.Machine.Name, y.Machine.Name) : x.Metadata.SourceID - y.Metadata.SourceID); return (norename ? String.Compare(x.Machine.Name, y.Machine.Name) : x.Metadata.SourceID - y.Metadata.SourceID);

View File

@@ -499,13 +499,13 @@ namespace SabreTools
{ {
if (File.Exists(input)) if (File.Exists(input))
{ {
DatTools.SplitByType(Path.GetFullPath(input), outdir, Path.GetDirectoryName(input), _logger); DatTools.SplitByType(Path.GetFullPath(input), outdir, Path.GetFullPath(Path.GetDirectoryName(input)), _logger);
} }
else if (Directory.Exists(input)) else if (Directory.Exists(input))
{ {
foreach (string file in Directory.EnumerateFiles(input, "*", SearchOption.AllDirectories)) foreach (string file in Directory.EnumerateFiles(input, "*", SearchOption.AllDirectories))
{ {
DatTools.SplitByType(file, outdir, (input.EndsWith(Path.DirectorySeparatorChar.ToString()) ? input : input + Path.DirectorySeparatorChar), _logger); DatTools.SplitByType(file, outdir, Path.GetFullPath((input.EndsWith(Path.DirectorySeparatorChar.ToString()) ? input : input + Path.DirectorySeparatorChar)), _logger);
} }
} }
else else