summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2009-04-28 11:00:13 +0200
committerYorhel <git@yorhel.nl>2009-04-28 11:07:24 +0200
commit3610121dabefdecbdd0665af1dc42f93c0e9012c (patch)
tree9ba208a76b395fcd22a48b8378df926824b21c9c
parentbba85675a94b9ab66e964bde5cb593f2b8459aad (diff)
Don't try to delete a directory that's not empty
-rw-r--r--src/delete.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/delete.c b/src/delete.c
index 6ffe922..a5b5b2d 100644
--- a/src/delete.c
+++ b/src/delete.c
@@ -185,7 +185,7 @@ int delete_dir(struct dir *dr) {
}
if((r = chdir("..")) < 0)
goto delete_nxt;
- r = rmdir(dr->name);
+ r = dr->sub == NULL ? rmdir(dr->name) : 0;
} else
r = unlink(dr->name);
@@ -198,11 +198,11 @@ delete_nxt:
while(state == DS_FAILED)
if(input_handle(0))
return 1;
- } else
+ } else if(!(dr->flags & FF_DIR && dr->sub != NULL)) {
freedir(dr);
- if(r == -1 && root == dr)
- return 1;
- return 0;
+ return 0;
+ }
+ return root == dr ? 1 : 0;
}