Axle v0.14.1
Package

std/ffi/runtime

Intrinsics provided by libaxle_runtime (not libc). Declared once
here and shared across the stdlib by use std::ffi::runtime::…, so
the @link(symbol = …) bindings to runtime symbols live in a single place
rather than being re-declared inline in every module.

Free functions

TypeMethod and description
void
panicMsg(msg : string) : void Abort the process with msg, never returning. Used on unrecoverable
paths that are not throws (e.g. an allocation failure inside a
mutating method), where dereferencing a NULL buffer would be worse
than a clean, described abort.
i32
pathKind(path : string) : i32 What exists at path: 0 = nothing, 1 = regular file, 2 = directory.
Symlinks are followed; query failures report 0.
i64
pathMtimeMs(path : string) : i64 Last-modification time of path in milliseconds since the Unix
epoch, or -1 when the path cannot be stat-ed.
i32
pathMkdir(path : string) : i32 Create the directory at path (parent must exist). 0 on success.
i32
pathMkdirs(path : string) : i32 Create the directory at path and every missing ancestor. 0 on success.
i32
pathRemoveRecursive(path : string) : i32 Remove path — recursively for a directory, as a single file
otherwise. 0 on success (missing path is a failure).
i64
getCwd(buf : ptr, cap : i64) : i64 Write the current working directory into buf (at most cap
bytes, no NUL). Returns the byte length written, or one of the
negative codes below.
i64
getExePath(buf : ptr, cap : i64) : i64 Write the running executable's path into buf (at most cap
bytes, no NUL). Returns the byte length written, or one of the
negative codes below.
i32
setCwd(path : string) : i32 Move this process's working directory to path. 0 on success,
non-zero when the platform refused it.

A runtime seam and not libc's chdir / _chdir, for the reason the
environment has one: the narrow entry point renders its argument
through the process code page on Windows, so a directory whose name
carries anything outside it addresses the wrong path or none.
ptr
fileOpen(path : string, mode : i32) : ptr Open path and return its FILE* stream, or NULL when the
platform refused it — the same report fopen makes, so a caller
reads one contract.

A runtime seam and not libc's fopen, for the reason setCwd is
one: the narrow entry point renders its argument through the
process code page on Windows, so a file whose name carries
anything outside it cannot be opened at all — while Path::exists
on that same name answered true, because it already came
through here.
i64
envGet(name : string, buf : ptr, cap : i64) : i64 Write the value of name into buf (at most cap bytes, no NUL).
Returns the byte length written, or one of the negative codes below.
i32
envIsSet(name : string) : i32 1 when name is set — including when its value is the empty string,
and including a value envGet would decline to render. 0 otherwise.
i32
envSet(name : string, value : string) : i32 Set name to value. 0 on success, otherwise one of the write
codes below.
i32
envUnset(name : string) : i32 Remove name. 0 on success, including when it was never set — the
postcondition is "not set", and it already held.
i32
argCount() : i32 How many arguments this process was started with, the program name
at index 0 included. 0 when the platform will not say.
i64
argAtInto(index : i32, buf : ptr, cap : i64) : i64 Write the argument at index into buf (at most cap bytes, no
NUL). Returns the byte length written, or one of the codes below.

Method detail

#panicMsg

panicMsg(msg : string) : void

Abort the process with msg, never returning. Used on unrecoverable
paths that are not throws (e.g. an allocation failure inside a
mutating method), where dereferencing a NULL buffer would be worse
than a clean, described abort.

#pathKind

pathKind(path : string) : i32

What exists at path: 0 = nothing, 1 = regular file, 2 = directory.
Symlinks are followed; query failures report 0.

#pathMtimeMs

pathMtimeMs(path : string) : i64

Last-modification time of path in milliseconds since the Unix
epoch, or -1 when the path cannot be stat-ed.

#pathMkdir

pathMkdir(path : string) : i32

Create the directory at path (parent must exist). 0 on success.

#pathMkdirs

pathMkdirs(path : string) : i32

Create the directory at path and every missing ancestor. 0 on success.

#pathRemoveRecursive

pathRemoveRecursive(path : string) : i32

Remove path — recursively for a directory, as a single file
otherwise. 0 on success (missing path is a failure).

#getCwd

getCwd(buf : ptr, cap : i64) : i64

Write the current working directory into buf (at most cap
bytes, no NUL). Returns the byte length written, or one of the
negative codes below.

#getExePath

getExePath(buf : ptr, cap : i64) : i64

Write the running executable's path into buf (at most cap
bytes, no NUL). Returns the byte length written, or one of the
negative codes below.

#setCwd

setCwd(path : string) : i32

Move this process's working directory to path. 0 on success,
non-zero when the platform refused it.

A runtime seam and not libc's chdir / _chdir, for the reason the
environment has one: the narrow entry point renders its argument
through the process code page on Windows, so a directory whose name
carries anything outside it addresses the wrong path or none.

#fileOpen

fileOpen(path : string, mode : i32) : ptr

Open path and return its FILE* stream, or NULL when the
platform refused it — the same report fopen makes, so a caller
reads one contract.

A runtime seam and not libc's fopen, for the reason setCwd is
one: the narrow entry point renders its argument through the
process code page on Windows, so a file whose name carries
anything outside it cannot be opened at all — while Path::exists
on that same name answered true, because it already came
through here.

Parameters
mode one of OPEN_READ / OPEN_WRITE / OPEN_APPEND;
every one of them opens in binary form. A value that
is none of the three opens nothing.

#envGet

envGet(name : string, buf : ptr, cap : i64) : i64

Write the value of name into buf (at most cap bytes, no NUL).
Returns the byte length written, or one of the negative codes below.

#envIsSet

envIsSet(name : string) : i32

1 when name is set — including when its value is the empty string,
and including a value envGet would decline to render. 0 otherwise.

#envSet

envSet(name : string, value : string) : i32

Set name to value. 0 on success, otherwise one of the write
codes below.

#envUnset

envUnset(name : string) : i32

Remove name. 0 on success, including when it was never set — the
postcondition is "not set", and it already held.

#argCount

argCount() : i32

How many arguments this process was started with, the program name
at index 0 included. 0 when the platform will not say.

#argAtInto

argAtInto(index : i32, buf : ptr, cap : i64) : i64

Write the argument at index into buf (at most cap bytes, no
NUL). Returns the byte length written, or one of the codes below.