mirror of
https://github.com/vbatts/go-mtree.git
synced 2024-11-25 17:45:39 +00:00
DirectoryHierarchy: UsedKeywords is a of the struct
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
parent
a8e4475c5e
commit
627c6e9ddd
4 changed files with 6 additions and 10 deletions
4
check.go
4
check.go
|
@ -8,7 +8,7 @@ package mtree
|
||||||
// keywords) and then doing a Compare(dh, newDh, keywords).
|
// keywords) and then doing a Compare(dh, newDh, keywords).
|
||||||
func Check(root string, dh *DirectoryHierarchy, keywords []string) ([]InodeDelta, error) {
|
func Check(root string, dh *DirectoryHierarchy, keywords []string) ([]InodeDelta, error) {
|
||||||
if keywords == nil {
|
if keywords == nil {
|
||||||
keywords = CollectUsedKeywords(dh)
|
keywords = dh.UsedKeywords()
|
||||||
}
|
}
|
||||||
|
|
||||||
newDh, err := Walk(root, nil, keywords)
|
newDh, err := Walk(root, nil, keywords)
|
||||||
|
@ -25,7 +25,7 @@ func Check(root string, dh *DirectoryHierarchy, keywords []string) ([]InodeDelta
|
||||||
// equivalent to Compare(dh, tarDH, keywords).
|
// equivalent to Compare(dh, tarDH, keywords).
|
||||||
func TarCheck(tarDH, dh *DirectoryHierarchy, keywords []string) ([]InodeDelta, error) {
|
func TarCheck(tarDH, dh *DirectoryHierarchy, keywords []string) ([]InodeDelta, error) {
|
||||||
if keywords == nil {
|
if keywords == nil {
|
||||||
keywords = CollectUsedKeywords(dh)
|
keywords = dh.UsedKeywords()
|
||||||
}
|
}
|
||||||
return Compare(dh, tarDH, keywords)
|
return Compare(dh, tarDH, keywords)
|
||||||
}
|
}
|
||||||
|
|
|
@ -200,7 +200,7 @@ func TestTarTime(t *testing.T) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
keywords := CollectUsedKeywords(dh)
|
keywords := dh.UsedKeywords()
|
||||||
|
|
||||||
// make sure "time" keyword works
|
// make sure "time" keyword works
|
||||||
_, err = Check(dir, dh, keywords)
|
_, err = Check(dir, dh, keywords)
|
||||||
|
|
|
@ -142,7 +142,7 @@ func app() error {
|
||||||
|
|
||||||
// We can't check against more fields than in the specKeywords list, so
|
// We can't check against more fields than in the specKeywords list, so
|
||||||
// currentKeywords can only have a subset of specKeywords.
|
// currentKeywords can only have a subset of specKeywords.
|
||||||
specKeywords = mtree.CollectUsedKeywords(specDh)
|
specKeywords = specDh.UsedKeywords()
|
||||||
}
|
}
|
||||||
|
|
||||||
// -list-used
|
// -list-used
|
||||||
|
|
|
@ -26,13 +26,9 @@ func (dh DirectoryHierarchy) WriteTo(w io.Writer) (n int64, err error) {
|
||||||
return sum, nil
|
return sum, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CollectUsedKeywords collects and returns all the keywords used in a
|
// UsedKeywords collects and returns all the keywords used in a
|
||||||
// a DirectoryHierarchy
|
// a DirectoryHierarchy
|
||||||
func CollectUsedKeywords(dh *DirectoryHierarchy) []string {
|
func (dh DirectoryHierarchy) UsedKeywords() []string {
|
||||||
if dh == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
usedkeywords := []string{}
|
usedkeywords := []string{}
|
||||||
for _, e := range dh.Entries {
|
for _, e := range dh.Entries {
|
||||||
switch e.Type {
|
switch e.Type {
|
||||||
|
|
Loading…
Reference in a new issue