fs/core

sourcefs/core.sx

fopen

private
extern (C) fn fopen(path: ref u8, mode: ref u8) ref void = trust { ... } = "fopen"

fclose

private
extern (C) fn fclose(stream: ref void) i32 = trust { ... } = "fclose"

fread

private
extern (C) fn fread(buf: ref void, size: usize, count: usize, stream: ref void) usize = trust { ... } = "fread"

fwrite

private
extern (C) fn fwrite(buf: ref void, size: usize, count: usize, stream: ref void) usize = trust { ... } = "fwrite"

fseek

private
extern (C) fn fseek(stream: ref void, offset: i64, whence: i32) i32 = trust { ... } = "fseek"

ftell

private
extern (C) fn ftell(stream: ref void) i64 = trust { ... } = "ftell"

rewind

private
extern (C) fn rewind(stream: ref void) void = trust { ... } = "rewind"

remove

private
extern (C) fn remove(path: ref u8) i32 = trust { ... } = "remove"

rename

private
extern (C) fn rename(old: ref u8, new: ref u8) i32 = trust { ... } = "rename"

strlen

private
extern (C) fn strlen(s: ref u8) i64 = trust { ... } = "strlen"

getcwd

private
extern (C) fn getcwd(buf: ref u8, size: usize) ref u8 = trust { ... } = "getcwd"

getenv

pub extern (C) fn getenv(name: ref u8) ref u8 = trust { ... } = "getenv"

mkdir

pub extern (C) fn mkdir(path: ref u8, mode: u32) i32 = trust { ... } = "mkdir"

rmdir

pub extern (C) fn rmdir(path: ref u8) i32 = trust { ... } = "rmdir"

opendir

pub extern (C) fn opendir(path: ref u8) ref void = trust { ... } = "opendir"

closedir

pub extern (C) fn closedir(dir: ref void) i32 = trust { ... } = "closedir"

readdir

pub extern (C) fn readdir(dir: ref void) ref Dirent = trust { ... } = "readdir"

Dirent

when linux
extern type Dirent = { d_ino: u64, d_off: i64, d_reclen: u16, d_type: u8, d_name: [256]u8 }

Fields

NameType
d_inou64
d_offi64
d_reclenu16
d_typeu8
d_name[256]u8

Dirent

when darwin
extern type Dirent = { d_ino: u64, d_seekoff: u64, d_reclen: u16, d_namlen: u16, d_type: u8, d_name: [1024]u8 }

Fields

NameType
d_inou64
d_seekoffu64
d_reclenu16
d_namlenu16
d_typeu8
d_name[1024]u8

Dirent

when freebsd
extern type Dirent = { d_fileno: u64, d_off: i64, d_reclen: u16, d_type: u8, d_pad0: u8, d_namlen: u16, d_pad1: u16, d_name: [256]u8 }

Fields

NameType
d_filenou64
d_offi64
d_reclenu16
d_typeu8
d_pad0u8
d_namlenu16
d_pad1u16
d_name[256]u8

Dirent

when openbsd
extern type Dirent = { d_fileno: u64, d_off: i64, d_reclen: u16, d_type: u8, d_namlen: u8, d_name: [256]u8 }

Fields

NameType
d_filenou64
d_offi64
d_reclenu16
d_typeu8
d_namlenu8
d_name[256]u8

Dirent

when netbsd
extern type Dirent = { d_fileno: u64, d_reclen: u16, d_namlen: u16, d_type: u8, d_name: [512]u8 }

Fields

NameType
d_filenou64
d_reclenu16
d_namlenu16
d_typeu8
d_name[512]u8

File

pub type File = { ptr: ref void }

Opaque file handle — wraps a C FILE*.

Fields

NameType
ptrref void

alloc_in

private
fn alloc_in[A: allocators.Allocator](ac: A, len: i64) ref void

alloc_cstr

private
fn alloc_cstr[A: allocators.Allocator](ac: A, len: i64) ref u8

copy_cstr

private
fn copy_cstr[A: allocators.Allocator](ac: A, text: ref u8) ref u8

copy_cstr_len

private
fn copy_cstr_len[A: allocators.Allocator](ac: A, text: ref u8, len: i64) ref u8

raw_alloc_cstr

private
fn raw_alloc_cstr(len: i64) ref u8 = trust { ... }

raw_copy_cstr_len

private
fn raw_copy_cstr_len(text: ref u8, len: i64) ref u8 = trust { ... }

dirent_name_len

private
fn dirent_name_len(entry: ref Dirent) i64 = trust { ... }

copy_dirent_name

private
fn copy_dirent_name[A: allocators.Allocator](ac: A, entry: ref Dirent) ref u8

raw_copy_dirent_name

private
fn raw_copy_dirent_name(entry: ref Dirent) ref u8 = trust { ... }

open

pub fn open(path: ref u8, mode: ref u8) option[ref void] = trust { ... }

close

pub fn close(f: ref void) void = trust { ... }

file_size

pub fn file_size(path: ref u8) option[i64] = trust { ... }

read_all

pub fn read_all[A: allocators.Allocator](ac: A, path: ref u8) option[ref u8]

read_all_raw

pub fn read_all_raw(path: ref u8) option[ref u8] = trust { ... }

read_line

pub fn read_line(f: ref void, buf: ref u8, max_len: i64) bool = trust { ... }

write

pub fn write(f: ref void, data: ref u8) void = trust { ... }

write_line

pub fn write_line(f: ref void, data: ref u8) void = trust { ... }

write_all

pub fn write_all(path: ref u8, data: ref u8) bool = trust { ... }

append_all

pub fn append_all(path: ref u8, data: ref u8) bool = trust { ... }

delete

pub fn delete(path: ref u8) bool = trust { ... }

rename_path

pub fn rename_path(old: ref u8, new: ref u8) bool = trust { ... }

mkdir_path

pub fn mkdir_path(path: ref u8) bool = trust { ... }

rmdir_path

pub fn rmdir_path(path: ref u8) bool = trust { ... }

cwd

pub fn cwd[A: allocators.Allocator](ac: A) option[ref u8]

cwd_raw

pub fn cwd_raw() option[ref u8] = trust { ... }

temp_dir

pub fn temp_dir[A: allocators.Allocator](ac: A) ref u8

temp_dir_raw

pub fn temp_dir_raw() ref u8 = trust { ... }

home_dir

pub fn home_dir[A: allocators.Allocator](ac: A) option[ref u8]

home_dir_raw

pub fn home_dir_raw() option[ref u8] = trust { ... }

config_dir

pub fn config_dir[A: allocators.Allocator](ac: A) option[ref u8]

config_dir_raw

pub fn config_dir_raw() option[ref u8] = trust { ... }

walk_dir

pub fn walk_dir[A: allocators.Allocator](ac: A, path: ref u8) option[list[ref u8]]

walk_dir_raw

pub fn walk_dir_raw(path: ref u8) option[list[ref u8]] = trust { ... }