_printable decides "text" from the first 512 bytes of a stream (more
than 90% printable). A carved file is classified from its whole data,
but scan_rpf passed only a 256-byte head for streams it does not keep
whole, so one stream could get two signatures: a stream whose first
306 bytes are printable read as "text" from the archive and as
"raw:..." from its carved file. af55ea1b4 removed the same split for
PSIN streams.
Keep a 512-byte head in the archive scan, the sample _printable takes.
The other head checks read at most 16 bytes, so nothing else changes.
Tested: new test_text_is_judged_on_the_same_512_bytes_as_a_carved_file
(fails before: 'text' from the archive, 'raw:6e616d65' from the data).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Guard the remaining unguarded os.link() calls in test_awc_names.py, test_gamedata_graph.py, test_navmesh_decode.py, test_restofworld_index.py, test_rtti_scan.py, test_save_keys.py, test_swizzle_search.py, and test_tex_headers_report_paths.py with try/except (OSError, NotImplementedError) so only the hard-link subtest/check is skipped when hard links are unavailable and the rest of each test still runs.
The independent rest-of-world scanner dropped textures below four pixels and misclassified dictionaries when their declared count included those descriptors.
scan_dir passed each carved file's inflated length as its stored size, so in folder mode
compressed_bytes equalled inflated_bytes and readable_fraction was always 1.0, while the same numbers
in archive mode are the compressed sizes and stored / span. With rpf9_carve.py's index.json in the
folder, each file's stored size and the carve's span, zero padding and unread bytes now come from it;
without one, the length on disk is still used.
Real data (counts only), script.rpf: archive mode and its carve folder now give the same summary,
1,057 files, compressed 2,581,192, inflated 6,180,256, zero padding 1,335,290, unread 441,870,
readable 0.59224; main's folder mode gave compressed 6,180,256 and readable 1.0.
Tests: FolderModeStoredBytesTest (main: the index case reports 1,000 stored bytes instead of 300).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
scan_rpf passed classify only the first 256 inflated bytes, so a PSIN whose
section chain runs past them lost its tags and complete flag, while scan_dir
read the same resource whole. The PSIN stream is kept (already capped by
max_inflate) and classified like a carved file.
Follow-up to #498 and #530 (claimed in #374):
- Reject --start and --limit when source is a directory (exit code 2 via ap.error).
- Pass --max-inflate to scan_dir() and skip .bin files larger than max_inflate, incrementing skipped_candidates.
- Wrap mmap.mmap() in scan_rpf() with a context manager so out-of-range start errors always close the mapping.
- Add unit tests covering all three fixes.
Same two problems as rbf0_index.py: a missing source ended in a traceback from
os.path.getsize, and an unwritable --out was found only after the full scan.
The source error is now "<source>: No such file or directory" (exit 1) and the
output path is checked first (exit 2).
Co-Authored-By: Claude Sonnet 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).
Add the full core_restofworld scan (1.21 GiB, 96% Bink 2 plus model/page data), re-measure story000_restofworld and story000_script, and cover the three small archives. Cross-check PSIN against script.rpf/story000 and core pages/models against packs.rpf/levels.rpf. Add a stdlib-only stream index tool and synthetic-header tests. No game data.