We can already call rmdir() if we know that we have a directory instead
of trying unlink() first and then falling back.
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
return mkdtemp(path);
}
-static int _unlink(const char* path, const struct stat* stat, int typeflag, struct FTW* ftwbuf) {
- return remove(path);
+static int _unlink(const char* path, const struct stat* stat,
+ const int type, struct FTW* ftwbuf) {
+ // Delete directories using rmdir()
+ if (type & FTW_D)
+ return rmdir(path);
+
+ // unlink() everything else
+ return unlink(path);
}
int pakfire_rmtree(const char* path, int flags) {