diff options
| author | Ondřej Surý <ondrej@sury.org> | 2011-07-08 09:16:22 +0200 |
|---|---|---|
| committer | Ondřej Surý <ondrej@sury.org> | 2011-07-08 09:52:32 +0200 |
| commit | 85cafef129c3826b0c5e290c89cfc7251fba43d5 (patch) | |
| tree | e59b124753eb1eec194ec682a7815c401388f10d /src/pkg/os/file.go | |
| parent | 67c487c4bd0fc91c2ce5972886d108e0d2939064 (diff) | |
| download | golang-85cafef129c3826b0c5e290c89cfc7251fba43d5.tar.gz | |
Imported Upstream version 2011.07.07
Diffstat (limited to 'src/pkg/os/file.go')
| -rw-r--r-- | src/pkg/os/file.go | 28 |
1 files changed, 1 insertions, 27 deletions
diff --git a/src/pkg/os/file.go b/src/pkg/os/file.go index 0e97e0bd9..4335d45e5 100644 --- a/src/pkg/os/file.go +++ b/src/pkg/os/file.go @@ -9,36 +9,12 @@ package os import ( - "runtime" - "sync" "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 - l sync.Mutex // used to implement windows pread/pwrite -} - -// Fd returns the integer Unix file descriptor referencing the open file. -func (file *File) Fd() int { return file.fd } - // Name returns the name of the file as presented to Open. func (file *File) Name() string { return file.name } -// 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 -} - // Stdin, Stdout, and Stderr are open Files pointing to the standard input, // standard output, and standard error file descriptors. var ( @@ -187,9 +163,7 @@ func (file *File) WriteString(s string) (ret int, err Error) { if file == nil { return 0, EINVAL } - b := syscall.StringByteSlice(s) - b = b[0 : len(b)-1] - return file.Write(b) + return file.Write([]byte(s)) } // Mkdir creates a new directory with the specified name and permission bits. |
