mirror of
https://github.com/golang/go
synced 2024-11-21 20:34:40 -07:00
os: fix build for Plan 9
R=golang-dev, alex.brainman CC=golang-dev https://golang.org/cl/4657074
This commit is contained in:
parent
cc9fed7c1a
commit
bedee318d5
@ -9,6 +9,32 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// File represents an open file descriptor.
|
||||||
|
type File struct {
|
||||||
|
fd int
|
||||||
|
name string
|
||||||
|
dirinfo *dirInfo // nil unless directory being read
|
||||||
|
nepipe int // number of consecutive EPIPE in Write
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fd returns the integer Unix file descriptor referencing the open file.
|
||||||
|
func (file *File) Fd() int {
|
||||||
|
if file == nil {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
return file.fd
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewFile returns a new File with the given file descriptor and name.
|
||||||
|
func NewFile(fd int, name string) *File {
|
||||||
|
if fd < 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
f := &File{fd: fd, name: name}
|
||||||
|
runtime.SetFinalizer(f, (*File).Close)
|
||||||
|
return f
|
||||||
|
}
|
||||||
|
|
||||||
// Auxiliary information if the File describes a directory
|
// Auxiliary information if the File describes a directory
|
||||||
type dirInfo struct {
|
type dirInfo struct {
|
||||||
buf [syscall.STATMAX]byte // buffer for directory I/O
|
buf [syscall.STATMAX]byte // buffer for directory I/O
|
||||||
|
@ -6,7 +6,6 @@ package os
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"runtime"
|
"runtime"
|
||||||
"sync"
|
|
||||||
"syscall"
|
"syscall"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -14,9 +13,8 @@ import (
|
|||||||
type File struct {
|
type File struct {
|
||||||
fd int
|
fd int
|
||||||
name string
|
name string
|
||||||
dirinfo *dirInfo // nil unless directory being read
|
dirinfo *dirInfo // nil unless directory being read
|
||||||
nepipe int // number of consecutive EPIPE in Write
|
nepipe int // number of consecutive EPIPE in Write
|
||||||
l sync.Mutex // used to implement windows pread/pwrite
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fd returns the integer Unix file descriptor referencing the open file.
|
// Fd returns the integer Unix file descriptor referencing the open file.
|
||||||
|
Loading…
Reference in New Issue
Block a user