Module os stdlib

os
Version:
0.3.3
License:
MIT
Dependencies from vmod:
0
Imports:
4
Imported by:
70
Repository:
OS-specific
Show selected OS-specific symbols.
Backend-specific
Show selected Backend-specific symbols.

Dependencies defined in v.mod

This section is empty.

Imports

Overview

os provides common OS/platform independent functions for accessing command line arguments, reading/writing files, listing folders, handling processes etc.


Security advice related to TOCTOU attacks

A few os module functions can lead to the TOCTOU vulnerability if used incorrectly. TOCTOU (Time-of-Check-to-Time-of-Use problem) can occur when a file, folder or similar is checked for certain specifications (e.g. read, write permissions) and a change is made afterwards. In the time between the initial check and the edit, an attacker can then cause damage. The following example shows an attack strategy on the left and an improved variant on the right so that TOCTOU is no longer possible.

Example Hint: os.create() opens a file in write-only mode

Possibility for TOCTOU attack
if os.is_writable("file"){

    // >> time to make a quick attack (e.g. symlink /etc/passwd to >file<) <<

    mut f := os.create('path/to/file') ?
        // <do something with file>
    f.close()
}
TOCTOU not possible
mut f := os.create('path/to/file') or {
    println("file not writable")
}

// >> do something with file; file is locked <<

f.close()

Proven affected functions
The following functions should be used with care and only when used correctly.

  • os.is_readable()
  • os.is_writable()
  • os.is_executable()
  • os.is_link()

Aliases

#type NativeActivity

Termux
type NativeActivity = C.ANativeActivity

NativeActivity defines the native side of an android.app.NativeActivity.

#type AssetManager

Termux
type AssetManager = C.AAssetManager

AssetManager provides access to an application's raw assets by creating Asset objects.

#fn (&AssetManager) open

Termux
fn (am &AssetManager) open(filename string, mode AssetMode) !&Asset

open opens an Android Asset

#type Asset

Termux
type Asset = C.AAsset

#fn (&Asset) get_buffer

Termux
fn (a &Asset) get_buffer() voidptr

get_buffer returns a pointer to a buffer holding the entire contents of the asset.

#fn (&Asset) get_length

Termux
fn (a &Asset) get_length() int

get_length returns the total size of the asset data.

#fn (&Asset) get_length_64

Termux
fn (a &Asset) get_length_64() i64

get_length_64 returns the total size of the asset data using a 64-bit number insted of 32-bit as get_length.

#fn (&Asset) read

Termux
fn (a &Asset) read(buffer voidptr, count usize) int

read attempts to read 'count' bytes of data from the current offset.

read returns the number of bytes read, zero on EOF, or < 0 on error.

#fn (&Asset) close

Termux
fn (a &Asset) close()

close closes the asset, freeing all associated resources.

#type HANDLE

Windows
type HANDLE = voidptr

#type HMODULE

Windows
type HMODULE = voidptr

Constants

#constant hkey_local_machine

Windows
hkey_local_machine     = voidptr(0x80000002)

Windows Registry Constants

#constant hkey_current_user

Windows
hkey_current_user      = voidptr(0x80000001)

Windows Registry Constants

#constant key_query_value

Windows
key_query_value        = 0x0001

Windows Registry Constants

#constant key_set_value

Windows
key_set_value          = 0x0002

Windows Registry Constants

#constant key_enumerate_sub_keys

Windows
key_enumerate_sub_keys = 0x0008

Windows Registry Constants

#constant key_wow64_32key

Windows
key_wow64_32key        = 0x0200

Windows Registry Constants

#constant hwnd_broadcast

Windows
hwnd_broadcast   = voidptr(0xFFFF)

Windows Messages

#constant wm_settingchange

Windows
wm_settingchange = 0x001A

Windows Messages

#constant smto_abortifhung

Windows
smto_abortifhung = 0x0002

Windows Messages

#constant args

args = []string{}

#constant path_delimiter

JavaScript
path_delimiter = get_path_delimiter()

#constant path_separator

JavaScript
path_separator = get_path_separator()

#constant args

JavaScript
args           = []string{}

#constant max_path_len

pub const max_path_len = 4096

#constant wd_at_startup

pub const wd_at_startup = getwd()

#constant sys_write

sys_write         = 4

#constant sys_open

sys_open          = 5

#constant sys_close

sys_close         = 6

#constant sys_mkdir

sys_mkdir         = 136

#constant sys_creat

sys_creat         = 8

#constant sys_open_nocancel

sys_open_nocancel = 398

#constant sys_stat64

sys_stat64        = 338

#constant sys_write

Linux
sys_write = 1

#constant sys_open

Linux
sys_open  = 2

#constant sys_close

Linux
sys_close = 3

#constant sys_mkdir

Linux
sys_mkdir = 83

#constant sys_creat

Linux
sys_creat = 85

#constant path_separator

Linux
path_separator = '/'

#constant path_delimiter

Linux
path_delimiter = ':'

#constant s_ifmt

Linux
s_ifmt  = 0xF000 // type of file

(Must be realized in Syscall) (Must be specified) ref: http://www.ccfit.nsu.ru/~deviv/courses/unix/unix/ng7c229.html

#constant s_ifdir

Linux
s_ifdir = 0x4000 // directory

(Must be realized in Syscall) (Must be specified) ref: http://www.ccfit.nsu.ru/~deviv/courses/unix/unix/ng7c229.html

#constant s_iflnk

Linux
s_iflnk = 0xa000 // link

(Must be realized in Syscall) (Must be specified) ref: http://www.ccfit.nsu.ru/~deviv/courses/unix/unix/ng7c229.html

#constant s_isuid

Linux
s_isuid = 0o4000 // SUID

(Must be realized in Syscall) (Must be specified) ref: http://www.ccfit.nsu.ru/~deviv/courses/unix/unix/ng7c229.html

#constant s_isgid

Linux
s_isgid = 0o2000 // SGID

(Must be realized in Syscall) (Must be specified) ref: http://www.ccfit.nsu.ru/~deviv/courses/unix/unix/ng7c229.html

#constant s_isvtx

Linux
s_isvtx = 0o1000 // Sticky

(Must be realized in Syscall) (Must be specified) ref: http://www.ccfit.nsu.ru/~deviv/courses/unix/unix/ng7c229.html

#constant s_irusr

Linux
s_irusr = 0o0400 // Read by owner

(Must be realized in Syscall) (Must be specified) ref: http://www.ccfit.nsu.ru/~deviv/courses/unix/unix/ng7c229.html

#constant s_iwusr

Linux
s_iwusr = 0o0200 // Write by owner

(Must be realized in Syscall) (Must be specified) ref: http://www.ccfit.nsu.ru/~deviv/courses/unix/unix/ng7c229.html

#constant s_ixusr

Linux
s_ixusr = 0o0100 // Execute by owner

(Must be realized in Syscall) (Must be specified) ref: http://www.ccfit.nsu.ru/~deviv/courses/unix/unix/ng7c229.html

#constant s_irgrp

Linux
s_irgrp = 0o0040 // Read by group

(Must be realized in Syscall) (Must be specified) ref: http://www.ccfit.nsu.ru/~deviv/courses/unix/unix/ng7c229.html

#constant s_iwgrp

Linux
s_iwgrp = 0o0020 // Write by group

(Must be realized in Syscall) (Must be specified) ref: http://www.ccfit.nsu.ru/~deviv/courses/unix/unix/ng7c229.html

#constant s_ixgrp

Linux
s_ixgrp = 0o0010 // Execute by group

(Must be realized in Syscall) (Must be specified) ref: http://www.ccfit.nsu.ru/~deviv/courses/unix/unix/ng7c229.html

#constant s_iroth

Linux
s_iroth = 0o0004 // Read by others

(Must be realized in Syscall) (Must be specified) ref: http://www.ccfit.nsu.ru/~deviv/courses/unix/unix/ng7c229.html

#constant s_iwoth

Linux
s_iwoth = 0o0002 // Write by others

(Must be realized in Syscall) (Must be specified) ref: http://www.ccfit.nsu.ru/~deviv/courses/unix/unix/ng7c229.html

#constant s_ixoth

Linux
s_ixoth = 0o0001 // Execute by others

(Must be realized in Syscall) (Must be specified) ref: http://www.ccfit.nsu.ru/~deviv/courses/unix/unix/ng7c229.html

#constant path_separator

Windows
path_separator = '\\'

#constant path_delimiter

Windows
path_delimiter = ';'

Sum types

This section is empty.

Functions

#fn abs_path

fn abs_path(path string) string

abs_path joins the current working directory with the given path (if the path is relative) and returns the absolute path representation.

#fn add_vectored_exception_handler

Windows
fn add_vectored_exception_handler(first bool, handler fn (&ExceptionPointers) u32)

This is defined in builtin because we use vectored exception handling for our unhandled exception handler on windows As a result this definition is commented out to prevent duplicate definitions from displeasing the compiler fn C.AddVectoredExceptionHandler(u32, VectoredExceptionHandler)

#fn args_after

fn args_after(cut_word string) []string

args_after returns all os.args, located after a specified cut_word.

When cut_word is NOT found, os.args is returned unmodified.

#fn args_before

fn args_before(cut_word string) []string

args_before returns all os.args, located before a specified cut_word.

When cut_word is NOT found, os.args is returned unmodified.

#fn base

fn base(opath string) string

base returns the last element of path.

Trailing path separators are removed before extracting the last element.

If the path is empty, base returns ".". If the path consists entirely of separators, base returns a single separator.

#fn cache_dir

fn cache_dir() string

cache_dir returns the path to a writable user specific folder, suitable for writing non-essential data.

#fn chdir

JavaScript
fn chdir(s string) !

#fn chdir

fn chdir(path string) !

chdir changes the current working directory to the new directory in path.

#fn chmod

JavaScript
fn chmod(path string, mode int) !

chmod change file access attributes of path to mode.

Octals like 0o600 can be used.

#fn chmod

fn chmod(path string, mode int) !

chmod change file access attributes of path to mode.

Octals like 0o600 can be used.

#fn chown

JavaScript
fn chown(path string, owner int, group int) !

chown changes the owner and group attributes of path to owner and group.

Octals like 0o600 can be used.

#fn chown

fn chown(path string, owner int, group int) !

chown changes the owner and group attributes of path to owner and group.

#fn config_dir

fn config_dir() !string

config_dir returns the path to the user configuration directory (depending on the platform).

On windows, that is %AppData%.

On macos, that is ~/Library/Application Support.

On the rest, that is $XDG_CONFIG_HOME, or if that is not available, ~/.config.

If the path cannot be determined, it returns an error.

(for example, when $HOME on linux, or %AppData% on windows is not defined)

#fn cp

JavaScript
fn cp(src string, dst string) !

#fn cp

fn cp(src string, dst string) !

cp copies files or folders from src to dst.

#fn cp_all

fn cp_all(src string, dst string, overwrite bool) !

cp_all will recursively copy src to dst, optionally overwriting files or dirs in dst.

#fn create

JavaScript
fn create(path string) !File

#fn create

fn create(path string) !File

create creates or opens a file at a specified location and returns a write-only File object.

#fn debugger_present

Windowsinline
fn debugger_present() bool

debugger_present returns a bool indicating if the process is being debugged

#fn debugger_present

Linuxinline
fn debugger_present() bool

debugger_present returns a bool indicating if the process is being debugged

#fn debugger_present

FreeBSDinline
fn debugger_present() bool

debugger_present returns a bool indicating if the process is being debugged

#fn debugger_present

inline
fn debugger_present() bool

debugger_present returns a bool indicating if the process is being debugged

#fn debugger_present

inline
fn debugger_present() bool

debugger_present returns a bool indicating if the process is being debugged

#fn dir

fn dir(opath string) string

dir returns all but the last element of path, typically the path's directory.

After dropping the final element, trailing slashes are removed.

If the path is empty, dir returns ".". If the path consists entirely of separators, dir returns a single separator.

The returned path does not end in a separator unless it is the root directory.

#fn ensure_folder_is_writable

Windows
fn ensure_folder_is_writable(folder string) !

ensure_folder_is_writable checks that folder exists, and is writable to the process by creating an empty file in it, then deleting it.

#fn ensure_folder_is_writable

Linuxmanualfree
fn ensure_folder_is_writable(folder string) !

ensure_folder_is_writable checks that folder exists, and is writable to the process by creating an empty file in it, then deleting it.

#fn ensure_folder_is_writable

JavaScript
fn ensure_folder_is_writable(path string) !

#fn environ

JavaScript
fn environ() map[string]string

#fn environ

fn environ() map[string]string

#fn executable

JavaScript
fn executable() string

#fn executable

manualfree
fn executable() string

executable returns the path name of the executable that started the current process.

#fn execute

Windows
fn execute(cmd string) Result

execute starts the specified command, waits for it to complete, and returns its output.

In opposition to raw_execute this function will safeguard against content that is known to cause a lot of problems when executing shell commands on Windows.

#fn execute

Linuxmanualfree
fn execute(cmd string) Result

execute starts the specified command, waits for it to complete, and returns its output.

#fn execute

JavaScript
fn execute(cmd string) Result

#fn execute_or_exit

fn execute_or_exit(cmd string) Result

#fn execute_or_panic

fn execute_or_panic(cmd string) Result

#fn execve

fn execve(cmdpath string, cmdargs []string, envs []string) !

execve - loads and executes a new child process, in place of the current process.

The child process executable is located in cmdpath.

The arguments, that will be passed to it are in args.

You can pass environment variables to through envs.

Note: this function will NOT return when successfull, since the child process will take control over execution.

#fn execvp

JavaScript
fn execvp(cmd string, args []string) !

#fn execvp

fn execvp(cmdpath string, cmdargs []string) !

execvp - loads and executes a new child process, in place of the current process.

The child process executable is located in cmdpath.

The arguments, that will be passed to it are in args.

Note: this function will NOT return when successfull, since the child process will take control over execution.

#fn existing_path

fn existing_path(path string) !string

existing_path returns the existing part of the given path.

An error is returned if there is no existing part of the given path.

#fn exists

JavaScript
fn exists(path string) bool

#fn exists

fn exists(path string) bool

exists returns true if path (file or directory) exists.

#fn exists_in_system_path

fn exists_in_system_path(prog string) bool

exists_in_system_path returns true if prog exists in the system's PATH

#fn expand_tilde_to_home

fn expand_tilde_to_home(path string) string

expand_tilde_to_home expands the character ~ in path to the user's home directory.

See also home_dir.

#fn fd_close

fn fd_close(fd int) int

close filedescriptor

#fn fd_read

fn fd_read(fd int, maxbytes int) (string, int)

read from filedescriptor, don't block return [bytestring,nrbytes]

#fn fd_slurp

fn fd_slurp(fd int) []string

read from filedescriptor, block until data

#fn fd_write

fn fd_write(fd int, s string)

#fn file_ext

fn file_ext(opath string) string

file_ext will return the part after the last occurence of in path.

The is included.

Examples:

 assert os.file_ext('file.v') == '.v'
 assert os.file_ext('.ignore_me') == ''
 assert os.file_ext('.') == ''

#fn file_last_mod_unix

JavaScript
fn file_last_mod_unix(path string) int

#fn file_last_mod_unix

fn file_last_mod_unix(path string) i64

file_last_mod_unix returns the "last modified" time stamp of file in path.

#fn file_name

fn file_name(opath string) string

file_name will return all characters found after the last occurence of path_separator.

file extension is included.

#fn file_size

fn file_size(path string) u64

file_size returns the size of the file located in path.

If an error occurs it returns 0.

Note that use of this on symbolic links on Windows returns always 0.

#fn fileno

fn fileno(cfile voidptr) int

fileno returns the file descriptor of an opened C file.

#fn find_abs_path_of_executable

fn find_abs_path_of_executable(exepath string) !string

find_abs_path_of_executable walks the environment PATH, just like most shell do, it returns the absolute path of the executable if found

#fn flush

JavaScript
fn flush()

flush will flush the stdout buffer.

#fn flush

fn flush()

flush will flush the stdout buffer.

#fn fork

fn fork() int

fork will fork the current system process and return the pid of the fork.

#fn from_slash

fn from_slash(path string) string

from_slash returns the result of replacing each slash (/) character is path with a separator character.

#fn get_error_msg

Windows
fn get_error_msg(code int) string

get_error_msg return error code representation in string.

#fn get_error_msg

Linux
fn get_error_msg(code int) string

get_error_msg return error code representation in string.

#fn get_file_handle

Windows
fn get_file_handle(path string) HANDLE

Ref - https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/get-osfhandle?view=vs-2019 get_file_handle retrieves the operating-system file handle that is associated with the specified file descriptor.

#fn get_line

fn get_line() string

get_line returns a one-line string from stdin

#fn get_lines

fn get_lines() []string

get_lines returns an array of strings read from from stdin.

reading is stopped when an empty line is read.

#fn get_lines_joined

fn get_lines_joined() string

get_lines_joined returns a string of the values read from from stdin.

reading is stopped when an empty line is read.

#fn get_module_filename

Windows
fn get_module_filename(handle HANDLE) !string

Ref - https://docs.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-getmodulefilenamea get_module_filename retrieves the fully qualified path for the file that contains the specified module.

The module must have been loaded by the current process.

#fn get_raw_line

JavaScript
fn get_raw_line() string

#fn get_raw_line

fn get_raw_line() string

get_raw_line returns a one-line string from stdin along with '\n' if there is any.

#fn get_raw_lines_joined

fn get_raw_lines_joined() string

get_raw_lines_joined reads all input lines from stdin.

It returns them as one large string. Note: unlike os.get_lines_joined, empty lines (that contain only \r\n or \n), will be present in the output.

Reading is stopped, only on EOF of stdin.

#fn get_raw_stdin

fn get_raw_stdin() []u8

get_raw_stdin will get the raw input from stdin.

#fn getegid

Windowsinline
fn getegid() int

#fn getegid

Linuxinline
fn getegid() int

#fn getenv

JavaScript
fn getenv(key string) string

getenv returns the value of the environment variable named by the key.

#fn getenv

fn getenv(key string) string

getenv returns the value of the environment variable named by the key.

If there is not one found, it returns an empty string ''.

#fn getenv_opt

JavaScript
fn getenv_opt(key string) ?string

getenv_opt returns the value of the environment variable named by the key.

If such an environment variable does not exist, then it returns none.

#fn getenv_opt

manualfree
fn getenv_opt(key string) ?string

getenv_opt returns the value of the environment variable named by the key If there is not one found, it returns none.

#fn geteuid

Windowsinline
fn geteuid() int

#fn geteuid

Linuxinline
fn geteuid() int

#fn getgid

Windowsinline
fn getgid() int

#fn getgid

Linuxinline
fn getgid() int

#fn getpid

Windowsinline
fn getpid() int

#fn getpid

Linuxinline
fn getpid() int

#fn getpid

JavaScript
fn getpid() int

#fn getppid

Windowsinline
fn getppid() int

#fn getppid

Linuxinline
fn getppid() int

#fn getuid

Windowsinline
fn getuid() int

#fn getuid

Linuxinline
fn getuid() int

#fn getuid

JavaScript
fn getuid() int

#fn getwd

JavaScript
fn getwd() string

#fn getwd

manualfree
fn getwd() string

getwd returns the absolute path of the current directory.

#fn glob

JavaScript
fn glob(patterns []string) ![]string

#fn glob

fn glob(patterns []string) ![]string

#fn home_dir

fn home_dir() string

home_dir returns path to the user's home directory.

#fn home_dir

JavaScript
fn home_dir() string

#fn hostname

Windows
fn hostname() !string

#fn hostname

Linux
fn hostname() !string

#fn inode

fn inode(path string) FileMode

inode returns the mode of the file/inode containing inode type and permission information it supports windows for regular files but it doesn't matter if you use owner, group or others when checking permissions on windows

#fn input

fn input(prompt string) string

input returns a one-line string from stdin, after printing a prompt.

In the event of error (end of input), it returns ''.

#fn input_opt

fn input_opt(prompt string) ?string

input_opt returns a one-line string from stdin, after printing a prompt.

In the event of error (end of input), it returns none.

#fn input_password

Windows
fn input_password(prompt string) !string

input_password prompts the user for a password-like secret. It disables the terminal echo during user input and resets it back to normal when done.

#fn input_password

Linux
fn input_password(prompt string) !string

input_password prompts the user for a password-like secret. It disables the terminal echo during user input and resets it back to normal when done.

#fn is_abs_path

fn is_abs_path(path string) bool

is_abs_path returns true if the given path is absolute.

#fn is_atty

JavaScript
fn is_atty(fd int) int

#fn is_atty

fn is_atty(fd int) int

is_atty returns 1 if the fd file descriptor is open and refers to a terminal

#fn is_dir

JavaScript
fn is_dir(path string) bool

#fn is_dir

fn is_dir(path string) bool

is_dir returns a bool indicating whether the given path is a directory.

#fn is_dir_empty

manualfree
fn is_dir_empty(path string) bool

is_dir_empty will return a bool whether or not path is empty.

Note that it will return true if path does not exist.

#fn is_executable

JavaScript
fn is_executable(path string) bool

#fn is_executable

fn is_executable(path string) bool

is_executable returns true if path is executable.

Warning: is_executable is known to cause a TOCTOU vulnerability when used incorrectly (for more information: https://github.com/vlang/v/blob/master/vlib/os/README.md)

#fn is_file

fn is_file(path string) bool

is_file returns a bool indicating whether the given path is a file.

#fn is_readable

JavaScript
fn is_readable(path string) bool

#fn is_readable

manualfree
fn is_readable(path string) bool

is_readable returns true if path is readable.

Warning: is_readable is known to cause a TOCTOU vulnerability when used incorrectly (for more information: https://github.com/vlang/v/blob/master/vlib/os/README.md)

#fn is_writable

manualfree
fn is_writable(path string) bool

is_writable returns true if path is writable.

Warning: is_writable is known to cause a TOCTOU vulnerability when used incorrectly (for more information: https://github.com/vlang/v/blob/master/vlib/os/README.md)

#fn is_writable_folder

deprecated:use os.ensure_folder_is_writable instead
fn is_writable_folder(folder string) !bool

#fn join_path

manualfree
fn join_path(base string, dirs []string) string

join_path returns a path as string from input string parameter(s).

#fn join_path

JavaScript
fn join_path(base string, dirs []string) string

join_path returns a path as string from input string parameter(s).

#fn join_path_single

manualfree
fn join_path_single(base string, elem string) string

join_path_single appends the elem after base, using a platform specific path_separator.

#fn join_path_single

JavaScript
fn join_path_single(base string, elem string) string

#fn last_error

fn last_error() IError

#fn log

fn log(s string)

log will print "os.log: "+s ...

#fn loginname

Windows
fn loginname() !string

#fn loginname

Linux
fn loginname() !string

#fn ls

Windows
fn ls(path string) ![]string

#fn ls

Linux
fn ls(path string) ![]string

#fn ls

JavaScript
fn ls(path string) ![]string

#fn mkdir

Windows
fn mkdir(path string, params MkdirParams) !

mkdir creates a new directory with the specified path.

#fn mkdir

Linux
fn mkdir(path string, params MkdirParams) !

mkdir creates a new directory with the specified path.

#fn mkdir

JavaScript
fn mkdir(path string, params MkdirParams) !

#fn mkdir_all

fn mkdir_all(opath string, params MkdirParams) !

mkdir_all will create a valid full path of all directories given in path.

#fn mv

fn mv(source string, target string) !

mv moves files or folders from src to dst.

#fn mv_by_cp

fn mv_by_cp(source string, target string) !

mv_by_cp first copies the source file, and if it is copied successfully, deletes the source file.

may be used when you are not sure that the source and target are on the same mount/partition.

#fn norm_path

direct_array_access
fn norm_path(path string) string

norm_path returns the normalized version of the given path by resolving backlinks (..), turning forward slashes into back slashes on a Windows system and eliminating:

  • references to current directories (.)

  • redundant path separators

  • the last path separator

#fn open

JavaScript
fn open(path string) !File

open tries to open a file for reading and returns back a read-only File object.

#fn open

fn open(path string) !File

open tries to open a file for reading and returns back a read-only File object.

#fn open_append

fn open_append(path string) !File

open_append opens path file for appending.

#fn open_file

JavaScript
fn open_file(path string, mode string, options []int) !File

#fn open_file

fn open_file(path string, mode string, options []int) !File

open_file can be used to open or create a file with custom flags and permissions and returns a File object.

#fn open_uri

Windows
fn open_uri(uri string) !

#fn open_uri

fn open_uri(uri string) !

#fn posix_get_error_msg

fn posix_get_error_msg(code int) string

posix_get_error_msg return error code representation in string.

#fn posix_set_permission_bit

Windows
fn posix_set_permission_bit(path_s string, mode u32, enable bool)

#fn posix_set_permission_bit

Linux
fn posix_set_permission_bit(path_s string, mode u32, enable bool)

Turns the given bit on or off, depending on the enable parameter

#fn quoted_path

fn quoted_path(path string) string

quoted path - return a quoted version of the path, depending on the platform.

#fn raw_execute

Windowsunsafe
fn raw_execute(cmd string) Result

raw_execute starts the specified command, waits for it to complete, and returns its output.

It's marked as unsafe to help emphasize the problems that may arise by allowing, for example, user provided escape sequences.

#fn raw_execute

Linuxunsafe
fn raw_execute(cmd string) Result

raw_execute does the same as execute on Unix platforms.

On Windows raw_execute starts the specified command, waits for it to complete, and returns its output.

It's marked as unsafe to help emphasize the problems that may arise by allowing, for example, user provided escape sequences.

#fn read_apk_asset

Termux
fn read_apk_asset(path string) ![]u8

read_apk_asset returns all the data located at path.

path is expected to be relative to the APK/AAB assets directory.

#fn read_bytes

manualfree
fn read_bytes(path string) ![]u8

read_bytes returns all bytes read from file in path.

#fn read_file

JavaScript
fn read_file(s string) !string

#fn read_file

manualfree
fn read_file(path string) !string

read_file reads the file in path and returns the contents.

#fn read_file_array[T]

fn read_file_array[T](path string) []T

read_file_array reads an array of T values from file path.

#fn read_lines

manualfree
fn read_lines(path string) ![]string

read_lines reads the file in path into an array of lines.

#fn real_path

JavaScript
fn real_path(fpath string) string

real_path returns the full absolute path for fpath, with all relative ../../, symlinks and so on resolved.

See http://pubs.opengroup.org/onlinepubs/9699919799/functions/realpath.html Also https://insanecoding.blogspot.com/2007/11/pathmax-simply-isnt.html and https://insanecoding.blogspot.com/2007/11/implementing-realpath-in-c.html Note: this particular rabbit hole is deep ...

#fn real_path

manualfree
fn real_path(fpath string) string

real_path returns the full absolute path for fpath, with all relative ../../, symlinks and so on resolved.

See http://pubs.opengroup.org/onlinepubs/9699919799/functions/realpath.html Also https://insanecoding.blogspot.com/2007/11/pathmax-simply-isnt.html and https://insanecoding.blogspot.com/2007/11/implementing-realpath-in-c.html Note: this particular rabbit hole is deep ...

#fn rename

JavaScript
fn rename(src string, dst string) !

#fn rename

fn rename(src string, dst string) !

rename renames the file or folder from src to dst.

Use mv to move or rename a file in a platform independent manner.

#fn rename_dir

fn rename_dir(src string, dst string) !

rename_dir renames the folder from src to dst.

Use mv to move or rename a file in a platform independent manner.

#fn resource_abs_path

manualfree
fn resource_abs_path(path string) string

resource_abs_path returns an absolute path, for the given path.

(the path is expected to be relative to the executable program) See https://discordapp.com/channels/592103645835821068/592294828432424960/630806741373943808 It gives a convenient way to access program resources like images, fonts, sounds and so on, no matter how the program was started, and what is the current working directory.

#fn rm

JavaScript
fn rm(path string) !

#fn rm

fn rm(path string) !

rm removes file in path.

#fn rmdir

JavaScript
fn rmdir(path string) !

#fn rmdir

fn rmdir(path string) !

rmdir removes a specified directory.

#fn rmdir_all

fn rmdir_all(path string) !

rmdir_all recursively removes the specified directory.

#fn setenv

JavaScript
fn setenv(key string, val string, overwrite bool)

setenv sets the value of an environment variable with name to value.

#fn setenv

fn setenv(name string, value string, overwrite bool) int

os.setenv sets the value of an environment variable with name to value.

#fn sigint_to_signal_name

fn sigint_to_signal_name(si int) string

sigint_to_signal_name will translate si signal integer code to it's string code representation.

#fn signal_opt

JavaScript
fn signal_opt(signum Signal, handler fn (Signal)) !fn (Signal)

signal will assign handler callback to be called when signum signal is received.

Behaviour on different backends:

  • NodeJS: Will use process.on and add handler to the listeners list for signum to happen

  • Browser: Will use window.addEventListener for handling signal

TODO: Add signal events implementation for browser backend

#fn signal_opt

fn signal_opt(signum Signal, handler fn (Signal)) !fn (Signal)

signal will assign handler callback to be called when signum signal is received.

#fn stderr

JavaScript
fn stderr() File

#fn stderr

fn stderr() File

stderr - return an os.File for stderr

#fn stdin

JavaScript
fn stdin() File

#fn stdin

fn stdin() File

stdin - return an os.File for stdin

#fn stdin_resume

JavaScript
fn stdin_resume()

#fn stdout

JavaScript
fn stdout() File

#fn stdout

fn stdout() File

stdout - return an os.File for stdout

#fn system

JavaScript
fn system(cmd string) int

#fn system

fn system(cmd string) int

system works like exec, but only returns a return code.

#fn temp_dir

fn temp_dir() string

temp_dir returns the path to a folder, that is suitable for storing temporary files.

#fn temp_dir

JavaScript
fn temp_dir() string

#fn to_slash

fn to_slash(path string) string

to_slash returns the result of replacing each separator character in path with a slash (/).

#fn truncate

fn truncate(path string, len u64) !

***************************** OS ops ************************

truncate changes the size of the file located in path to len.

Note that changing symbolic links on Windows only works as admin.

#fn uname

Windows
fn uname() Uname

uname returns information about the platform on which the program is running.

Currently uname on windows is not standardized, so it just mimics current practices from other popular software/language implementations:

busybox-v1.35.0 * busybox uname -a => "Windows_NT HOSTNAME 10.0 19044 x86_64 MS/Windows" rust/coreutils-v0.0.17 * coreutils uname -a => Windows_NT HOSTNAME 10.0 19044 x86_64 MS/Windows (Windows 10) Python3 => uname_result(system='Windows', node='HOSTNAME', release='10', version='10.0.19044', machine='AMD64') See: NT Version Info @@ https://archive.is/GnnvF and: NT Version Info (detailed)

#fn uname

Linux
fn uname() Uname

uname returns information about the platform on which the program is running For example:

os.Uname{ sysname: 'Linux' nodename: 'nemesis' release: '5.15.0-57-generic' version: '#63~20.04.1-Ubuntu SMP Wed Nov 30 13:40:16 UTC 2022' machine: 'x86_64' } where the fields have the following meaning:

sysname is the name of this implementation of the operating system nodename is the name of this node within an implementation-dependent communications network release is the current release level of this implementation version is the current version level of this release machine is the name of the hardware type, on which the system is running See also https://pubs.opengroup.org/onlinepubs/7908799/xsh/sysutsname.h.html

#fn unsetenv

JavaScript
fn unsetenv(name string) int

unsetenv clears an environment variable with name.

#fn unsetenv

fn unsetenv(name string) int

os.unsetenv clears an environment variable with name.

#fn user_names

fn user_names() ![]string

user_names returns an array of the name of every user on the system.

#fn user_os

fn user_os() string

user_os returns current user operating system name.

#fn utime

Windows
fn utime(path string, actime int, modtime int) !

#fn utime

Linux
fn utime(path string, actime int, modtime int) !

#fn vfopen

fn vfopen(path string, mode string) !&C.FILE

vfopen returns an opened C file, given its path and open mode.

Note: os.vfopen is useful for compatibility with C libraries, that expect FILE *.

If you write pure V code, os.create or os.open are more convenient.

#fn vmodules_dir

fn vmodules_dir() string

vmodules_dir returns the path to a folder, where v stores its global modules.

#fn vmodules_paths

fn vmodules_paths() []string

vmodules_paths returns a list of paths, where v looks up for modules.

You can customize it through setting the environment variable VMODULES [manualfree]

#fn vtmp_dir

fn vtmp_dir() string

vtmp_dir returns the path to a folder, that is writable to V programs, and specific to the OS user. It can be overridden by setting the env variable VTMP.

#fn wait

fn wait() int

wait blocks the calling process until one of its child processes exits or a signal is received.

After child process terminates, parent continues its execution after wait system call instruction.

#fn walk

fn walk(path string, f fn (string))

walk traverses the given directory path.

When a file is encountred, it will call the callback f with current file as argument.

Note: walk can be called even for deeply nested folders, since it does not recurse, but processes them iteratively.

#fn walk_ext

fn walk_ext(path string, ext string) []string

walk_ext returns a recursive list of all files in path ending with ext.

#fn walk_with_context

fn walk_with_context(path string, context voidptr, fcb fn (voidptr, string))

walk_with_context traverses the given directory path.

For each encountred file and directory, it will call your fcb callback, passing it the arbitrary context in its first parameter, and the path to the file in its second parameter.

Note: walk_with_context can be called even for deeply nested folders, since it does not recurse, but processes them iteratively.

#fn windows_volume

fn windows_volume(path string) string

windows_volume returns the volume name from the given path on a Windows system.

An empty string is returned if no Windows volume is present.

Examples (on a Windows system):

 assert os.windows_volume(r'C:\path\to\file.v') == 'C:'
 assert os.windows_volume('D:') == 'D:'
 assert os.windows_volume(r'\\Host\share\files\file.v') == r'\\Host\share'

#fn write_file

fn write_file(path string, text string) !

write_file writes text data to the file in path.

If path exists, the contents of path will be overwritten with the contents of text.

#fn write_file_array

JavaScript
fn write_file_array(path string, buffer array) !

#fn write_file_array

fn write_file_array(path string, buffer array) !

write_file_array writes the data in buffer to a file in path.

Structs

#struct Eof

pub struct Eof {
	Error
}

/ Eof error means that we reach the end of the file.

#struct NotExpected

pub struct NotExpected {
	cause string
	code  int
}

NotExpected is a generic error that means that we receave a not expecte error.

#fn (NotExpected) msg

fn (err NotExpected) msg() string

#fn (NotExpected) code

fn (err NotExpected) code() int

#struct File

pub struct File {
mut:
	cfile voidptr // Using void* instead of FILE*
pub:
	fd int
pub mut:
	is_opened bool
}

#fn (&File) eof

fn (f &File) eof() bool

eof returns true, when the end of file has been reached

#fn (&File) reopen

fn (mut f &File) reopen(path string, mode string) !

reopen allows a File to be reused. It is mostly useful for reopening standard input and output.

#fn (&File) read

fn (f &File) read(mut buf &[]u8) !int

read implements the Reader interface.

#fn (&File) write

fn (mut f &File) write(buf []u8) !int

**************************** Write ops *************************** write implements the Writer interface.

It returns how many bytes were actually written.

#fn (&File) writeln

fn (mut f &File) writeln(s string) !int

writeln writes the string s into the file, and appends a \n character.

It returns how many bytes were written, including the \n character.

#fn (&File) write_string

fn (mut f &File) write_string(s string) !int

write_string writes the string s into the file It returns how many bytes were actually written.

#fn (&File) write_to

fn (mut f &File) write_to(pos u64, buf []u8) !int

write_to implements the RandomWriter interface.

It returns how many bytes were actually written.

It resets the seek position to the end of the file.

#fn (&File) write_ptr

unsafe
fn (mut f &File) write_ptr(data voidptr, size int) int

write_ptr writes size bytes to the file, starting from the address in data.

Note: write_ptr is unsafe and should be used carefully, since if you pass invalid pointers to it, it will cause your programs to segfault.

#fn (&File) write_full_buffer

unsafe
fn (mut f &File) write_full_buffer(buffer voidptr, buffer_len usize) !

write_full_buffer writes a whole buffer of data to the file, starting from the address in buffer, no matter how many tries/partial writes it would take.

#fn (&File) write_ptr_at

unsafe
fn (mut f &File) write_ptr_at(data voidptr, size int, pos u64) int

write_ptr_at writes size bytes to the file, starting from the address in data, at byte offset pos, counting from the start of the file (pos 0).

Note: write_ptr_at is unsafe and should be used carefully, since if you pass invalid pointers to it, it will cause your programs to segfault.

#fn (&File) read_bytes

fn (f &File) read_bytes(size int) []u8

read_bytes reads bytes from the beginning of the file.

Utility method, same as .read_bytes_at(size, 0).

#fn (&File) read_bytes_at

fn (f &File) read_bytes_at(size int, pos u64) []u8

read_bytes_at reads size bytes at the given position in the file.

#fn (&File) read_bytes_into_newline

fn (f &File) read_bytes_into_newline(mut buf &[]u8) !int

read_bytes_into_newline reads from the beginning of the file into the provided buffer.

Each consecutive call on the same file continues reading where it previously ended.

A read call is either stopped, if the buffer is full, a newline was read or EOF.

#fn (&File) read_bytes_into

fn (f &File) read_bytes_into(pos u64, mut buf &[]u8) !int

read_bytes_into fills buf with bytes at the given position in the file.

buf must have length greater than zero.

Returns the number of read bytes, or an error.

#fn (&File) read_from

fn (f &File) read_from(pos u64, mut buf &[]u8) !int

read_from implements the RandomReader interface.

#fn (&File) read_into_ptr

fn (f &File) read_into_ptr(ptr &u8, max_size int) !int

read_into_ptr reads at most max_size bytes from the file and writes it into ptr.

Returns the amount of bytes read or an error.

#fn (&File) flush

fn (mut f &File) flush()

**************************** Utility ops *********************** flush writes any buffered unwritten data left in the file stream.

#fn (&File) read_struct[T]

fn (mut f &File) read_struct(mut t &T) !

read_struct reads a single struct of type T

#fn (&File) read_struct_at[T]

fn (mut f &File) read_struct_at(mut t &T, pos u64) !

read_struct_at reads a single struct of type T at position specified in file

#fn (&File) read_raw[T]

fn (mut f &File) read_raw() !T

read_raw reads and returns a single instance of type T

#fn (&File) read_raw_at[T]

fn (mut f &File) read_raw_at(pos u64) !T

read_raw_at reads and returns a single instance of type T starting at file byte offset pos

#fn (&File) write_struct[T]

fn (mut f &File) write_struct(t &T) !

write_struct writes a single struct of type T

#fn (&File) write_struct_at[T]

fn (mut f &File) write_struct_at(t &T, pos u64) !

write_struct_at writes a single struct of type T at position specified in file

#fn (&File) write_raw[T]

fn (mut f &File) write_raw(t &T) !

write_raw writes a single instance of type T

#fn (&File) write_raw_at[T]

fn (mut f &File) write_raw_at(t &T, pos u64) !

write_raw_at writes a single instance of type T starting at file byte offset pos

#fn (&File) seek

fn (mut f &File) seek(pos i64, mode SeekMode) !

seek moves the file cursor (if any) associated with a file to a new location, offset pos bytes from the origin. The origin is dependent on the mode and can be:

.start -> the origin is the start of the file .current -> the current position/cursor in the file .end -> the end of the file If the file is not seek-able, or an error occures, the error will be returned to the caller.

A successful call to the fseek() function clears the end-of-file indicator for the file.

#fn (&File) tell

fn (f &File) tell() !i64

tell will return the current offset of the file cursor measured from the start of the file, in bytes. It is complementary to seek, i.e.

you can use the return value as the pos parameter to .seek( pos, .start ), so that your next read will happen from the same place.

#fn (&File) close

JavaScript
fn (mut f &File) close()

#fn (&File) write_array

JavaScript
fn (mut f &File) write_array(buffer array) !int

#struct FileNotOpenedError

pub struct FileNotOpenedError {
	Error
}

#struct SizeOfTypeIs0Error

pub struct SizeOfTypeIs0Error {
	Error
}

#struct FileMode

pub struct FileMode {
pub:
	typ    FileType
	owner  FilePermission
	group  FilePermission
	others FilePermission
}

#fn (FileMode) bitmask

fn (m FileMode) bitmask() u32

bitmask returns a 9 bit sequence in the order owner + group + others.

This is a valid bitmask to use with chmod.

#struct Result

pub struct Result {
pub:
	exit_code int
	output    string
	// stderr string // TODO
}

#fn (&Result) free

unsafe
fn (mut result &Result) free()

#struct Command

pub struct Command {
mut:
	f voidptr
pub mut:
	eof       bool
	exit_code int
pub:
	path            string
	redirect_stdout bool
}

#fn (&Command) start

Linuxmanualfree
fn (mut c &Command) start() !

#fn (&Command) read_line

Linuxmanualfree
fn (mut c &Command) read_line() string

#fn (&Command) close

Linux
fn (mut c &Command) close() !

#struct ExecutableNotFoundError

pub struct ExecutableNotFoundError {
	Error
}

#struct MkdirParams

params
pub struct MkdirParams {
	mode u32 = 0o777 // note that the actual mode is affected by the process's umask
}

#struct Uname

pub struct Uname {
pub mut:
	sysname  string
	nodename string
	release  string
	version  string
	machine  string
}

#struct C.stat

pub struct C.stat {
	st_size  u64
	st_mode  u32
	st_mtime int
}

#struct C.stat

Linux
pub struct C.stat {
	st_dev     u64 // 8
	st_ino     u64 // 8
	st_nlink   u64 // 8
	st_mode    u32 // 4
	st_uid     u32 // 4
	st_gid     u32 // 4
	st_rdev    u64 // 8
	st_size    u64 // 8
	st_blksize u64 // 8
	st_blocks  u64 // 8
	st_atime   i64 // 8
	st_mtime   i64 // 8
	st_ctime   i64 // 8
}

#struct ExceptionRecord

Windows
pub struct ExceptionRecord {
pub:
	// status_ constants
	code        u32
	flags       u32
	record      &ExceptionRecord = unsafe { nil }
	address     voidptr
	param_count u32
	// params []voidptr
}

#struct ContextRecord

Windows
pub struct ContextRecord {
	// TODO
}

#struct ExceptionPointers

Windows
pub struct ExceptionPointers {
pub:
	exception_record &ExceptionRecord = unsafe { nil }
	context_record   &ContextRecord   = unsafe { nil }
}

#struct Process

heap
pub struct Process {
pub mut:
	filename string // the process's command file path
	pid      int    // the PID of the process
	code     int = -1
	// the exit code of the process, != -1 *only* when status is .exited *and* the process was not aborted
	status ProcessState = .not_started
	// the current status of the process
	err              string   // if the process fails, contains the reason why
	args             []string // the arguments that the command takes
	work_folder      string   // the initial working folder of the process. When '', reuse the same folder as the parent process.
	env_is_custom    bool     // true, when the environment was customized with .set_environment
	env              []string // the environment with which the process was started  (list of 'var=val')
	use_stdio_ctl    bool     // when true, then you can use p.stdin_write(), p.stdout_slurp() and p.stderr_slurp()
	use_pgroup       bool     // when true, the process will create a new process group, enabling .signal_pgkill()
	stdio_fd         [3]int   // the stdio file descriptors for the child process, used only by the nix implementation
	wdata            voidptr  // the WProcess; used only by the windows implementation
	create_no_window bool     // sets a value indicating whether to start the process in a new window, The default is false; used only by the windows implementation
}

#fn new_process

JavaScript
fn new_process(filename string) &Process

#fn (&Process) signal_kill

fn (mut p &Process) signal_kill()

signal_kill - kills the process, after that it is no longer running

#fn (&Process) signal_pgkill

fn (mut p &Process) signal_pgkill()

signal_pgkill - kills the whole process group

#fn (&Process) signal_stop

fn (mut p &Process) signal_stop()

signal_stop - stops the process, you can resume it with p.signal_continue()

#fn (&Process) signal_continue

fn (mut p &Process) signal_continue()

signal_continue - tell a stopped process to continue/resume its work

#fn (&Process) wait

fn (mut p &Process) wait()

wait - wait for a process to finish.

Note: You have to call p.wait(), otherwise a finished process would get to a zombie state, and its resources will not get released fully, until its parent process exits.

Note: This call will block the calling process until the child process is finished.

#fn (&Process) close

fn (mut p &Process) close()

close - free the OS resources associated with the process.

Can be called multiple times, but will free the resources just once.

This sets the process state to .closed, which is final.

#fn (&Process) free

unsafe
fn (mut p &Process) free()

#fn (&Process) _spawn

fn (mut p &Process) _spawn() int

_spawn - should not be called directly, but only by p.run()/p.wait() .

It encapsulates the fork/execve mechanism that allows the asynchronous starting of the new child process.

#fn (&Process) is_alive

fn (mut p &Process) is_alive() bool

is_alive - query whether the process p.pid is still alive

#fn (&Process) set_redirect_stdio

fn (mut p &Process) set_redirect_stdio()

#fn (&Process) stdin_write

fn (mut p &Process) stdin_write(s string)

#fn (&Process) stdout_slurp

fn (mut p &Process) stdout_slurp() string

will read from stdout pipe, will only return when EOF (end of file) or data means this will block unless there is data

#fn (&Process) stderr_slurp

fn (mut p &Process) stderr_slurp() string

read from stderr pipe, wait for data or EOF

#fn (&Process) stdout_read

fn (mut p &Process) stdout_read() string

read from stdout, return if data or not

#fn (&Process) stderr_read

fn (mut p &Process) stderr_read() string

#fn (&Process) _check_redirection_call

fn (mut p &Process) _check_redirection_call(fn_name string)

_check_redirection_call - should be called just by stdxxx methods

#fn (&Process) _signal_stop

fn (mut p &Process) _signal_stop()

_signal_stop - should not be called directly, except by p.signal_stop

#fn (&Process) _signal_continue

fn (mut p &Process) _signal_continue()

_signal_continue - should not be called directly, just by p.signal_continue

#fn (&Process) _signal_kill

fn (mut p &Process) _signal_kill()

_signal_kill - should not be called directly, except by p.signal_kill

#fn (&Process) _signal_pgkill

fn (mut p &Process) _signal_pgkill()

_signal_pgkill - should not be called directly, except by p.signal_pgkill

#fn (&Process) _wait

fn (mut p &Process) _wait()

_wait - should not be called directly, except by p.wait()

#fn (&Process) _is_alive

fn (mut p &Process) _is_alive() bool

_is_alive - should not be called directly, except by p.is_alive()

#fn (&Process) run

fn (mut p &Process) run()

run - starts the new process

#fn (&Process) spawn_internal

JavaScript
fn (mut p &Process) spawn_internal()

#fn (&Process) wait_internal

JavaScript
fn (mut p &Process) wait_internal()

#fn (&Process) stdin_resume

JavaScript
fn (mut p &Process) stdin_resume()

#fn (&Process) check_redirection_call

JavaScript
fn (mut p &Process) check_redirection_call(fn_name string)

_check_redirection_call - should be called just by stdxxx methods

#fn (&Process) set_args

fn (mut p &Process) set_args(pargs []string)

set_args - set the arguments for the new process

#fn (&Process) set_work_folder

fn (mut p &Process) set_work_folder(path string)

set_work_folder - set the initial working folder for the new process If you do not set it, it will reuse the current working folder of the parent process.

#fn (&Process) set_environment

fn (mut p &Process) set_environment(envs map[string]string)

set_environment - set a custom environment variable mapping for the new process

#fn (&Process) unix_spawn_process

Linux
fn (mut p &Process) unix_spawn_process() int

#fn (&Process) unix_stop_process

Linux
fn (mut p &Process) unix_stop_process()

#fn (&Process) unix_resume_process

Linux
fn (mut p &Process) unix_resume_process()

#fn (&Process) unix_kill_process

Linux
fn (mut p &Process) unix_kill_process()

#fn (&Process) unix_kill_pgroup

Linux
fn (mut p &Process) unix_kill_pgroup()

#fn (&Process) unix_wait

Linux
fn (mut p &Process) unix_wait()

#fn (&Process) unix_is_alive

Linux
fn (mut p &Process) unix_is_alive() bool

#fn (&Process) win_spawn_process

Linux
fn (mut p &Process) win_spawn_process() int

these are here to make v_win.c/v.c generation work in all cases:

#fn (&Process) win_stop_process

Linux
fn (mut p &Process) win_stop_process()

#fn (&Process) win_resume_process

Linux
fn (mut p &Process) win_resume_process()

#fn (&Process) win_kill_process

Linux
fn (mut p &Process) win_kill_process()

#fn (&Process) win_kill_pgroup

Linux
fn (mut p &Process) win_kill_pgroup()

#fn (&Process) win_wait

Linux
fn (mut p &Process) win_wait()

#fn (&Process) win_is_alive

Linux
fn (mut p &Process) win_is_alive() bool

#fn (&Process) win_write_string

Linux
fn (mut p &Process) win_write_string(idx int, s string)

#fn (&Process) win_read_string

Linux
fn (mut p &Process) win_read_string(idx int, maxbytes int) (string, int)

#fn (&Process) win_slurp

Linux
fn (mut p &Process) win_slurp(idx int) string

#struct WProcess

Windows
pub struct WProcess {
pub mut:
	proc_info    ProcessInformation
	command_line [65536]u8
	child_stdin  &u32 = unsafe { nil }
	//
	child_stdout_read  &u32 = unsafe { nil }
	child_stdout_write &u32 = unsafe { nil }
	//
	child_stderr_read  &u32 = unsafe { nil }
	child_stderr_write &u32 = unsafe { nil }
}

Interfaces

This section is empty.

Enums

#enum SeekMode

pub enum SeekMode {
	start
	current
	end
}

#enum FileType

pub enum FileType {
	regular
	directory
	character_device
	block_device
	fifo
	symbolic_link
	socket
}

#enum AssetMode

Termux
pub enum AssetMode {
	buffer = C.AASSET_MODE_BUFFER // Caller plans to ask for a read-only buffer with all data.
	random = C.AASSET_MODE_RANDOM // Read chunks, and seek forward and backward.
	streaming = C.AASSET_MODE_STREAMING // Read sequentially, with an occasional forward seek.
	unknown = C.AASSET_MODE_UNKNOWN // No specific information about how data will be accessed.
}

#enum ProcessState

pub enum ProcessState {
	not_started
	running
	stopped
	exited
	aborted
	closed
}

  • ProcessState.not_started - the process has not yet started

  • ProcessState.running - the process is currently running

  • ProcessState.stopped - the process was running, but was stopped temporarily

  • ProcessState.exited - the process has finished/exited

  • ProcessState.aborted - the process was terminated by a signal

  • ProcessState.closed - the process resources like opened file descriptors were freed/discarded, final state.

#enum Signal

pub enum Signal {
	hup = 1
	int = 2
	quit = 3
	ill = 4
	trap = 5
	abrt = 6
	bus = 7
	fpe = 8
	kill = 9
	usr1 = 10
	segv = 11
	usr2 = 12
	pipe = 13
	alrm = 14
	term = 15
	stkflt = 16
	chld = 17
	cont = 18
	stop = 19
	tstp = 20
	ttin = 21
	ttou = 22
	urg = 23
	xcpu = 24
	xfsz = 25
	vtalrm = 26
	prof = 27
	winch = 28
	poll = 29
	pwr = 30
	sys = 31
}