static void unzip_read(int fd, void *buf, size_t count)
{
if (bb_xread(fd, buf, count) != count) {
- bb_error_msg_and_die("Read failure");
+ bb_error_msg_and_die(bb_msg_read_error);
}
}
/* Create all leading directories */
char *name = bb_xstrdup(fn);
if (bb_make_directory(dirname(name), 0777, FILEUTILS_RECUR)) {
- bb_error_msg_and_die("Failed to create directory");
+ bb_error_msg_and_die("Exiting"); /* bb_make_directory is noisy */
}
free(name);
}
case 1: /* Include files */
if (opt == 1) {
- zaccept = llist_add_to(zaccept, optarg);
+ llist_add_to(&zaccept, optarg);
} else if (opt == 'd') {
base_dir = optarg;
case 2 : /* Exclude files */
if (opt == 1) {
- zreject = llist_add_to(zreject, optarg);
+ llist_add_to(&zreject, optarg);
} else if (opt == 'd') { /* Extract to base directory */
base_dir = optarg;
}
/* Change dir if necessary */
- if (base_dir && chdir(base_dir)) {
- bb_perror_msg_and_die("Cannot chdir");
- }
+ if (base_dir)
+ bb_xchdir(base_dir);
if (verbosity != v_silent)
printf("Archive: %s\n", src_fn);
/* Read filename */
free(dst_fn);
- dst_fn = xmalloc(zip_header.formated.filename_len + 1);
+ dst_fn = xzalloc(zip_header.formated.filename_len + 1);
unzip_read(src_fd, dst_fn, zip_header.formated.filename_len);
- dst_fn[zip_header.formated.filename_len] = 0;
/* Skip extra header bytes */
unzip_skip(src_fd, zip_header.formated.extra_len);
if ((verbosity == v_list) && !list_header_done){
- printf(" Length Date Time Name\n");
- printf(" -------- ---- ---- ----\n");
+ printf(" Length Date Time Name\n"
+ " -------- ---- ---- ----\n");
list_header_done = 1;
}
}
unzip_create_leading_dirs(dst_fn);
if (bb_make_directory(dst_fn, 0777, 0)) {
- bb_error_msg_and_die("Failed to create directory");
+ bb_error_msg_and_die("Exiting");
}
} else {
if (!S_ISDIR(stat_buf.st_mode)) {
return failed;
}
-
-/* END CODE */
-/*
-Local Variables:
-c-file-style: "linux"
-c-basic-offset: 4
-tab-width: 4
-End:
-*/