Commit Graph

34 Commits

Author SHA1 Message Date
89e3293375 bink_index: ask report_paths for the report-path guard 2026-11-29 14:16:15 +01:00
ea90aabfc4 Merge pull request #1022 from klikso/carry/old-10040-bink-index-validate
OLD-10040: bink_index: validate frame offsets within each stored stream
2026-11-28 22:52:45 +01:00
ea49f91cdd Merge pull request #2252 from kirigayakazima/codex/bink-index-truncated-probe-copy
bink_index: refuse an incomplete embedded stream before probing
2026-11-28 20:32:36 +01:00
a58ea6b4f9 bink_index: refuse an incomplete embedded stream before probing 2026-11-26 18:18:42 +08:00
77df8717a7 bink_index: validate frame offsets within each stored stream
AI-assisted (Codex).
2026-11-24 17:41:54 +00:00
070df2d53a bink_index: close mkstemp fd on fdopen error, restore mode before unlink, and publish mode on Windows (BINK-INDEX-STAGE-CLEANUP) 2026-11-24 17:12:19 +03:00
25764af7a5 bink_index: stage --out so a write failure keeps the previous report
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>
2026-11-23 20:51:33 +01:00
e6190e7b5f 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) (#6917)
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)
2026-11-23 09:45:39 -06:00
023952cf38 bink_index: refuse a named file that is not a Bink 2 stream or RPF (#6925)
Squash-merged after diff review of PR #6925 - bink_index: a named file that is not a Bink 2 stream or RPF is an error, not an empty index
2026-11-23 09:44:38 -06:00
51931245d5 docs: point 15 more tools at their --help usage line (#5535)
Squash-merged after review of PR #5535 - docs: point 15 more tools at their --help usage line
2026-11-23 08:09:32 -06:00
a038637e82 Merge pull request #4151 from fromthemoonx
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:11:47 -05:00
73c7b8d15a Merge pull request #4035 from Alex Collini
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:10:38 -05:00
d4f59e6d4e Merge pull request #4015 from AAyberkU
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:10:25 -05:00
8851927aff bink_index: only an RPF9 header with a +12 that is a multiple of 16 declares a trailer
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>
2026-11-23 03:24:47 +01:00
3b68a58021 Reserve the carve manifest path in bink_index, meshlet_page and anim_index
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
2026-11-22 23:41:37 +00:00
93cb49a099 rpf: review nits; the ImHex pattern names +12 trailer_size
movies.md says the bink_index counts for movies.rpf are derived, not a rerun, and names the 8 undecided
archives; rpf.md's small-block entropy wording; bink_index drops a redundant max().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 00:02:12 +01:00
03a3558ef4 rpf: the last u32 +12 bytes of an RPF9 are a trailer; movies.rpf's 22,812 tail bytes are zeros plus it (ASSET-318)
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>
2026-11-22 23:57:08 +01:00
d8e669f448 bink_index: a directory scan writes "/" in source and sorts the same on every platform
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>
2026-11-23 01:54:45 +03:00
a72427bd18 Refuse partial Bink indexes when a directory cannot be listed 2026-11-22 23:44:59 +01:00
1383aaffda Report unreadable skin and Bink index inputs 2026-11-22 16:37:59 -03:00
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
c334c78477 tools: CSV reports end their lines with LF on Windows too
csv.writer and csv.DictWriter default to lineterminator="\r\n", and every
one of these tools opens its report with newline="", which turns that into
CRLF on Windows and LF elsewhere: the same archive gave different report
bytes depending on the machine that exported it. awc_manifest and awc_shorts
already pin "\n" and bink_index documents why its stdout writer needs it, so
this brings the remaining 16 writers onto the same convention. A structural
test keeps new writers on it, and three tools are run end to end to check the
bytes.

Generated with Codebuff 🤖
Co-Authored-By: Codebuff <noreply@codebuff.com>
2026-11-22 07:13:06 -06:00
76f62c9f82 bink_index.py: exclude the selected report from repeat directory scans 2026-11-22 13:04:45 +01:00
89cf18645e Merge pull request #1428 from Dominik 2026-11-22 06:38:01 -05: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
736f9d6ebd bink_index, bvh_index: report paths cannot replace carve inputs
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.
2026-11-22 19:12:17 +08:00
22e17b94d3 Index tools: refuse to overwrite the source file 2026-11-22 03:24:01 -06:00
4101819c00 bink_index: report output file write errors 2026-11-22 04:23:44 -03:00
9e5aa404aa bink_index.py: audio descriptors stay inside the stream, and short files are counted
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>
2026-11-22 06:22:15 +01:00
fa69829920 bink_index.py: handle failed ffprobe runs and malformed responses 2026-11-22 01:01:59 +01:00
3888bce693 Merge pull request #356 from nicolas 2026-11-21 18:38:00 -05:00
02c89a380b bink_index.py: one line end per CSV row on stdout; a missing target is an error, not a traceback
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.
2026-11-21 23:54:13 +01:00
4cf04e2a18 Index Bink streams with fractional NTSC frame rates 2026-11-21 14:14:14 -07:00
f980852e23 movies: index Bink 2 streams and document the container 2026-11-21 18:14:41 +00:00