Capy-Bearer Documentation

file_read

host call

Capy

function file_read(handle : u64, count : u64) string

Description

file_read reads from the current handle position. It accepts a maximum count of 16 MiB. It advances the position by the bytes read. It can return fewer bytes at the end of a file.

Parameters

handle : readable handle returned by file_open

count : maximum number of bytes to read

Return Values

A string with up to count bytes from the current position.

Example

Capy

var writer := file_open("/tmp/doc-read.txt", "w")
file_write(writer, "hello world")
file_close(writer)
var reader := file_open("/tmp/doc-read.txt", "r")
print(file_read(reader, u64(5)), "\n")
file_close(reader)