summaryrefslogtreecommitdiff
path: root/src/pkg/os/file.go
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2009-12-04 11:46:56 -0800
committerIan Lance Taylor <iant@golang.org>2009-12-04 11:46:56 -0800
commitc9dba4936625c585c3b0a1bccb7d1b941889271a (patch)
tree81bc32098bd8010d05dc65f9d7c10f64b6f979d7 /src/pkg/os/file.go
parentb9c658aaeb201a2fd0e6782ffcb39dc147ec72d6 (diff)
downloadgolang-c9dba4936625c585c3b0a1bccb7d1b941889271a.tar.gz
Add os.Rename.
R=rsc http://codereview.appspot.com/166058
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 {