Return to index

os functions

bool = can_read(string)

top

Check if path is readable.

Example:

# Example for can_read
println can_read("/tmp")  # true


bool = can_write(string)

top

Check if path is writeable.

Example:

# Example for can_write
println can_write("/tmp")  # true


bool = cd(string)

top

Changes directory to a given path.

Example:

# Example for cd
println cd("/tmp")  # true


chroot(string)

top

Performs a chroot to a given path.

Example:

# Example for chroot
chroot("/mydir")


bool = copy(src_string,dest_string)

top

Copy a single file.

Example:

# Example for copy
copy("/tmp/file1","/tmp/file2")


string = cwd()

top

Returns the current working directory.

Example:

# Example for cwd
println cwd()  # current working directory


bool = delete(string)

top

Delete a file.

Example:

# Example for delete
delete("/tmp/file")


[]structs|[]string = dir([filepath[,filter[,options_map]])

top

Returns an array containing file information on path filepath.

[#SOL]filter can be specified, as a regex, to narrow results.

[#SOL]options_map supports: .depth(int), .names(bool), .exclude(str), .absolute(bool).

[#SOL]Each array element contains name,path,depth,mode,size,mtime and is_dir fields.

[#SOL]These specify filename, full path, recursion depth, file mode, file size, modification time and directory status respectively.

Example:

# Example for dir
println dir("/tmp")


string = env()

top

Return all available environmental variables.

Example:

# Example for env
println env()


string = get_env(key_name)

top

Return the value of the environmental variable key_name.

Example:

# Example for get_env
println get_env("HOME")  # /home/user


[]string = glob(pattern[,base_dir])

top

Returns an array of file paths matching a glob pattern.

[#SOL]pattern specifies the glob pattern (supports *, ?, []).

[#SOL]base_dir optionally specifies the base directory to search in (defaults to current directory).

[#SOL]Returns full paths to all matching files and directories.


bool = group_add(groupname[,options])

top

Add a system group. Options: gid (auto-allocated if not provided).


bool = group_del(groupname)

top

Remove a system group.


struct = group_info(groupname)

top

Get detailed information about a group.


[]struct = group_list()

top

List all system groups with details (gid, members).


bool = group_membership(username,groupname,action)

top

Manage group membership. Action: add, remove.


string = groupname(int)

top

Lookup a group name by group id.

Example:

# Example for groupname
println groupname(1000)


bool = is_device(mode_number)

top

Checks if a file mode indicates a device.

Example:

# Example for is_device
println is_device(6000)  # true for block device mode


bool = is_pipe(mode_number)

top

Checks if a file mode indicates a named pipe.

Example:

# Example for is_pipe
println is_pipe(4516)  # false


bool = is_setgid(mode_number)

top

Checks if a file mode indicates a setgid file.

Example:

# Example for is_setgid
println is_setgid(2755)  # true/false


bool = is_setuid(mode_number)

top

Checks if a file mode indicates a setuid file.

Example:

# Example for is_setuid
println is_setuid(4755)  # true/false


bool = is_socket(mode_number)

top

Checks if a file mode indicates a socket.

Example:

# Example for is_socket
println is_socket(49152)  # false


bool = is_sticky(mode_number)

top

Checks if a file mode indicates a sticky file.

Example:

# Example for is_sticky
println is_sticky(17407)  # true/false


bool = is_symlink(mode_number)

top

Checks if a file mode indicates a symbolic link.

Example:

# Example for is_symlink
println is_symlink(41471)  # true/false


string = parent(string)

top

Returns the parent directory.

Example:

# Example for parent
println parent("/usr/local/bin/")  # /usr/local


bool = rename(src_string,dest_string)

top

Rename a file.

Example:

# Example for rename
println rename("/tmp/old","/tmp/new")  # true


set_env(key_name,value_string)

top

Set the value of the environmental variable key_name.

Example:

# Example for set_env
set_env("MYVAR","abc")
println get_env("MYVAR")  # abc


int = umask(int)

top

Sets the umask value. Returns the previous value. umask() without args just returns the current value.

Example:

# Example for umask
println umask()  # e.g., 18


bool = user_add(username[,options])

top

Add a system user. Options: uid, gid, home, shell, groups, create_home.


bool = user_del(username[,options])

top

Remove a system user. Options: remove_home.


struct = user_info(username)

top

Get detailed information about a user.


[]struct = user_list()

top

List all system users with details (uid, gid, home, shell).


string = username(int)

top

Lookup a username by user id.

Example:

# Example for username
println username(1000)