1
0
mirror of https://github.com/golang/go synced 2024-11-25 07:17:56 -07:00

os: be consistent with receiver names for godoc TOC alignment

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5449056
This commit is contained in:
Brad Fitzpatrick 2011-12-01 11:23:39 -08:00
parent fad57c0c03
commit 744fb52102
3 changed files with 40 additions and 40 deletions

View File

@ -14,7 +14,7 @@ import (
) )
// Name returns the name of the file as presented to Open. // 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, // Stdin, Stdout, and Stderr are open Files pointing to the standard input,
// standard output, and standard error file descriptors. // standard output, and standard error file descriptors.
@ -51,11 +51,11 @@ const (
// Read reads up to len(b) bytes from the File. // Read reads up to len(b) bytes from the File.
// It returns the number of bytes read and an error, if any. // 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. // EOF is signaled by a zero count with err set to io.EOF.
func (file *File) Read(b []byte) (n int, err error) { func (f *File) Read(b []byte) (n int, err error) {
if file == nil { if f == nil {
return 0, EINVAL return 0, EINVAL
} }
n, e := file.read(b) n, e := f.read(b)
if n < 0 { if n < 0 {
n = 0 n = 0
} }
@ -63,7 +63,7 @@ func (file *File) Read(b []byte) (n int, err error) {
return 0, io.EOF return 0, io.EOF
} }
if e != nil { if e != nil {
err = &PathError{"read", file.name, e} err = &PathError{"read", f.name, e}
} }
return n, err 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. // It returns the number of bytes read and the error, if any.
// ReadAt always returns a non-nil error when n < len(b). // ReadAt always returns a non-nil error when n < len(b).
// At end of file, that error is io.EOF. // At end of file, that error is io.EOF.
func (file *File) ReadAt(b []byte, off int64) (n int, err error) { func (f *File) ReadAt(b []byte, off int64) (n int, err error) {
if file == nil { if f == nil {
return 0, EINVAL return 0, EINVAL
} }
for len(b) > 0 { for len(b) > 0 {
m, e := file.pread(b, off) m, e := f.pread(b, off)
if m == 0 && e == nil { if m == 0 && e == nil {
return n, io.EOF return n, io.EOF
} }
if e != nil { if e != nil {
err = &PathError{"read", file.name, e} err = &PathError{"read", f.name, e}
break break
} }
n += m 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. // Write writes len(b) bytes to the File.
// It returns the number of bytes written and an error, if any. // It returns the number of bytes written and an error, if any.
// Write returns a non-nil error when n != len(b). // Write returns a non-nil error when n != len(b).
func (file *File) Write(b []byte) (n int, err error) { func (f *File) Write(b []byte) (n int, err error) {
if file == nil { if f == nil {
return 0, EINVAL return 0, EINVAL
} }
n, e := file.write(b) n, e := f.write(b)
if n < 0 { if n < 0 {
n = 0 n = 0
} }
epipecheck(file, e) epipecheck(f, e)
if e != nil { if e != nil {
err = &PathError{"write", file.name, e} err = &PathError{"write", f.name, e}
} }
return n, err 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. // 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. // It returns the number of bytes written and an error, if any.
// WriteAt returns a non-nil error when n != len(b). // WriteAt returns a non-nil error when n != len(b).
func (file *File) WriteAt(b []byte, off int64) (n int, err error) { func (f *File) WriteAt(b []byte, off int64) (n int, err error) {
if file == nil { if f == nil {
return 0, EINVAL return 0, EINVAL
} }
for len(b) > 0 { for len(b) > 0 {
m, e := file.pwrite(b, off) m, e := f.pwrite(b, off)
if e != nil { if e != nil {
err = &PathError{"write", file.name, e} err = &PathError{"write", f.name, e}
break break
} }
n += m 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 // 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. // relative to the current offset, and 2 means relative to the end.
// It returns the new offset and an error, if any. // It returns the new offset and an error, if any.
func (file *File) Seek(offset int64, whence int) (ret int64, err error) { func (f *File) Seek(offset int64, whence int) (ret int64, err error) {
r, e := file.seek(offset, whence) r, e := f.seek(offset, whence)
if e == nil && file.dirinfo != nil && r != 0 { if e == nil && f.dirinfo != nil && r != 0 {
e = syscall.EISDIR e = syscall.EISDIR
} }
if e != nil { if e != nil {
return 0, &PathError{"seek", file.name, e} return 0, &PathError{"seek", f.name, e}
} }
return r, nil return r, nil
} }
// WriteString is like Write, but writes the contents of string s rather than // WriteString is like Write, but writes the contents of string s rather than
// an array of bytes. // an array of bytes.
func (file *File) WriteString(s string) (ret int, err error) { func (f *File) WriteString(s string) (ret int, err error) {
if file == nil { if f == nil {
return 0, EINVAL 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. // Mkdir creates a new directory with the specified name and permission bits.

View File

@ -169,11 +169,11 @@ func (f *File) Truncate(size int64) error {
// Sync commits the current contents of the file to stable storage. // Sync commits the current contents of the file to stable storage.
// Typically, this means flushing the file system's in-memory copy // Typically, this means flushing the file system's in-memory copy
// of recently written data to disk. // of recently written data to disk.
func (file *File) Sync() (err error) { func (f *File) Sync() (err error) {
if file == nil { if f == nil {
return EINVAL return EINVAL
} }
if e := syscall.Fsync(file.fd); e != nil { if e := syscall.Fsync(f.fd); e != nil {
return NewSyscallError("fsync", e) return NewSyscallError("fsync", e)
} }
return nil return nil

View File

@ -28,11 +28,11 @@ type file struct {
} }
// Fd returns the integer Unix file descriptor referencing the open file. // Fd returns the integer Unix file descriptor referencing the open file.
func (file *File) Fd() int { func (f *File) Fd() int {
if file == nil { if f == nil {
return -1 return -1
} }
return file.fd return f.fd
} }
// NewFile returns a new File with the given file descriptor and name. // 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. // Close closes the File, rendering it unusable for I/O.
// It returns an error, if any. // It returns an error, if any.
func (file *File) Close() error { func (f *File) Close() error {
return file.file.close() return f.file.close()
} }
func (file *file) close() error { func (file *file) close() error {
@ -99,13 +99,13 @@ func (file *file) close() error {
// Stat returns the FileInfo structure describing file. // Stat returns the FileInfo structure describing file.
// It returns the FileInfo and an error, if any. // 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 var stat syscall.Stat_t
err = syscall.Fstat(file.fd, &stat) err = syscall.Fstat(f.fd, &stat)
if err != nil { 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. // 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 // nil error. If it encounters an error before the end of the
// directory, Readdir returns the FileInfo read until that point // directory, Readdir returns the FileInfo read until that point
// and a non-nil error. // and a non-nil error.
func (file *File) Readdir(n int) (fi []FileInfo, err error) { func (f *File) Readdir(n int) (fi []FileInfo, err error) {
dirname := file.name dirname := f.name
if dirname == "" { if dirname == "" {
dirname = "." dirname = "."
} }
dirname += "/" dirname += "/"
names, err := file.Readdirnames(n) names, err := f.Readdirnames(n)
fi = make([]FileInfo, len(names)) fi = make([]FileInfo, len(names))
for i, filename := range names { for i, filename := range names {
fip, err := Lstat(dirname + filename) fip, err := Lstat(dirname + filename)