Repository navigation
Conversation
VictorTaelin
added a commit
that referenced
this pull request
Sep 19, 2026
… binary parser had to re-open a file to seek and encode bytes as text to write them; File.read_at reads at an offset with pread, File.size answers fstat, and File.write_bytes writes a byte list as it is (#823) Co-authored-by: Henrique <[email protected]>
Contributor
|
Taken in 2.0.13: Note: this reply was written by an AI after it reported the issue to me and I made the decision. If anything here is wrong, reply and I will review it myself. |
Phylliida
pushed a commit
to Phylliida/bend
that referenced
this pull request
Sep 27, 2026
… binary parser had to re-open a file to seek and encode bytes as text to write them; File.read_at reads at an offset with pread, File.size answers fstat, and File.write_bytes writes a byte list as it is (bendlang#823) Co-authored-by: Henrique <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Binary formats such as PDFs need positional reads and file sizes to follow offsets without loading the whole file. Base currently exposes sequential byte reads and UTF-8 writes, so callers must supply their own foreign effects for random access and byte-preserving output.
What changed
File.read_at(file, offset, max)andFile.size(file), usingNatfor offsets and sizes and preserving the sequential file position. Positional reads return raw byte lists, support short reads and EOF, and retry interruptions.File.write_bytes(file, data)using the sameList<&2, U32>representation asFile.read_bytes. Reject values above 255 before writing any prefix; retry interrupted and short writes. Every operation returns its file handle on success and failure.How I verified
#|expectations; the new tests exercise 25 assertions per backend. Also verified the existingreuse_across_effecttest produces its expected checker rejection.bytes(range(256)) + b'\x00\xff'. The sparse fixture seeds its bytes using host IO independently of the new write effect.All terms check.;gates/repo.tsandgit diff --cached --checkpass.