1
0
Fork 0
mirror of https://github.com/vbatts/go-mtree.git synced 2025-07-01 05:28:30 +00:00

tar: resolve hardlinks when streaming archive

Fill in the data of the Entry with the data of the
file that a hardlink actually represents.

Signed-off-by: Stephen Chung <schung@redhat.com>
This commit is contained in:
Stephen Chung 2016-08-10 11:40:47 -04:00
parent ea6c6eff1b
commit 5837d00b07
5 changed files with 108 additions and 1 deletions

View file

@ -42,6 +42,23 @@ func (e Entry) Descend(filename string) *Entry {
return nil
}
// Find is a wrapper around Descend that takes in a whole string path and tries
// to find that Entry
func (e Entry) Find(filepath string) *Entry {
resultnode := &e
for _, path := range strings.Split(filepath, "/") {
encoded, err := Vis(path)
if err != nil {
return nil
}
resultnode = resultnode.Descend(encoded)
if resultnode == nil {
return nil
}
}
return resultnode
}
// Ascend gets the parent of an Entry. Serves mainly to maintain readability
// when traversing up and down an Entry tree
func (e Entry) Ascend() *Entry {