Stdlib index
- Captured-borrow migration worklist (3.3.3)
- Owned-bind migration worklist (8.2.7)
- Return-side title audit — the ride-through enumeration
- stdlib ownership audit
- stdlib ownership dispositions (plan 1.3.1 / 4.3.1)
aot
codec
codec / csv
codec / json
collection
- ArrayList
- BPlusTree
- Cache
- Collectors
- HashMap
- HashSet
- Heap
- ImmutableList
- ImmutableMap
- ImmutableSet
- LinkedList
- RedBlackTree
- Sort
collection / ltm
concurrent
error
- Exception
- NoOptionalValueException
- NotProvidedException
- RecoverableException
- ScopedBuildFailedException
- ScopeNotActiveException
- Throwable
- UnrecoverableException
gfx
hash
ifx
io
io / file
io / net
io / net / dns
io / net / uri
lang
lang / stream
math
math / fft
math / linalg
math / npio
math / poly
math / random
math / stats
nucleo
- Columns — the Arrow-laid-out substrate
- Fused tensor expressions — Fuse
- Table — the lazy, typed dataframe
- Tape — define-by-run autograd
- Transform intrinsics — Grad, Vmap, Jit
process
reflect
search / distance
search / fuzzy
search / ngram
session
time
- Clock
- DateTimeFormatter
- Duration
- Instant
- LocalDate
- LocalDateTime
- LocalTime
- Period
- ZonedDateTime
- ZoneId
- ZoneOffset
wire
xpu
xpu / mesh
FileReader
cajeta.io.file.FileReader — streaming byte reader, returned by
File.openRead(path). The caller drives the byte loop: call
read(buf, max) repeatedly until it returns 0 (EOF). The native read drains
OS-level short reads, so a return shorter than max (including 0) means EOF
was reached on this call. There is no user-space buffer — bytes go straight
into the caller’s array via the syscall. Call close() when done; there is no
auto-close-on-drop destructor yet.
FileReader r #= File.openRead("/var/log/app.log");
int8[] buf = heap int8[4096];
int32 n = r.read(buf, 4096);
while (n != 0) {
// consume buf[0..n)
n = r.read(buf, 4096);
}
r.close();
Methods
| Signature | |
|---|---|
int32 read(int8[] buf, int32 max) ⚑ | Read up to max bytes into buf[0..max); returns the count filled, 0 at EOF |
int64 position() | Bytes consumed since open (streaming model only — no seek) |
#String readString(int32 maxBytes) ⚑ | Read up to maxBytes bytes and return them as a String (bytes taken as UTF-8, no transcoding) |
void close() | Close the underlying fd; idempotent |
⚑ = @EntryPoint
See also
- Tour: FileIoDemo
- Source:
runtime/src/cajeta/io/file/FileReader.cajeta - File — the factory (
openRead); FileWriter — the writing twin