Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
744fb521
Commit
744fb521
authored
Dec 01, 2011
by
Brad Fitzpatrick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
os: be consistent with receiver names for godoc TOC alignment
R=golang-dev, r CC=golang-dev
https://golang.org/cl/5449056
parent
fad57c0c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
40 deletions
+40
-40
file.go
src/pkg/os/file.go
+25
-25
file_posix.go
src/pkg/os/file_posix.go
+3
-3
file_unix.go
src/pkg/os/file_unix.go
+12
-12
No files found.
src/pkg/os/file.go
View file @
744fb521
...
...
@@ -14,7 +14,7 @@ import (
)
// Name returns the name of the file as presented to Open.
func
(
f
ile
*
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
(
f
ile
*
File
)
Read
(
b
[]
byte
)
(
n
int
,
err
error
)
{
if
f
ile
==
nil
{
func
(
f
*
File
)
Read
(
b
[]
byte
)
(
n
int
,
err
error
)
{
if
f
==
nil
{
return
0
,
EINVAL
}
n
,
e
:=
f
ile
.
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"
,
f
ile
.
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
(
f
ile
*
File
)
ReadAt
(
b
[]
byte
,
off
int64
)
(
n
int
,
err
error
)
{
if
f
ile
==
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
:=
f
ile
.
pread
(
b
,
off
)
m
,
e
:=
f
.
pread
(
b
,
off
)
if
m
==
0
&&
e
==
nil
{
return
n
,
io
.
EOF
}
if
e
!=
nil
{
err
=
&
PathError
{
"read"
,
f
ile
.
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
(
f
ile
*
File
)
Write
(
b
[]
byte
)
(
n
int
,
err
error
)
{
if
f
ile
==
nil
{
func
(
f
*
File
)
Write
(
b
[]
byte
)
(
n
int
,
err
error
)
{
if
f
==
nil
{
return
0
,
EINVAL
}
n
,
e
:=
f
ile
.
write
(
b
)
n
,
e
:=
f
.
write
(
b
)
if
n
<
0
{
n
=
0
}
epipecheck
(
f
ile
,
e
)
epipecheck
(
f
,
e
)
if
e
!=
nil
{
err
=
&
PathError
{
"write"
,
f
ile
.
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
(
f
ile
*
File
)
WriteAt
(
b
[]
byte
,
off
int64
)
(
n
int
,
err
error
)
{
if
f
ile
==
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
:=
f
ile
.
pwrite
(
b
,
off
)
m
,
e
:=
f
.
pwrite
(
b
,
off
)
if
e
!=
nil
{
err
=
&
PathError
{
"write"
,
f
ile
.
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
(
f
ile
*
File
)
Seek
(
offset
int64
,
whence
int
)
(
ret
int64
,
err
error
)
{
r
,
e
:=
f
ile
.
seek
(
offset
,
whence
)
if
e
==
nil
&&
f
ile
.
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"
,
f
ile
.
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
(
f
ile
*
File
)
WriteString
(
s
string
)
(
ret
int
,
err
error
)
{
if
f
ile
==
nil
{
func
(
f
*
File
)
WriteString
(
s
string
)
(
ret
int
,
err
error
)
{
if
f
==
nil
{
return
0
,
EINVAL
}
return
f
ile
.
Write
([]
byte
(
s
))
return
f
.
Write
([]
byte
(
s
))
}
// Mkdir creates a new directory with the specified name and permission bits.
...
...
src/pkg/os/file_posix.go
View file @
744fb521
...
...
@@ -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
(
f
ile
*
File
)
Sync
()
(
err
error
)
{
if
f
ile
==
nil
{
func
(
f
*
File
)
Sync
()
(
err
error
)
{
if
f
==
nil
{
return
EINVAL
}
if
e
:=
syscall
.
Fsync
(
f
ile
.
fd
);
e
!=
nil
{
if
e
:=
syscall
.
Fsync
(
f
.
fd
);
e
!=
nil
{
return
NewSyscallError
(
"fsync"
,
e
)
}
return
nil
...
...
src/pkg/os/file_unix.go
View file @
744fb521
...
...
@@ -28,11 +28,11 @@ type file struct {
}
// Fd returns the integer Unix file descriptor referencing the open file.
func
(
f
ile
*
File
)
Fd
()
int
{
if
f
ile
==
nil
{
func
(
f
*
File
)
Fd
()
int
{
if
f
==
nil
{
return
-
1
}
return
f
ile
.
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
(
f
ile
*
File
)
Close
()
error
{
return
f
ile
.
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
(
f
ile
*
File
)
Stat
()
(
fi
FileInfo
,
err
error
)
{
func
(
f
*
File
)
Stat
()
(
fi
FileInfo
,
err
error
)
{
var
stat
syscall
.
Stat_t
err
=
syscall
.
Fstat
(
f
ile
.
fd
,
&
stat
)
err
=
syscall
.
Fstat
(
f
.
fd
,
&
stat
)
if
err
!=
nil
{
return
nil
,
&
PathError
{
"stat"
,
f
ile
.
name
,
err
}
return
nil
,
&
PathError
{
"stat"
,
f
.
name
,
err
}
}
return
fileInfoFromStat
(
&
stat
,
f
ile
.
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
(
f
ile
*
File
)
Readdir
(
n
int
)
(
fi
[]
FileInfo
,
err
error
)
{
dirname
:=
f
ile
.
name
func
(
f
*
File
)
Readdir
(
n
int
)
(
fi
[]
FileInfo
,
err
error
)
{
dirname
:=
f
.
name
if
dirname
==
""
{
dirname
=
"."
}
dirname
+=
"/"
names
,
err
:=
f
ile
.
Readdirnames
(
n
)
names
,
err
:=
f
.
Readdirnames
(
n
)
fi
=
make
([]
FileInfo
,
len
(
names
))
for
i
,
filename
:=
range
names
{
fip
,
err
:=
Lstat
(
dirname
+
filename
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment