diff --git a/internal/fs/fs_reader.go b/internal/fs/fs_reader.go index 84a79168e..9dd5ff6eb 100644 --- a/internal/fs/fs_reader.go +++ b/internal/fs/fs_reader.go @@ -237,10 +237,6 @@ func (f fakeFile) Readdirnames(_ int) ([]string, error) { return nil, pathError("readdirnames", f.name, os.ErrInvalid) } -func (f fakeFile) Readdir(_ int) ([]os.FileInfo, error) { - return nil, pathError("readdir", f.name, os.ErrInvalid) -} - func (f fakeFile) Seek(int64, int) (int64, error) { return 0, pathError("seek", f.name, os.ErrInvalid) } @@ -279,13 +275,6 @@ func (d fakeDir) Readdirnames(n int) ([]string, error) { return names, nil } -func (d fakeDir) Readdir(n int) ([]os.FileInfo, error) { - if n > 0 { - return nil, pathError("readdir", d.name, errors.New("not implemented")) - } - return d.entries, nil -} - // fakeFileInfo implements the bare minimum of os.FileInfo. type fakeFileInfo struct { name string diff --git a/internal/fs/fs_reader_test.go b/internal/fs/fs_reader_test.go index 9fa67b5ac..442912fe3 100644 --- a/internal/fs/fs_reader_test.go +++ b/internal/fs/fs_reader_test.go @@ -60,77 +60,6 @@ func verifyDirectoryContents(t testing.TB, fs FS, dir string, want []string) { } } -type fiSlice []os.FileInfo - -func (s fiSlice) Len() int { - return len(s) -} - -func (s fiSlice) Less(i, j int) bool { - return s[i].Name() < s[j].Name() -} - -func (s fiSlice) Swap(i, j int) { - s[i], s[j] = s[j], s[i] -} - -func verifyDirectoryContentsFI(t testing.TB, fs FS, dir string, want []os.FileInfo) { - f, err := fs.OpenFile(dir, os.O_RDONLY, 0) - if err != nil { - t.Fatal(err) - } - - entries, err := f.Readdir(-1) - if err != nil { - t.Fatal(err) - } - - err = f.Close() - if err != nil { - t.Fatal(err) - } - - sort.Sort(fiSlice(want)) - sort.Sort(fiSlice(entries)) - - if len(want) != len(entries) { - t.Errorf("wrong number of entries returned, want %d, got %d", len(want), len(entries)) - } - max := len(want) - if len(entries) < max { - max = len(entries) - } - - for i := 0; i < max; i++ { - fi1 := want[i] - fi2 := entries[i] - - if fi1.Name() != fi2.Name() { - t.Errorf("entry %d: wrong value for Name: want %q, got %q", i, fi1.Name(), fi2.Name()) - } - - if fi1.IsDir() != fi2.IsDir() { - t.Errorf("entry %d: wrong value for IsDir: want %v, got %v", i, fi1.IsDir(), fi2.IsDir()) - } - - if fi1.Mode() != fi2.Mode() { - t.Errorf("entry %d: wrong value for Mode: want %v, got %v", i, fi1.Mode(), fi2.Mode()) - } - - if fi1.ModTime() != fi2.ModTime() { - t.Errorf("entry %d: wrong value for ModTime: want %v, got %v", i, fi1.ModTime(), fi2.ModTime()) - } - - if fi1.Size() != fi2.Size() { - t.Errorf("entry %d: wrong value for Size: want %v, got %v", i, fi1.Size(), fi2.Size()) - } - - if fi1.Sys() != fi2.Sys() { - t.Errorf("entry %d: wrong value for Sys: want %v, got %v", i, fi1.Sys(), fi2.Sys()) - } - } -} - func checkFileInfo(t testing.TB, fi os.FileInfo, filename string, modtime time.Time, mode os.FileMode, isdir bool) { if fi.IsDir() != isdir { t.Errorf("IsDir returned %t, want %t", fi.IsDir(), isdir) @@ -174,30 +103,6 @@ func TestFSReader(t *testing.T) { verifyDirectoryContents(t, fs, ".", []string{filename}) }, }, - { - name: "Readdir-slash", - f: func(t *testing.T, fs FS) { - fi := fakeFileInfo{ - mode: 0644, - modtime: now, - name: filename, - size: int64(len(data)), - } - verifyDirectoryContentsFI(t, fs, "/", []os.FileInfo{fi}) - }, - }, - { - name: "Readdir-current", - f: func(t *testing.T, fs FS) { - fi := fakeFileInfo{ - mode: 0644, - modtime: now, - name: filename, - size: int64(len(data)), - } - verifyDirectoryContentsFI(t, fs, ".", []os.FileInfo{fi}) - }, - }, { name: "file/OpenFile", f: func(t *testing.T, fs FS) { diff --git a/internal/fs/interface.go b/internal/fs/interface.go index bc6aab44a..7707abd1d 100644 --- a/internal/fs/interface.go +++ b/internal/fs/interface.go @@ -31,7 +31,6 @@ type File interface { Fd() uintptr Readdirnames(n int) ([]string, error) - Readdir(int) ([]os.FileInfo, error) Seek(int64, int) (int64, error) Stat() (os.FileInfo, error) Name() string