diff options
author | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-11-06 19:49:01 +0000 |
---|---|---|
committer | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-11-06 19:49:01 +0000 |
commit | 0ce10ea1348e9afd5d0eec6bca986bfe58bac5ac (patch) | |
tree | 39530b071991b2326f881b2a30a2d82d6c133fd6 /libgo/go/os/file_unix.go | |
parent | 57a8bf1b0c6057ccbacb0cf79eb84d1985c2c1fe (diff) |
libgo: Update to October 24 version of master library.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@204466 138bc75d-0d04-0410-961f-82ee72b054a4
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 993a4380c187..79eeaec5023c 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 |