diff --git a/walk.go b/walk.go index 1075f12..70c7d27 100644 --- a/walk.go +++ b/walk.go @@ -39,7 +39,9 @@ func walk(fileSystem LstatReadDirer, path string, walkFn filepath.WalkFunc, info } dirEntries, err := fileSystem.ReadDir(path) if err != nil { - return err + if err := walkFn(path, info, err); err != nil { + return err + } } sort.Sort(dirEntriesByName(dirEntries)) for _, dirEntry := range dirEntries { @@ -47,11 +49,14 @@ func walk(fileSystem LstatReadDirer, path string, walkFn filepath.WalkFunc, info if name == "." || name == ".." { continue } + path := filepath.Join(path, dirEntry.Name()) info, err := dirEntry.Info() if err != nil { - return err + if err := walkFn(path, info, err); err != nil { + return err + } } - if err := walk(fileSystem, filepath.Join(path, dirEntry.Name()), walkFn, info, nil); err != nil { + if err := walk(fileSystem, path, walkFn, info, nil); err != nil { return err } }