MCPcopy
hub / github.com/kopia/kopia / stripLeadingPath

Function stripLeadingPath

tools/gettool/autodownload/autodownload.go:52–63  ·  view source on GitHub ↗
(fname string, stripPathComponents int)

Source from the content-addressed store, hash-verified

50}
51
52func stripLeadingPath(fname string, stripPathComponents int) (string, bool) {
53 if stripPathComponents == 0 {
54 return fname, true
55 }
56
57 parts := strings.Split(filepath.ToSlash(filepath.Clean(fname)), "/")
58 if len(parts) <= stripPathComponents {
59 return "", false
60 }
61
62 return filepath.Join(parts[stripPathComponents:]...), true
63}
64
65func untar(dir string, r io.Reader, stripPathComponents int) error {
66 var (

Callers 2

untarFunction · 0.85
unzipFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected