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 [
Erf] value - 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 bytes
Archive 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.