summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAustin Clements <aclements@csail.mit.edu>2009-08-05 14:18:54 -0700
committerAustin Clements <aclements@csail.mit.edu>2009-08-05 14:18:54 -0700
commitf878417eaeb42a8919a9035eb6cae37b4797e43c (patch)
treedd1f7bc20c6e8eff62d7edd9efaf06f8cbbcb894 /src
parent0d573960f4c0c12f8103a86922927f7f386b639f (diff)
downloadgolang-f878417eaeb42a8919a9035eb6cae37b4797e43c.tar.gz
Make os.RemoveAll return no error if path does not exist.
This fixes a problem introduced by CL 32684 into gobuild, which used to use 'rm -rf' to remove the _obj directory. R=rsc APPROVED=rsc DELTA=8 (4 added, 0 deleted, 4 changed) OCL=32794 CL=32796
Diffstat (limited to 'src')
-rw-r--r--src/pkg/os/path.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/pkg/os/path.go b/src/pkg/os/path.go
index d8efe5183..586760e38 100644
--- a/src/pkg/os/path.go
+++ b/src/pkg/os/path.go
@@ -58,7 +58,8 @@ func MkdirAll(path string, perm int) Error {
// RemoveAll removes path and any children it contains.
// It removes everything it can but returns the first error
-// it encounters.
+// it encounters. If the path does not exist, RemoveAll
+// returns nil (no error).
func RemoveAll(path string) Error {
// Simple case: if Remove works, we're done.
err := Remove(path);
@@ -67,9 +68,12 @@ func RemoveAll(path string) Error {
}
// Otherwise, is this a directory we need to recurse into?
- dir, err := os.Lstat(path);
- if err != nil {
- return err;
+ dir, serr := os.Lstat(path);
+ if serr != nil {
+ if serr, ok := serr.(*PathError); ok && serr.Error == ENOENT {
+ return nil;
+ }
+ return serr;
}
if !dir.IsDirectory() {
// Not a directory; return the error from Remove.