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,
|
|
|
|
// keywords) and then doing a Compare(dh, newDh, keywords).
|
|
|
|
func Check(root string, dh *DirectoryHierarchy, keywords []string) ([]InodeDelta, error) {
|
|
|
|
if keywords == nil {
|
|
|
|
keywords = CollectUsedKeywords(dh)
|
2016-03-18 20:31:12 +00:00
|
|
|
}
|
|
|
|
|
2016-10-31 10:42:53 +00:00
|
|
|
newDh, err := Walk(root, nil, keywords)
|
|
|
|
if err != nil {
|
2016-03-18 20:31:12 +00:00
|
|
|
return nil, err
|
|
|
|
}
|
2016-07-26 13:02:30 +00:00
|
|
|
|
2016-10-31 10:42:53 +00:00
|
|
|
// TODO: Handle tar_time, if necessary.
|
|
|
|
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).
|
|
|
|
func TarCheck(tarDH, dh *DirectoryHierarchy, keywords []string) ([]InodeDelta, error) {
|
|
|
|
if keywords == nil {
|
|
|
|
keywords = CollectUsedKeywords(dh)
|
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
|
|
|
}
|