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).
§Format Layout
+------------------------------+ 0x0000
| Header (160 bytes) |
+------------------------------+ localized_strings_offset
| Localized string block |
| (variable size) |
+------------------------------+ keys_offset
| Key table |
| 24 bytes * entry_count |
+------------------------------+ resources_offset
| Resource table |
| 8 bytes * entry_count |
+------------------------------+ data offsets from resource table
| Resource payload blob |
| (concatenated file data) |
+------------------------------+MOD archives may include an optional legacy blank block between key and resource tables. This implementation supports both tight and blank-block variants for compatibility.
§Header (160 bytes)
0x00..0x04 file_type (fourcc: "ERF ", "MOD ", "HAK ", "SAV ")
0x04..0x08 version (fourcc: "V1.0" or "V1.1")
0x08..0x0C localized_string_count (u32)
0x0C..0x10 localized_string_size (u32, total byte length of string block)
0x10..0x14 entry_count (u32)
0x14..0x18 localized_strings_offset (u32)
0x18..0x1C keys_offset (u32)
0x1C..0x20 resources_offset (u32)
0x20..0x24 build_year (u32, years since 1900)
0x24..0x28 build_day (u32, day of year)
0x28..0x2C description_strref (i32)
0x2C..0xA0 reserved (116 bytes, preserved verbatim)§Key Entry (24 bytes)
0x00..0x10 resref[16] (null padded)
0x10..0x14 resource_id (u32)
0x14..0x16 type_id (u16)
0x16..0x18 unused (u16)§Resource Entry (8 bytes)
0x00..0x04 data_offset (u32)
0x04..0x08 data_size (u32)Structs§
- Erf
- In-memory ERF-family container.
- ErfLocalized
String - One localized ERF description entry.
- ErfRead
Options - Reader options for ERF/MOD/HAK parsing.
- ErfResource
- One resource entry stored in an ERF-family archive.
- ErfWrite
Options - Writer options for ERF-family serialization.
Enums§
- ErfBinary
Error - Errors produced while parsing or serializing ERF binary data.
- ErfFile
Type - Supported ERF-family container signatures.
- ErfRead
Mode - Input-profile behavior for ERF-family readers.
- ErfWrite
Mode - 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.
- 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.