Documentation ¶
Index ¶
- Constants
- Variables
- func StackTreeRange(trees []*FileTree, start, stop int) (*FileTree, []PathError, error)
- type Comparer
- func (cmp *Comparer) AggregatedIndexes() <-chan TreeIndexKey
- func (cmp *Comparer) BuildCache() (errors []error)
- func (cmp *Comparer) GetPathErrors(key TreeIndexKey) ([]PathError, error)
- func (cmp *Comparer) GetTree(key TreeIndexKey) (*FileTree, error)
- func (cmp *Comparer) NaturalIndexes() <-chan TreeIndexKey
- type DiffType
- type EfficiencyData
- type EfficiencySlice
- type FileAction
- type FileInfo
- type FileNode
- func (node *FileNode) AddChild(name string, data FileInfo) (child *FileNode)
- func (node *FileNode) AssignDiffType(diffType DiffType) error
- func (node *FileNode) Copy(parent *FileNode) *FileNode
- func (node *FileNode) IsLeaf() bool
- func (node *FileNode) IsWhiteout() bool
- func (node *FileNode) MetadataString() string
- func (node *FileNode) Path() string
- func (node *FileNode) Remove() error
- func (node *FileNode) String() string
- func (node *FileNode) VisitDepthChildFirst(visitor Visitor, evaluator VisitEvaluator) error
- func (node *FileNode) VisitDepthParentFirst(visitor Visitor, evaluator VisitEvaluator) error
- type FileTree
- func (tree *FileTree) AddPath(filepath string, data FileInfo) (*FileNode, []*FileNode, error)
- func (tree *FileTree) CompareAndMark(upper *FileTree) ([]PathError, error)
- func (tree *FileTree) Copy() *FileTree
- func (tree *FileTree) GetNode(path string) (*FileNode, error)
- func (tree *FileTree) RemovePath(path string) error
- func (tree *FileTree) Stack(upper *FileTree) (failed []PathError, stackErr error)
- func (tree *FileTree) String(showAttributes bool) string
- func (tree *FileTree) StringBetween(start, stop int, showAttributes bool) string
- func (tree *FileTree) VisibleSize() int
- func (tree *FileTree) VisitDepthChildFirst(visitor Visitor, evaluator VisitEvaluator) error
- func (tree *FileTree) VisitDepthParentFirst(visitor Visitor, evaluator VisitEvaluator) error
- type NodeData
- type PathError
- type TreeIndexKey
- type ViewInfo
- type VisitEvaluator
- type Visitor
Constants ¶
const (
AttributeFormat = "%s%s %11s %10s "
)
Variables ¶
var GlobalFileTreeCollapse bool
Functions ¶
Types ¶
type Comparer ¶
type Comparer struct {
// contains filtered or unexported fields
}
func NewComparer ¶
func (*Comparer) AggregatedIndexes ¶
func (cmp *Comparer) AggregatedIndexes() <-chan TreeIndexKey
case 2: aggregated compare (bottom tree is ENTIRELY fixed, top tree SIZE changes)
func (*Comparer) BuildCache ¶
func (*Comparer) GetPathErrors ¶
func (cmp *Comparer) GetPathErrors(key TreeIndexKey) ([]PathError, error)
func (*Comparer) NaturalIndexes ¶
func (cmp *Comparer) NaturalIndexes() <-chan TreeIndexKey
case 1: layer compare (top tree SIZE is fixed (BUT floats forward), Bottom tree SIZE changes)
type EfficiencyData ¶
type EfficiencyData struct { Path string Nodes []*FileNode CumulativeSize int64 // contains filtered or unexported fields }
EfficiencyData represents the storage and reference statistics for a given file tree path.
type EfficiencySlice ¶
type EfficiencySlice []*EfficiencyData
EfficiencySlice represents an ordered set of EfficiencyData data structures.
func Efficiency ¶
func Efficiency(trees []*FileTree) (float64, EfficiencySlice)
Efficiency returns the score and file set of the given set of FileTrees (layers). This is loosely based on: 1. Files that are duplicated across layers discounts your score, weighted by file size 2. Files that are removed discounts your score, weighted by the original file size
func (EfficiencySlice) Less ¶
func (efs EfficiencySlice) Less(i, j int) bool
Less comparison is required for sorting.
func (EfficiencySlice) Swap ¶
func (efs EfficiencySlice) Swap(i, j int)
Swap operation is required for sorting.
type FileAction ¶
type FileAction int
const ( ActionAdd FileAction = iota ActionRemove )
func (FileAction) String ¶
func (fa FileAction) String() string
type FileInfo ¶
type FileInfo struct { Path string TypeFlag byte Linkname string Size int64 Mode os.FileMode Uid int Gid int IsDir bool // contains filtered or unexported fields }
FileInfo contains tar metadata for a specific FileNode
func NewFileInfoFromTarHeader ¶
NewFileInfoFromTarHeader extracts the metadata from a tar header and file contents and generates a new FileInfo object.
type FileNode ¶
type FileNode struct { Tree *FileTree Parent *FileNode Name string Data NodeData Children map[string]*FileNode // contains filtered or unexported fields }
FileNode represents a single file, its relation to files beneath it, the tree it exists in, and the metadata of the given file.
func (*FileNode) AssignDiffType ¶
AssignDiffType will assign the given DiffType to this node, possibly affecting child nodes.
func (*FileNode) IsWhiteout ¶
IsWhiteout returns an indication if this file may be a overlay-whiteout file.
func (*FileNode) MetadataString ¶
MetadatString returns the FileNode metadata in a columnar string.
func (*FileNode) Path ¶
Path returns a slash-delimited string from the root of the greater tree to the current node (e.g. /a/path/to/here)
func (*FileNode) Remove ¶
Remove deletes the current FileNode from it's parent FileNode's relations.
func (*FileNode) String ¶
String shows the filename formatted into the proper color (by DiffType), additionally indicating if it is a symlink.
func (*FileNode) VisitDepthChildFirst ¶
func (node *FileNode) VisitDepthChildFirst(visitor Visitor, evaluator VisitEvaluator) error
VisitDepthChildFirst iterates a tree depth-first (starting at this FileNode), evaluating the deepest depths first (visit on bubble up)
func (*FileNode) VisitDepthParentFirst ¶
func (node *FileNode) VisitDepthParentFirst(visitor Visitor, evaluator VisitEvaluator) error
VisitDepthParentFirst iterates a tree depth-first (starting at this FileNode), evaluating the shallowest depths first (visit while sinking down)
type FileTree ¶
FileTree represents a set of files, directories, and their relations.
func (*FileTree) CompareAndMark ¶
CompareAndMark marks the FileNodes in the owning (lower) tree with DiffType annotations when compared to the given (upper) tree.
func (*FileTree) GetNode ¶
GetNode fetches a single node when given a slash-delimited string from root ('/') to the desired node (e.g. '/a/node/path')
func (*FileTree) RemovePath ¶
RemovePath removes a node from the tree given its path.
func (*FileTree) Stack ¶
Stack takes two trees and combines them together. This is done by "stacking" the given tree on top of the owning tree.
func (*FileTree) StringBetween ¶
StringBetween returns a partial tree in an ASCII representation.
func (*FileTree) VisibleSize ¶
func (*FileTree) VisitDepthChildFirst ¶
func (tree *FileTree) VisitDepthChildFirst(visitor Visitor, evaluator VisitEvaluator) error
VisitDepthChildFirst iterates the given tree depth-first, evaluating the deepest depths first (visit on bubble up)
func (*FileTree) VisitDepthParentFirst ¶
func (tree *FileTree) VisitDepthParentFirst(visitor Visitor, evaluator VisitEvaluator) error
VisitDepthParentFirst iterates the given tree depth-first, evaluating the shallowest depths first (visit while sinking down)
type NodeData ¶
NodeData is the payload for a FileNode
func NewNodeData ¶
func NewNodeData() *NodeData
NewNodeData creates an empty NodeData struct for a FileNode
type PathError ¶
type PathError struct { Path string Action FileAction Err error }
func NewPathError ¶
func NewPathError(path string, action FileAction, err error) PathError
type TreeIndexKey ¶
type TreeIndexKey struct {
// contains filtered or unexported fields
}
func NewTreeIndexKey ¶
func NewTreeIndexKey(bottomTreeStart, bottomTreeStop, topTreeStart, topTreeStop int) TreeIndexKey
func (TreeIndexKey) String ¶
func (index TreeIndexKey) String() string
type VisitEvaluator ¶
VisitEvaluator is a function that indicates whether the given node should be visited by a Visitor.