Changeset 2725 in MondoRescue for branches/2.2.9/mindi-busybox/coreutils/rmdir.c
- Timestamp:
- Feb 25, 2011, 9:26:54 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.9/mindi-busybox/coreutils/rmdir.c
r1765 r2725 5 5 * Copyright (C) 2003 Manuel Novoa III <mjn3@codepoet.org> 6 6 * 7 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.7 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 8 8 */ 9 9 … … 11 11 /* http://www.opengroup.org/onlinepubs/007904975/utilities/rmdir.html */ 12 12 13 #include <libgen.h>14 13 #include "libbb.h" 15 14 … … 17 16 18 17 19 int rmdir_main(int argc, char **argv); 20 int rmdir_main(int argc, char **argv) 18 #define PARENTS 0x01 19 #define IGNORE_NON_EMPTY 0x02 20 21 int rmdir_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 22 int rmdir_main(int argc UNUSED_PARAM, char **argv) 21 23 { 22 24 int status = EXIT_SUCCESS; 23 25 int flags; 24 int do_dot;25 26 char *path; 26 27 28 #if ENABLE_FEATURE_RMDIR_LONG_OPTIONS 29 static const char rmdir_longopts[] ALIGN1 = 30 "parents\0" No_argument "p" 31 /* Debian etch: many packages fail to be purged or installed 32 * because they desperately want this option: */ 33 "ignore-fail-on-non-empty\0" No_argument "\xff" 34 ; 35 applet_long_options = rmdir_longopts; 36 #endif 27 37 flags = getopt32(argv, "p"); 28 38 argv += optind; … … 35 45 path = *argv; 36 46 37 /* Record if the first char was a '.' so we can use dirname later. */38 do_dot = (*path == '.');39 40 47 while (1) { 41 48 if (rmdir(path) < 0) { 42 bb_perror_msg("'%s'", path); /* Match gnu rmdir msg. */ 49 #if ENABLE_FEATURE_RMDIR_LONG_OPTIONS 50 if ((flags & IGNORE_NON_EMPTY) && errno == ENOTEMPTY) 51 break; 52 #endif 53 bb_perror_msg("'%s'", path); /* Match gnu rmdir msg. */ 43 54 status = EXIT_FAILURE; 44 } else if (flags ) {45 /* Note: path was not empty or nullsince rmdir succeeded. */55 } else if (flags & PARENTS) { 56 /* Note: path was not "" since rmdir succeeded. */ 46 57 path = dirname(path); 47 /* Path is now just the parent component. Note that dirname 48 * returns "." if there are no parents. We must distinguish 49 * this from the case of the original path starting with '.'. 58 /* Path is now just the parent component. Dirname 59 * returns "." if there are no parents. 50 60 */ 51 if ( do_dot || (*path != '.') || path[1]) {61 if (NOT_LONE_CHAR(path, '.')) { 52 62 continue; 53 63 } … … 55 65 break; 56 66 } 57 58 67 } while (*++argv); 59 68
Note:
See TracChangeset
for help on using the changeset viewer.