tree

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2017 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry interface {
	IsFile() bool
	IsDir() bool
	IsMount() bool
	// contains filtered or unexported methods
}

Entry is any kind of tree node

type File

type File string

File is a leaf node in the tree

func (File) Add

func (f File) Add(Entry) error

Add always returns an error

func (File) IsDir

func (f File) IsDir() bool

IsDir always returns false

func (File) IsFile

func (f File) IsFile() bool

IsFile always returns true

func (File) IsMount

func (f File) IsMount() bool

IsMount always returns false

func (File) String

func (f File) String() string

String implement fmt.Stringer

type Folder

type Folder struct {
	Name    string           // Name is the displayed name of this folder
	Path    string           // Path is only used for mounts, it's the on-disk path
	Root    bool             // Root is used for the root node to remove any prefix
	Entries map[string]Entry // the sub-entries, prevents having files and folder w/ same name
}

Folder is intermediate tree node

func New

func New(name string) *Folder

New create a new root folder

func (*Folder) AddFile

func (f *Folder) AddFile(name string) error

AddFile adds a new file

func (*Folder) AddMount

func (f *Folder) AddMount(name, path string) error

AddMount adds a new mount

func (*Folder) FindFolder

func (f *Folder) FindFolder(name string) *Folder

FindFolder returns a sub-tree or nil, if the subtree does not exist

func (Folder) Format

func (f Folder) Format() string

Format returns a pretty printed tree

func (Folder) IsDir

func (f Folder) IsDir() bool

IsDir always returns true

func (Folder) IsFile

func (f Folder) IsFile() bool

IsFile always return false

func (Folder) IsMount

func (f Folder) IsMount() bool

IsMount returns true if the path is non-empty

func (Folder) List

func (f Folder) List() []string

List returns a flattened list of all sub nodes

func (Folder) String

func (f Folder) String() string

String implement fmt.Stringer

Jump to

Keyboard shortcuts

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