UCE Docs / file_read

Signature

String file_read(u64 h, u64 len)

Parameters

h : handle from file_open() opened for reading
len : maximum number of bytes to read
return value : up to len bytes from the current offset (shorter at end of file)

Reads up to len bytes starting at the handle's current offset and advances the offset. Returns fewer bytes (or "") at end of file. Use file_seek() to move the offset, or file_pread() to read at an absolute offset without moving it.

Example

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