main's 8599cfcc starts build_hw_oracle.cmd from the work folder; keep its paths and
this branch's UTF-8 reads of the script (its /Fo folder is under %TEMP%).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each tool refused a report at <source>/index.json only when a carve
manifest already existed there. A report written before the carve took
the name hashdict.py and the other tools read as the carve manifest.
Refuse that path whether or not the manifest exists yet, as #3156 does
for page_index and story_index. bvh_index is left to BUILD-454.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FXR27ZYP9qtZtN8SG7QPWW
hw_oracle's vcvars script is fixed on main by #2667 (UTF-8 + chcp 65001), so this
branch takes main's runner.py and drops its own 8.3-name version. Two of main's
new hw_oracle tests decoded that UTF-8 script as ASCII, which fails when %TEMP%
holds a non-ASCII user name; they now decode it as UTF-8.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A full run with the temp folder in a profile named in Cyrillic found:
- tools/hw_oracle/runner.py wrote build_hw_oracle.cmd with encoding
"ascii", so any non-ASCII path (the temp work folder, Visual Studio,
the source) raised UnicodeEncodeError before hw_oracle compiled
anything. Non-ASCII paths now go in as their 8.3 short names, the file
in the OEM code page cmd.exe reads it with (UTF-8 elsewhere). New check
in test_hw_oracle: a work folder named "Пользователь".
- test_spirv_metal_set0_extra: its subprocess stubs didn't take the
errors= argument this branch added to tools/spirv_metal_set0.py.
- test_user_sgpr_census, test_anim_index, test_awc_manifest,
test_gamedata_graph, test_manifest_verifier, test_world_build: they
decoded the Python child's output as UTF-8, but the tool writes in the
locale encoding (the ANSI code page on Windows), so a non-ASCII temp
path never matched; test_awc_manifest's reader thread died (no errors=).
AI-assisted (Claude Code).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The classifier gave any stream starting with a u32 of 2 or 3 and the bytes
01 01 00 00 the historical clip-stream signature, reported the count as a
clip version and called it a 24-byte header, even for truncated input.
Read the table as measured for ASSET-158 (#2406): u32 count (2 or 3), then
count {u32 tag, u32 payloadBytes} pairs with first tag 0x101, then the
payloads. The signature is assigned only when the directory and every
payload fit in the stream; trailing schema bytes are allowed. The record
now carries the entry count, tags and payload end instead of a version.
Pages that fail the check keep the generic raw/zero-prefix/text handling.
All callers pass whole inflated streams except the Bink head slice, which
cannot match. Synthetic tests cover exact fit, trailing data, overrun and
oversized payloads, a truncated directory, and wrong counts or first tags.
AI-assisted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
collect_rbf0_dir() and collect_skeletons_dir() missed f2a63040's .json/.csv skip in directory mode (and collect_rbf0_dir() iterated os.listdir unsorted before assigning fallback offsets). Skip .json and .csv files in both helpers, sort directory entries in collect_rbf0_dir(), and add a synthetic regression test.
anim_index.py accepted output paths that refer to the source .rpf archive, truncating the input file upon writing reports. When targeting a carved directory, output and --rigs paths could also silently overwrite index.json (the carve manifest) or carved .bin payload files. Furthermore, missing parent folders were checked only after completing the entire scan, and directory destinations or invalid extensions were not validated upfront.
Check destination paths before scanning:
- Refuse out or --rigs matching the source archive (same path, case, or hard link)
- Refuse out or --rigs overwriting the carve manifest or input files in directory mode
- Refuse directory destinations for out and --rigs
- Enforce valid report extensions (.json or .csv for out, .json for --rigs)
- Validate parent directories exist before the scan begins
- Add test coverage in tests/test_report_source_collision.py and tests/test_anim_index.py
collect_rbf0 and collect_rbf0_dir joined the next adjacent stream after the
RBF0 one unless it had a stop signature, an offset gap or was over 64 KiB, so
an unrelated raw stream right after a short (final) RBF0 stream was appended
to the rig table. A resource is split into 64 KiB streams, so only a full one
is followed by a continuation, the rule rbf0_index gets in #1148.
The RigArchiveTest fixture now pads the rig table to a full first stream:
the old one cut it at an arbitrary point, which real data never does.
main() passed a directory to scan_dir() and silently ignored --start and
--limit, so a windowed run over a carve folder indexed everything and looked
like the window had been applied. Both are now an error (exit 2) with a
directory, as bvh/page/story_index already do (#498).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
In directory mode the three tools read every regular file, so rpf9_carve.py's index.json (and any
.csv report next to the streams) was counted as a payload, with a made-up offset (its position in
the listing). On a 1.0.2.1 copy's script.rpf carve (1,057 streams) each reported 1,058 files, and
the inflated total was off by exactly the index's size; on the data.rpf carve rbf0_index reported
28,510 streams for 28,509.
page_index.py and navmesh_decode.py already skip .json and .csv; the three tools now do the same.
story_index keeps skipping its own report as well (#712).
Tests: each tool gets a carve folder with three streams plus an index.json and a report.csv, and
must list only the three streams. All three fail on the old code (offsets 3 and 4, or 4 streams
for 2).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 7372a903afdb4b6f1a9aa7df7e60283848965dc5)
main() caught only ValueError from the scan, so a missing source
(os.path.getsize), a folder that can't be listed or a stream that
can't be read ended in an OSError traceback, as did an output path in
a folder that doesn't exist. Both now exit through sys.exit() with one
line naming the path, like the ValueError case already does.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
--rigs opened its output for writing before parse_rbf0 ran, and the
ValueError parse_rbf0 raises for an RBF0 without anim/rigset/ keys was
not caught. The run ended in a traceback and left an existing rigs JSON
empty. Parse first, report the error and exit 2 without touching the file.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Adds the #283 argparse validators to anim_index, rbf0_index, restofworld_index and rpf9_carve: --start >= 0, --limit >= 1 (decimal or 0x hex), and --max-inflate >= 1 in restofworld_index. Bad ranges now exit 2 before any scan or output instead of silently scanning everything, less, or nothing. Synthetic CLI tests in all four test files; docs notes for each tool.
New item claimed in #156. AI-assisted (OpenCode).