fs

package
v0.0.0-...-b11c152 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2020 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Child

type Child interface {
	//Get the current child's index.
	Index() Index

	//Return the current child as a node, nil if the current child is not a node.
	Node() Node

	//Return the current child as data, nil if the current child is not data.
	Data() Data
}

Child is a node's child.

type Data

type Data interface {
	io.ReaderFrom
	io.WriterTo
	http.Handler

	//Return the path to this data.
	Path() Path

	//Stat returns info about the data.
	Stat() (os.FileInfo, error)

	//Deletes the data.
	Delete() error
}

Data is the lowlevel interface required for Files.

type Directory

type Directory struct {
	Node
}

Directory can contain files or other directories.

func (Directory) File

func (d Directory) File(name string) File

File returns the file inside the given directory with the given name.

func (Directory) Goto

func (d Directory) Goto(path Path) Directory

Goto goes to the given path.

type File

type File struct {
	Data
}

File contains Data

func (File) SetString

func (f File) SetString(contents string) error

SetString sets the contents of the file to the given string.

func (File) String

func (f File) String() string

String returns the contents of the file as a string.

type Index

type Index struct {
	Path   Path
	Int    int
	String string
}

Index is an index into a list returned by Node.List

type MetaData

type MetaData os.FileInfo

MetaData returned by File.Stat

type Node

type Node interface {
	//Create this node and all parent nodes required for this node to exist.
	Create() error

	//Delete this node and all children nodes and data.
	Delete() error

	//Return the node at the relative path.
	Goto(relative Path) Node

	//Return the data of this node at the relative path.
	Data(name string) Data

	//Return the path of this node.
	Path() Path

	//Stat returns info about the directory.
	Stat() (os.FileInfo, error)

	//Slice returns a slice of children.
	Slice(offset Index, length int) ([]Child, error)
}

Node is the lowlevel interface required for Directories. A node is a location within a tree, it doesn't have to exist.

type Path

type Path string

Path is a file-system path.

func (Path) Base

func (p Path) Base() string

Base returns the last element of path. Trailing slashes are removed before extracting the last element. If the path is empty, Base returns ".". If the path consists entirely of slashes, Base returns "/".

func (Path) Dir

func (p Path) Dir() Path

Dir returns all but the last element of path, typically the path's directory. After dropping the final element using Split, the path is Cleaned and trailing slashes are removed. If the path is empty, Dir returns ".". If the path consists entirely of slashes followed by non-slash bytes, Dir returns a single slash. In any other case, the returned path does not end in a slash.

func (Path) Join

func (p Path) Join(others ...Path) Path

Join joins any number of path elements into a single path, separating them with slashes. Empty elements are ignored. The result is Cleaned. However, if the argument list is empty or all its elements are empty, Join returns an empty string.

func (Path) String

func (p Path) String() string

type Root

type Root struct {
	Directory
}

Root is a file-system root.

func NewRoot

func NewRoot(node Node) Root

NewRoot returns a new Root from a given Node.

Directories

Path Synopsis
driver
os
s3

Jump to

Keyboard shortcuts

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