Commit 492039ae authored by Albert Strasheim's avatar Albert Strasheim Committed by Russ Cox

os: Fix MkdirAll("/thisdoesnotexist").

Fixes #1637.

R=rsc, rh, msolo
CC=golang-dev
https://golang.org/cl/4317049
parent 5a59b9eb
......@@ -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")
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment