std.fs¶
Files by path. A path here is its bytes alone, without the NUL a C call needs: each function copies it into NUL-terminated storage of its own, so a path from the command line, from a Vec or from a literal goes straight in. A path of 4096 bytes or more is ENAMETOOLONG (36), and one holding a NUL is EINVAL (22): both are values, never guards. std.io has the calls on an open File. Cost: one system call per step, the whole-file forms loop until done; nothing is buffered.
// effects: ffi:__errno_location, ffi:open, ffi_precondition, io, local_read, local_write, mmio, read:path,
// stack_storage, trap, zero_init
pub fn open(n:usize, path:ro<u8>[n]@host, flags:i32) -> std.core.Result[std.io.File, std.io.IoError]
// The whole file, read until the kernel says it ended: a pipe or a /proc file whose size is 0 reads whole.
// effects: alloc, diverge, ffi:__errno_location, ffi:close, ffi:lseek, ffi:open, ffi:read, ffi_precondition, free, io,
// local_read, local_write, mmio, read:path, stack_storage, trap, zero_init
pub fn read(n:usize, path:ro<u8>[n]@host) -> std.core.Result[std.vec.Vec[u8], std.io.IoError]
// Create the file or cut it to nothing, then write all of `data`.
// effects: diverge, ffi:__errno_location, ffi:close, ffi:open, ffi:write, ffi_precondition, io, local_read,
// local_write, mmio, read:data, read:path, stack_storage, trap, zero_init
pub fn write(n:usize, path:ro<u8>[n]@host, m:usize, data:ro<u8>[m]@host) -> std.core.Result[usize, std.io.IoError]
// Create the file or keep it, and write all of `data` at its end.
// effects: diverge, ffi:__errno_location, ffi:close, ffi:open, ffi:write, ffi_precondition, io, local_read,
// local_write, mmio, read:data, read:path, stack_storage, trap, zero_init
pub fn append(n:usize, path:ro<u8>[n]@host, m:usize, data:ro<u8>[m]@host) -> std.core.Result[usize, std.io.IoError]
// effects: ffi:__errno_location, ffi:unlink, ffi_precondition, io, local_read, local_write, mmio, read:path,
// stack_storage, trap, zero_init
pub fn remove(n:usize, path:ro<u8>[n]@host) -> std.core.Result[usize, std.io.IoError]
// One atomic replacement of `to` by `from`.
// effects: ffi:__errno_location, ffi:rename, ffi_precondition, io, local_read, local_write, mmio, read:from, read:to,
// stack_storage, trap, zero_init
pub fn rename(n:usize, from:ro<u8>[n]@host, k:usize, to:ro<u8>[k]@host) -> std.core.Result[usize, std.io.IoError]
// Whether anything is at `path` now; the answer can be stale by the time the next call runs.
// effects: ffi:access, ffi_precondition, io, local_read, local_write, read:path, stack_storage, trap, zero_init
pub fn exists(n:usize, path:ro<u8>[n]@host) -> bool
A generic function's effects are what it may do for any arguments within its bounds, besides what their own trait members do.