summaryrefslogtreecommitdiff
path: root/src/pkg/os/file.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/os/file.go')
-rw-r--r--src/pkg/os/file.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/pkg/os/file.go b/src/pkg/os/file.go
index dc722055a..03c6d5701 100644
--- a/src/pkg/os/file.go
+++ b/src/pkg/os/file.go
@@ -370,7 +370,7 @@ func Remove(name string) Error {
return &PathError{"remove", name, Errno(e)};
}
-// LinkError records an error during a link or symlink
+// LinkError records an error during a link or symlink or rename
// system call and the paths that caused it.
type LinkError struct {
Op string;
@@ -418,6 +418,15 @@ func Readlink(name string) (string, Error) {
return "", nil;
}
+// Rename renames a file.
+func Rename(oldname, newname string) Error {
+ e := syscall.Rename(oldname, newname);
+ if e != 0 {
+ return &LinkError{"rename", oldname, newname, Errno(e)}
+ }
+ return nil;
+}
+
// Chmod changes the mode of the named file to mode.
// If the file is a symbolic link, it changes the uid and gid of the link's target.
func Chmod(name string, mode int) Error {