Skip to content

Commit 852b3be

Browse files
author
Camilo Aguilar
committed
Make file interface a bit more interoperable
1 parent d7a8afc commit 852b3be

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

fs.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,17 @@ type File interface {
173173
Lock() error
174174
// Unlock unlocks the file.
175175
Unlock() error
176+
// Readdir reads the contents of the directory associated with file and returns a
177+
// slice of up to n FileInfo values, as would be returned by Lstat, in directory order.
178+
// Subsequent calls on the same file will yield further FileInfos.
179+
// If n > 0, Readdir returns at most n FileInfo structures. In this case, if Readdir
180+
// returns an empty slice, it will return a non-nil error explaining why. At the end of
181+
// a directory, the error is io.EOF.
182+
// If n <= 0, Readdir returns all the FileInfo from the directory in a single slice.
183+
// In this case, if Readdir succeeds (reads all the way to the end of the directory),
184+
// it returns the slice and a nil error. If it encounters an error before the end of the directory,
185+
// Readdir returns the FileInfo read until that point and a non-nil error.
186+
Readdir(count int) ([]os.FileInfo, error)
176187
// Truncate the file.
177188
Truncate(size int64) error
178189
}

test/mock.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ func (*FileMock) Truncate(size int64) error {
135135
return nil
136136
}
137137

138+
func (*FileMock) Readdir(count int) ([]os.FileInfo, error) {
139+
return nil, nil
140+
}
141+
138142
type OnlyReadCapFs struct {
139143
BasicMock
140144
}

0 commit comments

Comments
 (0)