Commit Graph

16 Commits

Author SHA1 Message Date
beb75ec566 rpf9_names: make the staging file deletable when a replace fails
The staged report carries the destination's bits, so on Windows a failed
os.replace over a read-only report leaves a read-only stage the
TemporaryDirectory cleanup refuses to delete, masking the real error with a
cleanup failure. The cleanup now makes the staged file writable before
deleting and lets one delete failure go, so the caller reports the replace;
a successful publish is unchanged and the prior report stays intact on
failure. Same shape as navmesh_index's, bvh_index's and story_index's
staging cleanup.

Regression test in the style of those failed-replace tests: it fails against
the old code on the made-deletable assertion. Synthetic archives only; no
game data.

Claimed in the coordination issue as RPF9-NAMES-STAGE-CLEANUP (issue #14).
AI-assisted.
2026-11-25 20:38:26 +01:00
e36d4c4561 rpf9_names: print the --out path without repr() in both error lines (EGEN-RPF9NAMES-PATHREPR) (#6737)
Squash-merged after diff review of PR #6737
2026-11-23 10:49:29 -06:00
73bd50e269 Merge pull request #2726 from Rafael 2026-11-22 15:11:30 -05:00
f206d479a6 tools: classify the gap between streams without copying it
Nine archive scanners sliced every gap out of the mmap to test whether it
was all zero (`gap = m[last:s]; gap.count(0) == len(gap)`). The slice is a
copy, so a gap of N bytes allocated N bytes at once; about half of
story000.rpf (~20 GB) is non-zlib, which ends in MemoryError on a 16 GB
machine.

tools/zero_span.py compares the gap with zeros 4 MiB at a time and stops at
the first non-zero window, with the same counts (all of a gap is padding
when every byte is zero, otherwise all of it is unread). rpf9_carve,
rpf9_names, bvh_index, navmesh_index, navmesh_decode, rbf0_index,
anim_index, restofworld_index and story_index use it.

tests/test_zero_span.py checks the counts against the old expression and
runs each scanner on a 48 MiB gap under tracemalloc: 50-51 MiB heap peak
on main, under 24 MiB with this change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 15:07:15 -03:00
85e368def5 Reduce short-stream read-ahead in the RPF9 name indexer 2026-11-22 23:35:48 +05:30
ec9b6cf22b tools: text reports are written with LF line ends on every platform (BUILD-468)
open(path, "w") without newline= turns each \n into \r\n on Windows, so the same JSON report, manifest or assembly
listing was CRLF there and LF elsewhere. 91 text-mode writes (open, os.fdopen, Path.write_text) under tools/, scripts/,
make_game.py and runtime/test/shaders/ now pass newline="\n". tests/test_text_write_line_endings.py reads the source
with ast and fails for a writer that forgets it; CONTRIBUTING.md names the convention.

AI-assisted (Claude), on behalf of dev-ewann.
2026-11-22 14:20:30 +00:00
eaa441d0ef Merge pull request #1586 from bbareth 2026-11-22 07:38:24 -05:00
23bc91f51c rpf9_names.py: bound transient output while inflating a stream 2026-11-22 13:26:46 +01:00
9c2717fe76 Merge pull request #1520 from bbareth 2026-11-22 07:08:01 -05:00
fc80bbf199 rpf9_names.py: protect the input and stage reports privately 2026-11-22 12:55:36 +01:00
f698bf2206 tools: a path outside the console's code page no longer crashes a tool's output
On Windows a redirected stdout uses the console's ANSI code page, and python -I ignores PYTHONUTF8 and
PYTHONIOENCODING, so a caller path with a character outside that code page ended a run with
UnicodeEncodeError as soon as a tool printed it. #1406 fixed make_game.py; every CLI tool in tools/ now starts
its __main__ block the same way (stdout errors="replace").

tests/test_tool_stdout_encoding.py checks every tool's __main__ block and reruns two measured crashes
(analyze_4240_full.py, meshlet_page.py) with a private-use-named input. Found by @abilliontokens.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 11:27:00 +00:00
95b94a215c Merge pull request #1049 from JavierBlanco23 2026-11-22 01:38:03 -05:00
f7ce2ff587 rpf9_names.py: bound --limit inflation to scan window and honour --quiet 2026-11-22 07:15:18 +01:00
09cfe2e854 rpf9_names: skip Bink 2 videos whole and keep inflation inside the --limit window
scan_archive() stepped three bytes past a KB2 signature and went on looking
for zlib headers inside the video body, so a stream embedded in a video was
reported with its names and the video's bytes were counted as zero padding or
unread. It now applies rpf9_carve.py's header test (length at +4, width and
height at +0x14) and skips a plausible video whole, counted in the new
bink2_files and bink2_bytes summary keys.

The inflate loop was bounded by the file size, not by the scan window, so a
stream crossing the end of a --limit window was still reported with a stored
size larger than the span. It is bounded by the window now, as in
rpf9_carve.py.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-22 13:04:28 +07:00
092b028bcd Tools: close archive mmaps on error and reject empty rpf9_names inputs 2026-11-21 22:12:32 -03:00
5b8dd6854b Tools: index named RPF9 resources without the TOC 2026-11-21 23:11:56 +00:00