[DatFile] Better parsing for DOSCenter DATS

This commit is contained in:
Matt Nadareski
2016-10-06 16:29:53 -07:00
parent b9388de8cb
commit d8caa8db50

View File

@@ -1667,37 +1667,52 @@ namespace SabreTools.Helper
// Special cases for DOSCenter DATs only // Special cases for DOSCenter DATs only
else if (line.Trim().StartsWith("file (")) else if (line.Trim().StartsWith("file ("))
{ {
// If we have a properly formed line... // Loop over the specifics
if (gc[i] == "name") for (int j = i; j < gc.Length; j++)
{ {
// Advance to the first part of the name // Names are not quoted, for some stupid reason
i++; if (gc[j] == "name")
item.Name = gc[i];
// Advance to the next item, adding until we find "size"
i++;
while (gc[i] != "size")
{ {
item.Name += " " + gc[i]; // Advance to the first part of the name
i++; j++;
item.Name = gc[j];
// Advance to the next item, adding until we find "size"
j++;
while (j < gc.Length && gc[j] != "size" && gc[j] != "date" && gc[j] != "crc")
{
item.Name += " " + gc[j];
j++;
}
} }
// Advance to the size and process it // Get the size from the next part
i++; else if (gc[j] == "size")
long tempsize = -1;
if (!Int64.TryParse(gc[i], out tempsize))
{ {
tempsize = 0; j++;
long tempsize = -1;
if (!Int64.TryParse(gc[j], out tempsize))
{
tempsize = 0;
}
((Rom)item).Size = tempsize;
j++;
} }
((Rom)item).Size = tempsize;
// Advance to the date and add it // Get the date from the next part
i += 2; else if (gc[j] == "date")
((Rom)item).Date = gc[i].Replace("\"", "") + " " + gc[i + 1].Replace("\"", ""); {
j++;
((Rom)item).Date = gc[j].Replace("\"", "") + " " + gc[j + 1].Replace("\"", "");
j += 3;
}
// Advance to the CRC and add it // Get the CRC from the next part
i += 3; else if (gc[j] == "crc")
((Rom)item).CRC = gc[i].Replace("\"", "").ToLowerInvariant(); {
j++;
((Rom)item).CRC = gc[j].Replace("\"", "").ToLowerInvariant();
}
} }
} }