file_pread
host callCapy
function file_pread(handle : u64, offset : u64, length : u64) string
Description
file_pread reads at an absolute byte offset. It clamps the requested length to 16 MiB. It does not change the handle position.
An offset beyond the file end returns an empty string. An offset outside the system's signed file-offset range also returns an empty string, without narrowing or wrapping.
Parameters
handle : readable handle returned by file_open
offset : absolute byte offset
length : maximum number of bytes to read
Return Values
A string with up to length bytes.
Example
Capy
var writer := file_open("/tmp/doc-pread.txt", "w")
file_write(writer, "hello world")
file_close(writer)
var reader := file_open("/tmp/doc-pread.txt", "r")
print(file_pread(reader, 6, 5), "\n")
file_close(reader)
Output
world