diff options
| author | Ian Lance Taylor <iant@golang.org> | 2009-12-04 11:46:56 -0800 |
|---|---|---|
| committer | Ian Lance Taylor <iant@golang.org> | 2009-12-04 11:46:56 -0800 |
| commit | c9dba4936625c585c3b0a1bccb7d1b941889271a (patch) | |
| tree | 81bc32098bd8010d05dc65f9d7c10f64b6f979d7 /src/pkg/os/file.go | |
| parent | b9c658aaeb201a2fd0e6782ffcb39dc147ec72d6 (diff) | |
| download | golang-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.go | 11 |
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 { |
