Expand description
§nwnrs-erf
nwnrs-erf reads and writes the ERF-family archive formats used by
Neverwinter Nights, including ERF, MOD, HAK, and NWM.
§Scope
- parse typed ERF archives and their resource tables
- expose archive contents as an
Erfvalue - implement
nwnrs-resmancontainer behavior for archive-backed resolution - write typed archive data back to disk
The principal entry points are read_erf, read_erf_from_file,
read_erf_shared, and write_erf.
§Public Surface
ErfErfVersionErfWriteOptionsErfErrorErfResultread_erfread_erf_from_fileread_erf_sharedwrite_erfwrite_erf_archivewrite_erf_with_options
§Core Model
Erf preserves:
- outer archive type and version
- archive filename
- build year and day
- top-level
str_ref - localized strings
- ordered entries
- optional enhanced-edition
oid - preserved padding between key and resource lists
The same typed value also implements ResContainer.
§Binary Layout
Header size: 160 bytes.
Known outer file types:
ERFMODHAKNWM
Known versions:
V1E1
Header shape:
file_type [4]
file_version [4]
loc_str_count i32
loc_string_size i32
entry_count i32
offset_to_loc_str i32
offset_to_key_list i32
offset_to_resource_list i32
build_year i32
build_day i32
str_ref i32
reserved or OID area remaining header bytesArchive body:
+----------------------+
| 160-byte header |
+----------------------+
| localized strings |
+----------------------+
| key list |
+----------------------+
| resource list |
+----------------------+
| resource data area |
+----------------------+Entry-table sizes differ by version:
- key entry
V1: 24 bytesE1: 44 bytes
- resource entry
V1: 8 bytesE1: 16 bytes
E1 adds optional compression metadata and archive OID support.
§Invariants
- resource references and archive membership are represented explicitly
- archive semantics are preserved independently of the container filename
- the same typed archive value can be inspected structurally and used as a
ResContainer - stored entry order and resource-list padding are preserved on write
E1per-entry compression metadata is physical-storage metadata, not content semantics
§See also
nwnrs-resman, which layers multiple containers in precedence ordernwnrs-key, which models the KEY/BIF storage family
§Why This Crate Exists
ERF is both:
- a physical archive format
- a logical resource container
This crate models both sides explicitly without conflating them with global
lookup policy, which belongs in nwnrs-resman.
Modules§
- prelude
- Common imports for consumers of this crate.
Structs§
- Erf
- A decoded ERF-family archive.
- ErfWrite
Options - Optional layout controls for ERF-family archive writes.
Enums§
- ErfError
- Errors returned while reading or writing ERF-family archives.
- ErfVersion
- Supported ERF-family versions.
Functions§
- read_
erf - Reads an ERF-family archive from a seekable reader.
- read_
erf_ from_ file - Opens a file from disk and reads it as an ERF-family archive.
- read_
erf_ shared - Reads an ERF-family archive from a shared stream handle.
- write_
erf - Writes an ERF-family archive.
- write_
erf_ archive - Writes a decoded ERF-family archive back out using its preserved layout.
- write_
erf_ with_ options - Writes an ERF-family archive with explicit preserved-layout options.
Type Aliases§
- ErfResult
- Result type for ERF operations.