mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Add Aaruformat validation and media item type (#29)
* Initial `media` and AaruFormat code * But... why? * Fix AIF reading * Fix D2D, Logiqx cleanup * Minor cleanup * Final cleanup round
This commit is contained in:
@@ -175,13 +175,13 @@ namespace SabreTools.Library.DatFiles
|
||||
|
||||
// If we have a "null" game (created by DATFromDir or something similar), log it to file
|
||||
if (item.ItemType == ItemType.Rom
|
||||
&& ((Rom)item).Size == -1
|
||||
&& ((Rom)item).CRC == "null")
|
||||
&& (item as Rom).Size == -1
|
||||
&& (item as Rom).CRC == "null")
|
||||
{
|
||||
Globals.Logger.Verbose($"Empty folder found: {item.Machine.Name}");
|
||||
|
||||
item.Name = (item.Name == "null" ? "-" : item.Name);
|
||||
((Rom)item).Size = Constants.SizeZero;
|
||||
(item as Rom).Size = Constants.SizeZero;
|
||||
}
|
||||
|
||||
// Set the new data to compare against
|
||||
@@ -255,7 +255,7 @@ namespace SabreTools.Library.DatFiles
|
||||
private bool WriteDatItem(SeparatedValueWriter svw, DatItem datItem, bool ignoreblanks = false)
|
||||
{
|
||||
// If we are in ignore blanks mode AND we have a blank (0-size) rom, skip
|
||||
if (ignoreblanks && (datItem.ItemType == ItemType.Rom && (((Rom)datItem).Size == 0 || ((Rom)datItem).Size == -1)))
|
||||
if (ignoreblanks && (datItem.ItemType == ItemType.Rom && ((datItem as Rom).Size == 0 || (datItem as Rom).Size == -1)))
|
||||
return true;
|
||||
|
||||
try
|
||||
|
||||
@@ -262,33 +262,8 @@ namespace SabreTools.Library.DatFiles
|
||||
containsItems = true;
|
||||
string itemKey = cmpr.InternalName;
|
||||
|
||||
ItemType itemType = ItemType.Rom;
|
||||
switch (itemKey)
|
||||
{
|
||||
case "archive":
|
||||
itemType = ItemType.Archive;
|
||||
break;
|
||||
case "biosset":
|
||||
itemType = ItemType.BiosSet;
|
||||
break;
|
||||
case "chip":
|
||||
itemType = ItemType.Chip;
|
||||
break;
|
||||
case "disk":
|
||||
itemType = ItemType.Disk;
|
||||
break;
|
||||
case "release":
|
||||
itemType = ItemType.Release;
|
||||
break;
|
||||
case "rom":
|
||||
itemType = ItemType.Rom;
|
||||
break;
|
||||
case "sample":
|
||||
itemType = ItemType.Sample;
|
||||
break;
|
||||
}
|
||||
|
||||
// Create the proper DatItem based on the type
|
||||
ItemType itemType = itemKey.AsItemType() ?? ItemType.Rom;
|
||||
DatItem item = DatItem.Create(itemType);
|
||||
|
||||
// Then populate it with information
|
||||
@@ -318,9 +293,9 @@ namespace SabreTools.Library.DatFiles
|
||||
if (item.ItemType == ItemType.Rom)
|
||||
{
|
||||
if (Int64.TryParse(attrVal, out long size))
|
||||
((Rom)item).Size = size;
|
||||
(item as Rom).Size = size;
|
||||
else
|
||||
((Rom)item).Size = -1;
|
||||
(item as Rom).Size = -1;
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -330,99 +305,97 @@ namespace SabreTools.Library.DatFiles
|
||||
|
||||
break;
|
||||
case "md5":
|
||||
if (item.ItemType == ItemType.Rom)
|
||||
if (item.ItemType == ItemType.Disk)
|
||||
(item as Disk).MD5 = attrVal;
|
||||
else if (item.ItemType == ItemType.Media)
|
||||
(item as Media).MD5 = attrVal;
|
||||
else if (item.ItemType == ItemType.Rom)
|
||||
(item as Rom).MD5 = attrVal;
|
||||
else if (item.ItemType == ItemType.Disk)
|
||||
((Disk)item).MD5 = attrVal;
|
||||
|
||||
break;
|
||||
#if NET_FRAMEWORK
|
||||
case "ripemd160":
|
||||
if (item.ItemType == ItemType.Rom)
|
||||
(item as Rom).RIPEMD160 = attrVal;
|
||||
else if (item.ItemType == ItemType.Disk)
|
||||
((Disk)item).RIPEMD160 = attrVal;
|
||||
|
||||
break;
|
||||
#endif
|
||||
case "sha1":
|
||||
if (item.ItemType == ItemType.Rom)
|
||||
if (item.ItemType == ItemType.Disk)
|
||||
(item as Disk).SHA1 = attrVal;
|
||||
else if (item.ItemType == ItemType.Media)
|
||||
(item as Media).SHA1 = attrVal;
|
||||
else if (item.ItemType == ItemType.Rom)
|
||||
(item as Rom).SHA1 = attrVal;
|
||||
else if (item.ItemType == ItemType.Disk)
|
||||
((Disk)item).SHA1 = attrVal;
|
||||
|
||||
break;
|
||||
case "sha256":
|
||||
if (item.ItemType == ItemType.Rom)
|
||||
((Rom)item).SHA256 = attrVal;
|
||||
else if (item.ItemType == ItemType.Disk)
|
||||
((Disk)item).SHA256 = attrVal;
|
||||
|
||||
if (item.ItemType == ItemType.Media)
|
||||
(item as Media).SHA256 = attrVal;
|
||||
else if (item.ItemType == ItemType.Rom)
|
||||
(item as Rom).SHA256 = attrVal;
|
||||
|
||||
break;
|
||||
case "sha384":
|
||||
if (item.ItemType == ItemType.Rom)
|
||||
((Rom)item).SHA384 = attrVal;
|
||||
else if (item.ItemType == ItemType.Disk)
|
||||
((Disk)item).SHA384 = attrVal;
|
||||
(item as Rom).SHA384 = attrVal;
|
||||
|
||||
break;
|
||||
case "sha512":
|
||||
if (item.ItemType == ItemType.Rom)
|
||||
((Rom)item).SHA512 = attrVal;
|
||||
else if (item.ItemType == ItemType.Disk)
|
||||
((Disk)item).SHA512 = attrVal;
|
||||
(item as Rom).SHA512 = attrVal;
|
||||
|
||||
break;
|
||||
case "status":
|
||||
ItemStatus tempFlagStatus = attrVal.AsItemStatus();
|
||||
if (item.ItemType == ItemType.Rom)
|
||||
((Rom)item).ItemStatus = tempFlagStatus;
|
||||
else if (item.ItemType == ItemType.Disk)
|
||||
((Disk)item).ItemStatus = tempFlagStatus;
|
||||
if (item.ItemType == ItemType.Disk)
|
||||
(item as Disk).ItemStatus = tempFlagStatus;
|
||||
else if (item.ItemType == ItemType.Rom)
|
||||
(item as Rom).ItemStatus = tempFlagStatus;
|
||||
|
||||
break;
|
||||
case "date":
|
||||
if (item.ItemType == ItemType.Rom)
|
||||
((Rom)item).Date = attrVal;
|
||||
else if (item.ItemType == ItemType.Release)
|
||||
((Release)item).Date = attrVal;
|
||||
if (item.ItemType == ItemType.Release)
|
||||
(item as Release).Date = attrVal;
|
||||
else if (item.ItemType == ItemType.Rom)
|
||||
(item as Rom).Date = attrVal;
|
||||
|
||||
break;
|
||||
case "default":
|
||||
if (item.ItemType == ItemType.BiosSet)
|
||||
((BiosSet)item).Default = attrVal.AsYesNo();
|
||||
(item as BiosSet).Default = attrVal.AsYesNo();
|
||||
else if (item.ItemType == ItemType.Release)
|
||||
((Release)item).Default = attrVal.AsYesNo();
|
||||
(item as Release).Default = attrVal.AsYesNo();
|
||||
|
||||
break;
|
||||
case "description":
|
||||
if (item.ItemType == ItemType.BiosSet)
|
||||
((BiosSet)item).Description = attrVal;
|
||||
(item as BiosSet).Description = attrVal;
|
||||
|
||||
break;
|
||||
case "region":
|
||||
if (item.ItemType == ItemType.Release)
|
||||
((Release)item).Region = attrVal;
|
||||
(item as Release).Region = attrVal;
|
||||
|
||||
break;
|
||||
case "language":
|
||||
if (item.ItemType == ItemType.Release)
|
||||
((Release)item).Language = attrVal;
|
||||
(item as Release).Language = attrVal;
|
||||
|
||||
break;
|
||||
case "tag":
|
||||
if (item.ItemType == ItemType.Chip)
|
||||
((Chip)item).Tag = attrVal;
|
||||
(item as Chip).Tag = attrVal;
|
||||
|
||||
break;
|
||||
case "type":
|
||||
if (item.ItemType == ItemType.Chip)
|
||||
((Chip)item).ChipType = attrVal;
|
||||
(item as Chip).ChipType = attrVal;
|
||||
|
||||
break;
|
||||
case "clock":
|
||||
if (item.ItemType == ItemType.Chip)
|
||||
((Chip)item).Clock = attrVal;
|
||||
(item as Chip).Clock = attrVal;
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -707,17 +680,21 @@ namespace SabreTools.Library.DatFiles
|
||||
cmpw.WriteStartElement("disk");
|
||||
cmpw.WriteRequiredAttributeString("name", disk.Name);
|
||||
cmpw.WriteOptionalAttributeString("md5", disk.MD5?.ToLowerInvariant());
|
||||
#if NET_FRAMEWORK
|
||||
cmpw.WriteOptionalAttributeString("ripemd160", disk.RIPEMD160?.ToLowerInvariant());
|
||||
#endif
|
||||
cmpw.WriteOptionalAttributeString("sha1", disk.SHA1?.ToLowerInvariant());
|
||||
cmpw.WriteOptionalAttributeString("sha256", disk.SHA256?.ToLowerInvariant());
|
||||
cmpw.WriteOptionalAttributeString("sha384", disk.SHA384?.ToLowerInvariant());
|
||||
cmpw.WriteOptionalAttributeString("sha512", disk.SHA512?.ToLowerInvariant());
|
||||
cmpw.WriteOptionalAttributeString("flags", disk.ItemStatus.FromItemStatus(false));
|
||||
cmpw.WriteEndElement();
|
||||
break;
|
||||
|
||||
case ItemType.Media:
|
||||
var media = datItem as Media;
|
||||
cmpw.WriteStartElement("media");
|
||||
cmpw.WriteRequiredAttributeString("name", media.Name);
|
||||
cmpw.WriteOptionalAttributeString("md5", media.MD5?.ToLowerInvariant());
|
||||
cmpw.WriteOptionalAttributeString("sha1", media.SHA1?.ToLowerInvariant());
|
||||
cmpw.WriteOptionalAttributeString("sha256", media.SHA256?.ToLowerInvariant());
|
||||
cmpw.WriteEndElement();
|
||||
break;
|
||||
|
||||
case ItemType.Release:
|
||||
var release = datItem as Release;
|
||||
cmpw.WriteStartElement("release");
|
||||
|
||||
@@ -1986,100 +1986,92 @@ namespace SabreTools.Library.DatFiles
|
||||
return key;
|
||||
}
|
||||
|
||||
// If we have a Rom or a Disk, clean the hash data
|
||||
if (item.ItemType == ItemType.Rom)
|
||||
// If we have a Disk, Media, or Rom, clean the hash data
|
||||
if (item.ItemType == ItemType.Disk)
|
||||
{
|
||||
Rom itemRom = (Rom)item;
|
||||
Disk disk = item as Disk;
|
||||
|
||||
// If the file has aboslutely no hashes, skip and log
|
||||
if (disk.ItemStatus != ItemStatus.Nodump
|
||||
&& string.IsNullOrWhiteSpace(disk.MD5)
|
||||
&& string.IsNullOrWhiteSpace(disk.SHA1))
|
||||
{
|
||||
Globals.Logger.Verbose($"Incomplete entry for '{disk.Name}' will be output as nodump");
|
||||
disk.ItemStatus = ItemStatus.Nodump;
|
||||
}
|
||||
|
||||
item = disk;
|
||||
}
|
||||
else if (item.ItemType == ItemType.Rom)
|
||||
{
|
||||
Rom rom = item as Rom;
|
||||
|
||||
// If we have the case where there is SHA-1 and nothing else, we don't fill in any other part of the data
|
||||
if (itemRom.Size == -1
|
||||
&& string.IsNullOrWhiteSpace(itemRom.CRC)
|
||||
&& string.IsNullOrWhiteSpace(itemRom.MD5)
|
||||
if (rom.Size == -1
|
||||
&& string.IsNullOrWhiteSpace(rom.CRC)
|
||||
&& string.IsNullOrWhiteSpace(rom.MD5)
|
||||
#if NET_FRAMEWORK
|
||||
&& string.IsNullOrWhiteSpace(itemRom.RIPEMD160)
|
||||
&& string.IsNullOrWhiteSpace(rom.RIPEMD160)
|
||||
#endif
|
||||
&& !string.IsNullOrWhiteSpace(itemRom.SHA1)
|
||||
&& string.IsNullOrWhiteSpace(itemRom.SHA256)
|
||||
&& string.IsNullOrWhiteSpace(itemRom.SHA384)
|
||||
&& string.IsNullOrWhiteSpace(itemRom.SHA512))
|
||||
&& !string.IsNullOrWhiteSpace(rom.SHA1)
|
||||
&& string.IsNullOrWhiteSpace(rom.SHA256)
|
||||
&& string.IsNullOrWhiteSpace(rom.SHA384)
|
||||
&& string.IsNullOrWhiteSpace(rom.SHA512))
|
||||
{
|
||||
// No-op, just catch it so it doesn't go further
|
||||
Globals.Logger.Verbose($"{Header.FileName}: Entry with only SHA-1 found - '{itemRom.Name}'");
|
||||
Globals.Logger.Verbose($"{Header.FileName}: Entry with only SHA-1 found - '{rom.Name}'");
|
||||
}
|
||||
|
||||
// If we have a rom and it's missing size AND the hashes match a 0-byte file, fill in the rest of the info
|
||||
else if ((itemRom.Size == 0 || itemRom.Size == -1)
|
||||
&& ((itemRom.CRC == Constants.CRCZero || string.IsNullOrWhiteSpace(itemRom.CRC))
|
||||
|| itemRom.MD5 == Constants.MD5Zero
|
||||
else if ((rom.Size == 0 || rom.Size == -1)
|
||||
&& ((rom.CRC == Constants.CRCZero || string.IsNullOrWhiteSpace(rom.CRC))
|
||||
|| rom.MD5 == Constants.MD5Zero
|
||||
#if NET_FRAMEWORK
|
||||
|| itemRom.RIPEMD160 == Constants.RIPEMD160Zero
|
||||
|| rom.RIPEMD160 == Constants.RIPEMD160Zero
|
||||
#endif
|
||||
|| itemRom.SHA1 == Constants.SHA1Zero
|
||||
|| itemRom.SHA256 == Constants.SHA256Zero
|
||||
|| itemRom.SHA384 == Constants.SHA384Zero
|
||||
|| itemRom.SHA512 == Constants.SHA512Zero))
|
||||
|| rom.SHA1 == Constants.SHA1Zero
|
||||
|| rom.SHA256 == Constants.SHA256Zero
|
||||
|| rom.SHA384 == Constants.SHA384Zero
|
||||
|| rom.SHA512 == Constants.SHA512Zero))
|
||||
{
|
||||
// TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually
|
||||
itemRom.Size = Constants.SizeZero;
|
||||
itemRom.CRC = Constants.CRCZero;
|
||||
itemRom.MD5 = Constants.MD5Zero;
|
||||
rom.Size = Constants.SizeZero;
|
||||
rom.CRC = Constants.CRCZero;
|
||||
rom.MD5 = Constants.MD5Zero;
|
||||
#if NET_FRAMEWORK
|
||||
itemRom.RIPEMD160 = null;
|
||||
//itemRom.RIPEMD160 = Constants.RIPEMD160Zero;
|
||||
rom.RIPEMD160 = null; // Constants.RIPEMD160Zero;
|
||||
#endif
|
||||
itemRom.SHA1 = Constants.SHA1Zero;
|
||||
itemRom.SHA256 = null;
|
||||
//itemRom.SHA256 = Constants.SHA256Zero;
|
||||
itemRom.SHA384 = null;
|
||||
//itemRom.SHA384 = Constants.SHA384Zero;
|
||||
itemRom.SHA512 = null;
|
||||
//itemRom.SHA512 = Constants.SHA512Zero;
|
||||
rom.SHA1 = Constants.SHA1Zero;
|
||||
rom.SHA256 = null; // Constants.SHA256Zero;
|
||||
rom.SHA384 = null; // Constants.SHA384Zero;
|
||||
rom.SHA512 = null; // Constants.SHA512Zero;
|
||||
}
|
||||
|
||||
// If the file has no size and it's not the above case, skip and log
|
||||
else if (itemRom.ItemStatus != ItemStatus.Nodump && (itemRom.Size == 0 || itemRom.Size == -1))
|
||||
else if (rom.ItemStatus != ItemStatus.Nodump && (rom.Size == 0 || rom.Size == -1))
|
||||
{
|
||||
Globals.Logger.Verbose($"{Header.FileName}: Incomplete entry for '{itemRom.Name}' will be output as nodump");
|
||||
itemRom.ItemStatus = ItemStatus.Nodump;
|
||||
Globals.Logger.Verbose($"{Header.FileName}: Incomplete entry for '{rom.Name}' will be output as nodump");
|
||||
rom.ItemStatus = ItemStatus.Nodump;
|
||||
}
|
||||
|
||||
// If the file has a size but aboslutely no hashes, skip and log
|
||||
else if (itemRom.ItemStatus != ItemStatus.Nodump
|
||||
&& itemRom.Size > 0
|
||||
&& string.IsNullOrWhiteSpace(itemRom.CRC)
|
||||
&& string.IsNullOrWhiteSpace(itemRom.MD5)
|
||||
else if (rom.ItemStatus != ItemStatus.Nodump
|
||||
&& rom.Size > 0
|
||||
&& string.IsNullOrWhiteSpace(rom.CRC)
|
||||
&& string.IsNullOrWhiteSpace(rom.MD5)
|
||||
#if NET_FRAMEWORK
|
||||
&& string.IsNullOrWhiteSpace(itemRom.RIPEMD160)
|
||||
&& string.IsNullOrWhiteSpace(rom.RIPEMD160)
|
||||
#endif
|
||||
&& string.IsNullOrWhiteSpace(itemRom.SHA1)
|
||||
&& string.IsNullOrWhiteSpace(itemRom.SHA256)
|
||||
&& string.IsNullOrWhiteSpace(itemRom.SHA384)
|
||||
&& string.IsNullOrWhiteSpace(itemRom.SHA512))
|
||||
&& string.IsNullOrWhiteSpace(rom.SHA1)
|
||||
&& string.IsNullOrWhiteSpace(rom.SHA256)
|
||||
&& string.IsNullOrWhiteSpace(rom.SHA384)
|
||||
&& string.IsNullOrWhiteSpace(rom.SHA512))
|
||||
{
|
||||
Globals.Logger.Verbose($"{Header.FileName}: Incomplete entry for '{itemRom.Name}' will be output as nodump");
|
||||
itemRom.ItemStatus = ItemStatus.Nodump;
|
||||
Globals.Logger.Verbose($"{Header.FileName}: Incomplete entry for '{rom.Name}' will be output as nodump");
|
||||
rom.ItemStatus = ItemStatus.Nodump;
|
||||
}
|
||||
|
||||
item = itemRom;
|
||||
}
|
||||
else if (item.ItemType == ItemType.Disk)
|
||||
{
|
||||
Disk itemDisk = (Disk)item;
|
||||
|
||||
// If the file has aboslutely no hashes, skip and log
|
||||
if (itemDisk.ItemStatus != ItemStatus.Nodump
|
||||
&& string.IsNullOrWhiteSpace(itemDisk.MD5)
|
||||
#if NET_FRAMEWORK
|
||||
&& string.IsNullOrWhiteSpace(itemDisk.RIPEMD160)
|
||||
#endif
|
||||
&& string.IsNullOrWhiteSpace(itemDisk.SHA1)
|
||||
&& string.IsNullOrWhiteSpace(itemDisk.SHA256)
|
||||
&& string.IsNullOrWhiteSpace(itemDisk.SHA384)
|
||||
&& string.IsNullOrWhiteSpace(itemDisk.SHA512))
|
||||
{
|
||||
Globals.Logger.Verbose($"Incomplete entry for '{itemDisk.Name}' will be output as nodump");
|
||||
itemDisk.ItemStatus = ItemStatus.Nodump;
|
||||
}
|
||||
|
||||
item = itemDisk;
|
||||
item = rom;
|
||||
}
|
||||
|
||||
// Get the key and add the file
|
||||
@@ -2349,7 +2341,13 @@ namespace SabreTools.Library.DatFiles
|
||||
private void ProcessFile(string item, string basePath, Hash omitFromScan, bool addDate, TreatAsFiles asFiles)
|
||||
{
|
||||
Globals.Logger.Verbose($"'{Path.GetFileName(item)}' treated like a file");
|
||||
BaseFile baseFile = FileExtensions.GetInfo(item, omitFromScan: omitFromScan, date: addDate, header: Header.HeaderSkipper, chdsAsFiles: asFiles.HasFlag(TreatAsFiles.CHDs));
|
||||
BaseFile baseFile = FileExtensions.GetInfo(
|
||||
item,
|
||||
omitFromScan: omitFromScan,
|
||||
date: addDate,
|
||||
header: Header.HeaderSkipper,
|
||||
aaruFormatAsFiles: asFiles.HasFlag(TreatAsFiles.AaruFormats),
|
||||
chdsAsFiles: asFiles.HasFlag(TreatAsFiles.CHDs));
|
||||
ProcessFileHelper(item, DatItem.Create(baseFile), basePath, string.Empty);
|
||||
}
|
||||
|
||||
@@ -2362,8 +2360,9 @@ namespace SabreTools.Library.DatFiles
|
||||
/// <param name="parent">Parent game to be used</param>
|
||||
private void ProcessFileHelper(string item, DatItem datItem, string basepath, string parent)
|
||||
{
|
||||
// If we somehow got something other than a Rom or Disk, cancel out
|
||||
if (datItem.ItemType != ItemType.Rom && datItem.ItemType != ItemType.Disk)
|
||||
// If we didn't get an accepted parsed type somehow, cancel out
|
||||
List<ItemType> parsed = new List<ItemType> { ItemType.Disk, ItemType.Media, ItemType.Rom };
|
||||
if (!parsed.Contains(datItem.ItemType))
|
||||
return;
|
||||
|
||||
try
|
||||
@@ -2401,7 +2400,7 @@ namespace SabreTools.Library.DatFiles
|
||||
private void SetDatItemInfo(DatItem datItem, string item, string parent, string basepath)
|
||||
{
|
||||
// Get the data to be added as game and item names
|
||||
string gamename, romname;
|
||||
string machineName, itemName;
|
||||
|
||||
// If the parent is blank, then we have a non-archive file
|
||||
if (string.IsNullOrWhiteSpace(parent))
|
||||
@@ -2409,15 +2408,15 @@ namespace SabreTools.Library.DatFiles
|
||||
// If we have a SuperDAT, we want anything that's not the base path as the game, and the file as the rom
|
||||
if (Header.Type == "SuperDAT")
|
||||
{
|
||||
gamename = Path.GetDirectoryName(item.Remove(0, basepath.Length));
|
||||
romname = Path.GetFileName(item);
|
||||
machineName = Path.GetDirectoryName(item.Remove(0, basepath.Length));
|
||||
itemName = Path.GetFileName(item);
|
||||
}
|
||||
|
||||
// Otherwise, we want just the top level folder as the game, and the file as everything else
|
||||
else
|
||||
{
|
||||
gamename = item.Remove(0, basepath.Length).Split(Path.DirectorySeparatorChar)[0];
|
||||
romname = item.Remove(0, (Path.Combine(basepath, gamename).Length));
|
||||
machineName = item.Remove(0, basepath.Length).Split(Path.DirectorySeparatorChar)[0];
|
||||
itemName = item.Remove(0, (Path.Combine(basepath, machineName).Length));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2427,36 +2426,58 @@ namespace SabreTools.Library.DatFiles
|
||||
// If we have a SuperDAT, we want the archive name as the game, and the file as everything else (?)
|
||||
if (Header.Type == "SuperDAT")
|
||||
{
|
||||
gamename = parent;
|
||||
romname = datItem.Name;
|
||||
machineName = parent;
|
||||
itemName = datItem.Name;
|
||||
}
|
||||
|
||||
// Otherwise, we want the archive name as the game, and the file as everything else
|
||||
else
|
||||
{
|
||||
gamename = parent;
|
||||
romname = datItem.Name;
|
||||
machineName = parent;
|
||||
itemName = datItem.Name;
|
||||
}
|
||||
}
|
||||
|
||||
// Sanitize the names
|
||||
gamename = gamename.Trim(Path.DirectorySeparatorChar);
|
||||
romname = romname?.Trim(Path.DirectorySeparatorChar) ?? string.Empty;
|
||||
machineName = machineName.Trim(Path.DirectorySeparatorChar);
|
||||
itemName = itemName?.Trim(Path.DirectorySeparatorChar) ?? string.Empty;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(gamename) && string.IsNullOrWhiteSpace(romname))
|
||||
if (!string.IsNullOrWhiteSpace(machineName) && string.IsNullOrWhiteSpace(itemName))
|
||||
{
|
||||
romname = gamename;
|
||||
gamename = "Default";
|
||||
itemName = machineName;
|
||||
machineName = "Default";
|
||||
}
|
||||
|
||||
// Update rom information
|
||||
datItem.Name = romname;
|
||||
datItem.Machine.Name = gamename;
|
||||
datItem.Machine.Description = gamename;
|
||||
// Update machine information
|
||||
datItem.Machine.Name = machineName;
|
||||
datItem.Machine.Description = machineName;
|
||||
|
||||
// If we have a Disk, then the ".chd" extension needs to be removed
|
||||
if (datItem.ItemType == ItemType.Disk)
|
||||
datItem.Name = datItem.Name.Replace(".chd", string.Empty);
|
||||
if (datItem.ItemType == ItemType.Disk && datItem.Name.EndsWith(".chd"))
|
||||
{
|
||||
datItem.Name = itemName.Substring(0, itemName.Length - 4);
|
||||
}
|
||||
|
||||
// If we have a Media, then the extension needs to be removed
|
||||
else if (datItem.ItemType == ItemType.Media)
|
||||
{
|
||||
if (datItem.Name.EndsWith(".dicf"))
|
||||
datItem.Name = itemName.Substring(0, itemName.Length - 5);
|
||||
else if (datItem.Name.EndsWith(".aaru"))
|
||||
datItem.Name = itemName.Substring(0, itemName.Length - 5);
|
||||
else if (datItem.Name.EndsWith(".aaruformat"))
|
||||
datItem.Name = itemName.Substring(0, itemName.Length - 11);
|
||||
else if (datItem.Name.EndsWith(".aaruf"))
|
||||
datItem.Name = itemName.Substring(0, itemName.Length - 6);
|
||||
else if (datItem.Name.EndsWith(".aif"))
|
||||
datItem.Name = itemName.Substring(0, itemName.Length - 3);
|
||||
}
|
||||
|
||||
// All others leave the extension alone
|
||||
else
|
||||
{
|
||||
datItem.Name = itemName;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -2617,6 +2638,8 @@ namespace SabreTools.Library.DatFiles
|
||||
bool usedInternally;
|
||||
if (Items[hash][0].ItemType == ItemType.Disk)
|
||||
usedInternally = RebuildIndividualFile(new Disk(fileinfo), foundpath, outDir, date, inverse, outputFormat, updateDat, false /* isZip */);
|
||||
else if (Items[hash][0].ItemType == ItemType.Media)
|
||||
usedInternally = RebuildIndividualFile(new Media(fileinfo), foundpath, outDir, date, inverse, outputFormat, updateDat, false /* isZip */);
|
||||
else
|
||||
usedInternally = RebuildIndividualFile(new Rom(fileinfo), foundpath, outDir, date, inverse, outputFormat, updateDat, false /* isZip */);
|
||||
|
||||
@@ -2810,11 +2833,17 @@ namespace SabreTools.Library.DatFiles
|
||||
// Scan the file externally
|
||||
|
||||
// TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually
|
||||
BaseFile externalFileInfo = FileExtensions.GetInfo(file, omitFromScan: (quickScan ? Hash.SecureHashes : Hash.DeepHashes),
|
||||
header: Header.HeaderSkipper, chdsAsFiles: asFiles.HasFlag(TreatAsFiles.CHDs));
|
||||
BaseFile externalFileInfo = FileExtensions.GetInfo(
|
||||
file,
|
||||
omitFromScan: (quickScan ? Hash.SecureHashes : Hash.DeepHashes),
|
||||
header: Header.HeaderSkipper,
|
||||
aaruFormatAsFiles: asFiles.HasFlag(TreatAsFiles.AaruFormats),
|
||||
chdsAsFiles: asFiles.HasFlag(TreatAsFiles.CHDs));
|
||||
|
||||
DatItem externalDatItem = null;
|
||||
if (externalFileInfo.Type == FileType.CHD)
|
||||
if (externalFileInfo.Type == FileType.AaruFormat)
|
||||
externalDatItem = new Media(externalFileInfo);
|
||||
else if (externalFileInfo.Type == FileType.CHD)
|
||||
externalDatItem = new Disk(externalFileInfo);
|
||||
else if (externalFileInfo.Type == FileType.None)
|
||||
externalDatItem = new Rom(externalFileInfo);
|
||||
@@ -2844,10 +2873,16 @@ namespace SabreTools.Library.DatFiles
|
||||
if (entries == null && File.Exists(file))
|
||||
{
|
||||
// TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually
|
||||
BaseFile internalFileInfo = FileExtensions.GetInfo(file, omitFromScan: (quickScan ? Hash.SecureHashes : Hash.DeepHashes), chdsAsFiles: asFiles.HasFlag(TreatAsFiles.CHDs));
|
||||
BaseFile internalFileInfo = FileExtensions.GetInfo(
|
||||
file,
|
||||
omitFromScan: (quickScan ? Hash.SecureHashes : Hash.DeepHashes),
|
||||
aaruFormatAsFiles: asFiles.HasFlag(TreatAsFiles.AaruFormats),
|
||||
chdsAsFiles: asFiles.HasFlag(TreatAsFiles.CHDs));
|
||||
|
||||
DatItem internalDatItem = null;
|
||||
if (internalFileInfo.Type == FileType.CHD)
|
||||
if (internalFileInfo.Type == FileType.AaruFormat)
|
||||
internalDatItem = new Media(internalFileInfo);
|
||||
else if (internalFileInfo.Type == FileType.CHD)
|
||||
internalDatItem = new Disk(internalFileInfo);
|
||||
else if (internalFileInfo.Type == FileType.None)
|
||||
internalDatItem = new Rom(internalFileInfo);
|
||||
@@ -2894,21 +2929,23 @@ namespace SabreTools.Library.DatFiles
|
||||
// Set the initial output value
|
||||
bool rebuilt = false;
|
||||
|
||||
// If the DatItem is a Disk, force rebuilding to a folder except if TGZ or TXZ
|
||||
if (datItem.ItemType == ItemType.Disk
|
||||
// If the DatItem is a Disk or Media, force rebuilding to a folder except if TGZ or TXZ
|
||||
if ((datItem.ItemType == ItemType.Disk || datItem.ItemType == ItemType.Media)
|
||||
&& !(outputFormat == OutputFormat.TorrentGzip || outputFormat == OutputFormat.TorrentGzipRomba)
|
||||
&& !(outputFormat == OutputFormat.TorrentXZ || outputFormat == OutputFormat.TorrentXZRomba))
|
||||
{
|
||||
outputFormat = OutputFormat.Folder;
|
||||
}
|
||||
|
||||
// If we have a disk, change it into a Rom for later use
|
||||
// If we have a disk or media, change it into a Rom for later use
|
||||
if (datItem.ItemType == ItemType.Disk)
|
||||
datItem = ((Disk)datItem).ConvertToRom();
|
||||
datItem = (datItem as Disk).ConvertToRom();
|
||||
if (datItem.ItemType == ItemType.Media)
|
||||
datItem = (datItem as Media).ConvertToRom();
|
||||
|
||||
// Prepopluate a few key strings
|
||||
string crc = ((Rom)datItem).CRC ?? string.Empty;
|
||||
string sha1 = ((Rom)datItem).SHA1 ?? string.Empty;
|
||||
string crc = (datItem as Rom).CRC ?? string.Empty;
|
||||
string sha1 = (datItem as Rom).SHA1 ?? string.Empty;
|
||||
|
||||
// Find if the file has duplicates in the DAT
|
||||
List<DatItem> dupes = Items.GetDuplicates(datItem, remove: updateDat);
|
||||
@@ -3027,7 +3064,7 @@ namespace SabreTools.Library.DatFiles
|
||||
Folder outputArchive = Folder.Create(outputFormat);
|
||||
|
||||
// Now rebuild to the output file
|
||||
outputArchive.Write(fileStream, outDir, (Rom)item, date: date, depth: Header.OutputDepot.Depth);
|
||||
outputArchive.Write(fileStream, outDir, item as Rom, date: date, depth: Header.OutputDepot.Depth);
|
||||
}
|
||||
|
||||
// Close the input stream
|
||||
@@ -3094,8 +3131,8 @@ namespace SabreTools.Library.DatFiles
|
||||
Folder outputArchive = Folder.Create(outputFormat);
|
||||
|
||||
// Now rebuild to the output file
|
||||
eitherSuccess |= outputArchive.Write(transformStream, outDir, (Rom)item, date: date, depth: Header.OutputDepot.Depth);
|
||||
eitherSuccess |= outputArchive.Write(fileStream, outDir, (Rom)datItem, date: date, depth: Header.OutputDepot.Depth);
|
||||
eitherSuccess |= outputArchive.Write(transformStream, outDir, item as Rom, date: date, depth: Header.OutputDepot.Depth);
|
||||
eitherSuccess |= outputArchive.Write(fileStream, outDir, datItem as Rom, date: date, depth: Header.OutputDepot.Depth);
|
||||
|
||||
// Now add the success of either rebuild
|
||||
rebuilt &= eitherSuccess;
|
||||
@@ -3253,13 +3290,17 @@ namespace SabreTools.Library.DatFiles
|
||||
var keys = Items.SortedKeys.ToList();
|
||||
foreach (string key in keys)
|
||||
{
|
||||
List<DatItem> roms = Items[key];
|
||||
foreach (DatItem rom in roms)
|
||||
List<DatItem> items = Items[key];
|
||||
foreach (DatItem datItem in items)
|
||||
{
|
||||
if (rom.Source.Index == 99)
|
||||
if (datItem.Source.Index == 99)
|
||||
{
|
||||
if (rom.ItemType == ItemType.Disk || rom.ItemType == ItemType.Rom)
|
||||
matched.Items.Add(((Disk)rom).SHA1, rom);
|
||||
if (datItem.ItemType == ItemType.Disk)
|
||||
matched.Items.Add((datItem as Disk).SHA1, datItem);
|
||||
else if (datItem.ItemType == ItemType.Media)
|
||||
matched.Items.Add((datItem as Media).SHA1, datItem);
|
||||
else if (datItem.ItemType == ItemType.Rom)
|
||||
matched.Items.Add((datItem as Rom).SHA1, datItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3269,9 +3310,9 @@ namespace SabreTools.Library.DatFiles
|
||||
{
|
||||
foreach (string key in Items.Keys)
|
||||
{
|
||||
List<DatItem> roms = Items[key];
|
||||
List<DatItem> newroms = DatItem.Merge(roms);
|
||||
foreach (Rom rom in newroms)
|
||||
List<DatItem> items = Items[key];
|
||||
List<DatItem> newItems = DatItem.Merge(items);
|
||||
foreach (Rom rom in newItems)
|
||||
{
|
||||
if (rom.Source.Index == 99)
|
||||
matched.Items.Add($"{rom.Size}-{rom.CRC}", rom);
|
||||
@@ -3414,59 +3455,61 @@ namespace SabreTools.Library.DatFiles
|
||||
List<DatItem> items = Items[key];
|
||||
foreach (DatItem item in items)
|
||||
{
|
||||
// If the file is not a Rom or Disk, continue
|
||||
if (item.ItemType != ItemType.Disk && item.ItemType != ItemType.Rom)
|
||||
// If the file is not a Disk, Media, or Rom, continue
|
||||
if (item.ItemType != ItemType.Disk && item.ItemType != ItemType.Media && item.ItemType != ItemType.Rom)
|
||||
return;
|
||||
|
||||
// If the file is a nodump
|
||||
if ((item.ItemType == ItemType.Rom && ((Rom)item).ItemStatus == ItemStatus.Nodump)
|
||||
|| (item.ItemType == ItemType.Disk && ((Disk)item).ItemStatus == ItemStatus.Nodump))
|
||||
if ((item.ItemType == ItemType.Rom && (item as Rom).ItemStatus == ItemStatus.Nodump)
|
||||
|| (item.ItemType == ItemType.Disk && (item as Disk).ItemStatus == ItemStatus.Nodump))
|
||||
{
|
||||
nodump.Items.Add(key, item);
|
||||
}
|
||||
// If the file has a SHA-512
|
||||
else if ((item.ItemType == ItemType.Rom && !string.IsNullOrWhiteSpace(((Rom)item).SHA512))
|
||||
|| (item.ItemType == ItemType.Disk && !string.IsNullOrWhiteSpace(((Disk)item).SHA512)))
|
||||
else if ((item.ItemType == ItemType.Rom && !string.IsNullOrWhiteSpace((item as Rom).SHA512)))
|
||||
{
|
||||
sha512.Items.Add(key, item);
|
||||
}
|
||||
// If the file has a SHA-384
|
||||
else if ((item.ItemType == ItemType.Rom && !string.IsNullOrWhiteSpace(((Rom)item).SHA384))
|
||||
|| (item.ItemType == ItemType.Disk && !string.IsNullOrWhiteSpace(((Disk)item).SHA384)))
|
||||
else if ((item.ItemType == ItemType.Rom && !string.IsNullOrWhiteSpace((item as Rom).SHA384)))
|
||||
{
|
||||
sha384.Items.Add(key, item);
|
||||
}
|
||||
// If the file has a SHA-256
|
||||
else if ((item.ItemType == ItemType.Rom && !string.IsNullOrWhiteSpace(((Rom)item).SHA256))
|
||||
|| (item.ItemType == ItemType.Disk && !string.IsNullOrWhiteSpace(((Disk)item).SHA256)))
|
||||
else if ((item.ItemType == ItemType.Media && !string.IsNullOrWhiteSpace((item as Media).SHA256))
|
||||
|| (item.ItemType == ItemType.Rom && !string.IsNullOrWhiteSpace((item as Rom).SHA256)))
|
||||
{
|
||||
sha256.Items.Add(key, item);
|
||||
}
|
||||
// If the file has a SHA-1
|
||||
else if ((item.ItemType == ItemType.Rom && !string.IsNullOrWhiteSpace(((Rom)item).SHA1))
|
||||
|| (item.ItemType == ItemType.Disk && !string.IsNullOrWhiteSpace(((Disk)item).SHA1)))
|
||||
else if ((item.ItemType == ItemType.Disk && !string.IsNullOrWhiteSpace((item as Disk).SHA1))
|
||||
|| (item.ItemType == ItemType.Media && !string.IsNullOrWhiteSpace((item as Media).SHA1))
|
||||
|| (item.ItemType == ItemType.Rom && !string.IsNullOrWhiteSpace((item as Rom).SHA1)))
|
||||
{
|
||||
sha1.Items.Add(key, item);
|
||||
}
|
||||
#if NET_FRAMEWORK
|
||||
// If the file has a RIPEMD160
|
||||
else if ((item.ItemType == ItemType.Rom && !string.IsNullOrWhiteSpace(((Rom)item).RIPEMD160))
|
||||
|| (item.ItemType == ItemType.Disk && !string.IsNullOrWhiteSpace(((Disk)item).RIPEMD160)))
|
||||
else if ((item.ItemType == ItemType.Rom && !string.IsNullOrWhiteSpace((item as Rom).RIPEMD160)))
|
||||
{
|
||||
ripemd160.Items.Add(key, item);
|
||||
}
|
||||
#endif
|
||||
// If the file has an MD5
|
||||
else if ((item.ItemType == ItemType.Rom && !string.IsNullOrWhiteSpace(((Rom)item).MD5))
|
||||
|| (item.ItemType == ItemType.Disk && !string.IsNullOrWhiteSpace(((Disk)item).MD5)))
|
||||
else if ((item.ItemType == ItemType.Disk && !string.IsNullOrWhiteSpace((item as Disk).MD5))
|
||||
|| (item.ItemType == ItemType.Media && !string.IsNullOrWhiteSpace((item as Media).MD5)
|
||||
|| (item.ItemType == ItemType.Rom && !string.IsNullOrWhiteSpace((item as Rom).MD5)))
|
||||
)
|
||||
{
|
||||
md5.Items.Add(key, item);
|
||||
}
|
||||
|
||||
// If the file has a CRC
|
||||
else if ((item.ItemType == ItemType.Rom && !string.IsNullOrWhiteSpace(((Rom)item).CRC)))
|
||||
else if ((item.ItemType == ItemType.Rom && !string.IsNullOrWhiteSpace((item as Rom).CRC)))
|
||||
{
|
||||
crc.Items.Add(key, item);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
other.Items.Add(key, item);
|
||||
@@ -3617,11 +3660,11 @@ namespace SabreTools.Library.DatFiles
|
||||
lessDat.Items.Add(key, item);
|
||||
|
||||
// If the file is a Rom and less than the radix, put it in the "lesser" dat
|
||||
else if (item.ItemType == ItemType.Rom && ((Rom)item).Size < radix)
|
||||
else if (item.ItemType == ItemType.Rom && (item as Rom).Size < radix)
|
||||
lessDat.Items.Add(key, item);
|
||||
|
||||
// If the file is a Rom and greater than or equal to the radix, put it in the "greater" dat
|
||||
else if (item.ItemType == ItemType.Rom && ((Rom)item).Size >= radix)
|
||||
else if (item.ItemType == ItemType.Rom && (item as Rom).Size >= radix)
|
||||
greaterEqualDat.Items.Add(key, item);
|
||||
}
|
||||
});
|
||||
@@ -3645,16 +3688,21 @@ namespace SabreTools.Library.DatFiles
|
||||
// Create each of the respective output DATs
|
||||
Globals.Logger.User("Creating and populating new DATs");
|
||||
|
||||
DatFile romdat = Create(Header.CloneStandard());
|
||||
romdat.Header.FileName += " (ROM)";
|
||||
romdat.Header.Name += " (ROM)";
|
||||
romdat.Header.Description += " (ROM)";
|
||||
|
||||
DatFile diskdat = Create(Header.CloneStandard());
|
||||
diskdat.Header.FileName += " (Disk)";
|
||||
diskdat.Header.Name += " (Disk)";
|
||||
diskdat.Header.Description += " (Disk)";
|
||||
|
||||
DatFile mediadat = Create(Header.CloneStandard());
|
||||
mediadat.Header.FileName += " (Media)";
|
||||
mediadat.Header.Name += " (Media)";
|
||||
mediadat.Header.Description += " (Media)";
|
||||
|
||||
DatFile romdat = Create(Header.CloneStandard());
|
||||
romdat.Header.FileName += " (Rom)";
|
||||
romdat.Header.Name += " (Rom)";
|
||||
romdat.Header.Description += " (Rom)";
|
||||
|
||||
DatFile sampledat = Create(Header.CloneStandard());
|
||||
sampledat.Header.FileName += " (Sample)";
|
||||
sampledat.Header.Name += " (Sample)";
|
||||
@@ -3666,14 +3714,18 @@ namespace SabreTools.Library.DatFiles
|
||||
List<DatItem> items = Items[key];
|
||||
foreach (DatItem item in items)
|
||||
{
|
||||
// If the file is a Rom
|
||||
if (item.ItemType == ItemType.Rom)
|
||||
romdat.Items.Add(key, item);
|
||||
|
||||
// If the file is a Disk
|
||||
else if (item.ItemType == ItemType.Disk)
|
||||
if (item.ItemType == ItemType.Disk)
|
||||
diskdat.Items.Add(key, item);
|
||||
|
||||
// If the file is a Media
|
||||
else if (item.ItemType == ItemType.Media)
|
||||
mediadat.Items.Add(key, item);
|
||||
|
||||
// If the file is a Rom
|
||||
else if (item.ItemType == ItemType.Rom)
|
||||
romdat.Items.Add(key, item);
|
||||
|
||||
// If the file is a Sample
|
||||
else if (item.ItemType == ItemType.Sample)
|
||||
sampledat.Items.Add(key, item);
|
||||
@@ -3683,8 +3735,9 @@ namespace SabreTools.Library.DatFiles
|
||||
// Now, output all of the files to the output directory
|
||||
Globals.Logger.User("DAT information created, outputting new files");
|
||||
bool success = true;
|
||||
success &= romdat.Write(outDir);
|
||||
success &= diskdat.Write(outDir);
|
||||
success &= mediadat.Write(outDir);
|
||||
success &= romdat.Write(outDir);
|
||||
success &= sampledat.Write(outDir);
|
||||
|
||||
return success;
|
||||
@@ -3843,28 +3896,40 @@ namespace SabreTools.Library.DatFiles
|
||||
// If we're in Depot mode, take care of that instead
|
||||
if (Header.OutputDepot?.IsActive ?? false)
|
||||
{
|
||||
if (item.ItemType == ItemType.Rom)
|
||||
if (item.ItemType == ItemType.Disk)
|
||||
{
|
||||
Rom romItem = item as Rom;
|
||||
Disk disk = item as Disk;
|
||||
|
||||
// We can only write out if there's a SHA-1
|
||||
if (!string.IsNullOrWhiteSpace(romItem.SHA1))
|
||||
if (!string.IsNullOrWhiteSpace(disk.SHA1))
|
||||
{
|
||||
name = PathExtensions.GetDepotPath(romItem.SHA1, Header.OutputDepot.Depth).Replace('\\', '/');
|
||||
item.Name = $"{pre}{name}{post}";
|
||||
}
|
||||
}
|
||||
else if (item.ItemType == ItemType.Disk)
|
||||
{
|
||||
Disk diskItem = item as Disk;
|
||||
|
||||
// We can only write out if there's a SHA-1
|
||||
if (!string.IsNullOrWhiteSpace(diskItem.SHA1))
|
||||
{
|
||||
name = PathExtensions.GetDepotPath(diskItem.SHA1, Header.OutputDepot.Depth).Replace('\\', '/');
|
||||
name = PathExtensions.GetDepotPath(disk.SHA1, Header.OutputDepot.Depth).Replace('\\', '/');
|
||||
item.Name = pre + name + post;
|
||||
}
|
||||
}
|
||||
else if (item.ItemType == ItemType.Media)
|
||||
{
|
||||
Media media = item as Media;
|
||||
|
||||
// We can only write out if there's a SHA-1
|
||||
if (!string.IsNullOrWhiteSpace(media.SHA1))
|
||||
{
|
||||
name = PathExtensions.GetDepotPath(media.SHA1, Header.OutputDepot.Depth).Replace('\\', '/');
|
||||
item.Name = pre + name + post;
|
||||
}
|
||||
}
|
||||
else if (item.ItemType == ItemType.Rom)
|
||||
{
|
||||
Rom rom = item as Rom;
|
||||
|
||||
// We can only write out if there's a SHA-1
|
||||
if (!string.IsNullOrWhiteSpace(rom.SHA1))
|
||||
{
|
||||
name = PathExtensions.GetDepotPath(rom.SHA1, Header.OutputDepot.Depth).Replace('\\', '/');
|
||||
item.Name = $"{pre}{name}{post}";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -3926,29 +3991,29 @@ namespace SabreTools.Library.DatFiles
|
||||
fix = (Header.Quotes ? "\"" : string.Empty) + Header.Postfix;
|
||||
|
||||
// Ensure we have the proper values for replacement
|
||||
if (item.ItemType == ItemType.Rom)
|
||||
if (item.ItemType == ItemType.Disk)
|
||||
{
|
||||
crc = ((Rom)item).CRC ?? string.Empty;
|
||||
md5 = ((Rom)item).MD5 ?? string.Empty;
|
||||
#if NET_FRAMEWORK
|
||||
ripemd160 = ((Rom)item).RIPEMD160 ?? string.Empty;
|
||||
#endif
|
||||
sha1 = ((Rom)item).SHA1 ?? string.Empty;
|
||||
sha256 = ((Rom)item).SHA256 ?? string.Empty;
|
||||
sha384 = ((Rom)item).SHA384 ?? string.Empty;
|
||||
sha512 = ((Rom)item).SHA512 ?? string.Empty;
|
||||
size = ((Rom)item).Size.ToString();
|
||||
md5 = (item as Disk).MD5 ?? string.Empty;
|
||||
sha1 = (item as Disk).SHA1 ?? string.Empty;
|
||||
}
|
||||
else if (item.ItemType == ItemType.Disk)
|
||||
else if (item.ItemType == ItemType.Media)
|
||||
{
|
||||
md5 = ((Disk)item).MD5 ?? string.Empty;
|
||||
md5 = (item as Media).MD5 ?? string.Empty;
|
||||
sha1 = (item as Media).SHA1 ?? string.Empty;
|
||||
sha256 = (item as Media).SHA256 ?? string.Empty;
|
||||
}
|
||||
else if (item.ItemType == ItemType.Rom)
|
||||
{
|
||||
crc = (item as Rom).CRC ?? string.Empty;
|
||||
md5 = (item as Rom).MD5 ?? string.Empty;
|
||||
#if NET_FRAMEWORK
|
||||
ripemd160 = ((Disk)item).RIPEMD160 ?? string.Empty;
|
||||
ripemd160 = (item as Rom).RIPEMD160 ?? string.Empty;
|
||||
#endif
|
||||
sha1 = ((Disk)item).SHA1 ?? string.Empty;
|
||||
sha256 = ((Disk)item).SHA256 ?? string.Empty;
|
||||
sha384 = ((Disk)item).SHA384 ?? string.Empty;
|
||||
sha512 = ((Disk)item).SHA512 ?? string.Empty;
|
||||
sha1 = (item as Rom).SHA1 ?? string.Empty;
|
||||
sha256 = (item as Rom).SHA256 ?? string.Empty;
|
||||
sha384 = (item as Rom).SHA384 ?? string.Empty;
|
||||
sha512 = (item as Rom).SHA512 ?? string.Empty;
|
||||
size = (item as Rom).Size.ToString();
|
||||
}
|
||||
|
||||
// Now do bulk replacement where possible
|
||||
|
||||
@@ -7,7 +7,6 @@ using System.Text;
|
||||
using SabreTools.Library.Data;
|
||||
using SabreTools.Library.DatItems;
|
||||
using SabreTools.Library.IO;
|
||||
using SabreTools.Library.Tools;
|
||||
|
||||
namespace SabreTools.Library.DatFiles
|
||||
{
|
||||
@@ -324,22 +323,22 @@ namespace SabreTools.Library.DatFiles
|
||||
|
||||
// If we have a "null" game (created by DATFromDir or something similar), log it to file
|
||||
if (rom.ItemType == ItemType.Rom
|
||||
&& ((Rom)rom).Size == -1
|
||||
&& ((Rom)rom).CRC == "null")
|
||||
&& (rom as Rom).Size == -1
|
||||
&& (rom as Rom).CRC == "null")
|
||||
{
|
||||
Globals.Logger.Verbose($"Empty folder found: {rom.Machine.Name}");
|
||||
|
||||
rom.Name = (rom.Name == "null" ? "-" : rom.Name);
|
||||
((Rom)rom).Size = Constants.SizeZero;
|
||||
((Rom)rom).CRC = ((Rom)rom).CRC == "null" ? Constants.CRCZero : null;
|
||||
((Rom)rom).MD5 = ((Rom)rom).MD5 == "null" ? Constants.MD5Zero : null;
|
||||
(rom as Rom).Size = Constants.SizeZero;
|
||||
(rom as Rom).CRC = (rom as Rom).CRC == "null" ? Constants.CRCZero : null;
|
||||
(rom as Rom).MD5 = (rom as Rom).MD5 == "null" ? Constants.MD5Zero : null;
|
||||
#if NET_FRAMEWORK
|
||||
((Rom)rom).RIPEMD160 = ((Rom)rom).RIPEMD160 == "null" ? Constants.RIPEMD160Zero : null;
|
||||
(rom as Rom).RIPEMD160 = (rom as Rom).RIPEMD160 == "null" ? Constants.RIPEMD160Zero : null;
|
||||
#endif
|
||||
((Rom)rom).SHA1 = ((Rom)rom).SHA1 == "null" ? Constants.SHA1Zero : null;
|
||||
((Rom)rom).SHA256 = ((Rom)rom).SHA256 == "null" ? Constants.SHA256Zero : null;
|
||||
((Rom)rom).SHA384 = ((Rom)rom).SHA384 == "null" ? Constants.SHA384Zero : null;
|
||||
((Rom)rom).SHA512 = ((Rom)rom).SHA512 == "null" ? Constants.SHA512Zero : null;
|
||||
(rom as Rom).SHA1 = (rom as Rom).SHA1 == "null" ? Constants.SHA1Zero : null;
|
||||
(rom as Rom).SHA256 = (rom as Rom).SHA256 == "null" ? Constants.SHA256Zero : null;
|
||||
(rom as Rom).SHA384 = (rom as Rom).SHA384 == "null" ? Constants.SHA384Zero : null;
|
||||
(rom as Rom).SHA512 = (rom as Rom).SHA512 == "null" ? Constants.SHA512Zero : null;
|
||||
}
|
||||
|
||||
// Now, output the rom data
|
||||
|
||||
@@ -255,5 +255,6 @@ namespace SabreTools.Library.DatFiles
|
||||
{
|
||||
CHDs = 1 << 0,
|
||||
Archives = 1 << 1,
|
||||
AaruFormats = 1 << 2,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ using System.Text;
|
||||
using SabreTools.Library.Data;
|
||||
using SabreTools.Library.DatItems;
|
||||
using SabreTools.Library.IO;
|
||||
using SabreTools.Library.Tools;
|
||||
|
||||
namespace SabreTools.Library.DatFiles
|
||||
{
|
||||
@@ -205,6 +204,14 @@ namespace SabreTools.Library.DatFiles
|
||||
name += disk.Name;
|
||||
break;
|
||||
|
||||
case ItemType.Media:
|
||||
var media = datItem as Media;
|
||||
if (Header.GameName)
|
||||
name = $"{media.Machine.Name}{Path.DirectorySeparatorChar}";
|
||||
|
||||
name += media.Name;
|
||||
break;
|
||||
|
||||
case ItemType.Rom:
|
||||
var rom = datItem as Rom;
|
||||
if (Header.GameName)
|
||||
@@ -239,6 +246,12 @@ namespace SabreTools.Library.DatFiles
|
||||
fields[1] = name;
|
||||
break;
|
||||
|
||||
case ItemType.Media:
|
||||
var media = datItem as Media;
|
||||
fields[0] = media.MD5;
|
||||
fields[1] = name;
|
||||
break;
|
||||
|
||||
case ItemType.Rom:
|
||||
var rom = datItem as Rom;
|
||||
fields[0] = rom.MD5;
|
||||
@@ -252,12 +265,6 @@ namespace SabreTools.Library.DatFiles
|
||||
case Hash.RIPEMD160:
|
||||
switch (datItem.ItemType)
|
||||
{
|
||||
case ItemType.Disk:
|
||||
var disk = datItem as Disk;
|
||||
fields[0] = disk.RIPEMD160;
|
||||
fields[1] = name;
|
||||
break;
|
||||
|
||||
case ItemType.Rom:
|
||||
var rom = datItem as Rom;
|
||||
fields[0] = rom.RIPEMD160;
|
||||
@@ -276,6 +283,12 @@ namespace SabreTools.Library.DatFiles
|
||||
fields[1] = name;
|
||||
break;
|
||||
|
||||
case ItemType.Media:
|
||||
var media = datItem as Media;
|
||||
fields[0] = media.SHA1;
|
||||
fields[1] = name;
|
||||
break;
|
||||
|
||||
case ItemType.Rom:
|
||||
var rom = datItem as Rom;
|
||||
fields[0] = rom.SHA1;
|
||||
@@ -288,9 +301,9 @@ namespace SabreTools.Library.DatFiles
|
||||
case Hash.SHA256:
|
||||
switch (datItem.ItemType)
|
||||
{
|
||||
case ItemType.Disk:
|
||||
var disk = datItem as Disk;
|
||||
fields[0] = disk.SHA256;
|
||||
case ItemType.Media:
|
||||
var media = datItem as Media;
|
||||
fields[0] = media.SHA256;
|
||||
fields[1] = name;
|
||||
break;
|
||||
|
||||
@@ -306,12 +319,6 @@ namespace SabreTools.Library.DatFiles
|
||||
case Hash.SHA384:
|
||||
switch (datItem.ItemType)
|
||||
{
|
||||
case ItemType.Disk:
|
||||
var disk = datItem as Disk;
|
||||
fields[0] = disk.SHA384;
|
||||
fields[1] = name;
|
||||
break;
|
||||
|
||||
case ItemType.Rom:
|
||||
var rom = datItem as Rom;
|
||||
fields[0] = rom.SHA384;
|
||||
@@ -324,12 +331,6 @@ namespace SabreTools.Library.DatFiles
|
||||
case Hash.SHA512:
|
||||
switch (datItem.ItemType)
|
||||
{
|
||||
case ItemType.Disk:
|
||||
var disk = datItem as Disk;
|
||||
fields[0] = disk.SHA512;
|
||||
fields[1] = name;
|
||||
break;
|
||||
|
||||
case ItemType.Rom:
|
||||
var rom = datItem as Rom;
|
||||
fields[0] = rom.SHA512;
|
||||
|
||||
@@ -100,6 +100,12 @@ namespace SabreTools.Library.DatFiles
|
||||
[JsonIgnore]
|
||||
public long DiskCount { get; private set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Number of Media items
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public long MediaCount { get; private set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Number of Release items
|
||||
/// </summary>
|
||||
@@ -399,46 +405,46 @@ namespace SabreTools.Library.DatFiles
|
||||
break;
|
||||
case ItemType.Disk:
|
||||
DiskCount += 1;
|
||||
if (((Disk)item).ItemStatus != ItemStatus.Nodump)
|
||||
if ((item as Disk).ItemStatus != ItemStatus.Nodump)
|
||||
{
|
||||
MD5Count += (string.IsNullOrWhiteSpace(((Disk)item).MD5) ? 0 : 1);
|
||||
#if NET_FRAMEWORK
|
||||
RIPEMD160Count += (string.IsNullOrWhiteSpace(((Disk)item).RIPEMD160) ? 0 : 1);
|
||||
#endif
|
||||
SHA1Count += (string.IsNullOrWhiteSpace(((Disk)item).SHA1) ? 0 : 1);
|
||||
SHA256Count += (string.IsNullOrWhiteSpace(((Disk)item).SHA256) ? 0 : 1);
|
||||
SHA384Count += (string.IsNullOrWhiteSpace(((Disk)item).SHA384) ? 0 : 1);
|
||||
SHA512Count += (string.IsNullOrWhiteSpace(((Disk)item).SHA512) ? 0 : 1);
|
||||
MD5Count += (string.IsNullOrWhiteSpace((item as Disk).MD5) ? 0 : 1);
|
||||
SHA1Count += (string.IsNullOrWhiteSpace((item as Disk).SHA1) ? 0 : 1);
|
||||
}
|
||||
|
||||
BaddumpCount += (((Disk)item).ItemStatus == ItemStatus.BadDump ? 1 : 0);
|
||||
GoodCount += (((Disk)item).ItemStatus == ItemStatus.Good ? 1 : 0);
|
||||
NodumpCount += (((Disk)item).ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
||||
VerifiedCount += (((Disk)item).ItemStatus == ItemStatus.Verified ? 1 : 0);
|
||||
BaddumpCount += ((item as Disk).ItemStatus == ItemStatus.BadDump ? 1 : 0);
|
||||
GoodCount += ((item as Disk).ItemStatus == ItemStatus.Good ? 1 : 0);
|
||||
NodumpCount += ((item as Disk).ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
||||
VerifiedCount += ((item as Disk).ItemStatus == ItemStatus.Verified ? 1 : 0);
|
||||
break;
|
||||
case ItemType.Media:
|
||||
MediaCount += 1;
|
||||
MD5Count += (string.IsNullOrWhiteSpace((item as Media).MD5) ? 0 : 1);
|
||||
SHA1Count += (string.IsNullOrWhiteSpace((item as Media).SHA1) ? 0 : 1);
|
||||
SHA256Count += (string.IsNullOrWhiteSpace((item as Media).SHA256) ? 0 : 1);
|
||||
break;
|
||||
case ItemType.Release:
|
||||
ReleaseCount += 1;
|
||||
break;
|
||||
case ItemType.Rom:
|
||||
RomCount += 1;
|
||||
if (((Rom)item).ItemStatus != ItemStatus.Nodump)
|
||||
if ((item as Rom).ItemStatus != ItemStatus.Nodump)
|
||||
{
|
||||
TotalSize += ((Rom)item).Size;
|
||||
CRCCount += (string.IsNullOrWhiteSpace(((Rom)item).CRC) ? 0 : 1);
|
||||
MD5Count += (string.IsNullOrWhiteSpace(((Rom)item).MD5) ? 0 : 1);
|
||||
TotalSize += (item as Rom).Size;
|
||||
CRCCount += (string.IsNullOrWhiteSpace((item as Rom).CRC) ? 0 : 1);
|
||||
MD5Count += (string.IsNullOrWhiteSpace((item as Rom).MD5) ? 0 : 1);
|
||||
#if NET_FRAMEWORK
|
||||
RIPEMD160Count += (string.IsNullOrWhiteSpace(((Rom)item).RIPEMD160) ? 0 : 1);
|
||||
RIPEMD160Count += (string.IsNullOrWhiteSpace((item as Rom).RIPEMD160) ? 0 : 1);
|
||||
#endif
|
||||
SHA1Count += (string.IsNullOrWhiteSpace(((Rom)item).SHA1) ? 0 : 1);
|
||||
SHA256Count += (string.IsNullOrWhiteSpace(((Rom)item).SHA256) ? 0 : 1);
|
||||
SHA384Count += (string.IsNullOrWhiteSpace(((Rom)item).SHA384) ? 0 : 1);
|
||||
SHA512Count += (string.IsNullOrWhiteSpace(((Rom)item).SHA512) ? 0 : 1);
|
||||
SHA1Count += (string.IsNullOrWhiteSpace((item as Rom).SHA1) ? 0 : 1);
|
||||
SHA256Count += (string.IsNullOrWhiteSpace((item as Rom).SHA256) ? 0 : 1);
|
||||
SHA384Count += (string.IsNullOrWhiteSpace((item as Rom).SHA384) ? 0 : 1);
|
||||
SHA512Count += (string.IsNullOrWhiteSpace((item as Rom).SHA512) ? 0 : 1);
|
||||
}
|
||||
|
||||
BaddumpCount += (((Rom)item).ItemStatus == ItemStatus.BadDump ? 1 : 0);
|
||||
GoodCount += (((Rom)item).ItemStatus == ItemStatus.Good ? 1 : 0);
|
||||
NodumpCount += (((Rom)item).ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
||||
VerifiedCount += (((Rom)item).ItemStatus == ItemStatus.Verified ? 1 : 0);
|
||||
BaddumpCount += ((item as Rom).ItemStatus == ItemStatus.BadDump ? 1 : 0);
|
||||
GoodCount += ((item as Rom).ItemStatus == ItemStatus.Good ? 1 : 0);
|
||||
NodumpCount += ((item as Rom).ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
||||
VerifiedCount += ((item as Rom).ItemStatus == ItemStatus.Verified ? 1 : 0);
|
||||
break;
|
||||
case ItemType.Sample:
|
||||
SampleCount += 1;
|
||||
@@ -456,7 +462,9 @@ namespace SabreTools.Library.DatFiles
|
||||
|
||||
ArchiveCount += stats.ArchiveCount;
|
||||
BiosSetCount += stats.BiosSetCount;
|
||||
ChipCount += stats.ChipCount;
|
||||
DiskCount += stats.DiskCount;
|
||||
MediaCount += stats.MediaCount;
|
||||
ReleaseCount += stats.ReleaseCount;
|
||||
RomCount += stats.RomCount;
|
||||
SampleCount += stats.SampleCount;
|
||||
@@ -522,46 +530,46 @@ namespace SabreTools.Library.DatFiles
|
||||
break;
|
||||
case ItemType.Disk:
|
||||
DiskCount -= 1;
|
||||
if (((Disk)item).ItemStatus != ItemStatus.Nodump)
|
||||
if ((item as Disk).ItemStatus != ItemStatus.Nodump)
|
||||
{
|
||||
MD5Count -= (string.IsNullOrWhiteSpace(((Disk)item).MD5) ? 0 : 1);
|
||||
#if NET_FRAMEWORK
|
||||
RIPEMD160Count -= (string.IsNullOrWhiteSpace(((Disk)item).RIPEMD160) ? 0 : 1);
|
||||
#endif
|
||||
SHA1Count -= (string.IsNullOrWhiteSpace(((Disk)item).SHA1) ? 0 : 1);
|
||||
SHA256Count -= (string.IsNullOrWhiteSpace(((Disk)item).SHA256) ? 0 : 1);
|
||||
SHA384Count -= (string.IsNullOrWhiteSpace(((Disk)item).SHA384) ? 0 : 1);
|
||||
SHA512Count -= (string.IsNullOrWhiteSpace(((Disk)item).SHA512) ? 0 : 1);
|
||||
MD5Count -= (string.IsNullOrWhiteSpace((item as Disk).MD5) ? 0 : 1);
|
||||
SHA1Count -= (string.IsNullOrWhiteSpace((item as Disk).SHA1) ? 0 : 1);
|
||||
}
|
||||
|
||||
BaddumpCount -= (((Disk)item).ItemStatus == ItemStatus.BadDump ? 1 : 0);
|
||||
GoodCount -= (((Disk)item).ItemStatus == ItemStatus.Good ? 1 : 0);
|
||||
NodumpCount -= (((Disk)item).ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
||||
VerifiedCount -= (((Disk)item).ItemStatus == ItemStatus.Verified ? 1 : 0);
|
||||
BaddumpCount -= ((item as Disk).ItemStatus == ItemStatus.BadDump ? 1 : 0);
|
||||
GoodCount -= ((item as Disk).ItemStatus == ItemStatus.Good ? 1 : 0);
|
||||
NodumpCount -= ((item as Disk).ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
||||
VerifiedCount -= ((item as Disk).ItemStatus == ItemStatus.Verified ? 1 : 0);
|
||||
break;
|
||||
case ItemType.Media:
|
||||
MediaCount -= 1;
|
||||
MD5Count -= (string.IsNullOrWhiteSpace((item as Media).MD5) ? 0 : 1);
|
||||
SHA1Count -= (string.IsNullOrWhiteSpace((item as Media).SHA1) ? 0 : 1);
|
||||
SHA256Count -= (string.IsNullOrWhiteSpace((item as Media).SHA256) ? 0 : 1);
|
||||
break;
|
||||
case ItemType.Release:
|
||||
ReleaseCount -= 1;
|
||||
break;
|
||||
case ItemType.Rom:
|
||||
RomCount -= 1;
|
||||
if (((Rom)item).ItemStatus != ItemStatus.Nodump)
|
||||
if ((item as Rom).ItemStatus != ItemStatus.Nodump)
|
||||
{
|
||||
TotalSize -= ((Rom)item).Size;
|
||||
CRCCount -= (string.IsNullOrWhiteSpace(((Rom)item).CRC) ? 0 : 1);
|
||||
MD5Count -= (string.IsNullOrWhiteSpace(((Rom)item).MD5) ? 0 : 1);
|
||||
TotalSize -= (item as Rom).Size;
|
||||
CRCCount -= (string.IsNullOrWhiteSpace((item as Rom).CRC) ? 0 : 1);
|
||||
MD5Count -= (string.IsNullOrWhiteSpace((item as Rom).MD5) ? 0 : 1);
|
||||
#if NET_FRAMEWORK
|
||||
RIPEMD160Count -= (string.IsNullOrWhiteSpace(((Rom)item).RIPEMD160) ? 0 : 1);
|
||||
RIPEMD160Count -= (string.IsNullOrWhiteSpace((item as Rom).RIPEMD160) ? 0 : 1);
|
||||
#endif
|
||||
SHA1Count -= (string.IsNullOrWhiteSpace(((Rom)item).SHA1) ? 0 : 1);
|
||||
SHA256Count -= (string.IsNullOrWhiteSpace(((Rom)item).SHA256) ? 0 : 1);
|
||||
SHA384Count -= (string.IsNullOrWhiteSpace(((Rom)item).SHA384) ? 0 : 1);
|
||||
SHA512Count -= (string.IsNullOrWhiteSpace(((Rom)item).SHA512) ? 0 : 1);
|
||||
SHA1Count -= (string.IsNullOrWhiteSpace((item as Rom).SHA1) ? 0 : 1);
|
||||
SHA256Count -= (string.IsNullOrWhiteSpace((item as Rom).SHA256) ? 0 : 1);
|
||||
SHA384Count -= (string.IsNullOrWhiteSpace((item as Rom).SHA384) ? 0 : 1);
|
||||
SHA512Count -= (string.IsNullOrWhiteSpace((item as Rom).SHA512) ? 0 : 1);
|
||||
}
|
||||
|
||||
BaddumpCount -= (((Rom)item).ItemStatus == ItemStatus.BadDump ? 1 : 0);
|
||||
GoodCount -= (((Rom)item).ItemStatus == ItemStatus.Good ? 1 : 0);
|
||||
NodumpCount -= (((Rom)item).ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
||||
VerifiedCount -= (((Rom)item).ItemStatus == ItemStatus.Verified ? 1 : 0);
|
||||
BaddumpCount -= ((item as Rom).ItemStatus == ItemStatus.BadDump ? 1 : 0);
|
||||
GoodCount -= ((item as Rom).ItemStatus == ItemStatus.Good ? 1 : 0);
|
||||
NodumpCount -= ((item as Rom).ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
||||
VerifiedCount -= ((item as Rom).ItemStatus == ItemStatus.Verified ? 1 : 0);
|
||||
break;
|
||||
case ItemType.Sample:
|
||||
SampleCount -= 1;
|
||||
@@ -817,29 +825,29 @@ namespace SabreTools.Library.DatFiles
|
||||
private Field GetBestAvailable()
|
||||
{
|
||||
// If all items are supposed to have a SHA-512, we bucket by that
|
||||
if (RomCount + DiskCount - NodumpCount == SHA512Count)
|
||||
if (DiskCount + MediaCount + RomCount - NodumpCount == SHA512Count)
|
||||
return Field.DatItem_SHA512;
|
||||
|
||||
// If all items are supposed to have a SHA-384, we bucket by that
|
||||
else if (RomCount + DiskCount - NodumpCount == SHA384Count)
|
||||
else if (DiskCount + MediaCount + RomCount - NodumpCount == SHA384Count)
|
||||
return Field.DatItem_SHA384;
|
||||
|
||||
// If all items are supposed to have a SHA-256, we bucket by that
|
||||
else if (RomCount + DiskCount - NodumpCount == SHA256Count)
|
||||
else if (DiskCount + MediaCount + RomCount - NodumpCount == SHA256Count)
|
||||
return Field.DatItem_SHA256;
|
||||
|
||||
// If all items are supposed to have a SHA-1, we bucket by that
|
||||
else if (RomCount + DiskCount - NodumpCount == SHA1Count)
|
||||
else if (DiskCount + MediaCount + RomCount - NodumpCount == SHA1Count)
|
||||
return Field.DatItem_SHA1;
|
||||
|
||||
#if NET_FRAMEWORK
|
||||
// If all items are supposed to have a RIPEMD160, we bucket by that
|
||||
else if (RomCount + DiskCount - NodumpCount == RIPEMD160Count)
|
||||
else if (DiskCount + MediaCount + RomCount - NodumpCount == RIPEMD160Count)
|
||||
return Field.DatItem_RIPEMD160;
|
||||
#endif
|
||||
|
||||
// If all items are supposed to have a MD5, we bucket by that
|
||||
else if (RomCount + DiskCount - NodumpCount == MD5Count)
|
||||
else if (DiskCount + MediaCount + RomCount - NodumpCount == MD5Count)
|
||||
return Field.DatItem_MD5;
|
||||
|
||||
// Otherwise, we bucket by CRC
|
||||
@@ -856,7 +864,9 @@ namespace SabreTools.Library.DatFiles
|
||||
|
||||
ArchiveCount = 0;
|
||||
BiosSetCount = 0;
|
||||
ChipCount = 0;
|
||||
DiskCount = 0;
|
||||
MediaCount = 0;
|
||||
ReleaseCount = 0;
|
||||
RomCount = 0;
|
||||
SampleCount = 0;
|
||||
|
||||
@@ -238,6 +238,9 @@ namespace SabreTools.Library.DatFiles
|
||||
case ItemType.Disk:
|
||||
datItem = datItemObj.ToObject<Disk>();
|
||||
break;
|
||||
case ItemType.Media:
|
||||
datItem = datItemObj.ToObject<Media>();
|
||||
break;
|
||||
case ItemType.Release:
|
||||
datItem = datItemObj.ToObject<Release>();
|
||||
break;
|
||||
@@ -322,22 +325,22 @@ namespace SabreTools.Library.DatFiles
|
||||
|
||||
// If we have a "null" game (created by DATFromDir or something similar), log it to file
|
||||
if (rom.ItemType == ItemType.Rom
|
||||
&& ((Rom)rom).Size == -1
|
||||
&& ((Rom)rom).CRC == "null")
|
||||
&& (rom as Rom).Size == -1
|
||||
&& (rom as Rom).CRC == "null")
|
||||
{
|
||||
Globals.Logger.Verbose($"Empty folder found: {rom.Machine.Name}");
|
||||
|
||||
rom.Name = (rom.Name == "null" ? "-" : rom.Name);
|
||||
((Rom)rom).Size = Constants.SizeZero;
|
||||
((Rom)rom).CRC = ((Rom)rom).CRC == "null" ? Constants.CRCZero : null;
|
||||
((Rom)rom).MD5 = ((Rom)rom).MD5 == "null" ? Constants.MD5Zero : null;
|
||||
(rom as Rom).Size = Constants.SizeZero;
|
||||
(rom as Rom).CRC = (rom as Rom).CRC == "null" ? Constants.CRCZero : null;
|
||||
(rom as Rom).MD5 = (rom as Rom).MD5 == "null" ? Constants.MD5Zero : null;
|
||||
#if NET_FRAMEWORK
|
||||
((Rom)rom).RIPEMD160 = ((Rom)rom).RIPEMD160 == "null" ? Constants.RIPEMD160Zero : null;
|
||||
(rom as Rom).RIPEMD160 = (rom as Rom).RIPEMD160 == "null" ? Constants.RIPEMD160Zero : null;
|
||||
#endif
|
||||
((Rom)rom).SHA1 = ((Rom)rom).SHA1 == "null" ? Constants.SHA1Zero : null;
|
||||
((Rom)rom).SHA256 = ((Rom)rom).SHA256 == "null" ? Constants.SHA256Zero : null;
|
||||
((Rom)rom).SHA384 = ((Rom)rom).SHA384 == "null" ? Constants.SHA384Zero : null;
|
||||
((Rom)rom).SHA512 = ((Rom)rom).SHA512 == "null" ? Constants.SHA512Zero : null;
|
||||
(rom as Rom).SHA1 = (rom as Rom).SHA1 == "null" ? Constants.SHA1Zero : null;
|
||||
(rom as Rom).SHA256 = (rom as Rom).SHA256 == "null" ? Constants.SHA256Zero : null;
|
||||
(rom as Rom).SHA384 = (rom as Rom).SHA384 == "null" ? Constants.SHA384Zero : null;
|
||||
(rom as Rom).SHA512 = (rom as Rom).SHA512 == "null" ? Constants.SHA512Zero : null;
|
||||
}
|
||||
|
||||
// Now, output the rom data
|
||||
|
||||
@@ -318,19 +318,19 @@ namespace SabreTools.Library.DatFiles
|
||||
|
||||
// If we have a "null" game (created by DATFromDir or something similar), log it to file
|
||||
if (rom.ItemType == ItemType.Rom
|
||||
&& ((Rom)rom).Size == -1
|
||||
&& ((Rom)rom).CRC == "null")
|
||||
&& (rom as Rom).Size == -1
|
||||
&& (rom as Rom).CRC == "null")
|
||||
{
|
||||
Globals.Logger.Verbose($"Empty folder found: {rom.Machine.Name}");
|
||||
|
||||
rom.Name = (rom.Name == "null" ? "-" : rom.Name);
|
||||
((Rom)rom).Size = Constants.SizeZero;
|
||||
((Rom)rom).CRC = ((Rom)rom).CRC == "null" ? Constants.CRCZero : null;
|
||||
((Rom)rom).MD5 = ((Rom)rom).MD5 == "null" ? Constants.MD5Zero : null;
|
||||
((Rom)rom).SHA1 = ((Rom)rom).SHA1 == "null" ? Constants.SHA1Zero : null;
|
||||
((Rom)rom).SHA256 = ((Rom)rom).SHA256 == "null" ? Constants.SHA256Zero : null;
|
||||
((Rom)rom).SHA384 = ((Rom)rom).SHA384 == "null" ? Constants.SHA384Zero : null;
|
||||
((Rom)rom).SHA512 = ((Rom)rom).SHA512 == "null" ? Constants.SHA512Zero : null;
|
||||
(rom as Rom).Size = Constants.SizeZero;
|
||||
(rom as Rom).CRC = (rom as Rom).CRC == "null" ? Constants.CRCZero : null;
|
||||
(rom as Rom).MD5 = (rom as Rom).MD5 == "null" ? Constants.MD5Zero : null;
|
||||
(rom as Rom).SHA1 = (rom as Rom).SHA1 == "null" ? Constants.SHA1Zero : null;
|
||||
(rom as Rom).SHA256 = (rom as Rom).SHA256 == "null" ? Constants.SHA256Zero : null;
|
||||
(rom as Rom).SHA384 = (rom as Rom).SHA384 == "null" ? Constants.SHA384Zero : null;
|
||||
(rom as Rom).SHA512 = (rom as Rom).SHA512 == "null" ? Constants.SHA512Zero : null;
|
||||
}
|
||||
|
||||
// Now, output the rom data
|
||||
|
||||
@@ -230,13 +230,7 @@ namespace SabreTools.Library.DatFiles
|
||||
{
|
||||
Name = reader.GetAttribute("name"),
|
||||
MD5 = reader.GetAttribute("md5"),
|
||||
#if NET_FRAMEWORK
|
||||
RIPEMD160 = reader.GetAttribute("ripemd160"),
|
||||
#endif
|
||||
SHA1 = reader.GetAttribute("sha1"),
|
||||
SHA256 = reader.GetAttribute("sha256"),
|
||||
SHA384 = reader.GetAttribute("sha384"),
|
||||
SHA512 = reader.GetAttribute("sha512"),
|
||||
MergeTag = reader.GetAttribute("merge"),
|
||||
Region = reader.GetAttribute("region"),
|
||||
Index = reader.GetAttribute("index"),
|
||||
@@ -1560,13 +1554,7 @@ namespace SabreTools.Library.DatFiles
|
||||
xtw.WriteStartElement("disk");
|
||||
xtw.WriteRequiredAttributeString("name", disk.Name);
|
||||
xtw.WriteOptionalAttributeString("md5", disk.MD5?.ToLowerInvariant());
|
||||
#if NET_FRAMEWORK
|
||||
xtw.WriteOptionalAttributeString("ripemd160", disk.RIPEMD160?.ToLowerInvariant());
|
||||
#endif
|
||||
xtw.WriteOptionalAttributeString("sha1", disk.SHA1?.ToLowerInvariant());
|
||||
xtw.WriteOptionalAttributeString("sha256", disk.SHA256?.ToLowerInvariant());
|
||||
xtw.WriteOptionalAttributeString("sha384", disk.SHA384?.ToLowerInvariant());
|
||||
xtw.WriteOptionalAttributeString("sha512", disk.SHA512?.ToLowerInvariant());
|
||||
xtw.WriteOptionalAttributeString("merge", disk.MergeTag);
|
||||
xtw.WriteOptionalAttributeString("region", disk.Region);
|
||||
xtw.WriteOptionalAttributeString("index", disk.Index);
|
||||
|
||||
@@ -237,13 +237,13 @@ namespace SabreTools.Library.DatFiles
|
||||
if (Header.System == null)
|
||||
Header.System = reader.GetAttribute("plugin");
|
||||
|
||||
if (Header.RomMode == null)
|
||||
if (Header.RomMode == MergingFlag.None)
|
||||
Header.RomMode = reader.GetAttribute("rommode").AsMergingFlag();
|
||||
|
||||
if (Header.BiosMode == null)
|
||||
if (Header.BiosMode == MergingFlag.None)
|
||||
Header.BiosMode = reader.GetAttribute("biosmode").AsMergingFlag();
|
||||
|
||||
if (Header.SampleMode == null)
|
||||
if (Header.SampleMode == MergingFlag.None)
|
||||
Header.SampleMode = reader.GetAttribute("samplemode").AsMergingFlag();
|
||||
|
||||
if (Header.LockRomMode == null)
|
||||
@@ -372,6 +372,128 @@ namespace SabreTools.Library.DatFiles
|
||||
reader.Skip();
|
||||
break;
|
||||
|
||||
case "archive":
|
||||
containsItems = true;
|
||||
|
||||
DatItem archive = new Archive
|
||||
{
|
||||
Name = reader.GetAttribute("name"),
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
|
||||
archive.CopyMachineInformation(machine);
|
||||
|
||||
// Now process and add the archive
|
||||
key = ParseAddHelper(archive);
|
||||
|
||||
reader.Read();
|
||||
break;
|
||||
|
||||
case "biosset":
|
||||
containsItems = true;
|
||||
|
||||
DatItem biosSet = new BiosSet
|
||||
{
|
||||
Name = reader.GetAttribute("name"),
|
||||
Description = reader.GetAttribute("description"),
|
||||
Default = reader.GetAttribute("default").AsYesNo(),
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
|
||||
biosSet.CopyMachineInformation(machine);
|
||||
|
||||
// Now process and add the biosSet
|
||||
key = ParseAddHelper(biosSet);
|
||||
|
||||
reader.Read();
|
||||
break;
|
||||
|
||||
case "chip":
|
||||
containsItems = true;
|
||||
|
||||
DatItem chip = new Chip
|
||||
{
|
||||
Name = reader.GetAttribute("name"),
|
||||
Tag = reader.GetAttribute("tag"),
|
||||
ChipType = reader.GetAttribute("type"),
|
||||
Clock = reader.GetAttribute("clock"),
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
|
||||
chip.CopyMachineInformation(machine);
|
||||
|
||||
// Now process and add the chip
|
||||
key = ParseAddHelper(chip);
|
||||
|
||||
reader.Read();
|
||||
break;
|
||||
|
||||
case "disk":
|
||||
containsItems = true;
|
||||
|
||||
DatItem disk = new Disk
|
||||
{
|
||||
Name = reader.GetAttribute("name"),
|
||||
MD5 = reader.GetAttribute("md5"),
|
||||
SHA1 = reader.GetAttribute("sha1"),
|
||||
MergeTag = reader.GetAttribute("merge"),
|
||||
ItemStatus = reader.GetAttribute("status").AsItemStatus(),
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
|
||||
disk.CopyMachineInformation(machine);
|
||||
|
||||
// Now process and add the disk
|
||||
key = ParseAddHelper(disk);
|
||||
|
||||
reader.Read();
|
||||
break;
|
||||
|
||||
case "media":
|
||||
containsItems = true;
|
||||
|
||||
DatItem media = new Media
|
||||
{
|
||||
Name = reader.GetAttribute("name"),
|
||||
MD5 = reader.GetAttribute("md5"),
|
||||
SHA1 = reader.GetAttribute("sha1"),
|
||||
SHA256 = reader.GetAttribute("sha256"),
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
|
||||
media.CopyMachineInformation(machine);
|
||||
|
||||
// Now process and add the media
|
||||
key = ParseAddHelper(media);
|
||||
|
||||
reader.Read();
|
||||
break;
|
||||
|
||||
case "release":
|
||||
containsItems = true;
|
||||
|
||||
@@ -386,36 +508,12 @@ namespace SabreTools.Library.DatFiles
|
||||
|
||||
release.CopyMachineInformation(machine);
|
||||
|
||||
// Now process and add the rom
|
||||
// Now process and add the release
|
||||
key = ParseAddHelper(release);
|
||||
|
||||
reader.Read();
|
||||
break;
|
||||
|
||||
case "biosset":
|
||||
containsItems = true;
|
||||
|
||||
DatItem biosset = new BiosSet
|
||||
{
|
||||
Name = reader.GetAttribute("name"),
|
||||
Description = reader.GetAttribute("description"),
|
||||
Default = reader.GetAttribute("default").AsYesNo(),
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
|
||||
biosset.CopyMachineInformation(machine);
|
||||
|
||||
// Now process and add the rom
|
||||
key = ParseAddHelper(biosset);
|
||||
|
||||
reader.Read();
|
||||
break;
|
||||
|
||||
case "rom":
|
||||
containsItems = true;
|
||||
|
||||
@@ -452,42 +550,10 @@ namespace SabreTools.Library.DatFiles
|
||||
reader.Read();
|
||||
break;
|
||||
|
||||
case "disk":
|
||||
containsItems = true;
|
||||
|
||||
DatItem disk = new Disk
|
||||
{
|
||||
Name = reader.GetAttribute("name"),
|
||||
MD5 = reader.GetAttribute("md5"),
|
||||
#if NET_FRAMEWORK
|
||||
RIPEMD160 = reader.GetAttribute("ripemd160"),
|
||||
#endif
|
||||
SHA1 = reader.GetAttribute("sha1"),
|
||||
SHA256 = reader.GetAttribute("sha256"),
|
||||
SHA384 = reader.GetAttribute("sha384"),
|
||||
SHA512 = reader.GetAttribute("sha512"),
|
||||
MergeTag = reader.GetAttribute("merge"),
|
||||
ItemStatus = reader.GetAttribute("status").AsItemStatus(),
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
|
||||
disk.CopyMachineInformation(machine);
|
||||
|
||||
// Now process and add the rom
|
||||
key = ParseAddHelper(disk);
|
||||
|
||||
reader.Read();
|
||||
break;
|
||||
|
||||
case "sample":
|
||||
containsItems = true;
|
||||
|
||||
DatItem samplerom = new Sample
|
||||
DatItem sample = new Sample
|
||||
{
|
||||
Name = reader.GetAttribute("name"),
|
||||
|
||||
@@ -498,57 +564,10 @@ namespace SabreTools.Library.DatFiles
|
||||
},
|
||||
};
|
||||
|
||||
samplerom.CopyMachineInformation(machine);
|
||||
sample.CopyMachineInformation(machine);
|
||||
|
||||
// Now process and add the rom
|
||||
key = ParseAddHelper(samplerom);
|
||||
|
||||
reader.Read();
|
||||
break;
|
||||
|
||||
case "archive":
|
||||
containsItems = true;
|
||||
|
||||
DatItem archiverom = new Archive
|
||||
{
|
||||
Name = reader.GetAttribute("name"),
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
|
||||
archiverom.CopyMachineInformation(machine);
|
||||
|
||||
// Now process and add the rom
|
||||
key = ParseAddHelper(archiverom);
|
||||
|
||||
reader.Read();
|
||||
break;
|
||||
|
||||
case "chip":
|
||||
containsItems = true;
|
||||
|
||||
DatItem chiprom = new Chip
|
||||
{
|
||||
Name = reader.GetAttribute("name"),
|
||||
Tag = reader.GetAttribute("tag"),
|
||||
ChipType = reader.GetAttribute("type"),
|
||||
Clock = reader.GetAttribute("clock"),
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
|
||||
chiprom.CopyMachineInformation(machine);
|
||||
|
||||
// Now process and add the rom
|
||||
key = ParseAddHelper(chiprom);
|
||||
// Now process and add the sample
|
||||
key = ParseAddHelper(sample);
|
||||
|
||||
reader.Read();
|
||||
break;
|
||||
@@ -729,22 +748,22 @@ namespace SabreTools.Library.DatFiles
|
||||
|
||||
// If we have a "null" game (created by DATFromDir or something similar), log it to file
|
||||
if (rom.ItemType == ItemType.Rom
|
||||
&& ((Rom)rom).Size == -1
|
||||
&& ((Rom)rom).CRC == "null")
|
||||
&& (rom as Rom).Size == -1
|
||||
&& (rom as Rom).CRC == "null")
|
||||
{
|
||||
Globals.Logger.Verbose($"Empty folder found: {rom.Machine.Name}");
|
||||
|
||||
rom.Name = (rom.Name == "null" ? "-" : rom.Name);
|
||||
((Rom)rom).Size = Constants.SizeZero;
|
||||
((Rom)rom).CRC = ((Rom)rom).CRC == "null" ? Constants.CRCZero : null;
|
||||
((Rom)rom).MD5 = ((Rom)rom).MD5 == "null" ? Constants.MD5Zero : null;
|
||||
(rom as Rom).Size = Constants.SizeZero;
|
||||
(rom as Rom).CRC = (rom as Rom).CRC == "null" ? Constants.CRCZero : null;
|
||||
(rom as Rom).MD5 = (rom as Rom).MD5 == "null" ? Constants.MD5Zero : null;
|
||||
#if NET_FRAMEWORK
|
||||
((Rom)rom).RIPEMD160 = ((Rom)rom).RIPEMD160 == "null" ? Constants.RIPEMD160Zero : null;
|
||||
(rom as Rom).RIPEMD160 = (rom as Rom).RIPEMD160 == "null" ? Constants.RIPEMD160Zero : null;
|
||||
#endif
|
||||
((Rom)rom).SHA1 = ((Rom)rom).SHA1 == "null" ? Constants.SHA1Zero : null;
|
||||
((Rom)rom).SHA256 = ((Rom)rom).SHA256 == "null" ? Constants.SHA256Zero : null;
|
||||
((Rom)rom).SHA384 = ((Rom)rom).SHA384 == "null" ? Constants.SHA384Zero : null;
|
||||
((Rom)rom).SHA512 = ((Rom)rom).SHA512 == "null" ? Constants.SHA512Zero : null;
|
||||
(rom as Rom).SHA1 = (rom as Rom).SHA1 == "null" ? Constants.SHA1Zero : null;
|
||||
(rom as Rom).SHA256 = (rom as Rom).SHA256 == "null" ? Constants.SHA256Zero : null;
|
||||
(rom as Rom).SHA384 = (rom as Rom).SHA384 == "null" ? Constants.SHA384Zero : null;
|
||||
(rom as Rom).SHA512 = (rom as Rom).SHA512 == "null" ? Constants.SHA512Zero : null;
|
||||
}
|
||||
|
||||
// Now, output the rom data
|
||||
@@ -1008,17 +1027,21 @@ namespace SabreTools.Library.DatFiles
|
||||
xtw.WriteStartElement("disk");
|
||||
xtw.WriteRequiredAttributeString("name", disk.Name);
|
||||
xtw.WriteOptionalAttributeString("md5", disk.MD5?.ToLowerInvariant());
|
||||
#if NET_FRAMEWORK
|
||||
xtw.WriteOptionalAttributeString("ripemd160", disk.RIPEMD160?.ToLowerInvariant());
|
||||
#endif
|
||||
xtw.WriteOptionalAttributeString("sha1", disk.SHA1?.ToLowerInvariant());
|
||||
xtw.WriteOptionalAttributeString("sha256", disk.SHA256?.ToLowerInvariant());
|
||||
xtw.WriteOptionalAttributeString("sha384", disk.SHA384?.ToLowerInvariant());
|
||||
xtw.WriteOptionalAttributeString("sha512", disk.SHA512?.ToLowerInvariant());
|
||||
xtw.WriteOptionalAttributeString("status", disk.ItemStatus.FromItemStatus(false));
|
||||
xtw.WriteEndElement();
|
||||
break;
|
||||
|
||||
case ItemType.Media:
|
||||
var media = datItem as Media;
|
||||
xtw.WriteStartElement("media");
|
||||
xtw.WriteRequiredAttributeString("name", media.Name);
|
||||
xtw.WriteOptionalAttributeString("md5", media.MD5?.ToLowerInvariant());
|
||||
xtw.WriteOptionalAttributeString("sha1", media.SHA1?.ToLowerInvariant());
|
||||
xtw.WriteOptionalAttributeString("sha256", media.SHA256?.ToLowerInvariant());
|
||||
xtw.WriteEndElement();
|
||||
break;
|
||||
|
||||
case ItemType.Release:
|
||||
var release = datItem as Release;
|
||||
xtw.WriteStartElement("release");
|
||||
|
||||
@@ -87,8 +87,8 @@ namespace SabreTools.Library.DatFiles
|
||||
|
||||
// If we have a "null" game (created by DATFromDir or something similar), log it to file
|
||||
if (rom.ItemType == ItemType.Rom
|
||||
&& ((Rom)rom).Size == -1
|
||||
&& ((Rom)rom).CRC == "null")
|
||||
&& (rom as Rom).Size == -1
|
||||
&& (rom as Rom).CRC == "null")
|
||||
{
|
||||
Globals.Logger.Verbose($"Empty folder found: {rom.Machine.Name}");
|
||||
lastgame = rom.Machine.Name;
|
||||
|
||||
@@ -644,8 +644,6 @@ namespace SabreTools.Library.DatFiles
|
||||
reader.ReadElementContentAsString().ToLowerInvariant()));
|
||||
break;
|
||||
|
||||
// TODO: Should I support the "custom" romMD5 and romSHA1 tags I write out?
|
||||
|
||||
default:
|
||||
reader.Read();
|
||||
break;
|
||||
@@ -727,22 +725,22 @@ namespace SabreTools.Library.DatFiles
|
||||
|
||||
// If we have a "null" game (created by DATFromDir or something similar), log it to file
|
||||
if (rom.ItemType == ItemType.Rom
|
||||
&& ((Rom)rom).Size == -1
|
||||
&& ((Rom)rom).CRC == "null")
|
||||
&& (rom as Rom).Size == -1
|
||||
&& (rom as Rom).CRC == "null")
|
||||
{
|
||||
Globals.Logger.Verbose($"Empty folder found: {rom.Machine.Name}");
|
||||
|
||||
rom.Name = (rom.Name == "null" ? "-" : rom.Name);
|
||||
((Rom)rom).Size = Constants.SizeZero;
|
||||
((Rom)rom).CRC = ((Rom)rom).CRC == "null" ? Constants.CRCZero : null;
|
||||
((Rom)rom).MD5 = ((Rom)rom).MD5 == "null" ? Constants.MD5Zero : null;
|
||||
(rom as Rom).Size = Constants.SizeZero;
|
||||
(rom as Rom).CRC = (rom as Rom).CRC == "null" ? Constants.CRCZero : null;
|
||||
(rom as Rom).MD5 = (rom as Rom).MD5 == "null" ? Constants.MD5Zero : null;
|
||||
#if NET_FRAMEWORK
|
||||
((Rom)rom).RIPEMD160 = ((Rom)rom).RIPEMD160 == "null" ? Constants.RIPEMD160Zero : null;
|
||||
(rom as Rom).RIPEMD160 = (rom as Rom).RIPEMD160 == "null" ? Constants.RIPEMD160Zero : null;
|
||||
#endif
|
||||
((Rom)rom).SHA1 = ((Rom)rom).SHA1 == "null" ? Constants.SHA1Zero : null;
|
||||
((Rom)rom).SHA256 = ((Rom)rom).SHA256 == "null" ? Constants.SHA256Zero : null;
|
||||
((Rom)rom).SHA384 = ((Rom)rom).SHA384 == "null" ? Constants.SHA384Zero : null;
|
||||
((Rom)rom).SHA512 = ((Rom)rom).SHA512 == "null" ? Constants.SHA512Zero : null;
|
||||
(rom as Rom).SHA1 = (rom as Rom).SHA1 == "null" ? Constants.SHA1Zero : null;
|
||||
(rom as Rom).SHA256 = (rom as Rom).SHA256 == "null" ? Constants.SHA256Zero : null;
|
||||
(rom as Rom).SHA384 = (rom as Rom).SHA384 == "null" ? Constants.SHA384Zero : null;
|
||||
(rom as Rom).SHA512 = (rom as Rom).SHA512 == "null" ? Constants.SHA512Zero : null;
|
||||
}
|
||||
|
||||
// Now, output the rom data
|
||||
@@ -929,29 +927,7 @@ namespace SabreTools.Library.DatFiles
|
||||
xtw.WriteElementString("sourceRom", "None");
|
||||
xtw.WriteElementString("language", "0");
|
||||
|
||||
if (datItem.ItemType == ItemType.Disk)
|
||||
{
|
||||
var disk = datItem as Disk;
|
||||
xtw.WriteStartElement("files");
|
||||
if (!string.IsNullOrWhiteSpace(disk.MD5))
|
||||
{
|
||||
xtw.WriteStartElement("romMD5");
|
||||
xtw.WriteAttributeString("extension", ".chd");
|
||||
xtw.WriteString(disk.MD5?.ToUpperInvariant());
|
||||
xtw.WriteEndElement();
|
||||
}
|
||||
else if (!string.IsNullOrWhiteSpace(disk.SHA1))
|
||||
{
|
||||
xtw.WriteStartElement("romSHA1");
|
||||
xtw.WriteAttributeString("extension", ".chd");
|
||||
xtw.WriteString(disk.SHA1?.ToUpperInvariant());
|
||||
xtw.WriteEndElement();
|
||||
}
|
||||
|
||||
// End files
|
||||
xtw.WriteEndElement();
|
||||
}
|
||||
else if (datItem.ItemType == ItemType.Rom)
|
||||
if (datItem.ItemType == ItemType.Rom)
|
||||
{
|
||||
var rom = datItem as Rom;
|
||||
string tempext = "." + PathExtensions.GetNormalizedExtension(rom.Name);
|
||||
@@ -964,20 +940,6 @@ namespace SabreTools.Library.DatFiles
|
||||
xtw.WriteString(rom.CRC?.ToUpperInvariant());
|
||||
xtw.WriteEndElement();
|
||||
}
|
||||
else if (!string.IsNullOrWhiteSpace(rom.MD5))
|
||||
{
|
||||
xtw.WriteStartElement("romMD5");
|
||||
xtw.WriteRequiredAttributeString("extension", tempext);
|
||||
xtw.WriteString(rom.MD5?.ToUpperInvariant());
|
||||
xtw.WriteEndElement();
|
||||
}
|
||||
else if (!string.IsNullOrWhiteSpace(rom.SHA1))
|
||||
{
|
||||
xtw.WriteStartElement("romSHA1");
|
||||
xtw.WriteRequiredAttributeString("extension", tempext);
|
||||
xtw.WriteString(rom.SHA1?.ToUpperInvariant());
|
||||
xtw.WriteEndElement();
|
||||
}
|
||||
|
||||
// End files
|
||||
xtw.WriteEndElement();
|
||||
|
||||
@@ -572,8 +572,8 @@ namespace SabreTools.Library.DatFiles
|
||||
|
||||
// If we have a "null" game (created by DATFromDir or something similar), log it to file
|
||||
if (rom.ItemType == ItemType.Rom
|
||||
&& ((Rom)rom).Size == -1
|
||||
&& ((Rom)rom).CRC == "null")
|
||||
&& (rom as Rom).Size == -1
|
||||
&& (rom as Rom).CRC == "null")
|
||||
{
|
||||
Globals.Logger.Verbose($"Empty folder found: {rom.Machine.Name}");
|
||||
|
||||
|
||||
@@ -419,22 +419,22 @@ namespace SabreTools.Library.DatFiles
|
||||
|
||||
// If we have a "null" game (created by DATFromDir or something similar), log it to file
|
||||
if (rom.ItemType == ItemType.Rom
|
||||
&& ((Rom)rom).Size == -1
|
||||
&& ((Rom)rom).CRC == "null")
|
||||
&& (rom as Rom).Size == -1
|
||||
&& (rom as Rom).CRC == "null")
|
||||
{
|
||||
Globals.Logger.Verbose($"Empty folder found: {rom.Machine.Name}");
|
||||
|
||||
rom.Name = (rom.Name == "null" ? "-" : rom.Name);
|
||||
((Rom)rom).Size = Constants.SizeZero;
|
||||
((Rom)rom).CRC = ((Rom)rom).CRC == "null" ? Constants.CRCZero : null;
|
||||
((Rom)rom).MD5 = ((Rom)rom).MD5 == "null" ? Constants.MD5Zero : null;
|
||||
(rom as Rom).Size = Constants.SizeZero;
|
||||
(rom as Rom).CRC = (rom as Rom).CRC == "null" ? Constants.CRCZero : null;
|
||||
(rom as Rom).MD5 = (rom as Rom).MD5 == "null" ? Constants.MD5Zero : null;
|
||||
#if NET_FRAMEWORK
|
||||
((Rom)rom).RIPEMD160 = ((Rom)rom).RIPEMD160 == "null" ? Constants.RIPEMD160Zero : null;
|
||||
(rom as Rom).RIPEMD160 = (rom as Rom).RIPEMD160 == "null" ? Constants.RIPEMD160Zero : null;
|
||||
#endif
|
||||
((Rom)rom).SHA1 = ((Rom)rom).SHA1 == "null" ? Constants.SHA1Zero : null;
|
||||
((Rom)rom).SHA256 = ((Rom)rom).SHA256 == "null" ? Constants.SHA256Zero : null;
|
||||
((Rom)rom).SHA384 = ((Rom)rom).SHA384 == "null" ? Constants.SHA384Zero : null;
|
||||
((Rom)rom).SHA512 = ((Rom)rom).SHA512 == "null" ? Constants.SHA512Zero : null;
|
||||
(rom as Rom).SHA1 = (rom as Rom).SHA1 == "null" ? Constants.SHA1Zero : null;
|
||||
(rom as Rom).SHA256 = (rom as Rom).SHA256 == "null" ? Constants.SHA256Zero : null;
|
||||
(rom as Rom).SHA384 = (rom as Rom).SHA384 == "null" ? Constants.SHA384Zero : null;
|
||||
(rom as Rom).SHA512 = (rom as Rom).SHA512 == "null" ? Constants.SHA512Zero : null;
|
||||
}
|
||||
|
||||
// Now, output the rom data
|
||||
|
||||
@@ -404,14 +404,24 @@ namespace SabreTools.Library.DatFiles
|
||||
{
|
||||
Name = reader.GetAttribute("name"),
|
||||
MD5 = reader.GetAttribute("md5"),
|
||||
#if NET_FRAMEWORK
|
||||
RIPEMD160 = reader.GetAttribute("ripemd160"),
|
||||
#endif
|
||||
SHA1 = reader.GetAttribute("sha1"),
|
||||
ItemStatus = its,
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
Index = indexId,
|
||||
Name = filename,
|
||||
},
|
||||
};
|
||||
break;
|
||||
|
||||
case "media":
|
||||
datItem = new Media
|
||||
{
|
||||
Name = reader.GetAttribute("name"),
|
||||
MD5 = reader.GetAttribute("md5"),
|
||||
SHA1 = reader.GetAttribute("sha1"),
|
||||
SHA256 = reader.GetAttribute("sha256"),
|
||||
SHA384 =reader.GetAttribute("sha384"),
|
||||
SHA512 = reader.GetAttribute("sha512"),
|
||||
ItemStatus = its,
|
||||
|
||||
Source = new Source
|
||||
{
|
||||
@@ -628,8 +638,8 @@ namespace SabreTools.Library.DatFiles
|
||||
|
||||
// If we have a "null" game (created by DATFromDir or something similar), log it to file
|
||||
if (rom.ItemType == ItemType.Rom
|
||||
&& ((Rom)rom).Size == -1
|
||||
&& ((Rom)rom).CRC == "null")
|
||||
&& (rom as Rom).Size == -1
|
||||
&& (rom as Rom).CRC == "null")
|
||||
{
|
||||
Globals.Logger.Verbose($"Empty folder found: {rom.Machine.Name}");
|
||||
|
||||
@@ -888,13 +898,7 @@ namespace SabreTools.Library.DatFiles
|
||||
xtw.WriteAttributeString("type", "disk");
|
||||
xtw.WriteRequiredAttributeString("name", disk.Name);
|
||||
xtw.WriteOptionalAttributeString("md5", disk.MD5?.ToLowerInvariant());
|
||||
#if NET_FRAMEWORK
|
||||
xtw.WriteOptionalAttributeString("ripemd160", disk.RIPEMD160?.ToLowerInvariant());
|
||||
#endif
|
||||
xtw.WriteOptionalAttributeString("sha1", disk.SHA1?.ToLowerInvariant());
|
||||
xtw.WriteOptionalAttributeString("sha256", disk.SHA256?.ToLowerInvariant());
|
||||
xtw.WriteOptionalAttributeString("sha384", disk.SHA384?.ToLowerInvariant());
|
||||
xtw.WriteOptionalAttributeString("sha512", disk.SHA512?.ToLowerInvariant());
|
||||
if (disk.ItemStatus != ItemStatus.None)
|
||||
{
|
||||
xtw.WriteStartElement("flags");
|
||||
@@ -910,6 +914,17 @@ namespace SabreTools.Library.DatFiles
|
||||
xtw.WriteEndElement();
|
||||
break;
|
||||
|
||||
case ItemType.Media:
|
||||
var media = datItem as Media;
|
||||
xtw.WriteStartElement("file");
|
||||
xtw.WriteAttributeString("type", "media");
|
||||
xtw.WriteRequiredAttributeString("name", media.Name);
|
||||
xtw.WriteOptionalAttributeString("md5", media.MD5?.ToLowerInvariant());
|
||||
xtw.WriteOptionalAttributeString("sha1", media.SHA1?.ToLowerInvariant());
|
||||
xtw.WriteOptionalAttributeString("sha256", media.SHA256?.ToLowerInvariant());
|
||||
xtw.WriteEndElement();
|
||||
break;
|
||||
|
||||
case ItemType.Release:
|
||||
var release = datItem as Release;
|
||||
xtw.WriteStartElement("file");
|
||||
|
||||
@@ -152,8 +152,8 @@ namespace SabreTools.Library.DatFiles
|
||||
|
||||
// If we have a "null" game (created by DATFromDir or something similar), log it to file
|
||||
if (rom.ItemType == ItemType.Rom
|
||||
&& ((Rom)rom).Size == -1
|
||||
&& ((Rom)rom).CRC == "null")
|
||||
&& (rom as Rom).Size == -1
|
||||
&& (rom as Rom).CRC == "null")
|
||||
{
|
||||
Globals.Logger.Verbose($"Empty folder found: {rom.Machine.Name}");
|
||||
}
|
||||
@@ -257,14 +257,30 @@ namespace SabreTools.Library.DatFiles
|
||||
fields[8] = string.Empty;
|
||||
fields[9] = string.Empty;
|
||||
fields[10] = disk.MD5.ToLowerInvariant();
|
||||
//fields[11] = disk.RIPEMD160?.ToLowerInvariant();
|
||||
//fields[11] = string.Empty;
|
||||
fields[11] = disk.SHA1.ToLowerInvariant();
|
||||
fields[12] = disk.SHA256.ToLowerInvariant();
|
||||
//fields[13] = disk.SHA384?.ToLowerInvariant();
|
||||
//fields[14] = disk.SHA512?.ToLowerInvariant();
|
||||
fields[12] = string.Empty;
|
||||
//fields[13] = string.Empty;
|
||||
//fields[14] = string.Empty;
|
||||
fields[13] = disk.ItemStatus.ToString();
|
||||
break;
|
||||
|
||||
case ItemType.Media:
|
||||
var media = datItem as Media;
|
||||
fields[5] = "media";
|
||||
fields[6] = string.Empty;
|
||||
fields[7] = media.Name;
|
||||
fields[8] = string.Empty;
|
||||
fields[9] = string.Empty;
|
||||
fields[10] = media.MD5.ToLowerInvariant();
|
||||
//fields[11] = string.Empty;
|
||||
fields[11] = media.SHA1.ToLowerInvariant();
|
||||
fields[12] = media.SHA256?.ToLowerInvariant();
|
||||
//fields[13] = string.Empty;
|
||||
//fields[14] = string.Empty;
|
||||
fields[13] = string.Empty;
|
||||
break;
|
||||
|
||||
case ItemType.Rom:
|
||||
var rom = datItem as Rom;
|
||||
fields[5] = "rom";
|
||||
|
||||
@@ -516,13 +516,7 @@ namespace SabreTools.Library.DatFiles
|
||||
{
|
||||
Name = reader.GetAttribute("name"),
|
||||
MD5 = reader.GetAttribute("md5"),
|
||||
#if NET_FRAMEWORK
|
||||
RIPEMD160 = reader.GetAttribute("ripemd160"),
|
||||
#endif
|
||||
SHA1 = reader.GetAttribute("sha1"),
|
||||
SHA256 = reader.GetAttribute("sha256"),
|
||||
SHA384 = reader.GetAttribute("sha384"),
|
||||
SHA512 = reader.GetAttribute("sha512"),
|
||||
ItemStatus = reader.GetAttribute("status").AsItemStatus(),
|
||||
Writable = reader.GetAttribute("writable").AsYesNo(),
|
||||
|
||||
@@ -652,8 +646,8 @@ namespace SabreTools.Library.DatFiles
|
||||
|
||||
// If we have a "null" game (created by DATFromDir or something similar), log it to file
|
||||
if (rom.ItemType == ItemType.Rom
|
||||
&& ((Rom)rom).Size == -1
|
||||
&& ((Rom)rom).CRC == "null")
|
||||
&& (rom as Rom).Size == -1
|
||||
&& (rom as Rom).CRC == "null")
|
||||
{
|
||||
Globals.Logger.Verbose($"Empty folder found: {rom.Machine.Name}");
|
||||
|
||||
@@ -870,13 +864,7 @@ namespace SabreTools.Library.DatFiles
|
||||
xtw.WriteStartElement("disk");
|
||||
xtw.WriteRequiredAttributeString("name", disk.Name);
|
||||
xtw.WriteOptionalAttributeString("md5", disk.MD5?.ToLowerInvariant());
|
||||
#if NET_FRAMEWORK
|
||||
xtw.WriteOptionalAttributeString("ripemd160", disk.RIPEMD160?.ToLowerInvariant());
|
||||
#endif
|
||||
xtw.WriteOptionalAttributeString("sha1", disk.SHA1?.ToLowerInvariant());
|
||||
xtw.WriteOptionalAttributeString("sha256", disk.SHA256?.ToLowerInvariant());
|
||||
xtw.WriteOptionalAttributeString("sha384", disk.SHA384?.ToLowerInvariant());
|
||||
xtw.WriteOptionalAttributeString("sha512", disk.SHA512?.ToLowerInvariant());
|
||||
xtw.WriteOptionalAttributeString("status", disk.ItemStatus.FromItemStatus(false));
|
||||
xtw.WriteOptionalAttributeString("writable", disk.Writable.FromYesNo());
|
||||
xtw.WriteEndElement();
|
||||
|
||||
Reference in New Issue
Block a user