Modules

System

moduleSource

Available on macOS, Linux, Windows, Android

#import "System";

Asks the operating system about the machine, the user and the running program.

Strings returned here live in temporary storage; copy one to keep it.

Example↗
path := get_path_of_running_executable();
assert(path.count > 0);

Procedures#

() -> u64

Returns a fast, monotonic tick count for timing short spans. Ticks are not seconds and the rate varies by machine, so compare readings only with each other.

start := read_cpu_counter();
stop := read_cpu_counter();
assert(stop >= start);
↗
() -> (string, success: bool)

Returns the name of the current user and whether the lookup worked.

name, ok := get_username();
assert(!ok || name.count > 0);
↗
(username := "") -> (string, success: bool)

Returns the home directory of username, or of the current user when it is empty, and whether the lookup worked.

home, ok := get_home_directory();
assert(!ok || home.count > 0);
↗

Types#

Constants#

:: Windows.GetLastError

Returns the last error code the operating system set: errno on Unix, GetLastError on Windows. Read it right after the call that failed.

description := get_error_string(get_error_value());
assert(description.count >= 0);
↗
get_passwd_for_userLinux, Android onlySource
:: Impl.get_passwd_for_user

Returns the user database entry for username, or for the current user when it is empty. Linux and Android only.