mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Goodbye .NET Framework 4.8 and RIPEMD160
This commit is contained in:
@@ -156,124 +156,6 @@ namespace SabreTools.DatItems
|
||||
/// <returns>DatItem of the specific internal type that corresponds to the inputs</returns>
|
||||
public static DatItem Create(ItemType? itemType)
|
||||
{
|
||||
#if NET_FRAMEWORK
|
||||
switch (itemType)
|
||||
{
|
||||
case ItemType.Adjuster:
|
||||
return new Adjuster();
|
||||
|
||||
case ItemType.Analog:
|
||||
return new Analog();
|
||||
|
||||
case ItemType.Archive:
|
||||
return new Archive();
|
||||
|
||||
case ItemType.BiosSet:
|
||||
return new BiosSet();
|
||||
|
||||
case ItemType.Blank:
|
||||
return new Blank();
|
||||
|
||||
case ItemType.Chip:
|
||||
return new Chip();
|
||||
|
||||
case ItemType.Condition:
|
||||
return new Condition();
|
||||
|
||||
case ItemType.Configuration:
|
||||
return new Configuration();
|
||||
|
||||
case ItemType.Control:
|
||||
return new Control();
|
||||
|
||||
case ItemType.DataArea:
|
||||
return new DataArea();
|
||||
|
||||
case ItemType.Device:
|
||||
return new Device();
|
||||
|
||||
case ItemType.DeviceReference:
|
||||
return new DeviceReference();
|
||||
|
||||
case ItemType.DipSwitch:
|
||||
return new DipSwitch();
|
||||
|
||||
case ItemType.Disk:
|
||||
return new Disk();
|
||||
|
||||
case ItemType.DiskArea:
|
||||
return new DiskArea();
|
||||
|
||||
case ItemType.Display:
|
||||
return new Display();
|
||||
|
||||
case ItemType.Driver:
|
||||
return new Driver();
|
||||
|
||||
case ItemType.Extension:
|
||||
return new Extension();
|
||||
|
||||
case ItemType.Feature:
|
||||
return new Feature();
|
||||
|
||||
case ItemType.Info:
|
||||
return new Info();
|
||||
|
||||
case ItemType.Input:
|
||||
return new Input();
|
||||
|
||||
case ItemType.Instance:
|
||||
return new Instance();
|
||||
|
||||
case ItemType.Location:
|
||||
return new Location();
|
||||
|
||||
case ItemType.Media:
|
||||
return new Media();
|
||||
|
||||
case ItemType.Part:
|
||||
return new Part();
|
||||
|
||||
case ItemType.PartFeature:
|
||||
return new PartFeature();
|
||||
|
||||
case ItemType.Port:
|
||||
return new Port();
|
||||
|
||||
case ItemType.RamOption:
|
||||
return new RamOption();
|
||||
|
||||
case ItemType.Release:
|
||||
return new Release();
|
||||
|
||||
case ItemType.Rom:
|
||||
return new Rom();
|
||||
|
||||
case ItemType.Sample:
|
||||
return new Sample();
|
||||
|
||||
case ItemType.Setting:
|
||||
return new Setting();
|
||||
|
||||
case ItemType.SharedFeature:
|
||||
return new SharedFeature();
|
||||
|
||||
case ItemType.Slot:
|
||||
return new Slot();
|
||||
|
||||
case ItemType.SlotOption:
|
||||
return new SlotOption();
|
||||
|
||||
case ItemType.SoftwareList:
|
||||
return new SoftwareList();
|
||||
|
||||
case ItemType.Sound:
|
||||
return new Sound();
|
||||
|
||||
default:
|
||||
return new Rom();
|
||||
}
|
||||
#else
|
||||
return itemType switch
|
||||
{
|
||||
ItemType.Adjuster => new Adjuster(),
|
||||
@@ -309,7 +191,6 @@ namespace SabreTools.DatItems
|
||||
ItemType.Sound => new Sound(),
|
||||
_ => new Rom(),
|
||||
};
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -458,18 +339,6 @@ namespace SabreTools.DatItems
|
||||
return CleanHashData(hash, Constants.MD5Length);
|
||||
}
|
||||
|
||||
#if NET_FRAMEWORK
|
||||
/// <summary>
|
||||
/// Clean a RIPEMD160 string and pad to the correct size
|
||||
/// </summary>
|
||||
/// <param name="hash">Hash string to sanitize</param>
|
||||
/// <returns>Cleaned string</returns>
|
||||
protected string CleanRIPEMD160(string hash)
|
||||
{
|
||||
return CleanHashData(hash, Constants.RIPEMD160Length);
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Clean a SHA1 string and pad to the correct size
|
||||
/// </summary>
|
||||
@@ -596,12 +465,6 @@ namespace SabreTools.DatItems
|
||||
key = Constants.MD5Zero;
|
||||
break;
|
||||
|
||||
#if NET_FRAMEWORK
|
||||
case Field.DatItem_RIPEMD160:
|
||||
key = Constants.RIPEMD160Zero;
|
||||
break;
|
||||
#endif
|
||||
|
||||
case Field.DatItem_SHA1:
|
||||
key = Constants.SHA1Zero;
|
||||
break;
|
||||
@@ -819,11 +682,7 @@ namespace SabreTools.DatItems
|
||||
if (datItem.ItemType == ItemType.Disk || datItem.ItemType == ItemType.Media || datItem.ItemType == ItemType.Rom)
|
||||
{
|
||||
datItemName += GetDuplicateSuffix(datItem);
|
||||
#if NET_FRAMEWORK
|
||||
lastrenamed = lastrenamed ?? datItemName;
|
||||
#else
|
||||
lastrenamed ??= datItemName;
|
||||
#endif
|
||||
}
|
||||
|
||||
// If we have a conflict with the last renamed item, do the right thing
|
||||
|
||||
@@ -708,11 +708,6 @@ namespace SabreTools.DatItems
|
||||
if (datItemFields.Contains(DatItemField.MD5))
|
||||
rom.MD5 = null;
|
||||
|
||||
#if NET_FRAMEWORK
|
||||
if (datItemFields.Contains(DatItemField.RIPEMD160))
|
||||
rom.RIPEMD160 = null;
|
||||
#endif
|
||||
|
||||
if (datItemFields.Contains(DatItemField.SHA1))
|
||||
rom.SHA1 = null;
|
||||
|
||||
@@ -1755,14 +1750,6 @@ namespace SabreTools.DatItems
|
||||
rom.MD5 = newItem.MD5;
|
||||
}
|
||||
|
||||
#if NET_FRAMEWORK
|
||||
if (datItemFields.Contains(DatItemField.RIPEMD160))
|
||||
{
|
||||
if (string.IsNullOrEmpty(rom.RIPEMD160) && !string.IsNullOrEmpty(newItem.RIPEMD160))
|
||||
rom.RIPEMD160 = newItem.RIPEMD160;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (datItemFields.Contains(DatItemField.SHA1))
|
||||
{
|
||||
if (string.IsNullOrEmpty(rom.SHA1) && !string.IsNullOrEmpty(newItem.SHA1))
|
||||
@@ -2829,11 +2816,6 @@ namespace SabreTools.DatItems
|
||||
if (datItemMappings.Keys.Contains(DatItemField.MD5))
|
||||
rom.MD5 = datItemMappings[DatItemField.MD5];
|
||||
|
||||
#if NET_FRAMEWORK
|
||||
if (datItemMappings.Keys.Contains(DatItemField.RIPEMD160))
|
||||
rom.RIPEMD160 = datItemMappings[DatItemField.RIPEMD160];
|
||||
#endif
|
||||
|
||||
if (datItemMappings.Keys.Contains(DatItemField.SHA1))
|
||||
rom.SHA1 = datItemMappings[DatItemField.SHA1];
|
||||
|
||||
|
||||
@@ -21,9 +21,6 @@ namespace SabreTools.DatItems
|
||||
|
||||
private byte[] _crc; // 8 bytes
|
||||
private byte[] _md5; // 16 bytes
|
||||
#if NET_FRAMEWORK
|
||||
private byte[] _ripemd160; // 20 bytes
|
||||
#endif
|
||||
private byte[] _sha1; // 20 bytes
|
||||
private byte[] _sha256; // 32 bytes
|
||||
private byte[] _sha384; // 48 bytes
|
||||
@@ -82,19 +79,6 @@ namespace SabreTools.DatItems
|
||||
set { _md5 = Utilities.StringToByteArray(CleanMD5(value)); }
|
||||
}
|
||||
|
||||
#if NET_FRAMEWORK
|
||||
/// <summary>
|
||||
/// File RIPEMD160 hash
|
||||
/// </summary>
|
||||
[JsonProperty("ripemd160", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
[XmlElement("ripemd160")]
|
||||
public string RIPEMD160
|
||||
{
|
||||
get { return _ripemd160.IsNullOrEmpty() ? null : Utilities.ByteArrayToString(_ripemd160); }
|
||||
set { _ripemd160 = Utilities.StringToByteArray(CleanRIPEMD160(value)); }
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// File SHA-1 hash
|
||||
/// </summary>
|
||||
@@ -391,9 +375,6 @@ namespace SabreTools.DatItems
|
||||
Size = baseFile.Size;
|
||||
_crc = baseFile.CRC;
|
||||
_md5 = baseFile.MD5;
|
||||
#if NET_FRAMEWORK
|
||||
_ripemd160 = baseFile.RIPEMD160;
|
||||
#endif
|
||||
_sha1 = baseFile.SHA1;
|
||||
_sha256 = baseFile.SHA256;
|
||||
_sha384 = baseFile.SHA384;
|
||||
@@ -426,9 +407,6 @@ namespace SabreTools.DatItems
|
||||
Size = this.Size,
|
||||
_crc = this._crc,
|
||||
_md5 = this._md5,
|
||||
#if NET_FRAMEWORK
|
||||
_ripemd160 = this._ripemd160,
|
||||
#endif
|
||||
_sha1 = this._sha1,
|
||||
_sha256 = this._sha256,
|
||||
_sha384 = this._sha384,
|
||||
@@ -471,9 +449,6 @@ namespace SabreTools.DatItems
|
||||
Size = this.Size,
|
||||
CRC = this._crc,
|
||||
MD5 = this._md5,
|
||||
#if NET_FRAMEWORK
|
||||
RIPEMD160 = this._ripemd160,
|
||||
#endif
|
||||
SHA1 = this._sha1,
|
||||
SHA256 = this._sha256,
|
||||
SHA384 = this._sha384,
|
||||
@@ -535,11 +510,6 @@ namespace SabreTools.DatItems
|
||||
if (_md5.IsNullOrEmpty() && !other._md5.IsNullOrEmpty())
|
||||
_md5 = other._md5;
|
||||
|
||||
#if NET_FRAMEWORK
|
||||
if (_ripemd160.IsNullOrEmpty() && !other._ripemd160.IsNullOrEmpty())
|
||||
_ripemd160 = other._ripemd160;
|
||||
#endif
|
||||
|
||||
if (_sha1.IsNullOrEmpty() && !other._sha1.IsNullOrEmpty())
|
||||
_sha1 = other._sha1;
|
||||
|
||||
@@ -588,9 +558,6 @@ namespace SabreTools.DatItems
|
||||
{
|
||||
return !_crc.IsNullOrEmpty()
|
||||
|| !_md5.IsNullOrEmpty()
|
||||
#if NET_FRAMEWORK
|
||||
|| !_ripemd160.IsNullOrEmpty()
|
||||
#endif
|
||||
|| !_sha1.IsNullOrEmpty()
|
||||
|| !_sha256.IsNullOrEmpty()
|
||||
|| !_sha384.IsNullOrEmpty()
|
||||
@@ -606,9 +573,6 @@ namespace SabreTools.DatItems
|
||||
{
|
||||
return (_crc != null && _crc.SequenceEqual(Constants.CRCZeroBytes))
|
||||
|| (_md5 != null && _md5.SequenceEqual(Constants.MD5ZeroBytes))
|
||||
#if NET_FRAMEWORK
|
||||
|| (_ripemd160 != null && _ripemd160.SequenceEqual(Constants.RIPEMD160ZeroBytes))
|
||||
#endif
|
||||
|| (_sha1 != null && _sha1.SequenceEqual(Constants.SHA1ZeroBytes))
|
||||
|| (_sha256 != null && _sha256.SequenceEqual(Constants.SHA256ZeroBytes))
|
||||
|| (_sha384 != null && _sha384.SequenceEqual(Constants.SHA384ZeroBytes))
|
||||
@@ -625,9 +589,6 @@ namespace SabreTools.DatItems
|
||||
{
|
||||
return !(_crc.IsNullOrEmpty() ^ other._crc.IsNullOrEmpty())
|
||||
|| !(_md5.IsNullOrEmpty() ^ other._md5.IsNullOrEmpty())
|
||||
#if NET_FRAMEWORK
|
||||
|| !(_ripemd160.IsNullOrEmpty() || other._ripemd160.IsNullOrEmpty())
|
||||
#endif
|
||||
|| !(_sha1.IsNullOrEmpty() ^ other._sha1.IsNullOrEmpty())
|
||||
|| !(_sha256.IsNullOrEmpty() ^ other._sha256.IsNullOrEmpty())
|
||||
|| !(_sha384.IsNullOrEmpty() ^ other._sha384.IsNullOrEmpty())
|
||||
@@ -653,9 +614,6 @@ namespace SabreTools.DatItems
|
||||
// Return if all hashes match according to merge rules
|
||||
return ConditionalHashEquals(_crc, other._crc)
|
||||
&& ConditionalHashEquals(_md5, other._md5)
|
||||
#if NET_FRAMEWORK
|
||||
&& ConditionalHashEquals(_ripemd160, other._ripemd160)
|
||||
#endif
|
||||
&& ConditionalHashEquals(_sha1, other._sha1)
|
||||
&& ConditionalHashEquals(_sha256, other._sha256)
|
||||
&& ConditionalHashEquals(_sha384, other._sha384)
|
||||
@@ -690,12 +648,6 @@ namespace SabreTools.DatItems
|
||||
key = MD5;
|
||||
break;
|
||||
|
||||
#if NET_FRAMEWORK
|
||||
case Field.DatItem_RIPEMD160:
|
||||
key = RIPEMD160;
|
||||
break;
|
||||
#endif
|
||||
|
||||
case Field.DatItem_SHA1:
|
||||
key = SHA1;
|
||||
break;
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net48;netcoreapp3.1;net5.0</TargetFrameworks>
|
||||
<TargetFrameworks>netcoreapp3.1;net5.0</TargetFrameworks>
|
||||
<RuntimeIdentifiers>win10-x64;win7-x86</RuntimeIdentifiers>
|
||||
<Configurations>Debug;Release</Configurations>
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(TargetFramework)'=='net48'">
|
||||
<DefineConstants>NET_FRAMEWORK</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\SabreTools.Core\SabreTools.Core.csproj" />
|
||||
<ProjectReference Include="..\SabreTools.FileTypes\SabreTools.FileTypes.csproj" />
|
||||
|
||||
Reference in New Issue
Block a user