namespace SabreTools.Data.Models.XZ
{
///
/// Represents a single compressed block in the stream
///
public class Block
{
///
/// Size of the header
///
///
/// The real header size can be calculated by the following:
/// (HeaderSize + 1) * 4
///
public byte HeaderSize { get; set; }
///
/// The Block Flags field is a bit field
///
public BlockFlags Flags { get; set; }
///
/// Size of the compressed data
/// Present if is set.
///
/// Stored as a variable-length integer
public ulong CompressedSize { get; set; }
///
/// Size of the block after decompression
/// Present if is set.
///
/// Stored as a variable-length integer
public ulong UncompressedSize { get; set; }
///
/// List of filter flags
///
///
/// The number of filter flags is given by the first two
/// bits of
///
public FilterFlag[] FilterFlags { get; set; } = [];
///
/// This field contains as many null byte as it is needed to make
/// the Block Header have the size specified in Block Header Size.
///
public byte[] HeaderPadding { get; set; } = [];
///
/// The CRC32 is calculated over everything in the Block Header
/// field except the CRC32 field itself. It is stored as an
/// unsigned 32-bit little endian integer.
///
public uint Crc32 { get; set; }
///
/// The format of Compressed Data depends on Block Flags and List
/// of Filter Flags
///
public byte[] CompressedData { get; set; } = [];
///
/// Block Padding MUST contain 0-3 null bytes to make the size of
/// the Block a multiple of four bytes. This can be needed when
/// the size of Compressed Data is not a multiple of four.
///
public byte[] BlockPadding { get; set; } = [];
///
/// The type and size of the Check field depends on which bits
/// are set in the Stream Flags field.
///
/// The Check, when used, is calculated from the original
/// uncompressed data.
///
public byte[] Check { get; set; } = [];
}
}