(fname string, stripPathComponents int)
| 50 | } |
| 51 | |
| 52 | func 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 | |
| 65 | func untar(dir string, r io.Reader, stripPathComponents int) error { |
| 66 | var ( |