mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Write-as-you-go for non-XML
This commit is contained in:
@@ -193,10 +193,8 @@ namespace SabreTools.Library.DatFiles
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string header = "#Title;Name;Emulator;CloneOf;Year;Manufacturer;Category;Players;Rotation;Control;Status;DisplayCount;DisplayType;AltRomname;AltTitle;Extra;Buttons\n";
|
sw.Write("#Title;Name;Emulator;CloneOf;Year;Manufacturer;Category;Players;Rotation;Control;Status;DisplayCount;DisplayType;AltRomname;AltTitle;Extra;Buttons\n");
|
||||||
|
|
||||||
// Write the header out
|
|
||||||
sw.Write(header);
|
|
||||||
sw.Flush();
|
sw.Flush();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -229,27 +227,24 @@ namespace SabreTools.Library.DatFiles
|
|||||||
// Pre-process the item name
|
// Pre-process the item name
|
||||||
ProcessItemName(datItem, true);
|
ProcessItemName(datItem, true);
|
||||||
|
|
||||||
string state = string.Empty;
|
sw.Write($"{datItem.GetField(Field.MachineName, ExcludeFields)};");
|
||||||
|
sw.Write($"{datItem.GetField(Field.Description, ExcludeFields)};");
|
||||||
|
sw.Write($"{FileName};");
|
||||||
|
sw.Write($"{datItem.GetField(Field.CloneOf, ExcludeFields)};");
|
||||||
|
sw.Write($"{datItem.GetField(Field.Year, ExcludeFields)};");
|
||||||
|
sw.Write($"{datItem.GetField(Field.Manufacturer, ExcludeFields)};");
|
||||||
|
sw.Write(";"); // $"{datItem.GetField(Field.Category, ExcludeFields)};");
|
||||||
|
sw.Write(";"); // $"{datItem.GetField(Field.Players, ExcludeFields)};");
|
||||||
|
sw.Write(";"); // $"{datItem.GetField(Field.Rotation, ExcludeFields)};");
|
||||||
|
sw.Write(";"); // $"{datItem.GetField(Field.Control, ExcludeFields)};");
|
||||||
|
sw.Write(";"); // $"{datItem.GetField(Field.Status, ExcludeFields)};");
|
||||||
|
sw.Write(";"); // $"{datItem.GetField(Field.DisplayCount, ExcludeFields)};");
|
||||||
|
sw.Write(";"); // $"{datItem.GetField(Field.DisplayType, ExcludeFields)};");
|
||||||
|
sw.Write(";"); // $"{datItem.GetField(Field.AltRomname, ExcludeFields)};");
|
||||||
|
sw.Write(";"); // $"{datItem.GetField(Field.AltTitle, ExcludeFields)};");
|
||||||
|
sw.Write($"{datItem.GetField(Field.Comment, ExcludeFields)};");
|
||||||
|
sw.Write(";"); // $"{datItem.GetField(Field.Buttons, ExcludeFields)};");
|
||||||
|
|
||||||
state += $"{datItem.GetField(Field.MachineName, ExcludeFields)};";
|
|
||||||
state += $"{datItem.GetField(Field.Description, ExcludeFields)};";
|
|
||||||
state += $"{FileName};";
|
|
||||||
state += $"{datItem.GetField(Field.CloneOf, ExcludeFields)};";
|
|
||||||
state += $"{datItem.GetField(Field.Year, ExcludeFields)};";
|
|
||||||
state += $"{datItem.GetField(Field.Manufacturer, ExcludeFields)};";
|
|
||||||
state += ";"; // $"{datItem.GetField(Field.Category, ExcludeFields)};";
|
|
||||||
state += ";"; // $"{datItem.GetField(Field.Players, ExcludeFields)};";
|
|
||||||
state += ";"; // $"{datItem.GetField(Field.Rotation, ExcludeFields)};";
|
|
||||||
state += ";"; // $"{datItem.GetField(Field.Control, ExcludeFields)};";
|
|
||||||
state += ";"; // $"{datItem.GetField(Field.Status, ExcludeFields)};";
|
|
||||||
state += ";"; // $"{datItem.GetField(Field.DisplayCount, ExcludeFields)};";
|
|
||||||
state += ";"; // $"{datItem.GetField(Field.DisplayType, ExcludeFields)};";
|
|
||||||
state += ";"; // $"{datItem.GetField(Field.AltRomname, ExcludeFields)};";
|
|
||||||
state += ";"; // $"{datItem.GetField(Field.AltTitle, ExcludeFields)};";
|
|
||||||
state += $"{datItem.GetField(Field.Comment, ExcludeFields)};";
|
|
||||||
state += ";"; // $"{datItem.GetField(Field.Buttons, ExcludeFields)};";
|
|
||||||
|
|
||||||
sw.Write(state);
|
|
||||||
sw.Flush();
|
sw.Flush();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ namespace SabreTools.Library.DatFiles
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents parsing and writing of a ClrMamePro DAT
|
/// Represents parsing and writing of a ClrMamePro DAT
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// TODO: Verify that all write for this DatFile type is correct
|
/// TODO: Can there be a writer like XmlTextWriter for this? Or too inconsistent?
|
||||||
internal class ClrMamePro : DatFile
|
internal class ClrMamePro : DatFile
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -764,51 +764,53 @@ namespace SabreTools.Library.DatFiles
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string header = "clrmamepro (\n";
|
sw.Write("clrmamepro (\n");
|
||||||
header += $"\tname \"{Name}\"\n";
|
sw.Write($"\tname \"{Name}\"\n");
|
||||||
header += $"\tdescription \"{Description}\"\n";
|
sw.Write($"\tdescription \"{Description}\"\n");
|
||||||
if (!string.IsNullOrWhiteSpace(Category))
|
if (!string.IsNullOrWhiteSpace(Category))
|
||||||
header += $"\tcategory \"{Category}\"\n";
|
sw.Write($"\tcategory \"{Category}\"\n");
|
||||||
header += $"\tversion \"{Version}\"\n";
|
sw.Write($"\tversion \"{Version}\"\n");
|
||||||
if (!string.IsNullOrWhiteSpace(Date))
|
if (!string.IsNullOrWhiteSpace(Date))
|
||||||
header += $"\tdate \"{Date}\"\n";
|
sw.Write($"\tdate \"{Date}\"\n");
|
||||||
header += $"\tauthor \"{Author}\"\n";
|
sw.Write($"\tauthor \"{Author}\"\n");
|
||||||
if (!string.IsNullOrWhiteSpace(Email))
|
if (!string.IsNullOrWhiteSpace(Email))
|
||||||
header += $"\temail \"{Email}\"\n";
|
sw.Write($"\temail \"{Email}\"\n");
|
||||||
if (!string.IsNullOrWhiteSpace(Homepage))
|
if (!string.IsNullOrWhiteSpace(Homepage))
|
||||||
header += $"\thomepage \"{Homepage}\"\n";
|
sw.Write($"\thomepage \"{Homepage}\"\n");
|
||||||
if (!string.IsNullOrWhiteSpace(Url))
|
if (!string.IsNullOrWhiteSpace(Url))
|
||||||
header += $"\turl \"{Url}\"\n";
|
sw.Write($"\turl \"{Url}\"\n");
|
||||||
if (!string.IsNullOrWhiteSpace(Comment))
|
if (!string.IsNullOrWhiteSpace(Comment))
|
||||||
header += $"\tcomment \"{Comment}\"\n";
|
sw.Write($"\tcomment \"{Comment}\"\n");
|
||||||
|
|
||||||
switch (ForcePacking)
|
switch (ForcePacking)
|
||||||
{
|
{
|
||||||
case ForcePacking.Unzip:
|
case ForcePacking.Unzip:
|
||||||
header += "\tforcezipping no\n";
|
sw.Write($"\tforcezipping no\n");
|
||||||
break;
|
break;
|
||||||
case ForcePacking.Zip:
|
case ForcePacking.Zip:
|
||||||
header += "\tforcezipping yes\n";
|
sw.Write($"\tforcezipping yes\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (ForceMerging)
|
switch (ForceMerging)
|
||||||
{
|
{
|
||||||
case ForceMerging.Full:
|
case ForceMerging.Full:
|
||||||
header += "\tforcemerging full\n";
|
sw.Write($"\tforcemerging full\n");
|
||||||
break;
|
break;
|
||||||
case ForceMerging.Split:
|
case ForceMerging.Split:
|
||||||
header += "\tforcemerging split\n";
|
sw.Write($"\tforcemerging split\n");
|
||||||
break;
|
break;
|
||||||
case ForceMerging.Merged:
|
case ForceMerging.Merged:
|
||||||
header += "\tforcemerging merged\n";
|
sw.Write($"\tforcemerging merged\n");
|
||||||
break;
|
break;
|
||||||
case ForceMerging.NonMerged:
|
case ForceMerging.NonMerged:
|
||||||
header += "\tforcemerging nonmerged\n";
|
sw.Write($"\tforcemerging nonmerged\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
header += ")\n";
|
|
||||||
|
|
||||||
// Write the header out
|
// End clrmamepro
|
||||||
sw.Write(header);
|
sw.Write(")\n");
|
||||||
|
|
||||||
sw.Flush();
|
sw.Flush();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -834,23 +836,23 @@ namespace SabreTools.Library.DatFiles
|
|||||||
datItem.MachineName = datItem.MachineName.TrimStart(Path.DirectorySeparatorChar);
|
datItem.MachineName = datItem.MachineName.TrimStart(Path.DirectorySeparatorChar);
|
||||||
|
|
||||||
// Build the state based on excluded fields
|
// Build the state based on excluded fields
|
||||||
string state = (datItem.MachineType == MachineType.Bios ? "resource" : "game");
|
sw.Write($"{(datItem.MachineType == MachineType.Bios ? "resource" : "game")} (\n");
|
||||||
state += $" (\n\tname \"{datItem.MachineName}\"\n";
|
sw.Write($"\tname \"{datItem.MachineName}\"\n");
|
||||||
state += $"\tromof \"{datItem.RomOf}\"\n";
|
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.RomOf, ExcludeFields)))
|
||||||
|
sw.Write($"\tromof \"{datItem.RomOf}\"\n");
|
||||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.CloneOf, ExcludeFields)))
|
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.CloneOf, ExcludeFields)))
|
||||||
state += $"\tcloneof \"{datItem.CloneOf}\"\n";
|
sw.Write($"\tcloneof \"{datItem.CloneOf}\"\n");
|
||||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SampleOf, ExcludeFields)))
|
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SampleOf, ExcludeFields)))
|
||||||
state += $"\tsampleof \"{datItem.SampleOf}\"\n";
|
sw.Write($"\tsampleof \"{datItem.SampleOf}\"\n");
|
||||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Description, ExcludeFields)))
|
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Description, ExcludeFields)))
|
||||||
state += $"\tdescription \"{datItem.MachineDescription}\"\n";
|
sw.Write($"\tdescription \"{datItem.MachineDescription}\"\n");
|
||||||
else if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Description, ExcludeFields)))
|
else if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Description, ExcludeFields)))
|
||||||
state += $"\tdescription \"{datItem.MachineName}\"\n";
|
sw.Write($"\tdescription \"{datItem.MachineName}\"\n");
|
||||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Year, ExcludeFields)))
|
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Year, ExcludeFields)))
|
||||||
state += $"\tyear \"{datItem.Year}\"\n";
|
sw.Write($"\tyear \"{datItem.Year}\"\n");
|
||||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Manufacturer, ExcludeFields)))
|
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Manufacturer, ExcludeFields)))
|
||||||
state += $"\tmanufacturer \"{datItem.Manufacturer}\"\n";
|
sw.Write($"\tmanufacturer \"{datItem.Manufacturer}\"\n");
|
||||||
|
|
||||||
sw.Write(state);
|
|
||||||
sw.Flush();
|
sw.Flush();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -876,11 +878,11 @@ namespace SabreTools.Library.DatFiles
|
|||||||
|
|
||||||
// Build the state based on excluded fields
|
// Build the state based on excluded fields
|
||||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SampleOf, ExcludeFields)))
|
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SampleOf, ExcludeFields)))
|
||||||
state += $"\tsampleof \"{datItem.SampleOf}\"\n";
|
sw.Write($"\tsampleof \"{datItem.SampleOf}\"\n");
|
||||||
|
|
||||||
state += ")\n";
|
// End game
|
||||||
|
sw.Write(")\n");
|
||||||
|
|
||||||
sw.Write(state);
|
|
||||||
sw.Flush();
|
sw.Flush();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -917,83 +919,89 @@ namespace SabreTools.Library.DatFiles
|
|||||||
switch (datItem.ItemType)
|
switch (datItem.ItemType)
|
||||||
{
|
{
|
||||||
case ItemType.Archive:
|
case ItemType.Archive:
|
||||||
state += $"\tarchive ( name\"{datItem.GetField(Field.Name, ExcludeFields)}\"";
|
sw.Write("\tarchive (");
|
||||||
state += " )\n";
|
sw.Write($" name\"{datItem.GetField(Field.Name, ExcludeFields)}\"");
|
||||||
|
sw.Write(" )\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ItemType.BiosSet:
|
case ItemType.BiosSet:
|
||||||
var biosSet = datItem as BiosSet;
|
var biosSet = datItem as BiosSet;
|
||||||
state += $"\tbiosset ( name\"{datItem.GetField(Field.Name, ExcludeFields)}\"";
|
sw.Write("\tbiosset (");
|
||||||
|
sw.Write($" name\"{biosSet.GetField(Field.Name, ExcludeFields)}\"");
|
||||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.BiosDescription, ExcludeFields)))
|
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.BiosDescription, ExcludeFields)))
|
||||||
state += $" description \"{biosSet.Description}\"";
|
sw.Write($" description \"{biosSet.Description}\"");
|
||||||
if (!ExcludeFields[(int)Field.Default] && biosSet.Default != null)
|
if (!ExcludeFields[(int)Field.Default] && biosSet.Default != null)
|
||||||
state += $" default \"{biosSet.Default.ToString().ToLowerInvariant()}\"";
|
sw.Write($" default \"{biosSet.Default.ToString().ToLowerInvariant()}\"");
|
||||||
state += " )\n";
|
sw.Write(" )\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ItemType.Disk:
|
case ItemType.Disk:
|
||||||
var disk = datItem as Disk;
|
var disk = datItem as Disk;
|
||||||
state += $"\tdisk ( name \"{datItem.GetField(Field.Name, ExcludeFields)}\"";
|
sw.Write("\tdisk (");
|
||||||
|
sw.Write($" name\"{disk.GetField(Field.Name, ExcludeFields)}\"");
|
||||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.MD5, ExcludeFields)))
|
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.MD5, ExcludeFields)))
|
||||||
state += $" md5 \"{disk.MD5.ToLowerInvariant()}\"";
|
sw.Write($" md5 \"{disk.MD5.ToLowerInvariant()}\"");
|
||||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.RIPEMD160, ExcludeFields)))
|
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.RIPEMD160, ExcludeFields)))
|
||||||
state += $" ripemd160 \"{disk.RIPEMD160.ToLowerInvariant()}\"";
|
sw.Write($" ripemd160 \"{disk.RIPEMD160.ToLowerInvariant()}\"");
|
||||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA1, ExcludeFields)))
|
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA1, ExcludeFields)))
|
||||||
state += $" sha1 \"{disk.SHA1.ToLowerInvariant()}\"";
|
sw.Write($" sha1 \"{disk.SHA1.ToLowerInvariant()}\"");
|
||||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA256, ExcludeFields)))
|
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA256, ExcludeFields)))
|
||||||
state += $" sha256 \"{disk.SHA256.ToLowerInvariant()}\"";
|
sw.Write($" sha256 \"{disk.SHA256.ToLowerInvariant()}\"");
|
||||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA384, ExcludeFields)))
|
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA384, ExcludeFields)))
|
||||||
state += $" sha384 \"{disk.SHA384.ToLowerInvariant()}\"";
|
sw.Write($" sha384 \"{disk.SHA384.ToLowerInvariant()}\"");
|
||||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA512, ExcludeFields)))
|
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA512, ExcludeFields)))
|
||||||
state += $" sha512 \"{disk.SHA512.ToLowerInvariant()}\"";
|
sw.Write($" sha512 \"{disk.SHA512.ToLowerInvariant()}\"");
|
||||||
if (!ExcludeFields[(int)Field.Status] && disk.ItemStatus != ItemStatus.None)
|
if (!ExcludeFields[(int)Field.Status] && disk.ItemStatus != ItemStatus.None)
|
||||||
state += $" flags \"{disk.ItemStatus.ToString().ToLowerInvariant()}\"";
|
sw.Write($" flags \"{disk.ItemStatus.ToString().ToLowerInvariant()}\"");
|
||||||
state += " )\n";
|
sw.Write(" )\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ItemType.Release:
|
case ItemType.Release:
|
||||||
var release = datItem as Release;
|
var release = datItem as Release;
|
||||||
state += $"\trelease ( name\"{datItem.GetField(Field.Name, ExcludeFields)}\"";
|
sw.Write("\trelease (");
|
||||||
|
sw.Write($" name\"{release.GetField(Field.Name, ExcludeFields)}\"");
|
||||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Region, ExcludeFields)))
|
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Region, ExcludeFields)))
|
||||||
state += $" region \"{release.Region}\"";
|
sw.Write($" region \"{release.Region}\"");
|
||||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Language, ExcludeFields)))
|
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Language, ExcludeFields)))
|
||||||
state += $" language \"{release.Language}\"";
|
sw.Write($" language \"{release.Language}\"");
|
||||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Date, ExcludeFields)))
|
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Date, ExcludeFields)))
|
||||||
state += $" date \"{release.Date}\"";
|
sw.Write($" date \"{release.Date}\"");
|
||||||
if (!ExcludeFields[(int)Field.Default] && release.Default != null)
|
if (!ExcludeFields[(int)Field.Default] && release.Default != null)
|
||||||
state += $" default \"{release.Default.ToString().ToLowerInvariant()}\"";
|
sw.Write($" default \"{release.Default.ToString().ToLowerInvariant()}\"");
|
||||||
state += " )\n";
|
sw.Write(" )\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ItemType.Rom:
|
case ItemType.Rom:
|
||||||
var rom = datItem as Rom;
|
var rom = datItem as Rom;
|
||||||
state += $"\trom ( name \"{datItem.GetField(Field.Name, ExcludeFields)}\"";
|
sw.Write("\trom (");
|
||||||
|
sw.Write($" name\"{rom.GetField(Field.Name, ExcludeFields)}\"");
|
||||||
if (!ExcludeFields[(int)Field.Size] && rom.Size != -1)
|
if (!ExcludeFields[(int)Field.Size] && rom.Size != -1)
|
||||||
state += $" size \"{rom.Size}\"";
|
sw.Write($" size \"{rom.Size}\"");
|
||||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.CRC, ExcludeFields)))
|
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.CRC, ExcludeFields)))
|
||||||
state += $" crc \"{rom.CRC.ToLowerInvariant()}\"";
|
sw.Write($" crc \"{rom.CRC.ToLowerInvariant()}\"");
|
||||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.MD5, ExcludeFields)))
|
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.MD5, ExcludeFields)))
|
||||||
state += $" md5 \"{rom.MD5.ToLowerInvariant()}\"";
|
sw.Write($" md5 \"{rom.MD5.ToLowerInvariant()}\"");
|
||||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.RIPEMD160, ExcludeFields)))
|
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.RIPEMD160, ExcludeFields)))
|
||||||
state += $" ripemd160 \"{rom.RIPEMD160.ToLowerInvariant()}\"";
|
sw.Write($" ripemd160 \"{rom.RIPEMD160.ToLowerInvariant()}\"");
|
||||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA1, ExcludeFields)))
|
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA1, ExcludeFields)))
|
||||||
state += $" sha1 \"{rom.SHA1.ToLowerInvariant()}\"";
|
sw.Write($" sha1 \"{rom.SHA1.ToLowerInvariant()}\"");
|
||||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA256, ExcludeFields)))
|
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA256, ExcludeFields)))
|
||||||
state += $" sha256 \"{rom.SHA256.ToLowerInvariant()}\"";
|
sw.Write($" sha256 \"{rom.SHA256.ToLowerInvariant()}\"");
|
||||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA384, ExcludeFields)))
|
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA384, ExcludeFields)))
|
||||||
state += $" sha384 \"{rom.SHA384.ToLowerInvariant()}\"";
|
sw.Write($" sha384 \"{rom.SHA384.ToLowerInvariant()}\"");
|
||||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA512, ExcludeFields)))
|
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA512, ExcludeFields)))
|
||||||
state += $" sha512 \"{rom.SHA512.ToLowerInvariant()}\"";
|
sw.Write($" sha512 \"{rom.SHA512.ToLowerInvariant()}\"");
|
||||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Date, ExcludeFields)))
|
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Date, ExcludeFields)))
|
||||||
state += $" date \"{rom.Date}\"";
|
sw.Write($" date \"{rom.Date}\"");
|
||||||
if (!ExcludeFields[(int)Field.Status] && rom.ItemStatus != ItemStatus.None)
|
if (!ExcludeFields[(int)Field.Status] && rom.ItemStatus != ItemStatus.None)
|
||||||
state += $" flags \"{rom.ItemStatus.ToString().ToLowerInvariant()}\"";
|
sw.Write($" flags \"{rom.ItemStatus.ToString().ToLowerInvariant()}\"");
|
||||||
state += " )\n";
|
sw.Write(" )\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ItemType.Sample:
|
case ItemType.Sample:
|
||||||
state += $"\tsample ( name\"{datItem.GetField(Field.Name, ExcludeFields)}\"";
|
sw.Write("\tsample (");
|
||||||
state += " )\n";
|
sw.Write($" name\"{datItem.GetField(Field.Name, ExcludeFields)}\"");
|
||||||
|
sw.Write(" )\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1018,10 +1026,9 @@ namespace SabreTools.Library.DatFiles
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string footer = footer = ")\n";
|
// End game
|
||||||
|
sw.Write(")\n");
|
||||||
|
|
||||||
// Write the footer out
|
|
||||||
sw.Write(footer);
|
|
||||||
sw.Flush();
|
sw.Flush();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|||||||
@@ -162,18 +162,16 @@ namespace SabreTools.Library.DatFiles
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string header = "DOSCenter (\n";
|
sw.Write("DOSCenter (\n");
|
||||||
header += $"\tName: {Name}\n";
|
sw.Write($"\tName: {Name}\n");
|
||||||
header += $"\tDescription: {Description}\n";
|
sw.Write($"\tDescription: {Description}\n");
|
||||||
header += $"\tVersion: {Version}\n";
|
sw.Write($"\tVersion: {Version}\n");
|
||||||
header += $"\tDate: {Date}\n";
|
sw.Write($"\tDate: {Date}\n");
|
||||||
header += $"\tAuthor: {Author}\n";
|
sw.Write($"\tAuthor: {Author}\n");
|
||||||
header += $"\tHomepage: {Homepage}\n";
|
sw.Write($"\tHomepage: {Homepage}\n");
|
||||||
header += $"\tComment: {Comment}\n";
|
sw.Write($"\tComment: {Comment}\n");
|
||||||
header += ")\n";
|
sw.Write(")\n");
|
||||||
|
|
||||||
// Write the header out
|
|
||||||
sw.Write(header);
|
|
||||||
sw.Flush();
|
sw.Flush();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -199,9 +197,9 @@ namespace SabreTools.Library.DatFiles
|
|||||||
datItem.MachineName = datItem.MachineName.TrimStart(Path.DirectorySeparatorChar);
|
datItem.MachineName = datItem.MachineName.TrimStart(Path.DirectorySeparatorChar);
|
||||||
|
|
||||||
// Build the state based on excluded fields
|
// Build the state based on excluded fields
|
||||||
string state = $"game (\n\tname \"{datItem.GetField(Field.MachineName, ExcludeFields)}.zip\n";
|
sw.Write("game (\n");
|
||||||
|
sw.Write($"\tname \"{datItem.GetField(Field.MachineName, ExcludeFields)}.zip\n");
|
||||||
|
|
||||||
sw.Write(state);
|
|
||||||
sw.Flush();
|
sw.Flush();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -223,15 +221,13 @@ namespace SabreTools.Library.DatFiles
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string state = string.Empty;
|
|
||||||
|
|
||||||
// Build the state based on excluded fields
|
// Build the state based on excluded fields
|
||||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SampleOf, ExcludeFields)))
|
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SampleOf, ExcludeFields)))
|
||||||
state += $"\tsampleof \"{datItem.SampleOf}\"\n";
|
sw.Write($"\tsampleof \"{datItem.SampleOf}\"\n");
|
||||||
|
|
||||||
state += ")\n";
|
// End game
|
||||||
|
sw.Write(")\n");
|
||||||
|
|
||||||
sw.Write(state);
|
|
||||||
sw.Flush();
|
sw.Flush();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -266,23 +262,17 @@ namespace SabreTools.Library.DatFiles
|
|||||||
// Build the state based on excluded fields
|
// Build the state based on excluded fields
|
||||||
switch (datItem.ItemType)
|
switch (datItem.ItemType)
|
||||||
{
|
{
|
||||||
case ItemType.Archive:
|
|
||||||
case ItemType.BiosSet:
|
|
||||||
case ItemType.Disk:
|
|
||||||
case ItemType.Release:
|
|
||||||
case ItemType.Sample:
|
|
||||||
// We don't output these at all for DosCenter
|
|
||||||
break;
|
|
||||||
case ItemType.Rom:
|
case ItemType.Rom:
|
||||||
var rom = datItem as Rom;
|
var rom = datItem as Rom;
|
||||||
state += $"\file ( name \"{datItem.GetField(Field.Name, ExcludeFields)}\"";
|
sw.Write("\tfile (");
|
||||||
|
sw.Write($" name \"{datItem.GetField(Field.Name, ExcludeFields)}\"");
|
||||||
if (!ExcludeFields[(int)Field.Size] && rom.Size != -1)
|
if (!ExcludeFields[(int)Field.Size] && rom.Size != -1)
|
||||||
state += $" size \"{rom.Size}\"";
|
sw.Write($" size \"{rom.Size}\"");
|
||||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Date, ExcludeFields)))
|
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Date, ExcludeFields)))
|
||||||
state += $" date \"{rom.Date}\"";
|
sw.Write($" date \"{rom.Date}\"");
|
||||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.CRC, ExcludeFields)))
|
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.CRC, ExcludeFields)))
|
||||||
state += $" crc \"{rom.CRC.ToLowerInvariant()}\"";
|
sw.Write($" crc \"{rom.CRC.ToLowerInvariant()}\"");
|
||||||
state += " )\n";
|
sw.Write(" )\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -307,10 +297,10 @@ namespace SabreTools.Library.DatFiles
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string footer = ")\n";
|
// End game
|
||||||
|
sw.Write(")\n");
|
||||||
|
|
||||||
// Write the footer out
|
// Write the footer out
|
||||||
sw.Write(footer);
|
|
||||||
sw.Flush();
|
sw.Flush();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|||||||
@@ -177,32 +177,21 @@ namespace SabreTools.Library.DatFiles
|
|||||||
// Pre-process the item name
|
// Pre-process the item name
|
||||||
ProcessItemName(datItem, true);
|
ProcessItemName(datItem, true);
|
||||||
|
|
||||||
string state = string.Empty;
|
|
||||||
|
|
||||||
// Build the state based on excluded fields
|
// Build the state based on excluded fields
|
||||||
switch (datItem.ItemType)
|
switch (datItem.ItemType)
|
||||||
{
|
{
|
||||||
case ItemType.Archive:
|
|
||||||
case ItemType.BiosSet:
|
|
||||||
case ItemType.Disk:
|
|
||||||
case ItemType.Release:
|
|
||||||
case ItemType.Sample:
|
|
||||||
// We don't output these at all for Everdrive SMDB
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ItemType.Rom:
|
case ItemType.Rom:
|
||||||
var rom = datItem as Rom;
|
var rom = datItem as Rom;
|
||||||
state += $"{rom.GetField(Field.SHA256, ExcludeFields)}\t";
|
sw.Write($"{rom.GetField(Field.SHA256, ExcludeFields)}\t");
|
||||||
state += $"{rom.GetField(Field.MachineName, ExcludeFields)}/\t";
|
sw.Write($"{rom.GetField(Field.MachineName, ExcludeFields)}/\t");
|
||||||
state += $"{rom.GetField(Field.Name, ExcludeFields)}\t";
|
sw.Write($"{rom.GetField(Field.Name, ExcludeFields)}\t");
|
||||||
state += $"{rom.GetField(Field.SHA1, ExcludeFields)}\t";
|
sw.Write($"{rom.GetField(Field.SHA1, ExcludeFields)}\t");
|
||||||
state += $"{rom.GetField(Field.MD5, ExcludeFields)}\t";
|
sw.Write($"{rom.GetField(Field.MD5, ExcludeFields)}\t");
|
||||||
state += $"{rom.GetField(Field.CRC, ExcludeFields)}";
|
sw.Write($"{rom.GetField(Field.CRC, ExcludeFields)}");
|
||||||
state += "\n";
|
sw.Write("\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
sw.Write(state);
|
|
||||||
sw.Flush();
|
sw.Flush();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|||||||
@@ -195,14 +195,16 @@ namespace SabreTools.Library.DatFiles
|
|||||||
switch (_hash)
|
switch (_hash)
|
||||||
{
|
{
|
||||||
case Hash.CRC:
|
case Hash.CRC:
|
||||||
if (datItem.ItemType == ItemType.Rom)
|
switch (datItem.ItemType)
|
||||||
{
|
{
|
||||||
|
case ItemType.Rom:
|
||||||
var rom = datItem as Rom;
|
var rom = datItem as Rom;
|
||||||
if (GameName)
|
if (GameName)
|
||||||
state += $"{rom.GetField(Field.MachineName, ExcludeFields)}{Path.DirectorySeparatorChar}";
|
sw.Write($"{rom.GetField(Field.MachineName, ExcludeFields)}{Path.DirectorySeparatorChar}");
|
||||||
state += $"{rom.GetField(Field.Name, ExcludeFields)}";
|
sw.Write($"{rom.GetField(Field.Name, ExcludeFields)}");
|
||||||
state += $"{rom.GetField(Field.CRC, ExcludeFields)}";
|
sw.Write($"{rom.GetField(Field.CRC, ExcludeFields)}");
|
||||||
state += "\n";
|
sw.Write("\n");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -213,23 +215,26 @@ namespace SabreTools.Library.DatFiles
|
|||||||
case Hash.SHA384:
|
case Hash.SHA384:
|
||||||
case Hash.SHA512:
|
case Hash.SHA512:
|
||||||
Field hashField = Utilities.GetFieldFromHash(_hash);
|
Field hashField = Utilities.GetFieldFromHash(_hash);
|
||||||
if (datItem.ItemType == ItemType.Rom)
|
|
||||||
{
|
switch (datItem.ItemType)
|
||||||
var rom = datItem as Rom;
|
|
||||||
state += $"{rom.GetField(hashField, ExcludeFields)}";
|
|
||||||
if (GameName)
|
|
||||||
state += $"{rom.GetField(Field.MachineName, ExcludeFields)}{Path.DirectorySeparatorChar}";
|
|
||||||
state += $"{rom.GetField(Field.Name, ExcludeFields)}";
|
|
||||||
state += "\n";
|
|
||||||
}
|
|
||||||
else if (datItem.ItemType == ItemType.Disk)
|
|
||||||
{
|
{
|
||||||
|
case ItemType.Disk:
|
||||||
var disk = datItem as Disk;
|
var disk = datItem as Disk;
|
||||||
state += $"{disk.GetField(hashField, ExcludeFields)}";
|
sw.Write($"{disk.GetField(hashField, ExcludeFields)}");
|
||||||
if (GameName)
|
if (GameName)
|
||||||
state += $"{disk.GetField(Field.MachineName, ExcludeFields)}{Path.DirectorySeparatorChar}";
|
sw.Write($"{disk.GetField(Field.MachineName, ExcludeFields)}{Path.DirectorySeparatorChar}");
|
||||||
state += $"{disk.GetField(Field.Name, ExcludeFields)}";
|
sw.Write($"{disk.GetField(Field.Name, ExcludeFields)}");
|
||||||
state += "\n";
|
sw.Write("\n");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ItemType.Rom:
|
||||||
|
var rom = datItem as Rom;
|
||||||
|
sw.Write($"{rom.GetField(hashField, ExcludeFields)}");
|
||||||
|
if (GameName)
|
||||||
|
sw.Write($"{rom.GetField(Field.MachineName, ExcludeFields)}{Path.DirectorySeparatorChar}");
|
||||||
|
sw.Write($"{rom.GetField(Field.Name, ExcludeFields)}");
|
||||||
|
sw.Write("\n");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -325,10 +325,9 @@ namespace SabreTools.Library.DatFiles
|
|||||||
rom.MachineName = rom.MachineName.TrimStart(Path.DirectorySeparatorChar);
|
rom.MachineName = rom.MachineName.TrimStart(Path.DirectorySeparatorChar);
|
||||||
|
|
||||||
// Build the state based on excluded fields
|
// Build the state based on excluded fields
|
||||||
string state = $"ROMs required for driver \"{rom.GetField(Field.MachineName, ExcludeFields)}\".\n";
|
sw.Write($"ROMs required for driver \"{rom.GetField(Field.MachineName, ExcludeFields)}\".\n");
|
||||||
state += "Name Size Checksum\n";
|
sw.Write("Name Size Checksum\n");
|
||||||
|
|
||||||
sw.Write(state);
|
|
||||||
sw.Flush();
|
sw.Flush();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -349,9 +348,9 @@ namespace SabreTools.Library.DatFiles
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string state = "\n";
|
// End driver
|
||||||
|
sw.Write("\n");
|
||||||
|
|
||||||
sw.Write(state);
|
|
||||||
sw.Flush();
|
sw.Flush();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -378,89 +377,79 @@ namespace SabreTools.Library.DatFiles
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string state = string.Empty;
|
|
||||||
|
|
||||||
// Pre-process the item name
|
// Pre-process the item name
|
||||||
ProcessItemName(datItem, true);
|
ProcessItemName(datItem, true);
|
||||||
|
|
||||||
// Build the state based on excluded fields
|
// Build the state based on excluded fields
|
||||||
switch (datItem.ItemType)
|
switch (datItem.ItemType)
|
||||||
{
|
{
|
||||||
case ItemType.Archive:
|
|
||||||
case ItemType.BiosSet:
|
|
||||||
case ItemType.Release:
|
|
||||||
case ItemType.Sample:
|
|
||||||
// We don't output these at all for Listrom
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ItemType.Disk:
|
case ItemType.Disk:
|
||||||
var disk = datItem as Disk;
|
var disk = datItem as Disk;
|
||||||
|
|
||||||
// The name is padded out to a particular length
|
// The name is padded out to a particular length
|
||||||
if (disk.Name.Length < 43)
|
if (disk.Name.Length < 43)
|
||||||
state += disk.Name.PadRight(43, ' ');
|
sw.Write(disk.Name.PadRight(43, ' '));
|
||||||
else
|
else
|
||||||
state += disk.Name + " ";
|
sw.Write($"{disk.Name} ");
|
||||||
|
|
||||||
// If we have a baddump, put the first indicator
|
// If we have a baddump, put the first indicator
|
||||||
if (!ExcludeFields[(int)Field.Status] && disk.ItemStatus == ItemStatus.BadDump)
|
if (!ExcludeFields[(int)Field.Status] && disk.ItemStatus == ItemStatus.BadDump)
|
||||||
state += " BAD";
|
sw.Write(" BAD");
|
||||||
|
|
||||||
// If we have a nodump, write out the indicator
|
// If we have a nodump, write out the indicator
|
||||||
if (!ExcludeFields[(int)Field.Status] && disk.ItemStatus == ItemStatus.Nodump)
|
if (!ExcludeFields[(int)Field.Status] && disk.ItemStatus == ItemStatus.Nodump)
|
||||||
state += " NO GOOD DUMP KNOWN";
|
sw.Write(" NO GOOD DUMP KNOWN");
|
||||||
|
|
||||||
// Otherwise, write out the SHA-1 hash
|
// Otherwise, write out the SHA-1 hash
|
||||||
else if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA1, ExcludeFields)))
|
else if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA1, ExcludeFields)))
|
||||||
state += $" SHA1({disk.SHA1})";
|
sw.Write($" SHA1({disk.SHA1})");
|
||||||
|
|
||||||
// If we have a baddump, put the second indicator
|
// If we have a baddump, put the second indicator
|
||||||
if (!ExcludeFields[(int)Field.Status] && disk.ItemStatus == ItemStatus.BadDump)
|
if (!ExcludeFields[(int)Field.Status] && disk.ItemStatus == ItemStatus.BadDump)
|
||||||
state += " BAD_DUMP";
|
sw.Write(" BAD_DUMP");
|
||||||
|
|
||||||
state += "\n";
|
sw.Write("\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ItemType.Rom:
|
case ItemType.Rom:
|
||||||
var rom = datItem as Rom;
|
var rom = datItem as Rom;
|
||||||
|
|
||||||
// The name is padded out to a particular length
|
// The name is padded out to a particular length
|
||||||
if (rom.Name.Length < 40)
|
if (rom.Name.Length < 43)
|
||||||
state += rom.Name.PadRight(43 - rom.Size.ToString().Length, ' ');
|
sw.Write(rom.Name.PadRight(43 - rom.Size.ToString().Length, ' '));
|
||||||
else
|
else
|
||||||
state += rom.Name + " ";
|
sw.Write($"{rom.Name} ");
|
||||||
|
|
||||||
// If we don't have a nodump, write out the size
|
// If we don't have a nodump, write out the size
|
||||||
if (rom.ItemStatus != ItemStatus.Nodump)
|
if (rom.ItemStatus != ItemStatus.Nodump)
|
||||||
state += rom.Size;
|
sw.Write(rom.Size);
|
||||||
|
|
||||||
// If we have a baddump, put the first indicator
|
// If we have a baddump, put the first indicator
|
||||||
if (!ExcludeFields[(int)Field.Status] && rom.ItemStatus == ItemStatus.BadDump)
|
if (!ExcludeFields[(int)Field.Status] && rom.ItemStatus == ItemStatus.BadDump)
|
||||||
state += " BAD";
|
sw.Write(" BAD");
|
||||||
|
|
||||||
// If we have a nodump, write out the indicator
|
// If we have a nodump, write out the indicator
|
||||||
if (!ExcludeFields[(int)Field.Status] && rom.ItemStatus == ItemStatus.Nodump)
|
if (!ExcludeFields[(int)Field.Status] && rom.ItemStatus == ItemStatus.Nodump)
|
||||||
{
|
{
|
||||||
state += " NO GOOD DUMP KNOWN";
|
sw.Write(" NO GOOD DUMP KNOWN");
|
||||||
}
|
}
|
||||||
// Otherwise, write out the CRC and SHA-1 hashes
|
// Otherwise, write out the CRC and SHA-1 hashes
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.CRC, ExcludeFields)))
|
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.CRC, ExcludeFields)))
|
||||||
state += $" CRC({rom.CRC})";
|
sw.Write($" CRC({rom.CRC})");
|
||||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA1, ExcludeFields)))
|
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA1, ExcludeFields)))
|
||||||
state += $" SHA1({rom.SHA1})";
|
sw.Write($" SHA1({rom.SHA1})");
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we have a baddump, put the second indicator
|
// If we have a baddump, put the second indicator
|
||||||
if (!ExcludeFields[(int)Field.Status] && rom.ItemStatus == ItemStatus.BadDump)
|
if (!ExcludeFields[(int)Field.Status] && rom.ItemStatus == ItemStatus.BadDump)
|
||||||
state += " BAD_DUMP";
|
sw.Write(" BAD_DUMP");
|
||||||
|
|
||||||
state += "\n";
|
sw.Write("\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
sw.Write(state);
|
|
||||||
sw.Flush();
|
sw.Flush();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|||||||
@@ -150,19 +150,19 @@ namespace SabreTools.Library.DatFiles
|
|||||||
// If we're in Romba mode, the state is consistent
|
// If we're in Romba mode, the state is consistent
|
||||||
if (Romba)
|
if (Romba)
|
||||||
{
|
{
|
||||||
state += $"{datItem.GetField(Field.SHA1, ExcludeFields)}\n";
|
sw.Write($"{datItem.GetField(Field.SHA1, ExcludeFields)}\n");
|
||||||
}
|
}
|
||||||
// Otherwise, use any flags
|
// Otherwise, use any flags
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!UseRomName && datItem.MachineName != lastgame)
|
if (!UseRomName && datItem.MachineName != lastgame)
|
||||||
{
|
{
|
||||||
state += $"{datItem.GetField(Field.MachineName, ExcludeFields)}\n";
|
sw.Write($"{datItem.GetField(Field.MachineName, ExcludeFields)}\n");
|
||||||
lastgame = datItem.MachineName;
|
lastgame = datItem.MachineName;
|
||||||
}
|
}
|
||||||
else if (UseRomName)
|
else if (UseRomName)
|
||||||
{
|
{
|
||||||
state += $"{datItem.GetField(Field.Name, ExcludeFields)}\n";
|
sw.Write($"{datItem.GetField(Field.Name, ExcludeFields)}\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -228,21 +228,19 @@ namespace SabreTools.Library.DatFiles
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string header = "[CREDITS]\n";
|
sw.Write("[CREDITS]\n");
|
||||||
header += $"author={Author}\n";
|
sw.Write($"author={Author}\n");
|
||||||
header += $"version={Version}\n";
|
sw.Write($"version={Version}\n");
|
||||||
header += $"comment={Comment}\n";
|
sw.Write($"comment={Comment}\n");
|
||||||
header += "[DAT]\n";
|
sw.Write("[DAT]\n");
|
||||||
header += "version=2.50\n";
|
sw.Write("version=2.50\n");
|
||||||
header += $"split={(ForceMerging == ForceMerging.Split ? "1" : "0")}\n";
|
sw.Write($"split={(ForceMerging == ForceMerging.Split ? "1" : "0")}\n");
|
||||||
header += $"merge={(ForceMerging == ForceMerging.Full || ForceMerging == ForceMerging.Merged ? "1" : "0")}\n";
|
sw.Write($"merge={(ForceMerging == ForceMerging.Full || ForceMerging == ForceMerging.Merged ? "1" : "0")}\n");
|
||||||
header += "[EMULATOR]\n";
|
sw.Write("[EMULATOR]\n");
|
||||||
header += $"refname={Name}\n";
|
sw.Write($"refname={Name}\n");
|
||||||
header += $"version={Description}\n";
|
sw.Write($"version={Description}\n");
|
||||||
header += "[GAMES]\n";
|
sw.Write("[GAMES]\n");
|
||||||
|
|
||||||
// Write the header out
|
|
||||||
sw.Write(header);
|
|
||||||
sw.Flush();
|
sw.Flush();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -278,38 +276,38 @@ namespace SabreTools.Library.DatFiles
|
|||||||
switch (datItem.ItemType)
|
switch (datItem.ItemType)
|
||||||
{
|
{
|
||||||
case ItemType.Disk:
|
case ItemType.Disk:
|
||||||
state += "¬";
|
sw.Write("¬");
|
||||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.CloneOf, ExcludeFields)))
|
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.CloneOf, ExcludeFields)))
|
||||||
state += datItem.CloneOf;
|
sw.Write(datItem.CloneOf);
|
||||||
state += "¬";
|
sw.Write("¬");
|
||||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.CloneOf, ExcludeFields)))
|
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.CloneOf, ExcludeFields)))
|
||||||
state += datItem.CloneOf;
|
sw.Write(datItem.CloneOf);
|
||||||
state += $"¬{datItem.GetField(Field.MachineName, ExcludeFields)}";
|
sw.Write($"¬{datItem.GetField(Field.MachineName, ExcludeFields)}");
|
||||||
if (string.IsNullOrWhiteSpace(datItem.MachineDescription))
|
if (string.IsNullOrWhiteSpace(datItem.MachineDescription))
|
||||||
state += $"¬{datItem.GetField(Field.MachineName, ExcludeFields)}";
|
sw.Write($"¬{datItem.GetField(Field.MachineName, ExcludeFields)}");
|
||||||
else
|
else
|
||||||
state += $"¬{datItem.GetField(Field.Description, ExcludeFields)}";
|
sw.Write($"¬{datItem.GetField(Field.Description, ExcludeFields)}");
|
||||||
state += $"¬{datItem.GetField(Field.Name, ExcludeFields)}";
|
sw.Write($"¬{datItem.GetField(Field.Name, ExcludeFields)}");
|
||||||
state += "¬¬¬¬¬\n";
|
sw.Write("¬¬¬¬¬\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ItemType.Rom:
|
case ItemType.Rom:
|
||||||
var rom = datItem as Rom;
|
var rom = datItem as Rom;
|
||||||
state += "¬";
|
sw.Write("¬");
|
||||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.CloneOf, ExcludeFields)))
|
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.CloneOf, ExcludeFields)))
|
||||||
state += datItem.CloneOf;
|
sw.Write(datItem.CloneOf);
|
||||||
state += "¬";
|
sw.Write("¬");
|
||||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.CloneOf, ExcludeFields)))
|
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.CloneOf, ExcludeFields)))
|
||||||
state += datItem.CloneOf;
|
sw.Write(datItem.CloneOf);
|
||||||
state += $"¬{datItem.GetField(Field.MachineName, ExcludeFields)}";
|
sw.Write($"¬{datItem.GetField(Field.MachineName, ExcludeFields)}");
|
||||||
if (string.IsNullOrWhiteSpace(datItem.MachineDescription))
|
if (string.IsNullOrWhiteSpace(datItem.MachineDescription))
|
||||||
state += $"¬{datItem.GetField(Field.MachineName, ExcludeFields)}";
|
sw.Write($"¬{datItem.GetField(Field.MachineName, ExcludeFields)}");
|
||||||
else
|
else
|
||||||
state += $"¬{datItem.GetField(Field.Description, ExcludeFields)}";
|
sw.Write($"¬{datItem.GetField(Field.Description, ExcludeFields)}");
|
||||||
state += $"¬{datItem.GetField(Field.Name, ExcludeFields)}";
|
sw.Write($"¬{datItem.GetField(Field.Name, ExcludeFields)}");
|
||||||
state += $"¬{datItem.GetField(Field.CRC, ExcludeFields)}";
|
sw.Write($"¬{datItem.GetField(Field.CRC, ExcludeFields)}");
|
||||||
state += $"¬{datItem.GetField(Field.Size, ExcludeFields)}";
|
sw.Write($"¬{datItem.GetField(Field.Size, ExcludeFields)}");
|
||||||
state += "¬¬¬\n";
|
sw.Write("¬¬¬\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -456,11 +456,9 @@ namespace SabreTools.Library.DatFiles
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string header = string.Format("\"File Name\"{0}\"Internal Name\"{0}\"Description\"{0}\"Game Name\"{0}\"Game Description\"{0}\"Type\"{0}\"" +
|
sw.Write(string.Format("\"File Name\"{0}\"Internal Name\"{0}\"Description\"{0}\"Game Name\"{0}\"Game Description\"{0}\"Type\"{0}\"" +
|
||||||
"Rom Name\"{0}\"Disk Name\"{0}\"Size\"{0}\"CRC\"{0}\"MD5\"{0}\"SHA1\"{0}\"SHA256\"{0}\"Nodump\"\n", _delim);
|
"Rom Name\"{0}\"Disk Name\"{0}\"Size\"{0}\"CRC\"{0}\"MD5\"{0}\"SHA1\"{0}\"SHA256\"{0}\"Nodump\"\n", _delim));
|
||||||
|
|
||||||
// Write the header out
|
|
||||||
sw.Write(header);
|
|
||||||
sw.Flush();
|
sw.Flush();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -485,84 +483,57 @@ namespace SabreTools.Library.DatFiles
|
|||||||
if (ignoreblanks && (datItem.ItemType == ItemType.Rom && ((datItem as Rom).Size == 0 || (datItem as Rom).Size == -1)))
|
if (ignoreblanks && (datItem.ItemType == ItemType.Rom && ((datItem as Rom).Size == 0 || (datItem as Rom).Size == -1)))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// TODO: Clean up this mess and make it more like the other DatFile types
|
|
||||||
// TODO: Specifically, make it so that each ItemType has its own block, if possible
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Initialize all strings
|
|
||||||
string state = string.Empty,
|
|
||||||
pre = string.Empty,
|
|
||||||
post = string.Empty,
|
|
||||||
type = string.Empty,
|
|
||||||
romname = string.Empty,
|
|
||||||
diskname = string.Empty,
|
|
||||||
size = string.Empty,
|
|
||||||
crc = string.Empty,
|
|
||||||
md5 = string.Empty,
|
|
||||||
ripemd160 = string.Empty,
|
|
||||||
sha1 = string.Empty,
|
|
||||||
sha256 = string.Empty,
|
|
||||||
sha384 = string.Empty,
|
|
||||||
sha512 = string.Empty,
|
|
||||||
status = string.Empty;
|
|
||||||
|
|
||||||
// Separated values should only output Rom and Disk
|
// Separated values should only output Rom and Disk
|
||||||
if (datItem.ItemType != ItemType.Disk && datItem.ItemType != ItemType.Rom)
|
if (datItem.ItemType != ItemType.Disk && datItem.ItemType != ItemType.Rom)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (datItem.ItemType == ItemType.Disk)
|
sw.Write(CreatePrefixPostfix(datItem, true));
|
||||||
|
|
||||||
|
sw.Write($"\"{FileName}\"{_delim}");
|
||||||
|
sw.Write($"\"{Name}\"{_delim}");
|
||||||
|
sw.Write($"\"{Description}\"{_delim}");
|
||||||
|
sw.Write($"\"{datItem.GetField(Field.MachineName, ExcludeFields)}\"{_delim}");
|
||||||
|
sw.Write($"\"{datItem.GetField(Field.Description, ExcludeFields)}\"{_delim}");
|
||||||
|
|
||||||
|
switch (datItem.ItemType)
|
||||||
{
|
{
|
||||||
|
case ItemType.Disk:
|
||||||
var disk = datItem as Disk;
|
var disk = datItem as Disk;
|
||||||
type = "disk";
|
sw.Write($"\"disk\"{_delim}");
|
||||||
diskname = datItem.Name;
|
sw.Write($"\"\"{_delim}");
|
||||||
md5 = disk.MD5;
|
sw.Write($"\"{disk.GetField(Field.Name, ExcludeFields)}\"{_delim}");
|
||||||
ripemd160 = disk.RIPEMD160;
|
sw.Write($"\"\"{_delim}");
|
||||||
sha1 = disk.SHA1;
|
sw.Write($"\"\"{_delim}");
|
||||||
sha256 = disk.SHA256;
|
sw.Write($"\"{disk.GetField(Field.MD5, ExcludeFields).ToLowerInvariant()}\"{_delim}");
|
||||||
sha384 = disk.SHA384;
|
//sw.Write($"\"{disk.GetField(Field.RIPEMD160, ExcludeFields).ToLowerInvariant()}\"{_delim}");
|
||||||
sha512 = disk.SHA512;
|
sw.Write($"\"{disk.GetField(Field.SHA1, ExcludeFields).ToLowerInvariant()}\"{_delim}");
|
||||||
status = (disk.ItemStatus != ItemStatus.None ? $"\"{disk.ItemStatus}\"" : "\"\"");
|
sw.Write($"\"{disk.GetField(Field.SHA256, ExcludeFields).ToLowerInvariant()}\"{_delim}");
|
||||||
}
|
//sw.Write($"\"{disk.GetField(Field.SHA384, ExcludeFields).ToLowerInvariant()}\"{_delim}");
|
||||||
else if (datItem.ItemType == ItemType.Rom)
|
//sw.Write($"\"{disk.GetField(Field.SHA512, ExcludeFields).ToLowerInvariant()}\"{_delim}");
|
||||||
{
|
sw.Write($"\"{disk.GetField(Field.Status, ExcludeFields)}\"{_delim}");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ItemType.Rom:
|
||||||
var rom = datItem as Rom;
|
var rom = datItem as Rom;
|
||||||
type = "rom";
|
sw.Write($"\"rom\"{_delim}");
|
||||||
romname = datItem.Name;
|
sw.Write($"\"{rom.GetField(Field.Name, ExcludeFields)}\"{_delim}");
|
||||||
size = rom.Size.ToString();
|
sw.Write($"\"\"{_delim}");
|
||||||
crc = rom.CRC;
|
sw.Write($"\"{rom.GetField(Field.Size, ExcludeFields)}\"{_delim}");
|
||||||
md5 = rom.MD5;
|
sw.Write($"\"{rom.GetField(Field.CRC, ExcludeFields).ToLowerInvariant()}\"{_delim}");
|
||||||
ripemd160 = rom.RIPEMD160;
|
sw.Write($"\"{rom.GetField(Field.MD5, ExcludeFields).ToLowerInvariant()}\"{_delim}");
|
||||||
sha1 = rom.SHA1;
|
//sw.Write($"\"{rom.GetField(Field.RIPEMD160, ExcludeFields).ToLowerInvariant()}\"{_delim}");
|
||||||
sha256 = rom.SHA256;
|
sw.Write($"\"{rom.GetField(Field.SHA1, ExcludeFields).ToLowerInvariant()}\"{_delim}");
|
||||||
sha384 = rom.SHA384;
|
sw.Write($"\"{rom.GetField(Field.SHA256, ExcludeFields).ToLowerInvariant()}\"{_delim}");
|
||||||
sha512 = rom.SHA512;
|
//sw.Write($"\"{rom.GetField(Field.SHA384, ExcludeFields).ToLowerInvariant()}\"{_delim}");
|
||||||
status = (rom.ItemStatus != ItemStatus.None ? $"\"{rom.ItemStatus}\"" : "\"\"");
|
//sw.Write($"\"{rom.GetField(Field.SHA512, ExcludeFields).ToLowerInvariant()}\"{_delim}");
|
||||||
|
sw.Write($"\"{rom.GetField(Field.Status, ExcludeFields)}\"{_delim}");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
pre = CreatePrefixPostfix(datItem, true);
|
sw.Write(CreatePrefixPostfix(datItem, false));
|
||||||
post = CreatePrefixPostfix(datItem, false);
|
|
||||||
string inline = string.Format($"\"{FileName}\""
|
|
||||||
+ $"{0}\"{Name}\""
|
|
||||||
+ $"{0}\"{Description}\""
|
|
||||||
+ $"{0}\"{(!ExcludeFields[(int)Field.MachineName] ? datItem.MachineName : string.Empty)}\""
|
|
||||||
+ $"{0}\"{(!ExcludeFields[(int)Field.Description] ? datItem.MachineDescription : string.Empty)}\""
|
|
||||||
+ $"{0}\"{type}\""
|
|
||||||
+ $"{0}\"{(!ExcludeFields[(int)Field.Name] ? romname : string.Empty)}\""
|
|
||||||
+ $"{0}\"{(!ExcludeFields[(int)Field.Name] ? diskname : string.Empty)}\""
|
|
||||||
+ $"{0}\"{(!ExcludeFields[(int)Field.Size] ? size : string.Empty)}\""
|
|
||||||
+ $"{0}\"{(!ExcludeFields[(int)Field.CRC] ? crc : string.Empty)}\""
|
|
||||||
+ $"{0}\"{(!ExcludeFields[(int)Field.MD5] ? md5 : string.Empty)}\""
|
|
||||||
// + $"{0}\"{(!ExcludeFields[(int)Field.RIPEMD160] ? ripemd160 : string.Empty)}\""
|
|
||||||
+ $"{0}\"{(!ExcludeFields[(int)Field.SHA1] ? sha1 : string.Empty)}\""
|
|
||||||
+ $"{0}\"{(!ExcludeFields[(int)Field.SHA256] ? sha256 : string.Empty)}\""
|
|
||||||
// + $"{0}\"{(!ExcludeFields[(int)Field.SHA384] ? sha384 : string.Empty)}\""
|
|
||||||
// + $"{0}\"{(!ExcludeFields[(int)Field.SHA512] ? sha512 : string.Empty)}\""
|
|
||||||
+ $"{0}\"{(!ExcludeFields[(int)Field.Status] ? status : string.Empty)}\"",
|
|
||||||
_delim);
|
|
||||||
|
|
||||||
state += $"{pre}{inline}{post}\n";
|
|
||||||
|
|
||||||
sw.Write(state);
|
|
||||||
sw.Flush();
|
sw.Flush();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|||||||
Reference in New Issue
Block a user