Documentation ¶
Index ¶
- Variables
- type File
- type MountErrType
- type MountError
- type Node
- type NodeSysFolder
- func (n *NodeSysFolder) AppendFile(file string) (io.Writer, error)
- func (n *NodeSysFolder) DeleteFile(file string) error
- func (n *NodeSysFolder) List(folder string) (files []File, err error)
- func (n *NodeSysFolder) MakeDirectory(dir string) error
- func (n *NodeSysFolder) Name() string
- func (n *NodeSysFolder) ReadFile(file string) (io.Reader, error)
- func (n *NodeSysFolder) RemoveDirectory(dir string) error
- func (n *NodeSysFolder) Stat(file string) (result File, err error)
- func (n *NodeSysFolder) WriteFile(file string) (io.Writer, error)
- type NodeTree
- func (n *NodeTree) AppendFile(file string) (io.Writer, error)
- func (n *NodeTree) DeleteFile(file string) error
- func (n *NodeTree) List(folder string) (files []File, err error)
- func (n *NodeTree) MakeDirectory(dir string) error
- func (root *NodeTree) Mount(path string, n Node) error
- func (*NodeTree) Name() string
- func (n *NodeTree) ReadFile(file string) (io.Reader, error)
- func (n *NodeTree) RemoveDirectory(dir string) error
- func (n *NodeTree) Stat(file string) (File, error)
- func (n *NodeTree) WriteFile(file string) (io.Writer, error)
Constants ¶
This section is empty.
Variables ¶
var ( ErrFileNotFound = os.ErrNotExist ErrFileFound = os.ErrExist ErrNoPermission = os.ErrPermission ErrNotFolder = errors.New("listing a non-folder") ErrOther = errors.New("unknown error") )
var MountErrMsg = [...]string{ MountErrorLeafHasChild: "mount leaf not empty", MountErrorPathHasLeaf: "mount path contains leaf", MountErrorLeafExists: "mount leaf exists", MountErrorRootIsNil: "mount called with (root *node) == nil", }
Functions ¶
This section is empty.
Types ¶
type MountErrType ¶
type MountErrType int
const ( MountErrorLeafHasChild MountErrType = iota MountErrorPathHasLeaf MountErrorLeafExists MountErrorRootIsNil )
type MountError ¶
type MountError struct {
MountPath, NodeName string
Type MountErrType
}
MountError indicates errors arising when mounting a node.
func (*MountError) Error ¶
func (err *MountError) Error() string
type Node ¶
type Node interface { // Name returns the name to be printed for a human reader to identify. Name() string List(folder string) ([]File, error) // List lists the files under the node. Stat(file string) (File, error) // Stat stats a single file under the node. // ReadFile returns a io.Reader created by reading the file // under this directory, possibly transversing through other // sub-directories. // // If the returned Reader satifies io.Closer, the file is // closed after use. ReadFile(file string) (io.Reader, error) // WriteFile returns a io.Writer that stores the file under // this directory, rewriting existing one if present. // // If the returned Writer satifies io.Closer, the file is // closed after use. WriteFile(file string) (io.Writer, error) // AppendFile returns a io.Writer that stores the file under // this directory, appending existing one if present. // // If the returned Writer satifies io.Closer, the file is // closed after use. AppendFile(file string) (io.Writer, error) // DeleteFile deletes a file at the given location, but // does nothing if the file is a directory. DeleteFile(file string) error // MakeDirectory makes a new directory (or directories) under // this node. MakeDirectory(dir string) error // RemoveDirectory deletes a directory at the given location, but // does nothing if the file is not a directory. RemoveDirectory(dir string) error }
Node is a node (folder) in the virtual filesystem. The file/dir parameters are relative paths, but with no "./" at the beginning, or other relative marks like "..".
The Node interface methods must be safe to call from multiple goroutines.
type NodeSysFolder ¶
type NodeSysFolder struct { // Path is the system filesystem path. Path string // NodeName is the name of the folder in the mount. It is not reflected // in the virtual filesystem. NodeName string }
NodeSysFolder is a virtual filesystem node mounted from a system filesystem folder.
func (*NodeSysFolder) AppendFile ¶
func (n *NodeSysFolder) AppendFile(file string) (io.Writer, error)
func (*NodeSysFolder) DeleteFile ¶
func (n *NodeSysFolder) DeleteFile(file string) error
func (*NodeSysFolder) MakeDirectory ¶
func (n *NodeSysFolder) MakeDirectory(dir string) error
func (*NodeSysFolder) Name ¶
func (n *NodeSysFolder) Name() string
func (*NodeSysFolder) RemoveDirectory ¶
func (n *NodeSysFolder) RemoveDirectory(dir string) error
type NodeTree ¶
type NodeTree node
NodeTree is a root node for containing a mount tree hierachy. It should also satsify Node, but please don't mount it onto another tree. Weird things might happen.
func NewNodeTree ¶
func NewNodeTree() *NodeTree
func NewNodeTreeFromFile ¶
NewNodeTreeFromFile creates a new node tree, with multiple system folder mounted, reading from a listing in the file filename.
The file is composed of lines that are empty, begin with #, or are of the following format:
[VFS mount target path]:[System folder path]
A TVFS path does not have colons so the first colon ends the target.
func (*NodeTree) DeleteFile ¶
func (*NodeTree) MakeDirectory ¶
func (*NodeTree) Mount ¶
Mount mounts the node at the path in the VFS rooted at root.
It must not be called concurrently with other access functions of *NodeTree.