diff options
author | Fabian Groffen <grobian@gentoo.org> | 2018-12-20 12:44:41 +0100 |
---|---|---|
committer | Fabian Groffen <grobian@gentoo.org> | 2018-12-20 19:22:36 +0100 |
commit | 5d274dbc605c72b43c13f8ac61c988eae40531ce (patch) | |
tree | 029fa5e7e5dab4067f2077fc01e3a3ceb7cf7e6e | |
parent | qsearch: avoid printing a trailing space, bug #672764 (diff) | |
download | portage-utils-5d274dbc605c72b43c13f8ac61c988eae40531ce.tar.gz portage-utils-5d274dbc605c72b43c13f8ac61c988eae40531ce.tar.bz2 portage-utils-5d274dbc605c72b43c13f8ac61c988eae40531ce.zip |
rm_rf_at: remove the object path points to
To better emulate 'rm -Rf' behaviour, if path points to a file, just
remove it. If it points to a directory, remove that directory instead
of leaving the (now) empty directory behind.
Signed-off-by: Fabian Groffen <grobian@gentoo.org>
-rw-r--r-- | libq/xmkdir.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/libq/xmkdir.c b/libq/xmkdir.c index 9a120ae2..ed30d6d3 100644 --- a/libq/xmkdir.c +++ b/libq/xmkdir.c @@ -58,7 +58,7 @@ rm_rf_at(int dfd, const char *path) dir = fdopendir(subdfd); if (!dir) { close(subdfd); - return -1; + return unlinkat(dfd, path, 0); } while ((de = readdir(dir)) != NULL) { @@ -78,6 +78,8 @@ rm_rf_at(int dfd, const char *path) } } + unlinkat(dfd, path, AT_REMOVEDIR); + /* this also does close(subdfd); */ closedir(dir); |