summaryrefslogtreecommitdiff
path: root/src/pkg/os/dir_unix.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/os/dir_unix.go')
-rw-r--r--src/pkg/os/dir_unix.go23
1 files changed, 7 insertions, 16 deletions
diff --git a/src/pkg/os/dir_unix.go b/src/pkg/os/dir_unix.go
index 7835ed52b..f41f939a9 100644
--- a/src/pkg/os/dir_unix.go
+++ b/src/pkg/os/dir_unix.go
@@ -2,9 +2,12 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+// +build darwin freebsd linux netbsd openbsd
+
package os
import (
+ "io"
"syscall"
)
@@ -12,19 +15,7 @@ const (
blockSize = 4096
)
-// Readdirnames reads and returns a slice of names from the directory f.
-//
-// If n > 0, Readdirnames returns at most n names. In this case, if
-// Readdirnames returns an empty slice, it will return a non-nil error
-// explaining why. At the end of a directory, the error is os.EOF.
-//
-// If n <= 0, Readdirnames returns all the names from the directory in
-// a single slice. In this case, if Readdirnames succeeds (reads all
-// the way to the end of the directory), it returns the slice and a
-// nil os.Error. If it encounters an error before the end of the
-// directory, Readdirnames returns the names read until that point and
-// a non-nil error.
-func (f *File) Readdirnames(n int) (names []string, err Error) {
+func (f *File) readdirnames(n int) (names []string, err error) {
// If this file has no dirinfo, create one.
if f.dirinfo == nil {
f.dirinfo = new(dirInfo)
@@ -44,9 +35,9 @@ func (f *File) Readdirnames(n int) (names []string, err Error) {
// Refill the buffer if necessary
if d.bufp >= d.nbuf {
d.bufp = 0
- var errno int
+ var errno error
d.nbuf, errno = syscall.ReadDirent(f.fd, d.buf)
- if errno != 0 {
+ if errno != nil {
return names, NewSyscallError("readdirent", errno)
}
if d.nbuf <= 0 {
@@ -61,7 +52,7 @@ func (f *File) Readdirnames(n int) (names []string, err Error) {
n -= nc
}
if n >= 0 && len(names) == 0 {
- return names, EOF
+ return names, io.EOF
}
return names, nil
}