]> Cypherpunks repositories - gostls13.git/commitdiff
os: fix Rename on Plan 9
authorDavid du Colombier <0intro@gmail.com>
Thu, 20 Feb 2014 06:59:38 +0000 (07:59 +0100)
committerDavid du Colombier <0intro@gmail.com>
Thu, 20 Feb 2014 06:59:38 +0000 (07:59 +0100)
Rename should fail when the directory doesn't match.
It will fix the newly introduced test from cmd/pack
on Plan 9.

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/65270044

src/pkg/os/file_plan9.go

index e6496558ca5ed95253e9e5912f92f77627eb5e1c..a804b81973135590061f07cd00db17c7a1a3e12b 100644 (file)
@@ -332,6 +332,8 @@ func rename(oldname, newname string) error {
        dirname := oldname[:lastIndex(oldname, '/')+1]
        if hasPrefix(newname, dirname) {
                newname = newname[len(dirname):]
+       } else {
+               return &LinkError{"rename", oldname, newname, ErrInvalid}
        }
 
        // If newname still contains slashes after removing the oldname