Refactor to prep for new filesys.Walk

This commit is contained in:
Jeffrey Regan
2019-11-26 11:34:19 -08:00
parent 73fb32c85a
commit 3b2988bda8
7 changed files with 228 additions and 44 deletions

21
api/filesys/util.go Normal file
View File

@@ -0,0 +1,21 @@
// Copyright 2019 The Kubernetes Authors.
// SPDX-License-Identifier: Apache-2.0
package filesys
import "path/filepath"
// RootedPath returns a rooted path, e.g. "/foo/bar" as
// opposed to "foo/bar".
func RootedPath(elem ...string) string {
return Separator + filepath.Join(elem...)
}
// StripTrailingSeps trims trailing filepath separators from input.
func StripTrailingSeps(s string) string {
k := len(s)
for k > 0 && s[k-1] == filepath.Separator {
k--
}
return s[:k]
}