Class ChdHeaderV5

Namespace
CHDSharp.Encoder.Models
Assembly
CHDSharpLib.dll

Represents the header structure for CHD version 5 files.

public class ChdHeaderV5
Inheritance
ChdHeaderV5
Inherited Members

Fields

Length

The serialized header length in bytes.

public const uint Length = 124

Field Value

uint

Tag

The CHD header tag as a byte array.

public static readonly byte[] Tag

Field Value

byte[]

TagString

The CHD header tag as a string.

public const string TagString = "MComprHD"

Field Value

string

Version

The CHD format version (5).

public const uint Version = 5

Field Value

uint

Properties

Compressors

Gets or sets the four compressor codec tags.

public uint[] Compressors { get; set; }

Property Value

uint[]

HunkBytes

Gets or sets the size of each hunk in bytes.

public uint HunkBytes { get; set; }

Property Value

uint

IsCompressed

Gets a value indicating whether the image uses compression.

public bool IsCompressed { get; }

Property Value

bool

LogicalBytes

Gets or sets the total logical (uncompressed) size in bytes.

public ulong LogicalBytes { get; set; }

Property Value

ulong

MapOffset

Gets or sets the byte offset of the hunk map within the file.

public ulong MapOffset { get; set; }

Property Value

ulong

MetaOffset

Gets or sets the byte offset of metadata within the file.

public ulong MetaOffset { get; set; }

Property Value

ulong

ParentSha1

Gets or sets the SHA-1 hash of the parent CHD, if applicable.

public byte[] ParentSha1 { get; set; }

Property Value

byte[]

RawSha1

Gets or sets the SHA-1 hash of the raw (uncompressed) data.

public byte[] RawSha1 { get; set; }

Property Value

byte[]

Sha1

Gets or sets the SHA-1 hash of the final CHD data.

public byte[] Sha1 { get; set; }

Property Value

byte[]

UnitBytes

Gets or sets the unit size in bytes.

public uint UnitBytes { get; set; }

Property Value

uint

Methods

CreateRaw(uint, ulong, uint, uint)

Creates a header for a raw (uncompressed) CHD image.

public static ChdHeaderV5 CreateRaw(uint compressors0, ulong logicalBytes, uint hunkBytes, uint unitBytes)

Parameters

compressors0 uint

The primary compressor codec tag.

logicalBytes ulong

The total logical size in bytes.

hunkBytes uint

The hunk size in bytes.

unitBytes uint

The unit size in bytes.

Returns

ChdHeaderV5

A new ChdHeaderV5 configured for a raw image.

CreateRaw(uint[], ulong, uint, uint)

Creates a header for a compressed CHD image with up to 4 codecs.

public static ChdHeaderV5 CreateRaw(uint[] compressors, ulong logicalBytes, uint hunkBytes, uint unitBytes)

Parameters

compressors uint[]

The compressor codec tags (up to 4; empty slots use None).

logicalBytes ulong

The total logical size in bytes.

hunkBytes uint

The hunk size in bytes.

unitBytes uint

The unit size in bytes.

Returns

ChdHeaderV5

A new ChdHeaderV5 configured for the image.

Deserialize(byte[])

Deserializes a CHD v5 header from a byte array.

public static ChdHeaderV5 Deserialize(byte[] data)

Parameters

data byte[]

The raw header bytes (at least 124 bytes).

Returns

ChdHeaderV5

A ChdHeaderV5 populated from the data.

Serialize()

Serializes the header into a 124-byte array in big-endian format.

public byte[] Serialize()

Returns

byte[]

A byte array containing the serialized header.

WriteToStream(Stream)

Writes the serialized header to a stream.

public void WriteToStream(Stream stream)

Parameters

stream Stream

The output stream to write to.