diff options
author | Glenn L McGrath <bug1@ihug.co.nz> | 2001-07-12 10:24:57 +0000 |
---|---|---|
committer | Glenn L McGrath <bug1@ihug.co.nz> | 2001-07-12 10:24:57 +0000 |
commit | 3e94f729a54d13301d10b2a1c0225a951aaf074a (patch) | |
tree | 39a696609a5c484294907cfa62288758ba798229 | |
parent | c1270088401f1e3f4f8a6bfa2ff5b7228c4a8da0 (diff) | |
download | busybox-w32-3e94f729a54d13301d10b2a1c0225a951aaf074a.tar.gz busybox-w32-3e94f729a54d13301d10b2a1c0225a951aaf074a.tar.bz2 busybox-w32-3e94f729a54d13301d10b2a1c0225a951aaf074a.zip |
Quiet mode, sometimes error messages arent wanted
-rw-r--r-- | include/libbb.h | 3 | ||||
-rw-r--r-- | libbb/libbb.h | 3 | ||||
-rw-r--r-- | libbb/unarchive.c | 28 |
3 files changed, 24 insertions, 10 deletions
diff --git a/include/libbb.h b/include/libbb.h index 4a4b9191c..224c561d5 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -237,7 +237,8 @@ enum extract_functions_e { | |||
237 | extract_control_tar_gz = 128, | 237 | extract_control_tar_gz = 128, |
238 | extract_unzip_only = 256, | 238 | extract_unzip_only = 256, |
239 | extract_unconditional = 512, | 239 | extract_unconditional = 512, |
240 | extract_create_leading_dirs = 1024 | 240 | extract_create_leading_dirs = 1024, |
241 | extract_quiet = 2048 | ||
241 | }; | 242 | }; |
242 | char *unarchive(FILE *src_stream, FILE *out_stream, file_header_t *(*get_header)(FILE *), | 243 | char *unarchive(FILE *src_stream, FILE *out_stream, file_header_t *(*get_header)(FILE *), |
243 | const int extract_function, const char *prefix, char **extract_names); | 244 | const int extract_function, const char *prefix, char **extract_names); |
diff --git a/libbb/libbb.h b/libbb/libbb.h index 4a4b9191c..224c561d5 100644 --- a/libbb/libbb.h +++ b/libbb/libbb.h | |||
@@ -237,7 +237,8 @@ enum extract_functions_e { | |||
237 | extract_control_tar_gz = 128, | 237 | extract_control_tar_gz = 128, |
238 | extract_unzip_only = 256, | 238 | extract_unzip_only = 256, |
239 | extract_unconditional = 512, | 239 | extract_unconditional = 512, |
240 | extract_create_leading_dirs = 1024 | 240 | extract_create_leading_dirs = 1024, |
241 | extract_quiet = 2048 | ||
241 | }; | 242 | }; |
242 | char *unarchive(FILE *src_stream, FILE *out_stream, file_header_t *(*get_header)(FILE *), | 243 | char *unarchive(FILE *src_stream, FILE *out_stream, file_header_t *(*get_header)(FILE *), |
243 | const int extract_function, const char *prefix, char **extract_names); | 244 | const int extract_function, const char *prefix, char **extract_names); |
diff --git a/libbb/unarchive.c b/libbb/unarchive.c index d95f2cfc7..5c5bb49f3 100644 --- a/libbb/unarchive.c +++ b/libbb/unarchive.c | |||
@@ -116,15 +116,19 @@ char *extract_archive(FILE *src_stream, FILE *out_stream, const file_header_t *f | |||
116 | unlink(full_name); /* Directories might not be empty etc */ | 116 | unlink(full_name); /* Directories might not be empty etc */ |
117 | } | 117 | } |
118 | } else { | 118 | } else { |
119 | error_msg("%s not created: newer or same age file exists", file_entry->name); | 119 | if ((function & extract_quiet) != extract_quiet) { |
120 | seek_sub_file(src_stream, file_entry->size); | 120 | error_msg("%s not created: newer or same age file exists", file_entry->name); |
121 | } | ||
122 | seek_sub_file(src_stream, file_entry->size); | ||
121 | return (NULL); | 123 | return (NULL); |
122 | } | 124 | } |
123 | } | 125 | } |
124 | if (function & extract_create_leading_dirs) { /* Create leading directories with default umask */ | 126 | if (function & extract_create_leading_dirs) { /* Create leading directories with default umask */ |
125 | char *parent = dirname(full_name); | 127 | char *parent = dirname(full_name); |
126 | if (make_directory (parent, -1, FILEUTILS_RECUR) != 0) { | 128 | if (make_directory (parent, -1, FILEUTILS_RECUR) != 0) { |
127 | error_msg("couldn't create leading directories"); | 129 | if ((function & extract_quiet) != extract_quiet) { |
130 | error_msg("couldn't create leading directories"); | ||
131 | } | ||
128 | } | 132 | } |
129 | free (parent); | 133 | free (parent); |
130 | } | 134 | } |
@@ -132,8 +136,10 @@ char *extract_archive(FILE *src_stream, FILE *out_stream, const file_header_t *f | |||
132 | case S_IFREG: | 136 | case S_IFREG: |
133 | if (file_entry->link_name) { /* Found a cpio hard link */ | 137 | if (file_entry->link_name) { /* Found a cpio hard link */ |
134 | if (link(file_entry->link_name, full_name) != 0) { | 138 | if (link(file_entry->link_name, full_name) != 0) { |
135 | perror_msg("Cannot link from %s to '%s'", | 139 | if ((function & extract_quiet) != extract_quiet) { |
136 | file_entry->name, file_entry->link_name); | 140 | perror_msg("Cannot link from %s to '%s'", |
141 | file_entry->name, file_entry->link_name); | ||
142 | } | ||
137 | } | 143 | } |
138 | } else { | 144 | } else { |
139 | if ((dst_stream = wfopen(full_name, "w")) == NULL) { | 145 | if ((dst_stream = wfopen(full_name, "w")) == NULL) { |
@@ -148,13 +154,17 @@ char *extract_archive(FILE *src_stream, FILE *out_stream, const file_header_t *f | |||
148 | case S_IFDIR: | 154 | case S_IFDIR: |
149 | if (stat_res != 0) { | 155 | if (stat_res != 0) { |
150 | if (mkdir(full_name, file_entry->mode) < 0) { | 156 | if (mkdir(full_name, file_entry->mode) < 0) { |
151 | perror_msg("extract_archive: "); | 157 | if ((function & extract_quiet) != extract_quiet) { |
158 | perror_msg("extract_archive: "); | ||
159 | } | ||
152 | } | 160 | } |
153 | } | 161 | } |
154 | break; | 162 | break; |
155 | case S_IFLNK: | 163 | case S_IFLNK: |
156 | if (symlink(file_entry->link_name, full_name) < 0) { | 164 | if (symlink(file_entry->link_name, full_name) < 0) { |
157 | perror_msg("Cannot create symlink from %s to '%s'", file_entry->name, file_entry->link_name); | 165 | if ((function & extract_quiet) != extract_quiet) { |
166 | perror_msg("Cannot create symlink from %s to '%s'", file_entry->name, file_entry->link_name); | ||
167 | } | ||
158 | return NULL; | 168 | return NULL; |
159 | } | 169 | } |
160 | break; | 170 | break; |
@@ -163,7 +173,9 @@ char *extract_archive(FILE *src_stream, FILE *out_stream, const file_header_t *f | |||
163 | case S_IFCHR: | 173 | case S_IFCHR: |
164 | case S_IFIFO: | 174 | case S_IFIFO: |
165 | if (mknod(full_name, file_entry->mode, file_entry->device) == -1) { | 175 | if (mknod(full_name, file_entry->mode, file_entry->device) == -1) { |
166 | perror_msg("Cannot create node %s", file_entry->name); | 176 | if ((function & extract_quiet) != extract_quiet) { |
177 | perror_msg("Cannot create node %s", file_entry->name); | ||
178 | } | ||
167 | return NULL; | 179 | return NULL; |
168 | } | 180 | } |
169 | break; | 181 | break; |