diff options
Diffstat (limited to 'libgo/go/os/file_plan9.go')
-rw-r--r-- | libgo/go/os/file_plan9.go | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/libgo/go/os/file_plan9.go b/libgo/go/os/file_plan9.go index c83fa028b9..5276a7ec54 100644 --- a/libgo/go/os/file_plan9.go +++ b/libgo/go/os/file_plan9.go @@ -5,14 +5,15 @@ package os import ( + "io" "runtime" "syscall" "time" ) -// File represents an open file descriptor. -type File struct { - *file +// fixLongPath is a noop on non-Windows platforms. +func fixLongPath(path string) string { + return path } // file is the real representation of *File. @@ -75,8 +76,8 @@ func syscallMode(i FileMode) (o uint32) { } // OpenFile is the generalized open call; most users will use Open -// or Create instead. It opens the named file with specified flag -// (O_RDONLY etc.) and perm, (0666 etc.) if applicable. If successful, +// or Create instead. It opens the named file with specified flag +// (O_RDONLY etc.) and perm, (0666 etc.) if applicable. If successful, // methods on the returned File can be used for I/O. // If there is an error, it will be of type *PathError. func OpenFile(name string, flag int, perm FileMode) (*File, error) { @@ -123,7 +124,7 @@ func OpenFile(name string, flag int, perm FileMode) (*File, error) { } if append { - if _, e = syscall.Seek(fd, 0, SEEK_END); e != nil { + if _, e = syscall.Seek(fd, 0, io.SeekEnd); e != nil { return nil, &PathError{"seek", name, e} } } @@ -134,23 +135,21 @@ func OpenFile(name string, flag int, perm FileMode) (*File, 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 + if err := f.checkValid("close"); err != nil { + return err } return f.file.close() } func (file *file) close() error { - if file == nil || file.fd < 0 { + if file == nil || file.fd == badFd { return ErrInvalid } var err error - syscall.ForkLock.RLock() if e := syscall.Close(file.fd); e != nil { err = &PathError{"close", file.name, e} } - syscall.ForkLock.RUnlock() - file.fd = -1 // so it can't be closed again + file.fd = badFd // so it can't be closed again // no need for a finalizer anymore runtime.SetFinalizer(file, nil) @@ -419,12 +418,9 @@ func Chtimes(name string, atime time.Time, mtime time.Time) error { func Pipe() (r *File, w *File, err error) { var p [2]int - syscall.ForkLock.RLock() if e := syscall.Pipe(p[0:]); e != nil { - syscall.ForkLock.RUnlock() return nil, nil, NewSyscallError("pipe", e) } - syscall.ForkLock.RUnlock() return NewFile(uintptr(p[0]), "|0"), NewFile(uintptr(p[1]), "|1"), nil } |