Documentation ¶
Index ¶
- Constants
- type DiffType
- type EfficiencyData
- type EfficiencySlice
- 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(path string, data FileInfo) (*FileNode, error)
- func (tree *FileTree) Compare(upper *FileTree) 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) error
- func (tree *FileTree) String(showAttributes bool) string
- func (tree *FileTree) StringBetween(start, stop uint, showAttributes bool) string
- func (tree *FileTree) VisitDepthChildFirst(visitor Visitor, evaluator VisitEvaluator) error
- func (tree *FileTree) VisitDepthParentFirst(visitor Visitor, evaluator VisitEvaluator) error
- type NodeData
- type ViewInfo
- type VisitEvaluator
- type Visitor
Constants ¶
const (
AttributeFormat = "%s%s %10s %10s "
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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 FileInfo ¶
FileInfo contains tar metadata for a specific FileNode
func NewFileInfo ¶
NewFileInfo 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, possible 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 StackRange ¶
StackRange combines an array of trees into a single tree
func (*FileTree) Compare ¶
Compare 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) 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 VisitEvaluator ¶
VisitEvaluator is a function that indicates whether the given node should be visited by a Visitor.