io/fs
lib/io/fs.vklib/io/fs.vk
Pure-Veko connected filesystem io/Stream adapters and positioned handle helpers over os/{open,pread,pwrite,fsync,truncate,close}.
Requires .fs capability.
FileStreamState = struct { fd i64, path str, pos i64 = ... }
Backing state for a positioned file-backed io/Stream.
open-file = fn [path str, mode str] io/Stream
Opens path with mode ('r', 'w', 'rw', or 'a') and wraps the handle in an io/Stream.
Executable Example
use [io, ifs = io/fs]
p = 'dist/.doctest_io_fs.bin'
mut ws = ifs/open-file p 'w'
_ = io/write-all mut ws (bytes/from-str 'stream-disk-ok')
_ = io/close mut ws
mut rs = ifs/open-file p 'r'
got = io/read-all mut rs
_ = io/close mut rs
_ = os/remove/or p [ .ok ]
if (bytes/to-str got) != 'stream-disk-ok' [ err 'io/fs open-file' ] else [ .ok ]
open-write = fn [path str] io/Stream
Opens path for writing (creating or truncating) as an io/Stream.
seek = fn [mut s io/Stream, offset i64] i64
Seeks a file-backed io/Stream s to absolute byte offset.
sync = fn [s io/Stream] enum
Flushes a file-backed io/Stream s to durable storage via os/fsync.
pread-exact = fn [fd i64, offset i64, n i64] bytes
Reads exact n bytes at offset from raw positioned handle fd (errors on short read/EOF).
pwrite-all = fn [fd i64, offset i64, data bytes] i64
Writes all bytes of data at offset to raw positioned handle fd.