diff options
Diffstat (limited to 'libgo/go/os/file_unix.go')
-rw-r--r-- | libgo/go/os/file_unix.go | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/libgo/go/os/file_unix.go b/libgo/go/os/file_unix.go index 993a4380c18..79eeaec5023 100644 --- a/libgo/go/os/file_unix.go +++ b/libgo/go/os/file_unix.go @@ -2,7 +2,7 @@ // 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 +// +build darwin dragonfly freebsd linux netbsd openbsd package os @@ -95,6 +95,9 @@ func OpenFile(name string, flag int, perm FileMode) (file *File, err error) { // Close closes the File, rendering it unusable for I/O. // It returns an error, if any. func (f *File) Close() error { + if f == nil { + return ErrInvalid + } return f.file.close() } @@ -128,6 +131,9 @@ func (file *file) close() error { // Stat returns the FileInfo structure describing file. // If there is an error, it will be of type *PathError. func (f *File) Stat() (fi FileInfo, err error) { + if f == nil { + return nil, ErrInvalid + } var stat syscall.Stat_t err = syscall.Fstat(f.fd, &stat) if err != nil { @@ -169,11 +175,14 @@ func (f *File) readdir(n int) (fi []FileInfo, err error) { names, err := f.Readdirnames(n) fi = make([]FileInfo, len(names)) for i, filename := range names { - fip, err := Lstat(dirname + filename) - if err == nil { + fip, lerr := lstat(dirname + filename) + if lerr == nil { fi[i] = fip } else { fi[i] = &fileStat{name: filename} + if err == nil { + err = lerr + } } } return fi, err |