mirror of https://github.com/spf13/afero.git
parent
63644898a8
commit
787d034dfe
|
@ -570,6 +570,25 @@ func TestReaddir(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// https://github.com/spf13/afero/issues/169
|
||||
func TestReaddirRegularFile(t *testing.T) {
|
||||
defer removeAllTestFiles(t)
|
||||
for _, fs := range Fss {
|
||||
f := tmpFile(fs)
|
||||
defer f.Close()
|
||||
|
||||
_, err := f.Readdirnames(-1)
|
||||
if err == nil {
|
||||
t.Fatal("Expected error")
|
||||
}
|
||||
|
||||
_, err = f.Readdir(-1)
|
||||
if err == nil {
|
||||
t.Fatal("Expected error")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type myFileInfo []os.FileInfo
|
||||
|
||||
func (m myFileInfo) String() string {
|
||||
|
|
|
@ -131,6 +131,9 @@ func (f *File) Sync() error {
|
|||
}
|
||||
|
||||
func (f *File) Readdir(count int) (res []os.FileInfo, err error) {
|
||||
if !f.fileData.dir {
|
||||
return nil, &os.PathError{Op: "readdir", Path: f.fileData.name, Err: errors.New("not a dir")}
|
||||
}
|
||||
var outLength int64
|
||||
|
||||
f.fileData.Lock()
|
||||
|
|
Loading…
Reference in New Issue