Namespace: joker.os
v1.0Provides a platform-independent interface to operating system functionality.
Index
- args
- chdir
- close
- create
- cwd
- env
- exec
- exists?
- exit
- ls
- mkdir
- open
- remove
- remove-all
- set-env
- sh
- sh-from
- stat
-
args
Function v1.0(args)
Returns a sequence of the command line arguments, starting with the program name (normally, joker).
-
chdir
Function v1.0(chdir dirname)
Chdir changes the current working directory to the named directory. If there is an error, an exception will be thrown. Returns nil.
-
close
Function v1.0(close f)
Closes the file, rendering it unusable for I/O.
-
create
Function v1.0(create name)
Creates the named file with mode 0666 (before umask), truncating it if it already exists.
-
cwd
Function v1.0(cwd)
Returns a rooted path name corresponding to the current directory. If the current directory can
be reached via multiple paths (due to symbolic links), cwd may return any one of them. -
env
Function v1.0(env)
Returns a map representing the environment.
-
exec
Function v1.0(exec name opts)
Executes the named program with the given arguments. opts is a map with the following keys (all optional):
:args - vector of arguments (all arguments must be strings),
:dir - if specified, working directory will be set to this value before executing the program,
:stdin - if specified, provides stdin for the program. Can be either a string or an IOReader.
If it's a string, the string's content will serve as stdin for the program. IOReader can be, for example,
*in* (in which case Joker's stdin will be redirected to the program's stdin) or the value returned by (joker.os/open).
:stdout - if specified, must be an IOWriter. It can be, for example, *out* (in which case the program's stdout will be redirected
to Joker's stdout) or the value returned by (joker.os/create).
:stderr - the same as :stdout, but for stderr.
Returns a map with the following keys:
:success - whether or not the execution was successful,
:err-msg (present iff :success if false) - string capturing error object returned by Go runtime
:exit - exit code of program (or attempt to execute it),
:out - string capturing stdout of the program (unless :stdout option was passed)
:err - string capturing stderr of the program (unless :stderr option was passed). -
exists?
Function v1.0(exists? path)
Returns true if file or directory with the given path exists. Otherwise returns false.
-
exit
Function v1.0(exit code)
Causes the current program to exit with the given status code.
-
ls
Function v1.0(ls dirname)
Reads the directory named by dirname and returns a list of directory entries sorted by filename.
-
mkdir
Function v1.0(mkdir name perm)
Creates a new directory with the specified name and permission bits.
-
open
Function v1.0(open name)
Opens the named file for reading. If successful, the file can be used for reading;
the associated file descriptor has mode O_RDONLY. -
remove
Function v1.0(remove name)
Removes the named file or (empty) directory.
-
remove-all
Function v1.0(remove-all path)
Removes path and any children it contains.
It removes everything it can, then panics with the first error (if
any) it encountered. -
set-env
Function v1.0(set-env key value)
Sets the specified key to the specified value in the environment.
-
sh
Function v1.0(sh name & arguments)
Executes the named program with the given arguments. Returns a map with the following keys:
:success - whether or not the execution was successful,
:err-msg (present iff :success if false) - string capturing error object returned by Go runtime
:exit - exit code of program (or attempt to execute it),
:out - string capturing stdout of the program,
:err - string capturing stderr of the program. -
sh-from
Function v1.0(sh-from dir name & arguments)
Executes the named program with the given arguments and working directory set to dir.
Returns a map with the following keys:
:success - whether or not the execution was successful,
:err-msg (present iff :success if false) - string capturing error object returned by Go runtime
:exit - exit code of program (or attempt to execute it),
:out - string capturing stdout of the program,
:err - string capturing stderr of the program. -
stat
Function v1.0(stat filename)
Returns a map describing the named file. The info map has the following attributes:
:name - base name of the file
:size - length in bytes for regular files; system-dependent for others
:mode - file mode bits
:modtime - modification time
:dir? - true if file is a directory