Check if path is readable.
Example:
# Example for can_read
println can_read("/etc/passwd")
println can_read("/nonexistent/file")
Check if path is writeable.
Example:
# Example for can_write
println can_write("/tmp")
Changes directory to a given path.
Example:
# Example for cd
println cd("/tmp")
Change file permissions. Mode string is octal (e.g. "755").
Example:
# Example for chmod
touch("/tmp/za_chmod.txt")
chmod("/tmp/za_chmod.txt", "644")
Change file owner and group. User and group can be names or numeric IDs.
Example:
# Example for chown
try
println chown("/tmp", "root", "root")
catch err
println "Chown failed"
endtry
Performs a chroot to a given path.
Example:
# Example for chroot
try
println chroot("/tmp")
catch err
println "Chroot failed"
endtry
Copy a single file.
Example:
# Example for copy
write_file("/tmp/test.txt", "hello")
println copy("/tmp/test.txt", "/tmp/test2.txt")
Returns the current working directory.
Example:
# Example for cwd println cwd()
Delete a file.
Example:
# Example for delete
write_file("/tmp/test.txt", "hello")
println delete("/tmp/test.txt")
Returns an array containing file information on path filepath.
filter can be specified, as a regex, to narrow results.
options_map supports: .depth(int), .names(bool), .exclude(str), .absolute(bool).
Each array element contains name,path,depth,mode,size,mtime and is_dir fields.
These specify filename, full path, recursion depth, file mode, file size, modification time and directory status respectively.
Example:
# Example for dir dir() # usage
Return all available environmental variables.
Example:
# Example for env println env()
Return the value of the environmental variable key_name.
Example:
# Example for get_env
println get_env("HOME")
println get_env("PATH")
println get_env("NONEXISTENT_VAR")
Returns an array of file paths matching a glob pattern.
pattern specifies the glob pattern (supports *, ?, []).
base_dir optionally specifies the base directory to search in (defaults to current directory).
Returns full paths to all matching files and directories.
Example:
# Example for glob
glob("hello") # usage
Add a system group. Options: gid (auto-allocated if not provided).
Example:
# Example for group_add
try
group_add("testgroup")
catch err
println "Group add failed"
endtry
Remove a system group.
Example:
# Example for group_del
try
group_del("testgroup")
catch err
println "Group del failed"
endtry
Get detailed information about a group.
Example:
# Example for group_info
try
println group_info("root")
catch err
println "Group info failed"
endtry
List all system groups with details (gid, members).
Example:
# Example for group_list println group_list()
Manage group membership. Action: add, remove.
Example:
# Example for group_membership
try
println group_membership("root")
catch err
println "Group membership failed"
endtry
Lookup a group name by group id.
Example:
# Example for groupname println groupname(3.14)
Checks if a file mode indicates a device.
Example:
# Example for is_device
mode = file_mode("/dev/null")
println is_device(mode)
println is_device(file_mode("/tmp"))
Checks if a file mode indicates a named pipe.
Example:
# Example for is_pipe
mode = file_mode("/tmp")
println is_pipe(mode)
Checks if a file mode indicates a setgid file.
Example:
# Example for is_setgid
mode = file_mode("/etc/passwd")
println is_setgid(mode)
Checks if a file mode indicates a setuid file.
Example:
# Example for is_setuid
mode = file_mode("/etc/passwd")
println is_setuid(mode)
Checks if a file mode indicates a socket.
Example:
# Example for is_socket
mode = file_mode("/tmp")
println is_socket(mode)
Checks if a file mode indicates a sticky file.
Example:
# Example for is_sticky println is_sticky(42)
Checks if a file mode indicates a symbolic link.
Example:
# Example for is_symlink println is_symlink(42)
Create a directory. Mode string is octal (e.g. "755"). Options map: .recursive (bool), .mode (string).
Example:
# Example for mkdir
mkdir("/tmp/za_mkdir_test")
if is_dir("/tmp/za_mkdir_test")
delete("/tmp/za_mkdir_test")
endif
Create a directory and all parent directories. Mode string is octal (e.g. "755").
Example:
# Example for mkdir_p
mkdir_p("/tmp/test_mkdir_p") # usage
Returns the parent directory.
Example:
# Example for parent
println parent("/home/user/documents/file.txt")
Return the target of a symbolic link, or empty string if not a symlink.
Example:
# Example for readlink
println readlink("/etc/localtime")
Rename a file.
Example:
# Example for rename
write_file("/tmp/old.txt", "hello")
println rename("/tmp/old.txt", "/tmp/new.txt")
Set the value of the environmental variable key_name.
Example:
# Example for set_env
set_env("ZA_TEST", "hello")
Create a symbolic link.
Example:
# Example for symlink
try
println symlink("/etc/passwd", "/tmp/za_symlink_example")
catch err
println "symlink failed"
endtry
Flush all filesystem buffers to disk.
Example:
# Example for sync println sync()
Create a temporary directory and return its path.
Example:
# Example for temp_dir
d = temp_dir("za-example-")
println d
write_file(d + "/test.txt", "hello")
println read_file(d + "/test.txt")
Create a temporary file and return its path.
Example:
# Example for temp_file
f = temp_file("za-example-")
println f
write_file(f, "hello world")
println read_file(f)
Create an empty file if it does not exist, or update its modification time if it does.
Example:
# Example for touch
f = temp_file("za-touch-")
println touch(f)
Truncate a file to the specified size.
Example:
# Example for truncate
f = temp_file("za-truncate-")
write_file(f, "hello world")
println truncate(f, 5)
Sets the umask value. Returns the previous value. umask() without args just returns the current value.
Example:
# Example for umask println umask(022)
Add a system user. Options: uid, gid, home, shell, groups, create_home.
Example:
# Example for user_add
try
user_add("testuser", "password")
catch err
println "User add failed"
endtry
Remove a system user. Options: remove_home.
Example:
# Example for user_del
try
user_del("testuser")
catch err
println "User del failed"
endtry
Get detailed information about a user.
Example:
# Example for user_info
try
println user_info("root")
catch err
println "User info failed"
endtry
List all system users with details (uid, gid, home, shell).
Example:
# Example for user_list println user_list()
Lookup a username by user id.
Example:
# Example for username println username(3.14)