mirror of
https://github.com/golang/go
synced 2024-11-22 03:24:41 -07:00
os: Fix MkdirAll("/thisdoesnotexist").
Fixes #1637. R=rsc, rh, msolo CC=golang-dev https://golang.org/cl/4317049
This commit is contained in:
parent
5a59b9eba3
commit
492039ae7f
@ -33,7 +33,7 @@ func MkdirAll(path string, perm uint32) Error {
|
||||
j--
|
||||
}
|
||||
|
||||
if j > 0 {
|
||||
if j > 1 {
|
||||
// Create parent
|
||||
err = MkdirAll(path[0:j-1], perm)
|
||||
if err != nil {
|
||||
|
@ -179,3 +179,20 @@ func TestMkdirAllWithSymlink(t *testing.T) {
|
||||
t.Errorf("MkdirAll %q: %s", path, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMkdirAllAtSlash(t *testing.T) {
|
||||
if runtime.GOOS == "windows" {
|
||||
return
|
||||
}
|
||||
RemoveAll("/_go_os_test")
|
||||
err := MkdirAll("/_go_os_test/dir", 0777)
|
||||
if err != nil {
|
||||
pathErr, ok := err.(*PathError)
|
||||
// common for users not to be able to write to /
|
||||
if ok && pathErr.Error == EACCES {
|
||||
return
|
||||
}
|
||||
t.Fatalf(`MkdirAll "/_go_os_test/dir": %v`, err)
|
||||
}
|
||||
RemoveAll("/_go_os_test")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user