summaryrefslogtreecommitdiffstats
path: root/helpers/path.go
diff options
context:
space:
mode:
Diffstat (limited to 'helpers/path.go')
-rw-r--r--helpers/path.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/helpers/path.go b/helpers/path.go
index f39815b6e..1ac5a87d8 100644
--- a/helpers/path.go
+++ b/helpers/path.go
@@ -428,6 +428,24 @@ func FindCWD() (string, error) {
return path, nil
}
+// SymbolicWalk is like filepath.Walk, but it supports the root being a
+// symbolic link. It will still not follow symbolic links deeper down in
+// the file structure
+func SymbolicWalk(fs afero.Fs, root string, walker filepath.WalkFunc) error {
+ rootContent, err := afero.ReadDir(fs, root)
+
+ if err != nil {
+ return walker(root, nil, err)
+ }
+
+ for _, fi := range rootContent {
+ afero.Walk(fs, filepath.Join(root, fi.Name()), walker)
+ }
+
+ return nil
+
+}
+
// Same as WriteToDisk but checks to see if file/directory already exists.
func SafeWriteToDisk(inpath string, r io.Reader, fs afero.Fs) (err error) {
return afero.SafeWriteReader(fs, inpath, r)