From: Jim Meyering Date: Sat, 20 Nov 1999 12:15:46 +0000 (+0000) Subject: (errno_rmdir_non_empty): New function to encapsulate errno comparison. X-Git-Tag: FILEUTILS-4_0j~29 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=783c48e864f6a1ecaed9e4614c68d57766214e6f;p=thirdparty%2Fcoreutils.git (errno_rmdir_non_empty): New function to encapsulate errno comparison. (remove_parents): Use it. (main): Use it. --- diff --git a/src/rmdir.c b/src/rmdir.c index 9e8e2363a5..1a5b20b29c 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);