Documentation ¶
Overview ¶
Package hashtree contains a merkle tree for the filesystem, which can be updated efficiently using delta calculations based on a files ModTime.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Debug = false
Debug is a global flag, which is only used by the command line program to track errors down.
Functions ¶
func FindFile ¶
FindFile returns the first entry index or -1 if not found. Expects that s is sorted ascending by name.
func ReadDir ¶
ReadDir walks in sorted order from root to any leaf. It ignores anything starting with a dot. If a directory matches that name, it is ignored entirely. To improve performance, it will only ever read leaf-files if they are unknown or if the ModTime is different. Extra in-memory nodes are removed, if they are not present in the filesystem anymore. Note that this performance improvement will fail on systems where the ModTime is not updated or the timer resolution is not small enough.
Types ¶
type File ¶
type File struct { Prefix string // Prefix is a constant Filename string // Filename is a relative but full file name Node *Node }
File should represent a real physical file with the given meta data. It still virtual, as the file may not exist.
type Node ¶
A Node is an element in a merkle tree. This one represents a part of the real filesystem. Using a hash tree, we can efficiently decide and find changes in very large and complex trees.
func (*Node) Flatten ¶
Flatten returns hashtree files with absolute file names according to the given root. The array is sorted ascending.
func (*Node) IndexOf ¶
IndexOf returns the found index or nil in log(n), because children are sorted ascending by name.