Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dir ¶
type Dir struct { // Fp contains the absolute path, relative path and current directory name Fp Fpath `json:"fpath,omitempty"` Children map[string]*Dir `json:"children,omitempty"` Files map[string]Entry `json:"files,omitempty"` }
Dir is a directory in the filetree. It contains a map of its children directories and a map of its files.
type Entry ¶
type Entry interface { // Ext returns the file extension in lowercase Ext() string // Abs returns the absolute path to the file Abs() string // Rel returns the relative path from the root of where it was scanned // to the file. This is the path that is used to find the file in the // FileTree. Rel() string // Dir returns the directory name of the file Dir() string fs.DirEntry }
type FileTree ¶
type FileTree struct {
Root *Dir `json:"head"`
}
FileTree is a tree of directories and files.
func (*FileTree) Find ¶
Find finds a directory in the filetree by its path. The path requested must define the full path relative to the root directory.
type Fpath ¶
type Fpath struct {
// contains filtered or unexported fields
}
type Stepper ¶
type Stepper interface { // Walk is ran on each file in the FileTree. Walk(e Entry, r io.Reader) error // Given an extension, returns true if the Stepper wants to read the file. Wants(ext string) bool }
Stepper is an interface used to act in place of fs.WalkDirFunc. To determine if a Stepper wants to read a file, the extension of a file is passed onto the want method.
type Walker ¶
type Walker struct {
// contains filtered or unexported fields
}
Walker is used to walk a FileTree and run Steppers on each file. This makes it easier to do things like read files which multiple Steppers may want to read.
func BuildWalker ¶
BuildWalker returns a new Walker with the given root and steppers.
func (*Walker) AddStepper ¶
AddStepper adds a Stepper to the Walker.