aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@golang.org>2011-12-01 11:23:39 -0800
committerBrad Fitzpatrick <bradfitz@golang.org>2011-12-01 11:23:39 -0800
commit744fb52102642382d09968d8bc0fe4090af20360 (patch)
treeb793e22880fc4fb78f97b9f8bff2299dae7a5115
parentfad57c0c030b5f5b6204b781b33d4343f95d6c40 (diff)
downloadgo-744fb52102642382d09968d8bc0fe4090af20360.tar.gz
go-744fb52102642382d09968d8bc0fe4090af20360.zip
os: be consistent with receiver names for godoc TOC alignment
R=golang-dev, r CC=golang-dev https://golang.org/cl/5449056
-rw-r--r--src/pkg/os/file.go50
-rw-r--r--src/pkg/os/file_posix.go6
-rw-r--r--src/pkg/os/file_unix.go24
3 files changed, 40 insertions, 40 deletions
diff --git a/src/pkg/os/file.go b/src/pkg/os/file.go
index 6a8d346f5c..71845d3c9c 100644
--- a/src/pkg/os/file.go
+++ b/src/pkg/os/file.go
@@ -14,7 +14,7 @@ import (
)
// Name returns the name of the file as presented to Open.
-func (file *File) Name() string { return file.name }
+func (f *File) Name() string { return f.name }
// Stdin, Stdout, and Stderr are open Files pointing to the standard input,
// standard output, and standard error file descriptors.
@@ -51,11 +51,11 @@ const (
// Read reads up to len(b) bytes from the File.
// It returns the number of bytes read and an error, if any.
// EOF is signaled by a zero count with err set to io.EOF.
-func (file *File) Read(b []byte) (n int, err error) {
- if file == nil {
+func (f *File) Read(b []byte) (n int, err error) {
+ if f == nil {
return 0, EINVAL
}
- n, e := file.read(b)
+ n, e := f.read(b)
if n < 0 {
n = 0
}
@@ -63,7 +63,7 @@ func (file *File) Read(b []byte) (n int, err error) {
return 0, io.EOF
}
if e != nil {
- err = &PathError{"read", file.name, e}
+ err = &PathError{"read", f.name, e}
}
return n, err
}
@@ -72,17 +72,17 @@ func (file *File) Read(b []byte) (n int, err error) {
// It returns the number of bytes read and the error, if any.
// ReadAt always returns a non-nil error when n < len(b).
// At end of file, that error is io.EOF.
-func (file *File) ReadAt(b []byte, off int64) (n int, err error) {
- if file == nil {
+func (f *File) ReadAt(b []byte, off int64) (n int, err error) {
+ if f == nil {
return 0, EINVAL
}
for len(b) > 0 {
- m, e := file.pread(b, off)
+ m, e := f.pread(b, off)
if m == 0 && e == nil {
return n, io.EOF
}
if e != nil {
- err = &PathError{"read", file.name, e}
+ err = &PathError{"read", f.name, e}
break
}
n += m
@@ -95,19 +95,19 @@ func (file *File) ReadAt(b []byte, off int64) (n int, err error) {
// Write writes len(b) bytes to the File.
// It returns the number of bytes written and an error, if any.
// Write returns a non-nil error when n != len(b).
-func (file *File) Write(b []byte) (n int, err error) {
- if file == nil {
+func (f *File) Write(b []byte) (n int, err error) {
+ if f == nil {
return 0, EINVAL
}
- n, e := file.write(b)
+ n, e := f.write(b)
if n < 0 {
n = 0
}
- epipecheck(file, e)
+ epipecheck(f, e)
if e != nil {
- err = &PathError{"write", file.name, e}
+ err = &PathError{"write", f.name, e}
}
return n, err
}
@@ -115,14 +115,14 @@ func (file *File) Write(b []byte) (n int, err error) {
// WriteAt writes len(b) bytes to the File starting at byte offset off.
// It returns the number of bytes written and an error, if any.
// WriteAt returns a non-nil error when n != len(b).
-func (file *File) WriteAt(b []byte, off int64) (n int, err error) {
- if file == nil {
+func (f *File) WriteAt(b []byte, off int64) (n int, err error) {
+ if f == nil {
return 0, EINVAL
}
for len(b) > 0 {
- m, e := file.pwrite(b, off)
+ m, e := f.pwrite(b, off)
if e != nil {
- err = &PathError{"write", file.name, e}
+ err = &PathError{"write", f.name, e}
break
}
n += m
@@ -136,24 +136,24 @@ func (file *File) WriteAt(b []byte, off int64) (n int, err error) {
// according to whence: 0 means relative to the origin of the file, 1 means
// relative to the current offset, and 2 means relative to the end.
// It returns the new offset and an error, if any.
-func (file *File) Seek(offset int64, whence int) (ret int64, err error) {
- r, e := file.seek(offset, whence)
- if e == nil && file.dirinfo != nil && r != 0 {
+func (f *File) Seek(offset int64, whence int) (ret int64, err error) {
+ r, e := f.seek(offset, whence)
+ if e == nil && f.dirinfo != nil && r != 0 {
e = syscall.EISDIR
}
if e != nil {
- return 0, &PathError{"seek", file.name, e}
+ return 0, &PathError{"seek", f.name, e}
}
return r, nil
}
// WriteString is like Write, but writes the contents of string s rather than
// an array of bytes.
-func (file *File) WriteString(s string) (ret int, err error) {
- if file == nil {
+func (f *File) WriteString(s string) (ret int, err error) {
+ if f == nil {
return 0, EINVAL
}
- return file.Write([]byte(s))
+ return f.Write([]byte(s))
}
// Mkdir creates a new directory with the specified name and permission bits.
diff --git a/src/pkg/os/file_posix.go b/src/pkg/os/file_posix.go
index 9662f64da3..a4ab5d6ae2 100644
--- a/src/pkg/os/file_posix.go
+++ b/src/pkg/os/file_posix.go
@@ -169,11 +169,11 @@ func (f *File) Truncate(size int64) error {
// Sync commits the current contents of the file to stable storage.
// Typically, this means flushing the file system's in-memory copy
// of recently written data to disk.
-func (file *File) Sync() (err error) {
- if file == nil {
+func (f *File) Sync() (err error) {
+ if f == nil {
return EINVAL
}
- if e := syscall.Fsync(file.fd); e != nil {
+ if e := syscall.Fsync(f.fd); e != nil {
return NewSyscallError("fsync", e)
}
return nil
diff --git a/src/pkg/os/file_unix.go b/src/pkg/os/file_unix.go
index 6e08eb6134..5e16780741 100644
--- a/src/pkg/os/file_unix.go
+++ b/src/pkg/os/file_unix.go
@@ -28,11 +28,11 @@ type file struct {
}
// Fd returns the integer Unix file descriptor referencing the open file.
-func (file *File) Fd() int {
- if file == nil {
+func (f *File) Fd() int {
+ if f == nil {
return -1
}
- return file.fd
+ return f.fd
}
// NewFile returns a new File with the given file descriptor and name.
@@ -78,8 +78,8 @@ func OpenFile(name string, flag int, perm uint32) (file *File, err error) {
// Close closes the File, rendering it unusable for I/O.
// It returns an error, if any.
-func (file *File) Close() error {
- return file.file.close()
+func (f *File) Close() error {
+ return f.file.close()
}
func (file *file) close() error {
@@ -99,13 +99,13 @@ func (file *file) close() error {
// Stat returns the FileInfo structure describing file.
// It returns the FileInfo and an error, if any.
-func (file *File) Stat() (fi FileInfo, err error) {
+func (f *File) Stat() (fi FileInfo, err error) {
var stat syscall.Stat_t
- err = syscall.Fstat(file.fd, &stat)
+ err = syscall.Fstat(f.fd, &stat)
if err != nil {
- return nil, &PathError{"stat", file.name, err}
+ return nil, &PathError{"stat", f.name, err}
}
- return fileInfoFromStat(&stat, file.name), nil
+ return fileInfoFromStat(&stat, f.name), nil
}
// Stat returns a FileInfo describing the named file and an error, if any.
@@ -149,13 +149,13 @@ func Lstat(name string) (fi FileInfo, err error) {
// nil error. If it encounters an error before the end of the
// directory, Readdir returns the FileInfo read until that point
// and a non-nil error.
-func (file *File) Readdir(n int) (fi []FileInfo, err error) {
- dirname := file.name
+func (f *File) Readdir(n int) (fi []FileInfo, err error) {
+ dirname := f.name
if dirname == "" {
dirname = "."
}
dirname += "/"
- names, err := file.Readdirnames(n)
+ names, err := f.Readdirnames(n)
fi = make([]FileInfo, len(names))
for i, filename := range names {
fip, err := Lstat(dirname + filename)