Lynxer

Documentation

os

Filesystem, process, environment and platform helpers.

Backend: native — stdlib/os.so, built from stdlib/os.cpp over <filesystem> and the host APIs (POSIX or Win32). Import: import("os") → global.os.*

Functions return safe defaults on failure (false, "", -1, an empty list).

Files and directories

FunctionSignatureNotes
getcwd() -> strCurrent working directory
chdir(str path) -> boolChanges the working directory
listdir(str path) -> listDirectory entries, in filesystem order
listdirExt(str path, str ext) -> listEntries whose name ends with ext
walkFiles(str path) -> strRecursive file paths as a newline-joined string
mkdir(str path) -> boolCreates one directory; false if it exists
makedirs(str path) -> boolCreates a directory tree (existing is fine)
rmdir(str path) -> boolRemoves an empty directory
remove(str path) -> boolRemoves a file
rename(str src, str dst) -> boolRenames or moves
rmTree(str path) -> boolRecursively removes a tree
copyTree(str src, str dst) -> boolRecursively copies; fails if dst exists
exists / isFile / isDir(str path) -> boolPath predicates

Paths and environment

FunctionSignatureNotes
joinPath(str a, str b) -> strJoins with the platform separator
basename / dirname(str path) -> strFinal / parent component
absPath(str path) -> strAbsolute, normalized path
extname(str path) -> strExtension including the dot
normPath(str path) -> strCollapses ., .. and repeated separators
expandUser(str path) -> strExpands a leading ~ or ~user
sep() -> str/ on POSIX hosts
getenv / setenv(str key[, str value])Reads / writes an environment variable
tempDir() -> str$TMPDIR, $TEMP, $TMP, else /tmp (Windows: GetTempPathW)
homedir() -> str$HOME (Windows: %USERPROFILE%)
configDir() -> str$XDG_CONFIG_HOME or $HOME/.config (Windows: %APPDATA%)
dataDir() -> str$XDG_DATA_HOME or $HOME/.local/share (Windows: %LOCALAPPDATA%)
cacheDir() -> str$XDG_CACHE_HOME or $HOME/.cache (Windows: %LOCALAPPDATA%)
username() -> strLogin name from the password database
hostname() -> strgethostname(2)
getpid() -> intProcess id
cpuCount() -> intOnline CPUs, at least 1
diskTotal / diskFree(str path) -> intBytes via statvfs; -1 on error

Platform information

getSystemName, getSystemRelease, getSystemVersion, getSystemMachine, getSystemProcessor, getSystemNode — all () -> str from uname(2). getSystemArchitecture() -> str returns "64bit" or "32bit".

JSON-returning helpers:

FunctionSignatureReturns
getSystemUname() -> str{system, node, release, version, machine, processor}
getSystemInfo() -> strThe same fields plus architecture
getSystemDistro() -> strParsed /etc/os-release, or {}

The Python-compat getters (getPythonVersion, getPythonImplementation) and the python* fields of getSystemInfo are gone: there is no Python runtime to introspect, and a standing ""/"Lynxer" value was a lie. See removed-features.

Example

global setup(){ import("os"); }

global main(){
    println(global.os.getcwd());
    list entries = global.os.listdir(".");
    println(returnLength(entries));
    println(global.os.getSystemName());
}

See also