diff options
author | Jim Meyering <jim@meyering.net> | 1999-11-20 12:15:46 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 1999-11-20 12:15:46 +0000 |
commit | 783c48e864f6a1ecaed9e4614c68d57766214e6f (patch) | |
tree | 0931d4bf1879e514740e89519257180ecf4420eb /src | |
parent | 07632c3ed9603aeb01ec25682e0c1f89550417f8 (diff) | |
download | coreutils-783c48e864f6a1ecaed9e4614c68d57766214e6f.tar.xz |
(errno_rmdir_non_empty): New function to encapsulate errno comparison.
(remove_parents): Use it.
(main): Use it.
Diffstat (limited to 'src')
-rw-r--r-- | src/rmdir.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/rmdir.c b/src/rmdir.c index 9e8e2363a..1a5b20b29 100644 --- a/src/rmdir.c +++ b/src/rmdir.c @@ -72,6 +72,16 @@ static struct option const longopts[] = {NULL, 0, NULL, 0} }; +/* Return nonzero if ERROR_NUMBER is one of the values associated + with a failed rmdir due to non-empty target directory. */ + +static int +errno_rmdir_non_empty (int error_number) +{ + return (error_number == ENOTEMPTY + || error_number == EEXIST); +} + /* Remove any empty parent directories of PATH. If PATH contains slash characters, at least one of them (beginning with the rightmost) is replaced with a NUL byte. */ @@ -103,7 +113,7 @@ remove_parents (char *path) { /* Stop quietly if --ignore-fail-on-non-empty. */ if (ignore_fail_on_non_empty - && (errno == ENOTEMPTY || errno == EEXIST)) + && errno_rmdir_non_empty (errno)) { fail = 0; } @@ -204,7 +214,7 @@ main (int argc, char **argv) if (fail) { if (ignore_fail_on_non_empty - && (errno == ENOTEMPTY || errno == EEXIST)) + && errno_rmdir_non_empty (errno)) continue; error (0, errno, "%s", dir); |