diff options
author | Eric Andersen <andersen@codepoet.org> | 1999-11-15 17:33:30 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 1999-11-15 17:33:30 +0000 |
commit | a9c95ea6551eb3d894fcc56822c8aa394972b699 (patch) | |
tree | 59359f25ba4bd356c2dfce79735fb66db4bb4151 /rm.c | |
parent | 80974fad03689b4344888820d89b514d4e4d166b (diff) | |
download | busybox-w32-a9c95ea6551eb3d894fcc56822c8aa394972b699.tar.gz busybox-w32-a9c95ea6551eb3d894fcc56822c8aa394972b699.tar.bz2 busybox-w32-a9c95ea6551eb3d894fcc56822c8aa394972b699.zip |
Updates
Diffstat (limited to 'rm.c')
-rw-r--r-- | rm.c | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -26,6 +26,7 @@ | |||
26 | #include <time.h> | 26 | #include <time.h> |
27 | #include <utime.h> | 27 | #include <utime.h> |
28 | #include <dirent.h> | 28 | #include <dirent.h> |
29 | #include <errno.h> | ||
29 | 30 | ||
30 | static const char* rm_usage = "rm [OPTION]... FILE...\n\n" | 31 | static const char* rm_usage = "rm [OPTION]... FILE...\n\n" |
31 | "Remove (unlink) the FILE(s).\n\n" | 32 | "Remove (unlink) the FILE(s).\n\n" |
@@ -59,6 +60,7 @@ static int dirAction(const char *fileName, struct stat* statbuf) | |||
59 | 60 | ||
60 | extern int rm_main(int argc, char **argv) | 61 | extern int rm_main(int argc, char **argv) |
61 | { | 62 | { |
63 | struct stat statbuf; | ||
62 | 64 | ||
63 | if (argc < 2) { | 65 | if (argc < 2) { |
64 | usage( rm_usage); | 66 | usage( rm_usage); |
@@ -85,9 +87,14 @@ extern int rm_main(int argc, char **argv) | |||
85 | 87 | ||
86 | while (argc-- > 0) { | 88 | while (argc-- > 0) { |
87 | srcName = *(argv++); | 89 | srcName = *(argv++); |
88 | if (recursiveAction( srcName, recursiveFlag, FALSE, TRUE, | 90 | if (forceFlag == TRUE && lstat(srcName, &statbuf) != 0 && errno == ENOENT) { |
89 | fileAction, dirAction) == FALSE) { | 91 | /* do not reports errors for non-existent files if -f, just skip them */ |
90 | exit( FALSE); | 92 | } |
93 | else { | ||
94 | if (recursiveAction( srcName, recursiveFlag, FALSE, | ||
95 | TRUE, fileAction, dirAction) == FALSE) { | ||
96 | exit( FALSE); | ||
97 | } | ||
91 | } | 98 | } |
92 | } | 99 | } |
93 | exit( TRUE); | 100 | exit( TRUE); |