mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Add gated code for Hashfile HasRequiredFields
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
using SabreTools.Core;
|
||||
@@ -107,6 +109,31 @@ namespace SabreTools.DatFiles.Formats
|
||||
return new ItemType[] { ItemType.Disk, ItemType.Media, ItemType.Rom };
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override bool HasRequiredFields(DatItem datItem)
|
||||
{
|
||||
return true;
|
||||
|
||||
// TODO: Use this code once `strict` rules determined
|
||||
return (_hash, datItem.ItemType) switch
|
||||
{
|
||||
(Hash.CRC, ItemType.Rom) => !string.IsNullOrEmpty((datItem as Rom)?.CRC),
|
||||
(Hash.MD5, ItemType.Disk) => !string.IsNullOrEmpty((datItem as Disk)?.MD5),
|
||||
(Hash.MD5, ItemType.Media) => !string.IsNullOrEmpty((datItem as Media)?.MD5),
|
||||
(Hash.MD5, ItemType.Rom) => !string.IsNullOrEmpty((datItem as Rom)?.MD5),
|
||||
(Hash.SHA1, ItemType.Disk) => !string.IsNullOrEmpty((datItem as Disk)?.SHA1),
|
||||
(Hash.SHA1, ItemType.Media) => !string.IsNullOrEmpty((datItem as Media)?.SHA1),
|
||||
(Hash.SHA1, ItemType.Rom) => !string.IsNullOrEmpty((datItem as Rom)?.SHA1),
|
||||
(Hash.SHA256, ItemType.Media) => !string.IsNullOrEmpty((datItem as Media)?.SHA256),
|
||||
(Hash.SHA256, ItemType.Rom) => !string.IsNullOrEmpty((datItem as Rom)?.SHA256),
|
||||
(Hash.SHA384, ItemType.Rom) => !string.IsNullOrEmpty((datItem as Rom)?.SHA384),
|
||||
(Hash.SHA512, ItemType.Rom) => !string.IsNullOrEmpty((datItem as Rom)?.SHA512),
|
||||
(Hash.SpamSum, ItemType.Media) => !string.IsNullOrEmpty((datItem as Media)?.SpamSum),
|
||||
(Hash.SpamSum, ItemType.Rom) => !string.IsNullOrEmpty((datItem as Rom)?.SpamSum),
|
||||
_ => false,
|
||||
};
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool WriteToFile(string outfile, bool ignoreblanks = false, bool throwOnError = false)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user