diff options
author | Ondřej Surý <ondrej@sury.org> | 2011-08-03 16:54:30 +0200 |
---|---|---|
committer | Ondřej Surý <ondrej@sury.org> | 2011-08-03 16:54:30 +0200 |
commit | 28592ee1ea1f5cdffcf85472f9de0285d928cf12 (patch) | |
tree | 32944e18b23f7fe4a0818a694aa2a6dfb1835463 /src/pkg/os/file.go | |
parent | e836bee4716dc0d4d913537ad3ad1925a7ac32d0 (diff) | |
download | golang-upstream/59.tar.gz |
Imported Upstream version 59upstream/59
Diffstat (limited to 'src/pkg/os/file.go')
-rw-r--r-- | src/pkg/os/file.go | 30 |
1 files changed, 3 insertions, 27 deletions
diff --git a/src/pkg/os/file.go b/src/pkg/os/file.go index dff8fa862..4335d45e5 100644 --- a/src/pkg/os/file.go +++ b/src/pkg/os/file.go @@ -4,39 +4,17 @@ // Package os provides a platform-independent interface to operating system // functionality. The design is Unix-like. +// The os interface is intended to be uniform across all operating systems. +// Features not generally available appear in the system-specific package syscall. 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 ( @@ -185,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. |