Documentation
¶
Index ¶
- func CompareAndMark(treeA, treeB *FileTreeModel) error
- func GetXid(info os.FileInfo) (string, string)
- type DiffType
- type FileInfo
- type FileNode
- func (node *FileNode) AbsPath() string
- func (node *FileNode) AddChild(name string, info FileInfo) *FileNode
- func (node *FileNode) AssignDiffType(diffType DiffType) error
- func (node *FileNode) Copy(parent *FileNode) *FileNode
- func (node *FileNode) DepthFirstSearch(visitor Visitor, evaluator VisitEvaluator) error
- func (node *FileNode) IsDir() bool
- func (node *FileNode) IsLeaf() bool
- func (node *FileNode) MetadataAsStringArray() []string
- func (node *FileNode) MetadataString() string
- func (node *FileNode) Remove() error
- func (node *FileNode) String() string
- type FileTreeModel
- func (tree *FileTreeModel) AddPath(fqfp string, info FileInfo) (*FileNode, []*FileNode, error)
- func (tree *FileTreeModel) Clone() *FileTreeModel
- func (tree *FileTreeModel) DepthFirstSearch(visitor Visitor, evaluator VisitEvaluator) error
- func (tree *FileTreeModel) GetNode(fqfp string) (*FileNode, error)
- func (tree *FileTreeModel) GetNodeAt(index int) *FileNode
- func (tree *FileTreeModel) GetNodeByName(name string) *FileNode
- func (tree *FileTreeModel) GetPwd() string
- func (tree *FileTreeModel) RemovePath(fqfp string) error
- func (tree *FileTreeModel) SetPwd(fqfp string) error
- func (tree *FileTreeModel) String(showAttributes bool) string
- func (tree *FileTreeModel) StringArrayBetween(start, stop int) ([][]string, []*FileNode)
- func (tree *FileTreeModel) StringBetween(start, stop int, showAttributes bool) string
- func (tree *FileTreeModel) VisibleSize() int
- type NodeData
- type VisitEvaluator
- type Visitor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompareAndMark ¶
func CompareAndMark(treeA, treeB *FileTreeModel) error
CompareAndMark compares this treeA and treeB by performing two passages: 1: iterate over nodes in A and if they are absent in B - mark them as "deleted" 2: iterate over nodes in B and if they are absent in A - mark them as "added" *: rest of the nodes are compared for being "modified" NOTE: for every "added", "deleted" or "modified" node - all their parents are marked as well as "modified"
Types ¶
type FileInfo ¶
type FileInfo struct { // fully qualified file path: slash-delimited string from the root ('/') to the desired node (e.g. '/a/node/fqfp') Fqfp string Linkname string Size int64 Mode os.FileMode Uid string // User Id - owner of the file Gid string // Group Id - owner of the file Err error // error discovered while retrieving metadata about this file, such as Insufficient Permission // contains filtered or unexported fields }
FileInfo contains tar metadata for a specific FileNode
func NewFileInfo ¶
NewFileInfo extracts the metadata from the info and file contents and generates a new FileInfo object.
type FileNode ¶
type FileNode struct { Tree *FileTreeModel Parent *FileNode Children map[string]*FileNode Data NodeData Name string // 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 NewFileNode ¶
NewFileNode creates a new FileNode relative to the given parent node with a payload.
func (*FileNode) AssignDiffType ¶
AssignDiffType will assign the given DiffType to this node, possibly affecting child nodes.
func (*FileNode) DepthFirstSearch ¶
func (node *FileNode) DepthFirstSearch(visitor Visitor, evaluator VisitEvaluator) error
DepthFirstSearch starts at the tree root explores as far as possible along each branch before backtracking
func (*FileNode) MetadataAsStringArray ¶
MetadataString returns the FileNode metadata for columnar representation
func (*FileNode) MetadataString ¶
MetadataString returns the FileNode metadata in a columnar string.
type FileTreeModel ¶
type FileTreeModel struct { // absolute root of the filesystem Root *FileNode // number of files and folders in this Tree // NOTE: this number is different from the len(pwd.Children) Size int Name string // contains filtered or unexported fields }
FileTreeModel represents a set of files, directories, and their relations.
func NewFileTreeModel ¶
func NewFileTreeModel() (tree *FileTreeModel)
NewFileTreeModel creates an empty FileTreeModel
func ReadFileTree ¶
func ReadFileTree(fqfp string) (*FileTreeModel, error)
ReadFileTree reads directory specified by the fqfp (Fully Qualified File AbsPath)
func (*FileTreeModel) AddPath ¶
AddPath adds a new node to the tree when given fully qualified file path and optional payload
func (*FileTreeModel) Clone ¶
func (tree *FileTreeModel) Clone() *FileTreeModel
Clone returns a copy of the given FileTreeModel
func (*FileTreeModel) DepthFirstSearch ¶
func (tree *FileTreeModel) DepthFirstSearch(visitor Visitor, evaluator VisitEvaluator) error
DepthFirstSearch starts at the tree root explores as far as possible along each branch before backtracking
func (*FileTreeModel) GetNode ¶
func (tree *FileTreeModel) GetNode(fqfp string) (*FileNode, error)
GetNode fetches a single node when given a fully qualified file path - slash-delimited string from the root ('/') to the desired node (e.g. '/a/node/path.txt')
func (*FileTreeModel) GetNodeAt ¶
func (tree *FileTreeModel) GetNodeAt(index int) *FileNode
GetNodeAt returns FileNode representing n-th element in the FileTree by the 0-based index
func (*FileTreeModel) GetNodeByName ¶
func (tree *FileTreeModel) GetNodeByName(name string) *FileNode
GetNodeByName returns FileNode by name in the subtree represented by PWD; supports ".." name returns nil if name can not be found
func (*FileTreeModel) GetPwd ¶
func (tree *FileTreeModel) GetPwd() string
func (*FileTreeModel) RemovePath ¶
func (tree *FileTreeModel) RemovePath(fqfp string) error
RemovePath removes a node from the tree given its fully qualified file path - slash-delimited string from the root ('/') to the desired node (e.g. '/a/node/path.txt').
func (*FileTreeModel) SetPwd ¶
func (tree *FileTreeModel) SetPwd(fqfp string) error
func (*FileTreeModel) String ¶
func (tree *FileTreeModel) String(showAttributes bool) string
String returns the entire tree in an ASCII representation.
func (*FileTreeModel) StringArrayBetween ¶
func (tree *FileTreeModel) StringArrayBetween(start, stop int) ([][]string, []*FileNode)
StringArrayBetween returns a partial tree in an ASCII representation. start is inclusive, 0-based index pointer stop is exclusive, 0-based index pointer
func (*FileTreeModel) StringBetween ¶
func (tree *FileTreeModel) StringBetween(start, stop int, showAttributes bool) string
StringBetween returns a partial tree in an ASCII representation. start is inclusive, 0-based index pointer stop is exclusive, 0-based index pointer
func (*FileTreeModel) VisibleSize ¶
func (tree *FileTreeModel) VisibleSize() int
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 returns True if the given node should be visited by a Visitor.