2016-03-16 19:59:34 +00:00
|
|
|
package mtree
|
|
|
|
|
2016-04-12 20:49:52 +00:00
|
|
|
// Check a root directory path against the DirectoryHierarchy, regarding only
|
|
|
|
// the available keywords from the list and each entry in the hierarchy.
|
|
|
|
// If keywords is nil, the check all present in the DirectoryHierarchy
|
2016-10-31 10:42:53 +00:00
|
|
|
//
|
|
|
|
// This is equivalent to creating a new DirectoryHierarchy with Walk(root, nil,
|
2016-11-18 07:53:26 +00:00
|
|
|
// keywords, fs) and then doing a Compare(dh, newDh, keywords).
|
|
|
|
func Check(root string, dh *DirectoryHierarchy, keywords []Keyword, fs FsEval) ([]InodeDelta, error) {
|
2016-10-31 10:42:53 +00:00
|
|
|
if keywords == nil {
|
2016-12-14 05:24:02 +00:00
|
|
|
keywords = dh.UsedKeywords()
|
2016-03-18 20:31:12 +00:00
|
|
|
}
|
|
|
|
|
2016-11-18 07:53:26 +00:00
|
|
|
newDh, err := Walk(root, nil, keywords, fs)
|
2016-10-31 10:42:53 +00:00
|
|
|
if err != nil {
|
2016-03-18 20:31:12 +00:00
|
|
|
return nil, err
|
|
|
|
}
|
2016-12-14 05:24:02 +00:00
|
|
|
|
2016-10-31 10:42:53 +00:00
|
|
|
return Compare(dh, newDh, keywords)
|
2016-03-16 19:59:34 +00:00
|
|
|
}
|
2016-06-28 20:40:35 +00:00
|
|
|
|
2016-10-31 10:42:53 +00:00
|
|
|
// TarCheck is the tar equivalent of checking a file hierarchy spec against a
|
|
|
|
// tar stream to determine if files have been changed. This is precisely
|
|
|
|
// equivalent to Compare(dh, tarDH, keywords).
|
2016-11-18 00:47:31 +00:00
|
|
|
func TarCheck(tarDH, dh *DirectoryHierarchy, keywords []Keyword) ([]InodeDelta, error) {
|
2016-10-31 10:42:53 +00:00
|
|
|
if keywords == nil {
|
2016-11-18 00:47:31 +00:00
|
|
|
return Compare(dh, tarDH, dh.UsedKeywords())
|
2016-06-28 20:40:35 +00:00
|
|
|
}
|
2016-10-31 10:42:53 +00:00
|
|
|
return Compare(dh, tarDH, keywords)
|
2016-06-28 20:40:35 +00:00
|
|
|
}
|