Os package
This package provides an interface for operating systems.
{
"type": "system"
}
Install
{
"dependencies": {
"Os": "pen:///os"
}
}
Os'Context module
Types
Context
A context of an operating system.
type Context = context'Context
Functions
No functions are defined.
Os'Directory module
Types
No types are defined.
Functions
Read
Read a directory and return file paths it contains.
\(ctx Context, path string) [string] | error
Create
Create a directory.
\(ctx Context, path string) none | error
Remove
Remove a directory.
\(ctx Context, path string) none | error
Os'Environment module
Types
No types are defined.
Functions
Arguments
Get command line arguments.
\(ctx Context) [string]
Variable
Get an environment variable.
\(ctx Context, name string) string | error
Os'File module
Types
File
A file on a file system.
type File {
# ...
}
Functions
StdIn
A file of standard input.
\() File
StdOut
A file of standard output.
\() File
StdErr
A file of standard error.
\() File
Open
Open a file for read-only.
\(ctx Context, path string) File | error
OpenWithOptions
Open a file with options.
\(ctx Context, path string, opt OpenOptions) File | error
Read
Read a file.
\(ctx Context, file File) string | error
ReadLimit
Read a file until a size limit.
\(ctx Context, file File, limit number) string | error
Write
Write data to a file.
\(ctx Context, file File, data string) number | error
Copy
Copy a file to another path.
\(ctx Context, src string, dest string) none | error
Move
Move a file to another path.
\(ctx Context, src string, dest string) none | error
Remove
Remove a file.
\(ctx Context, path string) none | error
Metadata
Get metadata of a file at a path.
\(ctx Context, path string) Metadata | error
Os'File'Metadata module
Types
Metadata
File metadata
type Metadata {
Size number
}
Functions
No functions are defined.
Os'File'OpenOptions module
Types
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
Default
Get default options to open a file. They do not include any permission.
\() OpenOptions
Os'Process module
Types
No types are defined.
Functions
Exit
Exit a current process.
\(ctx Context, code number) none
Run
Run a command.
\(ctx Context, cmd string, args [string]) none | error
Os'Tcp module
Types
No types are defined.
Functions
Bind
Create a listener bound to a server address.
\(ctx Context, address string) Listener | error
Connect
Create a stream connected to a peer address.
\(ctx Context, address string) Stream | error
Accept
Accept a client connection and create its stream.
\(ctx Context, l Listener) AcceptedStream | error
Receive
Receive data from a peer through a stream with a size limit in bytes.
\(ctx Context, s Stream, limit number) string | error
Send
Send data to a peer through a stream.
\(ctx Context, s Stream, data string) number | error
Os'Tcp'AcceptedStream module
Types
AcceptedStream
A TCP stream accepted on a server with a client address
type AcceptedStream {
Stream Stream
Address string
}
Functions
No functions are defined.
Os'Tcp'Listener module
Types
Listener
A TCP listener to listen for client connections
type Listener {
# ...
}
Functions
No functions are defined.
Os'Tcp'Stream module
Types
Stream
A TCP stream
type Stream {
# ...
}
Functions
No functions are defined.
Os'Time module
Types
No types are defined.
Functions
Now
Fetch a current system time in milliseconds.
\(ctx Context) number
Sleep
Pause a current execution context for a given amount of time.
\(ctx Context, milliseconds number) none
Os'Udp module
Types
No types are defined.
Functions
Bind
Bind a socket with a server address.
\(ctx Context, address string) Socket | error
Connect
Connect a socket to a peer address.
\(ctx Context, s Socket, address string) none | error
Receive
Receive a datagram from a connected address.
\(ctx Context, s Socket) string | error
ReceiveFrom
Receive a datagram from any address.
\(ctx Context, s Socket) Datagram | error
Send
Send a datagram to a connected address.
\(ctx Context, s Socket, data string) number | error
SendTo
Send a datagram to a specified address.
\(ctx Context, s Socket, data string, address string) number | error
Os'Udp'Datagram module
Types
Datagram
UDP datagram
type Datagram {
Data string
Address string
}
Functions
No functions are defined.
Os'Udp'Socket module
Types
Socket
UDP socket
type Socket {
# ...
}
Functions
No functions are defined.