2023-07-28 21:34:34 -04:00
|
|
|
|
using SabreTools.Core;
|
2017-10-09 18:04:49 -07:00
|
|
|
|
|
2020-12-09 22:11:35 -08:00
|
|
|
|
namespace SabreTools.DatFiles.Formats
|
2017-10-09 18:04:49 -07:00
|
|
|
|
{
|
2019-01-11 13:43:15 -08:00
|
|
|
|
/// <summary>
|
2023-07-28 21:34:34 -04:00
|
|
|
|
/// Represents a hashfile such as an SFV, MD5, or SHA-1 file
|
2019-01-11 13:43:15 -08:00
|
|
|
|
/// </summary>
|
2023-07-28 21:34:34 -04:00
|
|
|
|
internal partial class Hashfile : DatFile
|
2019-01-11 13:43:15 -08:00
|
|
|
|
{
|
|
|
|
|
|
// Private instance variables specific to Hashfile DATs
|
2023-09-11 10:27:17 -04:00
|
|
|
|
private readonly Serialization.Hash _hash;
|
2019-01-11 13:43:15 -08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Constructor designed for casting a base DatFile
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="datFile">Parent DatFile to copy from</param>
|
|
|
|
|
|
/// <param name="hash">Type of hash that is associated with this DAT</param>
|
2023-08-10 23:22:14 -04:00
|
|
|
|
public Hashfile(DatFile? datFile, Hash hash)
|
2020-07-15 09:41:59 -07:00
|
|
|
|
: base(datFile)
|
2019-01-11 13:43:15 -08:00
|
|
|
|
{
|
2023-09-11 10:27:17 -04:00
|
|
|
|
_hash = ConvertHash(hash);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Convert hash types between internal and Serialization
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private Serialization.Hash ConvertHash(Hash hash)
|
|
|
|
|
|
{
|
|
|
|
|
|
return hash switch
|
|
|
|
|
|
{
|
|
|
|
|
|
Hash.CRC => Serialization.Hash.CRC,
|
|
|
|
|
|
Hash.MD5 => Serialization.Hash.MD5,
|
|
|
|
|
|
Hash.SHA1 => Serialization.Hash.SHA1,
|
|
|
|
|
|
Hash.SHA256 => Serialization.Hash.SHA256,
|
|
|
|
|
|
Hash.SHA384 => Serialization.Hash.SHA384,
|
|
|
|
|
|
Hash.SHA512 => Serialization.Hash.SHA512,
|
|
|
|
|
|
Hash.SpamSum => Serialization.Hash.SpamSum,
|
|
|
|
|
|
_ => throw new System.ArgumentOutOfRangeException(),
|
|
|
|
|
|
};
|
2019-01-11 13:43:15 -08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-10-09 18:04:49 -07:00
|
|
|
|
}
|