using System.IO;
using SabreTools.IO.Extensions;
namespace SabreTools.FileTypes.Aaru
{
///
/// Checksum block, contains a checksum of all user data sectors
/// (except for optical discs that is 2352 bytes raw sector if available
///
///
public class ChecksumHeader
{
/// Identifier,
public AaruBlockType identifier;
/// Length in bytes of the block
public uint length;
/// How many checksums follow
public byte entries;
///
/// Read a stream as an ChecksumHeader
///
/// ChecksumHeader as a stream
/// Populated ChecksumHeader, null on failure
public static ChecksumHeader Deserialize(Stream stream)
{
var checksumHeader = new ChecksumHeader();
checksumHeader.identifier = (AaruBlockType)stream.ReadUInt32();
checksumHeader.length = stream.ReadUInt32();
checksumHeader.entries = stream.ReadByteValue();
return checksumHeader;
}
}
}