aboutsummaryrefslogtreecommitdiff
path: root/src/path/filepath
diff options
context:
space:
mode:
Diffstat (limited to 'src/path/filepath')
-rw-r--r--src/path/filepath/path.go15
-rw-r--r--src/path/filepath/path_test.go15
2 files changed, 2 insertions, 28 deletions
diff --git a/src/path/filepath/path.go b/src/path/filepath/path.go
index 41fa733af9..6dcb0e1fb9 100644
--- a/src/path/filepath/path.go
+++ b/src/path/filepath/path.go
@@ -545,7 +545,7 @@ func WalkDir(root string, fn fs.WalkDirFunc) error {
if err != nil {
err = fn(root, nil, err)
} else {
- err = walkDir(root, &statDirEntry{info}, fn)
+ err = walkDir(root, fs.FileInfoToDirEntry(info), fn)
}
if err == SkipDir || err == SkipAll {
return nil
@@ -553,19 +553,6 @@ func WalkDir(root string, fn fs.WalkDirFunc) error {
return err
}
-type statDirEntry struct {
- info fs.FileInfo
-}
-
-func (d *statDirEntry) Name() string { return d.info.Name() }
-func (d *statDirEntry) IsDir() bool { return d.info.IsDir() }
-func (d *statDirEntry) Type() fs.FileMode { return d.info.Mode().Type() }
-func (d *statDirEntry) Info() (fs.FileInfo, error) { return d.info, nil }
-
-func (d *statDirEntry) String() string {
- return fs.FormatDirEntry(d)
-}
-
// Walk walks the file tree rooted at root, calling fn for each file or
// directory in the tree, including root.
//
diff --git a/src/path/filepath/path_test.go b/src/path/filepath/path_test.go
index 621208d31e..51e6a20554 100644
--- a/src/path/filepath/path_test.go
+++ b/src/path/filepath/path_test.go
@@ -560,25 +560,12 @@ func tempDirCanonical(t *testing.T) string {
func TestWalk(t *testing.T) {
walk := func(root string, fn fs.WalkDirFunc) error {
return filepath.Walk(root, func(path string, info fs.FileInfo, err error) error {
- return fn(path, &statDirEntry{info}, err)
+ return fn(path, fs.FileInfoToDirEntry(info), err)
})
}
testWalk(t, walk, 1)
}
-type statDirEntry struct {
- info fs.FileInfo
-}
-
-func (d *statDirEntry) Name() string { return d.info.Name() }
-func (d *statDirEntry) IsDir() bool { return d.info.IsDir() }
-func (d *statDirEntry) Type() fs.FileMode { return d.info.Mode().Type() }
-func (d *statDirEntry) Info() (fs.FileInfo, error) { return d.info, nil }
-
-func (d *statDirEntry) String() string {
- return fs.FormatDirEntry(d)
-}
-
func TestWalkDir(t *testing.T) {
testWalk(t, filepath.WalkDir, 2)
}