Module sys/file

sys/file
Stability: unstable — may still change; see below.

Async and sync file operations.

Provides low-level file I/O wrappers around the C runtime externs.

Async operations return IoFuture which resolves to:

  • Positive value: success (fd for open, bytes for read/write, 0 for others)
  • Negative value: -errno on failure

Stability

unstable — a raw wrapper over the C file calls whose async results are a bare i32 that is a value on success and -errno on failure, which a caller converts with IoError.from_result. std/fs is the typed face (File, read_to_string, write, the Reader/Writer impls) and is what should be imported.

It freezes, if ever, as an implementation detail of std/fs. The one thing worth knowing before then is that the *u8 + length parameter shape here is the same one std/io's traits carry, for the same reason — Yo has no slice type — so if a slice type arrives, both layers change together.

Functions

openat function
fn(dirfd : i32, path : *u8, flags : i32, mode : i32) -> IoFuture

Parameters

NameTypeNotes
dirfdi32
path*u8
flagsi32
modei32

Returns: IoFuture

close function
fn(fd : i32) -> IoFuture

Parameters

NameTypeNotes
fdi32

Returns: IoFuture

read function
fn(fd : i32, buffer : *u8, size : u32, offset : u64) -> IoFuture

Parameters

NameTypeNotes
fdi32
buffer*u8
sizeu32
offsetu64

Returns: IoFuture

write function
fn(fd : i32, buffer : *u8, size : u32, offset : u64) -> IoFuture

Parameters

NameTypeNotes
fdi32
buffer*u8
sizeu32
offsetu64

Returns: IoFuture

statx function
fn(dirfd : i32, path : *u8, flags : i32, mask : u32, statxbuf : *u8) -> IoFuture

Parameters

NameTypeNotes
dirfdi32
path*u8
flagsi32
masku32
statxbuf*u8

Returns: IoFuture

fsync function
fn(fd : i32) -> IoFuture

Parameters

NameTypeNotes
fdi32

Returns: IoFuture

fdatasync function
fn(fd : i32) -> IoFuture

Parameters

NameTypeNotes
fdi32

Returns: IoFuture

ftruncate function
fn(fd : i32, length : i64) -> IoFuture

Parameters

NameTypeNotes
fdi32
lengthi64

Returns: IoFuture

open_sync function
fn(path : *u8, flags : i32, mode : i32) -> i32

Parameters

NameTypeNotes
path*u8
flagsi32
modei32

Returns: i32

close_sync function
fn(fd : i32) -> unit

Parameters

NameTypeNotes
fdi32

Returns: unit

write_sync function
fn(fd : i32, buf : *u8, count : u32, offset : u64) -> i32

Parameters

NameTypeNotes
fdi32
buf*u8
countu32
offsetu64

Returns: i32

file_size function
fn(fd : i32) -> i64

Parameters

NameTypeNotes
fdi32

Returns: i64

fstat function
fn(fd : i32, statxbuf : *u8) -> i32

Parameters

NameTypeNotes
fdi32
statxbuf*u8

Returns: i32