mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
This effectively doesn't do much for the time being since there's only one "Dat type" that's being used. Realistically, this is probably the best bet since a given DAT should not be restricted to an output type as much as an ItemType is bound to its data. This also removes the experimental classes that won't be in use for forever. More work still might need to be done but it is unknown at this point.
88 lines
2.1 KiB
C#
88 lines
2.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace SabreTools.Helper
|
|
{
|
|
#region Dat-to-Hash structs
|
|
|
|
/// <summary>
|
|
/// Intermediate struct for holding and processing hash data
|
|
/// </summary>
|
|
public struct Hash : IEquatable<Hash>
|
|
{
|
|
public long Size;
|
|
public string CRC;
|
|
public string MD5;
|
|
public string SHA1;
|
|
|
|
public bool Equals(Hash other)
|
|
{
|
|
return this.Equals(other, false);
|
|
}
|
|
|
|
public bool Equals(Hash other, bool IsDisk)
|
|
{
|
|
bool equals = false;
|
|
|
|
if (IsDisk &&
|
|
((String.IsNullOrEmpty(this.MD5) || String.IsNullOrEmpty(other.MD5)) || this.MD5 == other.MD5) &&
|
|
((String.IsNullOrEmpty(this.SHA1) || String.IsNullOrEmpty(other.SHA1)) || this.SHA1 == other.SHA1))
|
|
{
|
|
equals = true;
|
|
}
|
|
else if (!IsDisk &&
|
|
(this.Size == other.Size) &&
|
|
((String.IsNullOrEmpty(this.CRC) || String.IsNullOrEmpty(other.CRC)) || this.CRC == other.CRC) &&
|
|
((String.IsNullOrEmpty(this.MD5) || String.IsNullOrEmpty(other.MD5)) || this.MD5 == other.MD5) &&
|
|
((String.IsNullOrEmpty(this.SHA1) || String.IsNullOrEmpty(other.SHA1)) || this.SHA1 == other.SHA1))
|
|
{
|
|
equals = true;
|
|
}
|
|
|
|
return equals;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Skipper structs
|
|
|
|
/// <summary>
|
|
/// Intermediate struct for holding header skipper information
|
|
/// </summary>
|
|
public struct Skipper
|
|
{
|
|
public string Name;
|
|
public string Author;
|
|
public string Version;
|
|
public List<SkipperRule> Rules;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Intermediate struct for holding header skipper rule information
|
|
/// </summary>
|
|
public struct SkipperRule
|
|
{
|
|
public long? StartOffset; // null is EOF
|
|
public long? EndOffset; // null if EOF
|
|
public HeaderSkipOperation Operation;
|
|
public List<SkipperTest> Tests;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Intermediate struct for holding header test information
|
|
/// </summary>
|
|
public struct SkipperTest
|
|
{
|
|
public HeaderSkipTest Type;
|
|
public long? Offset; // null is EOF
|
|
public byte[] Value;
|
|
public bool Result;
|
|
public byte[] Mask;
|
|
public long? Size; // null is PO2, "power of 2" filesize
|
|
public HeaderSkipTestFileOperator Operator;
|
|
}
|
|
|
|
#endregion
|
|
}
|