aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/os/file_posix.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/os/file_posix.go')
-rw-r--r--libgo/go/os/file_posix.go32
1 files changed, 14 insertions, 18 deletions
diff --git a/libgo/go/os/file_posix.go b/libgo/go/os/file_posix.go
index 86ac1cab2cb..073bd56a471 100644
--- a/libgo/go/os/file_posix.go
+++ b/libgo/go/os/file_posix.go
@@ -24,20 +24,8 @@ func epipecheck(file *File, e error) {
}
}
-// LinkError records an error during a link or symlink or rename
-// system call and the paths that caused it.
-type LinkError struct {
- Op string
- Old string
- New string
- Err error
-}
-
-func (e *LinkError) Error() string {
- return e.Op + " " + e.Old + " " + e.New + ": " + e.Err.Error()
-}
-
-// Link creates a hard link.
+// Link creates newname as a hard link to the oldname file.
+// If there is an error, it will be of type *LinkError.
func Link(oldname, newname string) error {
e := syscall.Link(oldname, newname)
if e != nil {
@@ -46,7 +34,8 @@ func Link(oldname, newname string) error {
return nil
}
-// Symlink creates a symbolic link.
+// Symlink creates newname as a symbolic link to oldname.
+// If there is an error, it will be of type *LinkError.
func Symlink(oldname, newname string) error {
e := syscall.Symlink(oldname, newname)
if e != nil {
@@ -55,8 +44,8 @@ func Symlink(oldname, newname string) error {
return nil
}
-// Readlink reads the contents of a symbolic link: the destination of
-// the link. It returns the contents and an error, if any.
+// Readlink returns the destination of the named symbolic link.
+// If there is an error, it will be of type *PathError.
func Readlink(name string) (string, error) {
for len := 128; ; len *= 2 {
b := make([]byte, len)
@@ -99,6 +88,7 @@ func syscallMode(i FileMode) (o uint32) {
// Chmod changes the mode of the named file to mode.
// If the file is a symbolic link, it changes the mode of the link's target.
+// If there is an error, it will be of type *PathError.
func Chmod(name string, mode FileMode) error {
if e := syscall.Chmod(name, syscallMode(mode)); e != nil {
return &PathError{"chmod", name, e}
@@ -107,6 +97,7 @@ func Chmod(name string, mode FileMode) error {
}
// Chmod changes the mode of the file to mode.
+// If there is an error, it will be of type *PathError.
func (f *File) Chmod(mode FileMode) error {
if e := syscall.Fchmod(f.fd, syscallMode(mode)); e != nil {
return &PathError{"chmod", f.name, e}
@@ -116,6 +107,7 @@ func (f *File) Chmod(mode FileMode) error {
// Chown changes the numeric uid and gid of the named file.
// If the file is a symbolic link, it changes the uid and gid of the link's target.
+// If there is an error, it will be of type *PathError.
func Chown(name string, uid, gid int) error {
if e := syscall.Chown(name, uid, gid); e != nil {
return &PathError{"chown", name, e}
@@ -125,6 +117,7 @@ func Chown(name string, uid, gid int) error {
// Lchown changes the numeric uid and gid of the named file.
// If the file is a symbolic link, it changes the uid and gid of the link itself.
+// If there is an error, it will be of type *PathError.
func Lchown(name string, uid, gid int) error {
if e := syscall.Lchown(name, uid, gid); e != nil {
return &PathError{"lchown", name, e}
@@ -133,6 +126,7 @@ func Lchown(name string, uid, gid int) error {
}
// Chown changes the numeric uid and gid of the named file.
+// If there is an error, it will be of type *PathError.
func (f *File) Chown(uid, gid int) error {
if e := syscall.Fchown(f.fd, uid, gid); e != nil {
return &PathError{"chown", f.name, e}
@@ -142,6 +136,7 @@ func (f *File) Chown(uid, gid int) error {
// Truncate changes the size of the file.
// It does not change the I/O offset.
+// If there is an error, it will be of type *PathError.
func (f *File) Truncate(size int64) error {
if e := syscall.Ftruncate(f.fd, size); e != nil {
return &PathError{"truncate", f.name, e}
@@ -154,7 +149,7 @@ func (f *File) Truncate(size int64) error {
// of recently written data to disk.
func (f *File) Sync() (err error) {
if f == nil {
- return EINVAL
+ return syscall.EINVAL
}
if e := syscall.Fsync(f.fd); e != nil {
return NewSyscallError("fsync", e)
@@ -167,6 +162,7 @@ func (f *File) Sync() (err error) {
//
// The underlying filesystem may truncate or round the values to a
// less precise time unit.
+// If there is an error, it will be of type *PathError.
func Chtimes(name string, atime time.Time, mtime time.Time) error {
var utimes [2]syscall.Timeval
atime_ns := atime.Unix()*1e9 + int64(atime.Nanosecond())