diff options
author | Ian Lance Taylor <iant@google.com> | 2016-02-03 21:58:02 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2016-02-03 21:58:02 +0000 |
commit | f98dd1a338867a408f7c72d73fbad7fe7fc93e3a (patch) | |
tree | 2f8da9862a9c1fe0df138917f997b03439c02773 /libgo/go/os/file_plan9.go | |
parent | b081ed4efc144da0c45a6484aebfd10e0eb9fda3 (diff) | |
download | gcc-f98dd1a338867a408f7c72d73fbad7fe7fc93e3a.tar.gz |
libgo: Update to go1.6rc1.
Reviewed-on: https://go-review.googlesource.com/19200
From-SVN: r233110
Diffstat (limited to 'libgo/go/os/file_plan9.go')
-rw-r--r-- | libgo/go/os/file_plan9.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/libgo/go/os/file_plan9.go b/libgo/go/os/file_plan9.go index 085ebc4c8a6..c83fa028b99 100644 --- a/libgo/go/os/file_plan9.go +++ b/libgo/go/os/file_plan9.go @@ -339,7 +339,9 @@ func rename(oldname, newname string) error { // If newname still contains slashes after removing the oldname // prefix, the rename is cross-directory and must be rejected. - // This case is caught by d.Marshal below. + if lastIndex(newname, '/') >= 0 { + return &LinkError{"rename", oldname, newname, ErrInvalid} + } var d syscall.Dir @@ -351,6 +353,13 @@ func rename(oldname, newname string) error { if err != nil { return &LinkError{"rename", oldname, newname, err} } + + // If newname already exists and is not a directory, rename replaces it. + f, err := Stat(dirname + newname) + if err == nil && !f.IsDir() { + Remove(dirname + newname) + } + if err = syscall.Wstat(oldname, buf[:n]); err != nil { return &LinkError{"rename", oldname, newname, err} } |