simple

package
v1.8.6 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File struct {
	Name     string
	Metadata map[string]string
}

File is a leaf node in the tree

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
	HasTpl  bool
	Folders map[string]*Folder // the sub-entries, prevents having files and folder w/ same name
	Files   map[string]*File
}

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, contentType 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) AddTemplate

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

AddTemplate adds a new template

func (*Folder) FindFolder

func (f *Folder) FindFolder(name string) (tree.Tree, error)

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

func (*Folder) Format

func (f *Folder) Format(maxDepth int) string

Format returns a pretty printed tree

func (*Folder) IsMount

func (f *Folder) IsMount() bool

IsMount returns true if the path is non-empty

func (*Folder) Len

func (f *Folder) Len() int

Len returns the number of entries in this folder and all subfolder including this folder itself

func (*Folder) List

func (f *Folder) List(maxDepth int) []string

List returns a flattened list of all sub nodes

func (*Folder) ListFolders added in v1.8.3

func (f *Folder) ListFolders(maxDepth int) []string

ListFolders returns a flattened list of all nodes without leaf

func (*Folder) SetName

func (f *Folder) SetName(name string)

SetName sets the name of this folder

func (*Folder) SetRoot

func (f *Folder) SetRoot(on bool)

SetRoot sets the root flag of this folder

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