File module

file_read

procedure · 1 overloadSource

Reads up to bytes_to_read bytes from the current position into vdata, and returns (success, total_read).

file_read :: (
    f: File,
    vdata: *void,
    bytes_to_read: s64
) -> (success: bool, total_read: s64)

It keeps reading until the count is met or the end is reached, so a short count with true means the end of the file (or of a pipe whose writer closed), and 0 means it is at the end. A closed file, a null buffer or a count of 0 or less fails with 0 bytes. A read error gives false with the bytes that did arrive. The position moves by total_read.

Parameters

f: File
vdata: *void
bytes_to_read: s64

Returns

success: bool
total_read: s64

See also