diff options
author | Matt Kraai <kraai@debian.org> | 2000-12-05 05:11:41 +0000 |
---|---|---|
committer | Matt Kraai <kraai@debian.org> | 2000-12-05 05:11:41 +0000 |
commit | d27753afd983ffeae45b80dee92f02d0518ca7bf (patch) | |
tree | 1ecefa6dc73279cfe4ae3a45cc647823094248f0 | |
parent | 0e836ed8db86ef0274510c27e173f7ac66c6b2a6 (diff) | |
download | busybox-w32-d27753afd983ffeae45b80dee92f02d0518ca7bf.tar.gz busybox-w32-d27753afd983ffeae45b80dee92f02d0518ca7bf.tar.bz2 busybox-w32-d27753afd983ffeae45b80dee92f02d0518ca7bf.zip |
Use perrorMsg instead of perror and keep removing files if we encounter
an error.
-rw-r--r-- | coreutils/rm.c | 11 | ||||
-rw-r--r-- | rm.c | 11 | ||||
-rw-r--r-- | utility.c | 10 |
3 files changed, 17 insertions, 15 deletions
diff --git a/coreutils/rm.c b/coreutils/rm.c index c62083e9b..566335158 100644 --- a/coreutils/rm.c +++ b/coreutils/rm.c | |||
@@ -37,7 +37,7 @@ static const char *srcName; | |||
37 | static int fileAction(const char *fileName, struct stat *statbuf, void* junk) | 37 | static int fileAction(const char *fileName, struct stat *statbuf, void* junk) |
38 | { | 38 | { |
39 | if (unlink(fileName) < 0) { | 39 | if (unlink(fileName) < 0) { |
40 | perror(fileName); | 40 | perrorMsg("%s", fileName); |
41 | return (FALSE); | 41 | return (FALSE); |
42 | } | 42 | } |
43 | return (TRUE); | 43 | return (TRUE); |
@@ -47,11 +47,11 @@ static int dirAction(const char *fileName, struct stat *statbuf, void* junk) | |||
47 | { | 47 | { |
48 | if (recursiveFlag == FALSE) { | 48 | if (recursiveFlag == FALSE) { |
49 | errno = EISDIR; | 49 | errno = EISDIR; |
50 | perror(fileName); | 50 | perrorMsg("%s", fileName); |
51 | return (FALSE); | 51 | return (FALSE); |
52 | } | 52 | } |
53 | if (rmdir(fileName) < 0) { | 53 | if (rmdir(fileName) < 0) { |
54 | perror(fileName); | 54 | perrorMsg("%s", fileName); |
55 | return (FALSE); | 55 | return (FALSE); |
56 | } | 56 | } |
57 | return (TRUE); | 57 | return (TRUE); |
@@ -59,6 +59,7 @@ static int dirAction(const char *fileName, struct stat *statbuf, void* junk) | |||
59 | 59 | ||
60 | extern int rm_main(int argc, char **argv) | 60 | extern int rm_main(int argc, char **argv) |
61 | { | 61 | { |
62 | int status = EXIT_SUCCESS; | ||
62 | int stopIt=FALSE; | 63 | int stopIt=FALSE; |
63 | struct stat statbuf; | 64 | struct stat statbuf; |
64 | 65 | ||
@@ -102,9 +103,9 @@ extern int rm_main(int argc, char **argv) | |||
102 | } else { | 103 | } else { |
103 | if (recursiveAction(srcName, recursiveFlag, FALSE, | 104 | if (recursiveAction(srcName, recursiveFlag, FALSE, |
104 | TRUE, fileAction, dirAction, NULL) == FALSE) { | 105 | TRUE, fileAction, dirAction, NULL) == FALSE) { |
105 | return EXIT_FAILURE; | 106 | status = EXIT_FAILURE; |
106 | } | 107 | } |
107 | } | 108 | } |
108 | } | 109 | } |
109 | return EXIT_SUCCESS; | 110 | return status; |
110 | } | 111 | } |
@@ -37,7 +37,7 @@ static const char *srcName; | |||
37 | static int fileAction(const char *fileName, struct stat *statbuf, void* junk) | 37 | static int fileAction(const char *fileName, struct stat *statbuf, void* junk) |
38 | { | 38 | { |
39 | if (unlink(fileName) < 0) { | 39 | if (unlink(fileName) < 0) { |
40 | perror(fileName); | 40 | perrorMsg("%s", fileName); |
41 | return (FALSE); | 41 | return (FALSE); |
42 | } | 42 | } |
43 | return (TRUE); | 43 | return (TRUE); |
@@ -47,11 +47,11 @@ static int dirAction(const char *fileName, struct stat *statbuf, void* junk) | |||
47 | { | 47 | { |
48 | if (recursiveFlag == FALSE) { | 48 | if (recursiveFlag == FALSE) { |
49 | errno = EISDIR; | 49 | errno = EISDIR; |
50 | perror(fileName); | 50 | perrorMsg("%s", fileName); |
51 | return (FALSE); | 51 | return (FALSE); |
52 | } | 52 | } |
53 | if (rmdir(fileName) < 0) { | 53 | if (rmdir(fileName) < 0) { |
54 | perror(fileName); | 54 | perrorMsg("%s", fileName); |
55 | return (FALSE); | 55 | return (FALSE); |
56 | } | 56 | } |
57 | return (TRUE); | 57 | return (TRUE); |
@@ -59,6 +59,7 @@ static int dirAction(const char *fileName, struct stat *statbuf, void* junk) | |||
59 | 59 | ||
60 | extern int rm_main(int argc, char **argv) | 60 | extern int rm_main(int argc, char **argv) |
61 | { | 61 | { |
62 | int status = EXIT_SUCCESS; | ||
62 | int stopIt=FALSE; | 63 | int stopIt=FALSE; |
63 | struct stat statbuf; | 64 | struct stat statbuf; |
64 | 65 | ||
@@ -102,9 +103,9 @@ extern int rm_main(int argc, char **argv) | |||
102 | } else { | 103 | } else { |
103 | if (recursiveAction(srcName, recursiveFlag, FALSE, | 104 | if (recursiveAction(srcName, recursiveFlag, FALSE, |
104 | TRUE, fileAction, dirAction, NULL) == FALSE) { | 105 | TRUE, fileAction, dirAction, NULL) == FALSE) { |
105 | return EXIT_FAILURE; | 106 | status = EXIT_FAILURE; |
106 | } | 107 | } |
107 | } | 108 | } |
108 | } | 109 | } |
109 | return EXIT_SUCCESS; | 110 | return status; |
110 | } | 111 | } |
@@ -641,7 +641,7 @@ int recursiveAction(const char *fileName, | |||
641 | "status=%d followLinks=%d TRUE=%d\n", | 641 | "status=%d followLinks=%d TRUE=%d\n", |
642 | status, followLinks, TRUE); | 642 | status, followLinks, TRUE); |
643 | #endif | 643 | #endif |
644 | perror(fileName); | 644 | perrorMsg("%s", fileName); |
645 | return FALSE; | 645 | return FALSE; |
646 | } | 646 | } |
647 | 647 | ||
@@ -666,13 +666,13 @@ int recursiveAction(const char *fileName, | |||
666 | 666 | ||
667 | dir = opendir(fileName); | 667 | dir = opendir(fileName); |
668 | if (!dir) { | 668 | if (!dir) { |
669 | perror(fileName); | 669 | perrorMsg("%s", fileName); |
670 | return FALSE; | 670 | return FALSE; |
671 | } | 671 | } |
672 | if (dirAction != NULL && depthFirst == FALSE) { | 672 | if (dirAction != NULL && depthFirst == FALSE) { |
673 | status = dirAction(fileName, &statbuf, userData); | 673 | status = dirAction(fileName, &statbuf, userData); |
674 | if (status == FALSE) { | 674 | if (status == FALSE) { |
675 | perror(fileName); | 675 | perrorMsg("%s", fileName); |
676 | return FALSE; | 676 | return FALSE; |
677 | } | 677 | } |
678 | } | 678 | } |
@@ -699,13 +699,13 @@ int recursiveAction(const char *fileName, | |||
699 | } | 699 | } |
700 | status = closedir(dir); | 700 | status = closedir(dir); |
701 | if (status < 0) { | 701 | if (status < 0) { |
702 | perror(fileName); | 702 | perrorMsg("%s", fileName); |
703 | return FALSE; | 703 | return FALSE; |
704 | } | 704 | } |
705 | if (dirAction != NULL && depthFirst == TRUE) { | 705 | if (dirAction != NULL && depthFirst == TRUE) { |
706 | status = dirAction(fileName, &statbuf, userData); | 706 | status = dirAction(fileName, &statbuf, userData); |
707 | if (status == FALSE) { | 707 | if (status == FALSE) { |
708 | perror(fileName); | 708 | perrorMsg("%s", fileName); |
709 | return FALSE; | 709 | return FALSE; |
710 | } | 710 | } |
711 | } | 711 | } |