diff --git a/cmd/restic/cmd_find.go b/cmd/restic/cmd_find.go index b2a67da5d..053b72984 100644 --- a/cmd/restic/cmd_find.go +++ b/cmd/restic/cmd_find.go @@ -3,7 +3,7 @@ package main import ( "context" "encoding/json" - "path/filepath" + "path" "strings" "time" @@ -111,7 +111,7 @@ func (s *statefulOutput) PrintJSON(prefix string, node *restic.Node) { Content byte `json:"content,omitempty"` Subtree byte `json:"subtree,omitempty"` }{ - Path: filepath.Join(prefix, node.Name), + Path: path.Join(prefix, node.Name), Permissions: node.Mode.String(), findNode: (*findNode)(node), }) @@ -202,7 +202,7 @@ func (f *Finder) findInTree(ctx context.Context, treeID restic.ID, prefix string name = strings.ToLower(name) } - m, err := filepath.Match(f.pat.pattern, name) + m, err := path.Match(f.pat.pattern, name) if err != nil { return err } @@ -224,7 +224,7 @@ func (f *Finder) findInTree(ctx context.Context, treeID restic.ID, prefix string } if node.Type == "dir" { - if err := f.findInTree(ctx, *node.Subtree, filepath.Join(prefix, node.Name)); err != nil { + if err := f.findInTree(ctx, *node.Subtree, path.Join(prefix, node.Name)); err != nil { return err } } @@ -241,7 +241,7 @@ func (f *Finder) findInSnapshot(ctx context.Context, sn *restic.Snapshot) error debug.Log("searching in snapshot %s\n for entries within [%s %s]", sn.ID(), f.pat.oldest, f.pat.newest) f.out.newsn = sn - return f.findInTree(ctx, *sn.Tree, string(filepath.Separator)) + return f.findInTree(ctx, *sn.Tree, "/") } func runFind(opts FindOptions, gopts GlobalOptions, args []string) error { diff --git a/cmd/restic/format.go b/cmd/restic/format.go index 1f8ab366e..9ced5ba78 100644 --- a/cmd/restic/format.go +++ b/cmd/restic/format.go @@ -3,7 +3,7 @@ package main import ( "fmt" "os" - "path/filepath" + "path" "time" "github.com/restic/restic/internal/restic" @@ -64,7 +64,7 @@ func formatDuration(d time.Duration) string { } func formatNode(prefix string, n *restic.Node, long bool) string { - nodepath := prefix + string(filepath.Separator) + n.Name + nodepath := path.Join(prefix, n.Name) if !long { return nodepath }