Skip to main content

Module erf

Module erf 

Source
Expand description

ERF-family archive support. ERF/MOD/HAK binary reader and writer.

This module provides a strict, roundtrip-safe implementation of the KotOR ERF family container format. Compatibility mode can also parse legacy non-canonical variants (for example SAV headers).

§Shape of the container

A fixed 160-byte header, a localized string block, then two parallel tables – keys and resources, both sized by entry_count – and finally the payload. Key n says what resource n is; resource n says where its bytes live.

Every block after the header is found by an offset read out of the header rather than by following on from the block before it. That is why the blank block some .mod files carry between the two tables costs a reader nothing: trusting the offsets absorbs it, while assuming the tables are adjacent reads garbage.

Byte-level field maps for the header and both entry records live in docs/src/formats/archives/erf.md, with the engine’s own load sequence.

Structs§

Erf
In-memory ERF-family container.
ErfIndex
A lazily-read ERF-family archive.
ErfIndexEntry
One indexed resource: its identity and where its bytes live.
ErfLocalizedString
One localized ERF description entry.
ErfReadOptions
Reader options for ERF/MOD/HAK parsing.
ErfResource
One resource entry stored in an ERF-family archive.
ErfWriteOptions
Writer options for ERF-family serialization.

Enums§

ErfBinaryError
Errors produced while parsing or serializing ERF binary data.
ErfFileType
Supported ERF-family container signatures.
ErfReadMode
Input-profile behavior for ERF-family readers.
ErfRewriteError
Errors produced while rewriting an ERF-family archive.
ErfWriteMode
Output-profile behavior for ERF-family writers.
ModLayout
Layout mode for MOD key/resource table spacing during writes.

Functions§

read_erf
Reads an ERF/MOD/HAK archive from a reader.
read_erf_from_bytes
Reads an ERF/MOD/HAK archive from bytes.
read_erf_from_bytes_with_options
Reads an ERF-family archive from bytes with explicit read options.
read_erf_with_options
Reads an ERF-family archive from a reader with explicit read options.
read_save_archive
Reads a save archive from a reader.
read_save_archive_from_bytes
Reads a save archive directly from bytes.
rewrite_erf
Writes source to writer, replacing the named entries’ bytes.
rewrite_erf_to_vec
Serializes a rewritten archive to bytes.
write_erf
Writes an ERF/MOD/HAK archive to a writer.
write_erf_to_vec
Serializes an ERF/MOD/HAK archive to bytes.
write_erf_to_vec_with_options
Serializes an ERF/MOD/HAK archive to bytes with explicit layout options.
write_erf_with_options
Writes an ERF/MOD/HAK archive to a writer with explicit layout options.
write_save_archive
Writes a save archive to a writer.
write_save_archive_to_vec
Serializes a save archive to bytes.