mirror of
https://github.com/vbatts/go-mtree.git
synced 2024-11-22 08:25:38 +00:00
Merge pull request #4 from vbatts/fix_base_dir_path
walk: when directory is root, use "."
This commit is contained in:
commit
a544d45c4c
1 changed files with 5 additions and 3 deletions
8
walk.go
8
walk.go
|
@ -36,6 +36,7 @@ func Walk(root string, exlcudes []ExcludeFunc, keywords []string) (*DirectoryHie
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
entryPathName := filepath.Base(path)
|
||||||
if info.IsDir() {
|
if info.IsDir() {
|
||||||
creator.DH.Entries = append(creator.DH.Entries, Entry{
|
creator.DH.Entries = append(creator.DH.Entries, Entry{
|
||||||
Type: BlankType,
|
Type: BlankType,
|
||||||
|
@ -46,13 +47,14 @@ func Walk(root string, exlcudes []ExcludeFunc, keywords []string) (*DirectoryHie
|
||||||
if creator.curDir != nil {
|
if creator.curDir != nil {
|
||||||
creator.DH.Entries = append(creator.DH.Entries, Entry{
|
creator.DH.Entries = append(creator.DH.Entries, Entry{
|
||||||
Pos: len(creator.DH.Entries),
|
Pos: len(creator.DH.Entries),
|
||||||
Raw: "# " + filepath.Join(creator.curDir.Path(), filepath.Base(path)),
|
Raw: "# " + filepath.Join(creator.curDir.Path(), entryPathName),
|
||||||
Type: CommentType,
|
Type: CommentType,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
entryPathName = "."
|
||||||
creator.DH.Entries = append(creator.DH.Entries, Entry{
|
creator.DH.Entries = append(creator.DH.Entries, Entry{
|
||||||
Pos: len(creator.DH.Entries),
|
Pos: len(creator.DH.Entries),
|
||||||
Raw: "# " + filepath.Base(path),
|
Raw: "# .",
|
||||||
Type: CommentType,
|
Type: CommentType,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -105,7 +107,7 @@ func Walk(root string, exlcudes []ExcludeFunc, keywords []string) (*DirectoryHie
|
||||||
}
|
}
|
||||||
|
|
||||||
e := Entry{
|
e := Entry{
|
||||||
Name: filepath.Base(path),
|
Name: entryPathName,
|
||||||
Pos: len(creator.DH.Entries),
|
Pos: len(creator.DH.Entries),
|
||||||
Type: RelativeType,
|
Type: RelativeType,
|
||||||
Set: creator.curSet,
|
Set: creator.curSet,
|
||||||
|
|
Loading…
Reference in a new issue