diff options
author | Eric Andersen <andersen@codepoet.org> | 1999-10-05 16:24:54 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 1999-10-05 16:24:54 +0000 |
commit | cc8ed39b240180b58810784f844e253263594ac3 (patch) | |
tree | 15feebbb4be9a9168209609f48f0b100f9364420 /rm.c | |
download | busybox-w32-0_29alpha2.tar.gz busybox-w32-0_29alpha2.tar.bz2 busybox-w32-0_29alpha2.zip |
Initial revision0_29alpha2
Diffstat (limited to '')
-rw-r--r-- | rm.c | 30 |
1 files changed, 30 insertions, 0 deletions
@@ -0,0 +1,30 @@ | |||
1 | #include "internal.h" | ||
2 | #include <errno.h> | ||
3 | |||
4 | const char rm_usage[] = "rm [-r] file [file ...]\n" | ||
5 | "\n" | ||
6 | "\tDelete files.\n" | ||
7 | "\n" | ||
8 | "\t-r:\tRecursively remove files and directories.\n"; | ||
9 | |||
10 | extern int | ||
11 | rm_main(struct FileInfo * i, int argc, char * * argv) | ||
12 | { | ||
13 | i->processDirectoriesAfterTheirContents = 1; | ||
14 | return monadic_main(i, argc, argv); | ||
15 | } | ||
16 | |||
17 | extern int | ||
18 | rm_fn(const struct FileInfo * i) | ||
19 | { | ||
20 | if ( i->recursive | ||
21 | && !i->isSymbolicLink | ||
22 | && (i->stat.st_mode & S_IFMT) == S_IFDIR ) | ||
23 | return rmdir_fn(i); | ||
24 | else if ( unlink(i->source) != 0 && errno != ENOENT && !i->force ) { | ||
25 | name_and_error(i->source); | ||
26 | return 1; | ||
27 | } | ||
28 | else | ||
29 | return 0; | ||
30 | } | ||