View on GitHub

IFTools

A collection of tools for Interactive Fiction

Chunk

Namespace: Casasoft.IF.GBlorbLib

Represents a chunk of data with a name, length, and address.

public class Chunk : IChunk

Inheritance ObjectChunk
Implements IChunk
Attributes NullableContextAttribute, NullableAttribute

Properties

Name

Gets or sets the name of the chunk.

public string Name { get; set; }

Property Value

String

Length

Gets or sets the length of the chunk.

public int Length { get; set; }

Property Value

Int32

Address

Gets or sets the address of the chunk.

public int Address { get; set; }

Property Value

Int32

ResourceID

Gets or sets the resource ID of the chunk.

public int ResourceID { get; set; }

Property Value

Int32

Constructors

Chunk()

Initializes a new instance of the Chunk class with a default name.

public Chunk()

Chunk(String)

Initializes a new instance of the Chunk class with the specified name.

public Chunk(string name)

Parameters

name String
The name of the chunk.

Chunk(Byte[], Int32)

Initializes a new instance of the Chunk class with the specified data and offset.

public Chunk(Byte[] data, int offset)

Parameters

data Byte[]
The byte array containing the chunk data.

offset Int32
The offset within the byte array where the chunk starts.

Methods

ToString()

Returns a string that represents the current chunk.

public string ToString()

Returns

String
A string that represents the current chunk.

Write(Byte[], Int32)

Writes the chunk data to the specified byte array at the given offset.

public void Write(Byte[] data, int offset)

Parameters

data Byte[]
The byte array to write the chunk data to.

offset Int32
The offset within the byte array where the chunk data should be written.

FillZero(Byte[], Int32)

Fills the specified byte array with zero at the given offset if the chunk length is odd.

public void FillZero(Byte[] data, int offset)

Parameters

data Byte[]
The byte array to fill with zero.

offset Int32
The offset within the byte array where the zero should be written.

Export(String)

Exports the chunk data to the specified file.

public void Export(string filename)

Parameters

filename String
The name of the file to export the chunk data to.

IsResource()

Determines whether the chunk is a resource.

public bool IsResource()

Returns

Boolean
true if the chunk is a resource; otherwise, false.

ResourceType()

Gets the resource type of the chunk.

public string ResourceType()

Returns

String
The resource type as a string, or an empty string if the chunk is not a resource.

FileExtension()

Gets the file extension associated with the chunk.

public string FileExtension()

Returns

String
The file extension as a string.

SkipZeroBytes(Byte[], Int32)

Skips zero bytes in the specified byte array starting from the given offset.

protected void SkipZeroBytes(Byte[] data, int offset)

Parameters

data Byte[]
The byte array to skip zero bytes in.

offset Int32
The offset within the byte array to start skipping zero bytes from.