*: cleaner Parent handling

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
Vincent Batts 2016-03-18 16:30:54 -04:00
parent 3b6cb6e117
commit a05d8ebbbd
4 changed files with 47 additions and 10 deletions

View file

@ -3,6 +3,7 @@ package mtree
import (
"fmt"
"io"
"path/filepath"
"sort"
"strings"
)
@ -45,6 +46,13 @@ type Entry struct {
Type EntryType
}
func (e Entry) Path() string {
if e.Parent == nil {
return e.Name
}
return filepath.Join(e.Parent.Path(), e.Name)
}
func (e Entry) String() string {
if e.Raw != "" {
return e.Raw