Capy-Bearer Documentation

file_seek

host call

Capy

function file_seek(handle : u64, offset : s64, whence : s64) s64

Description

file_seek sets the position for file reads and writes.

Parameters

handle : handle from file_open

offset : byte offset

whence : 0 for the start, 1 for the current position, or 2 for the end

Return Values

The new byte offset. Returns -1 on error.

Example

Capy

var handle := file_open("/tmp/doc-seek.txt", "w")
file_write(handle, "hello world")
file_close(handle)
handle = file_open("/tmp/doc-seek.txt", "r")
file_seek(handle, s64(6), s64(0))
print(file_read(handle, u64(5)), "\n")
file_close(handle)