mirror of
https://github.com/vbatts/go-mtree.git
synced 2025-07-03 14:28:28 +00:00
vis: refactored code to reflect using vis/unvis for file names
Added some more test cases for `vis`ing and `unvis`ing strings, and a test case that walks/checks a directory with filenames that require encoding. Had to change Path() to account for possible errors Unvis() could return. Refactored Vis()/Unvis() into go-mtree tar functionality as well. Signed-off-by: Stephen Chung <schung@redhat.com>
This commit is contained in:
parent
a63f83d94d
commit
773763fb87
12 changed files with 177 additions and 41 deletions
13
walk.go
13
walk.go
|
@ -47,9 +47,13 @@ func Walk(root string, exlcudes []ExcludeFunc, keywords []string) (*DirectoryHie
|
|||
|
||||
// Insert a comment of the full path of the directory's name
|
||||
if creator.curDir != nil {
|
||||
dirname, err := creator.curDir.Path()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
creator.DH.Entries = append(creator.DH.Entries, Entry{
|
||||
Pos: len(creator.DH.Entries),
|
||||
Raw: "# " + filepath.Join(creator.curDir.Path(), entryPathName),
|
||||
Raw: "# " + filepath.Join(dirname, entryPathName),
|
||||
Type: CommentType,
|
||||
})
|
||||
} else {
|
||||
|
@ -147,9 +151,12 @@ func Walk(root string, exlcudes []ExcludeFunc, keywords []string) (*DirectoryHie
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
encodedEntryName, err := Vis(entryPathName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
e := Entry{
|
||||
Name: entryPathName,
|
||||
Name: encodedEntryName,
|
||||
Pos: len(creator.DH.Entries),
|
||||
Type: RelativeType,
|
||||
Set: creator.curSet,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue