Documentation ¶
Index ¶
- func Basename(path string) string
- func Dirname(path string) []string
- func Register(alias string, cmd Command)
- type Command
- type Computer
- type ErrorCode
- type Exit
- type FSFile
- type File
- type Filesystem
- type IO
- type Network
- type PermissionDenied
- type Permissions
- type State
- func (state State) Authenticate() bool
- func (state *State) Cmd(cmd string) error
- func (state *State) Exit(str string) error
- func (state State) GetUser() string
- func (state State) Open(fsf *FSFile, opts int) (*File, error)
- func (state State) OpenPath(path string, opts int) (io.ReadWriteSeeker, error)
- func (state *State) PromptlessRepl(_io IO) error
- func (state *State) Push(c *Computer, user string)
- func (state State) Pwd() (string, error)
- func (state *State) Repl(prompt func(*State, IO), _io IO) error
- func (state State) ResolveDir(path []string) (*Filesystem, error)
- func (state *State) SetUser(user string, _io IO) error
- func (state *State) SetWD(fs *Filesystem)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Computer ¶
type Computer struct { FS *Filesystem Network Network // Map usernames to passwords Users map[string]string // A map in order to be type-compatible with Users. Value is ignored Admins map[string]string Hostname string }
A Computer represents the current state of a computer. It has a Filesystem, a Network, a set of users, some of whom may be admins, and a hostname.
type Exit ¶
type Exit string
Exit means that the interpreter wants to exit. This may be used to implement exit(1). Before exiting on Exit e, the REPL should print e.Error().
type FSFile ¶
type FSFile struct { OwnerPermissions Permissions OtherPermissions Permissions Owner string // contains filtered or unexported fields }
An FSFile is a file "on disk". It doesn't contain an offset, so it can't be written to directly.
type File ¶
type File struct { File *FSFile // contains filtered or unexported fields }
A File is an FSFile that has been opened, in order to read or write to it.
type Filesystem ¶
type Filesystem struct { Subdirs map[string]*Filesystem Files map[string]*FSFile }
A Filesystem is a directory. It has a set of subdirectories and a set of files.
func (*Filesystem) GetCwd ¶
func (fs *Filesystem) GetCwd() ([]string, error)
GetCwd gets the current working directory of a filesystem.
type Network ¶
type Network []*Computer
A Network is the set of computers to which a computer is connected.
type PermissionDenied ¶
type PermissionDenied string
PermissionDenied means that permission was denied when reading from a file
func (PermissionDenied) Error ¶
func (p PermissionDenied) Error() string
type Permissions ¶
Permissions represents the actions a user may be allowed to perform on a file.
type State ¶
type State struct { Computer *Computer Commands map[string]Command // contains filtered or unexported fields }
State represents the current state of the interpreter. It is the REPL's job to store state between commands.
func (State) Authenticate ¶
Authenticate returns true if the current user is an administrator
func (*State) PromptlessRepl ¶
PromptlessRepl spawns a REPL without a prompt
func (State) Pwd ¶
Pwd prints the current working directory. This is made public so that the REPL may include the current working directory in the prompt.
func (State) ResolveDir ¶
func (state State) ResolveDir(path []string) (*Filesystem, error)
ResolveDir turns a path into a Filesystem
func (*State) SetWD ¶
func (state *State) SetWD(fs *Filesystem)
SetWD sets the working directory of a state