Skip to content
Snippets Groups Projects
Commit 3610121d authored by Yorhel's avatar Yorhel
Browse files

Don't try to delete a directory that's not empty

parent bba85675
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment