Os
This package provides an interface for operating systems.
{ "type": "system"}Install
Section titled “Install”{ "dependencies": { "Os": "pen:///os" }}Os'Context module
Section titled “Os'Context module”Context
Section titled “Context”A context of an operating system.
type Context = context'ContextFunctions
Section titled “Functions”No functions are defined.
Os'Directory module
Section titled “Os'Directory module”No types are defined.
Functions
Section titled “Functions”Read a directory and return file paths it contains.
\(ctx Context, path string) [string] | errorCreate
Section titled “Create”Create a directory.
\(ctx Context, path string) none | errorRemove
Section titled “Remove”Remove a directory.
\(ctx Context, path string) none | errorOs'Environment module
Section titled “Os'Environment module”No types are defined.
Functions
Section titled “Functions”Arguments
Section titled “Arguments”Get command line arguments.
\(ctx Context) [string]Variable
Section titled “Variable”Get an environment variable.
\(ctx Context, name string) string | errorOs'File module
Section titled “Os'File module”A file on a file system.
type File { # ...}Functions
Section titled “Functions”A file of standard input.
\() FileStdOut
Section titled “StdOut”A file of standard output.
\() FileStdErr
Section titled “StdErr”A file of standard error.
\() FileOpen a file for read-only.
\(ctx Context, path string) File | errorOpenWithOptions
Section titled “OpenWithOptions”Open a file with options.
\(ctx Context, path string, opt OpenOptions) File | errorRead a file.
\(ctx Context, file File) string | errorReadLimit
Section titled “ReadLimit”Read a file until a size limit.
\(ctx Context, file File, limit number) string | errorWrite data to a file.
\(ctx Context, file File, data string) number | errorCopy a file to another path.
\(ctx Context, src string, dest string) none | errorMove a file to another path.
\(ctx Context, src string, dest string) none | errorRemove
Section titled “Remove”Remove a file.
\(ctx Context, path string) none | errorMetadata
Section titled “Metadata”Get metadata of a file at a path.
\(ctx Context, path string) Metadata | errorOs'File'Metadata module
Section titled “Os'File'Metadata module”Metadata
Section titled “Metadata”File metadata
type Metadata { Size number}Functions
Section titled “Functions”No functions are defined.
Os'File'OpenOptions module
Section titled “Os'File'OpenOptions module”OpenOptions
Section titled “OpenOptions”Options to open a file
Appendallows appending data to the file.Createcreates a new file if the file doesn’t exist or opens it otherwise.CreateNewcreates a new file. If the file already exists, it emits an error.Readallows reading data from the file.Truncatetruncates the file to zero byte.Writeallows writing data to the file.
type OpenOptions { Append boolean Create boolean CreateNew boolean Read boolean Truncate boolean Write boolean}Functions
Section titled “Functions”Default
Section titled “Default”Get default options to open a file. They do not include any permission.
\() OpenOptionsOs'Process module
Section titled “Os'Process module”No types are defined.
Functions
Section titled “Functions”Exit a current process.
\(ctx Context, code number) noneRun a command.
\(ctx Context, cmd string, args [string]) none | errorOs'Tcp module
Section titled “Os'Tcp module”No types are defined.
Functions
Section titled “Functions”Create a listener bound to a server address.
\(ctx Context, address string) Listener | errorConnect
Section titled “Connect”Create a stream connected to a peer address.
\(ctx Context, address string) Stream | errorAccept
Section titled “Accept”Accept a client connection and create its stream.
\(ctx Context, l Listener) AcceptedStream | errorReceive
Section titled “Receive”Receive data from a peer through a stream with a size limit in bytes.
\(ctx Context, s Stream, limit number) string | errorSend data to a peer through a stream.
\(ctx Context, s Stream, data string) number | errorOs'Tcp'AcceptedStream module
Section titled “Os'Tcp'AcceptedStream module”AcceptedStream
Section titled “AcceptedStream”A TCP stream accepted on a server with a client address
type AcceptedStream { Stream Stream Address string}Functions
Section titled “Functions”No functions are defined.
Os'Tcp'Listener module
Section titled “Os'Tcp'Listener module”Listener
Section titled “Listener”A TCP listener to listen for client connections
type Listener { # ...}Functions
Section titled “Functions”No functions are defined.
Os'Tcp'Stream module
Section titled “Os'Tcp'Stream module”Stream
Section titled “Stream”A TCP stream
type Stream { # ...}Functions
Section titled “Functions”No functions are defined.
Os'Time module
Section titled “Os'Time module”No types are defined.
Functions
Section titled “Functions”Fetch a current system time in milliseconds.
\(ctx Context) numberPause a current execution context for a given amount of time.
\(ctx Context, milliseconds number) noneOs'Udp module
Section titled “Os'Udp module”No types are defined.
Functions
Section titled “Functions”Bind a socket with a server address.
\(ctx Context, address string) Socket | errorConnect
Section titled “Connect”Connect a socket to a peer address.
\(ctx Context, s Socket, address string) none | errorReceive
Section titled “Receive”Receive a datagram from a connected address.
\(ctx Context, s Socket) string | errorReceiveFrom
Section titled “ReceiveFrom”Receive a datagram from any address.
\(ctx Context, s Socket) Datagram | errorSend a datagram to a connected address.
\(ctx Context, s Socket, data string) number | errorSendTo
Section titled “SendTo”Send a datagram to a specified address.
\(ctx Context, s Socket, data string, address string) number | errorOs'Udp'Datagram module
Section titled “Os'Udp'Datagram module”Datagram
Section titled “Datagram”UDP datagram
type Datagram { Data string Address string}Functions
Section titled “Functions”No functions are defined.
Os'Udp'Socket module
Section titled “Os'Udp'Socket module”Socket
Section titled “Socket”UDP socket
type Socket { # ...}Functions
Section titled “Functions”No functions are defined.