Publish CSV and JSON indexes through a temp file + replace so a mid-write OSError leaves any prior complete report intact. Align the refused-file test substring with the (KB2) wording the tool already prints.
Co-authored-by: Cursor <cursoragent@cursor.com>
Squash-merged after diff review of PR #6917 - bink_index: a single named file that holds no stream is one error line, not a 0-stream scan (EGEN-BINK-INDEX-NAMED-TARGET, DeepSeek9)
Review nits on #4035: the '?FPR' check still gives the data start for any RPF header, but +12 is a
measured trailer size only on RPF9, where it is a multiple of 16 in all 22 archives.
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
In movies.rpf the 22,812 bytes after the last Bink stream are 3,884 zeros up to a 4 KiB boundary and then
exactly the header's u32 +12 (18,928) bytes to EOF. Over the package's 22 RPF9 archives the same holds in 14
(10 page-aligned after zero padding, 4 found by walking 16-byte-aligned zlib streams to the end); the other 8
end in a non-zlib file and can't be checked without the TOC. None contradicts it. bink_index.py counts the
trailer as rpf_trailer instead of unread.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A directory scan stored os.path.relpath() as each stream's source, so on Windows a nested file
came out as "movies\x.bk2" and on POSIX as "movies/x.bk2", and the files were sorted by their
native path, so "movies0.bk2" came before "movies\x.bk2" on Windows and after "movies/x.bk2"
elsewhere. bink_names sorts streams by source and keys --pins by it, so the same folder gave a
different report, alignment order and pin match per platform. The relative path is now taken
with "/" (the replace(os.sep, "/") the other tools use) and the files are sorted on it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With a carve directory as the target, --out (and bvh_index's --csv) could
replace <dir>/index.json (or a carved payload through a hard link) and
exit 0; #1264 only compared the report with the target path itself, which
covers an .rpf target but not a directory. bvh_index also lost the report
to a FileNotFoundError in a missing folder, and ended in a PermissionError
traceback when the report path was an existing directory.
Refuse report paths that resolve to the carve manifest or an input file,
create the report folder before writing, and reject a directory report
path; tests cover each shape on synthetic fixtures.
parse_header() checked each audio descriptor table against the end of the
whole buffer, not the stream's declared size, so the bytes after a stream
(the next stream, or archive data) could be read as its audio rates and
channel counts. The table must now fit inside the declared stream.
scan_file() returned zero span for any file shorter than a Bink header, so
a 20-byte file vanished from the byte accounting. Only an empty file is
skipped now; a short one is counted as unread bytes like any other gap.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The CSV written to stdout (the default output) used csv's "\r\n" on a text stream
that already turns "\n" into the platform line end, so every row ended "\r\r\n" on
Windows and a redirected index read as one blank row after each row. The stdout writer
now uses lineterminator="\n", as awc_manifest.py does; --out files were already right.
A target that does not exist ended in a FileNotFoundError traceback from
os.path.getsize; it now prints an error and exits 2, as awc_manifest.py does.
Tests: a stdout stream that writes "\r\n" like Windows' (so the check also runs on
Linux CI) and the missing-target exit code; both fail without the fix.