os

package
v0.36.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 28, 2024 License: ISC Imports: 10 Imported by: 0

Documentation

Overview

Package os provides variadic function definitions for IO/OS builtins.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFileReader added in v0.25.0

func NewFileReader(f *os.File) goal.V

NewFileReader returns a buffered reader handle for the given file.

func NewFileWriter added in v0.25.0

func NewFileWriter(f *os.File) goal.V

NewFileWriter returns a buffered writer handle for the given file.

func VFChdir added in v0.10.0

func VFChdir(ctx *goal.Context, args []goal.V) goal.V

VFChdir implements the chdir monad.

chdir s : change current directory to s, or return an error.

It returns a true value on success.

func VFClose added in v0.10.0

func VFClose(ctx *goal.Context, args []goal.V) goal.V

VFClose implements the close monad.

close h : flush any buffered data, then close handle.

It returns a true value on success, and an error otherwise.

func VFEnv added in v0.10.0

func VFEnv(ctx *goal.Context, args []goal.V) goal.V

VFEnv implements the env dyad.

env s : retrieve environment variable s, or return an error if unset. As a special case, "" returns a dictionary representing the whole environment.

x env s : sets the value of the environment variable x to s. It returns a true value of success, and an error otherwise. Also, the special form env[x;0] unsets a variable, and as a special case, env["";0] clears the whole environment.

func VFFlush added in v0.10.0

func VFFlush(ctx *goal.Context, args []goal.V) goal.V

VFFlush implements the flush monad.

flush h : flushes any buffered data for handle.

It returns a true value on success, and an error otherwise.

func VFImport added in v0.10.0

func VFImport(ctx *goal.Context, args []goal.V) goal.V

VFImport implements the import dyad.

import s : read/eval wrapper roughly equivalent to eval[read path;path;pfx] where 1) path~s or path~env["GOALLIB"]+s+".goal" 2) pfx is path's basename without extension.

x import s : same as import s but use prefix x for globals. If x is empty, no prefix is used.

It returns 0 and does nothing if a file has already been evaluated.

func VFMkdir added in v0.25.0

func VFMkdir(ctx *goal.Context, args []goal.V) goal.V

VFMkdir implements the mkdir monad.

mkdir s : create directory s or return an error.

It returns the number of directories created, or an error.

func VFOpen added in v0.10.0

func VFOpen(ctx *goal.Context, args []goal.V) goal.V

VFOpen implements the open dyad.

open "path" : opens file "path" for reading.

x open "path" : opens file "path" using the given fopen(3) mode x.

x can be: "r", "w", "a", "|-", "-|". In the last two modes, the path is instead interpreted as a command, and can be a list of strings.

It returns a filehandle value of type "h" on success, and an error otherwise.

func VFPrint added in v0.10.0

func VFPrint(ctx *goal.Context, args []goal.V) goal.V

VFPrint implements the print dyad.

print x : outputs x to standard output. It returns a true value on success. It uses implicit conversion to string for non-string inputs.

x print y : outputs y to x, where x is an io.Writer handle or a filename (goal.S).

func VFRead added in v0.10.0

func VFRead(ctx *goal.Context, args []goal.V) goal.V

VFRead implements the read dyad.

read h : reads from handle h until EOF or an error occurs.

read s : reads file into string or directory into dictionary with keys "dir""mtime""size".

s read h : reads from handle h until delimiter s or EOF, or an error occurs.

i read h : reads i bytes from handle h until EOF (returning possibly less than i bytes) or an error occurs.

It returns the read content as a string on success, and an error otherwise.

func VFRemove added in v0.25.0

func VFRemove(ctx *goal.Context, args []goal.V) goal.V

VFRemove implements the remove monad.

remove s : remove the named file or empty directory.

It returns the number of files removed, or an error.

func VFRename added in v0.25.0

func VFRename(ctx *goal.Context, args []goal.V) goal.V

VFRename implements the rename dyad.

rename[old;new] : rename path old to new.

It returns a true value on success, and an error otherwise.

func VFRun added in v0.10.0

func VFRun(ctx *goal.Context, args []goal.V) goal.V

VFRun implements the run monad.

run s : run command s, with arguments if s is an array.

x run s : run command s, with input string x as standard input.

In the first form, standard input and error are inherited from the parent. In the second form, only standard error is inherited. Both commands return their own standard output, or an error.

func VFSay added in v0.10.0

func VFSay(ctx *goal.Context, args []goal.V) goal.V

VFSay implements the say dyad. It is the same as print, but appends a newline to the result.

func VFShell added in v0.10.0

func VFShell(ctx *goal.Context, args []goal.V) goal.V

VFShell implements the shell dyad. It works like the run dyad, but runs a single string command through /bin/sh instead.

func VFStat added in v0.25.0

func VFStat(ctx *goal.Context, args []goal.V) goal.V

VFStat implements the stat monad.

stat x : return dict "size""mode""mtime"!(i;i;i) for path or filehandle.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL