diff options
author | markw <markw@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2001-03-13 00:40:19 +0000 |
---|---|---|
committer | markw <markw@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2001-03-13 00:40:19 +0000 |
commit | a2173d99ae8c69d2dc95d7402dade2a600e6c5f2 (patch) | |
tree | 468e0e8126f57b7be69f471ed3ac046a9f8fedb4 /rm.c | |
parent | ef4de035b88f9018f3891f2b13c657fe87f1b8c1 (diff) | |
download | busybox-w32-a2173d99ae8c69d2dc95d7402dade2a600e6c5f2.tar.gz busybox-w32-a2173d99ae8c69d2dc95d7402dade2a600e6c5f2.tar.bz2 busybox-w32-a2173d99ae8c69d2dc95d7402dade2a600e6c5f2.zip |
Applied patch from Christophe Boyanique to add -i support to rm.
git-svn-id: svn://busybox.net/trunk/busybox@2053 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'rm.c')
-rw-r--r-- | rm.c | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -33,11 +33,21 @@ | |||
33 | 33 | ||
34 | static int recursiveFlag = FALSE; | 34 | static int recursiveFlag = FALSE; |
35 | static int forceFlag = FALSE; | 35 | static int forceFlag = FALSE; |
36 | #ifdef BB_FEATURE_RM_INTERACTIVE | ||
37 | static int interactiveFlag = FALSE; | ||
38 | #endif | ||
36 | static const char *srcName; | 39 | static const char *srcName; |
37 | 40 | ||
38 | 41 | ||
39 | static int fileAction(const char *fileName, struct stat *statbuf, void* junk) | 42 | static int fileAction(const char *fileName, struct stat *statbuf, void* junk) |
40 | { | 43 | { |
44 | #ifdef BB_FEATURE_RM_INTERACTIVE | ||
45 | if (interactiveFlag == TRUE) { | ||
46 | printf("rm: remove `%s'? ", fileName); | ||
47 | if (ask_confirmation() == 0) | ||
48 | return (TRUE); | ||
49 | } | ||
50 | #endif | ||
41 | if (unlink(fileName) < 0) { | 51 | if (unlink(fileName) < 0) { |
42 | perror_msg("%s", fileName); | 52 | perror_msg("%s", fileName); |
43 | return (FALSE); | 53 | return (FALSE); |
@@ -52,6 +62,13 @@ static int dirAction(const char *fileName, struct stat *statbuf, void* junk) | |||
52 | perror_msg("%s", fileName); | 62 | perror_msg("%s", fileName); |
53 | return (FALSE); | 63 | return (FALSE); |
54 | } | 64 | } |
65 | #ifdef BB_FEATURE_RM_INTERACTIVE | ||
66 | if (interactiveFlag == TRUE) { | ||
67 | printf("rm: remove directory `%s'? ", fileName); | ||
68 | if (ask_confirmation() == 0) | ||
69 | return (TRUE); | ||
70 | } | ||
71 | #endif | ||
55 | if (rmdir(fileName) < 0) { | 72 | if (rmdir(fileName) < 0) { |
56 | perror_msg("%s", fileName); | 73 | perror_msg("%s", fileName); |
57 | return (FALSE); | 74 | return (FALSE); |
@@ -79,6 +96,14 @@ extern int rm_main(int argc, char **argv) | |||
79 | break; | 96 | break; |
80 | case 'f': | 97 | case 'f': |
81 | forceFlag = TRUE; | 98 | forceFlag = TRUE; |
99 | #ifdef BB_FEATURE_RM_INTERACTIVE | ||
100 | interactiveFlag = FALSE; | ||
101 | #endif | ||
102 | break; | ||
103 | case 'i': | ||
104 | #ifdef BB_FEATURE_RM_INTERACTIVE | ||
105 | interactiveFlag = TRUE; | ||
106 | #endif | ||
82 | break; | 107 | break; |
83 | case '-': | 108 | case '-': |
84 | stopIt = TRUE; | 109 | stopIt = TRUE; |