Commit 5c44cc47 authored by Constantin Konstantinidis's avatar Constantin Konstantinidis Committed by Ian Lance Taylor

os: handle long path in RemoveAll for windows

Fixes #36375

Change-Id: I407a1db23868880b83e73bc136d274659483fb69
Reviewed-on: https://go-review.googlesource.com/c/go/+/214437
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
parent 5d8a61a4
......@@ -27,6 +27,7 @@ func removeAll(path string) error {
}
// Simple case: if Remove works, we're done.
path = fixLongPath(path)
err := Remove(path)
if err == nil || IsNotExist(err) {
return nil
......
......@@ -206,6 +206,26 @@ func TestRemoveAllLongPath(t *testing.T) {
}
}
func TestRemoveAllLongPathWindows(t *testing.T) {
startPath, err := ioutil.TempDir("", "TestRemoveAllLongPath-")
if err != nil {
t.Fatalf("Could not create TempDir: %s", err)
}
defer RemoveAll(startPath)
// Make a long path
err = MkdirAll(filepath.Join(startPath, "foo", "bar", strings.Repeat("a", 150),
strings.Repeat("b", 150)), ModePerm)
if err != nil {
t.Fatal(err)
}
err = RemoveAll("foo")
if err != nil {
t.Fatal(err)
}
}
func TestRemoveAllDot(t *testing.T) {
prevDir, err := Getwd()
if err != nil {
......
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