mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
os: yet more Readdir tests and fix earlier regression
R=golang-dev, fshahriar CC=golang-dev https://golang.org/cl/4548068
This commit is contained in:
parent
0e865ab8e7
commit
685a8157e6
2 changed files with 16 additions and 9 deletions
|
|
@ -32,11 +32,11 @@ func (f *File) Readdirnames(n int) (names []string, err Error) {
|
|||
f.dirinfo.buf = make([]byte, blockSize)
|
||||
}
|
||||
d := f.dirinfo
|
||||
wantAll := n <= 0
|
||||
|
||||
size := n
|
||||
if size < 0 {
|
||||
if size <= 0 {
|
||||
size = 100
|
||||
n = -1
|
||||
}
|
||||
|
||||
names = make([]string, 0, size) // Empty with room to grow.
|
||||
|
|
@ -60,7 +60,7 @@ func (f *File) Readdirnames(n int) (names []string, err Error) {
|
|||
d.bufp += nb
|
||||
n -= nc
|
||||
}
|
||||
if !wantAll && len(names) == 0 {
|
||||
if n >= 0 && len(names) == 0 {
|
||||
return names, EOF
|
||||
}
|
||||
return names, nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue