diff options
author | Glenn L McGrath | 2002-11-03 14:05:15 +0000 |
---|---|---|
committer | Glenn L McGrath | 2002-11-03 14:05:15 +0000 |
commit | 237ae42fc96ede945d28d9054f045b73e419d089 (patch) | |
tree | 3fb6a9c10150303aca3c218b47aaf327a186382a /archival/tar.c | |
parent | 2fc54a9258c3aa5dad2ce9807ba85cf29af2668e (diff) | |
download | busybox-237ae42fc96ede945d28d9054f045b73e419d089.zip busybox-237ae42fc96ede945d28d9054f045b73e419d089.tar.gz |
Abstract read and seek in unarchiving code, convert bunzip to file descriptors, support tar -j
Diffstat (limited to 'archival/tar.c')
-rw-r--r-- | archival/tar.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/archival/tar.c b/archival/tar.c index 48d6ce2..e1e121a 100644 --- a/archival/tar.c +++ b/archival/tar.c @@ -627,7 +627,7 @@ int tar_main(int argc, char **argv) tar_handle = init_handle(); tar_handle->flags = ARCHIVE_CREATE_LEADING_DIRS; - while ((opt = getopt(argc, argv, "ctxT:X:C:f:Opvz")) != -1) { + while ((opt = getopt(argc, argv, "cjtxT:X:C:f:Opvz")) != -1) { switch (opt) { /* One and only one of these is required */ #ifdef CONFIG_FEATURE_TAR_CREATE @@ -684,9 +684,8 @@ int tar_main(int argc, char **argv) break; #endif #ifdef CONFIG_FEATURE_TAR_BZIP2 - /* Not enabled yet */ case 'j': - archive_handle->archive_action = bunzip2; + tar_handle->read = read_bz2; break; #endif default: @@ -703,14 +702,8 @@ int tar_main(int argc, char **argv) /* Setup an array of filenames to work with */ /* TODO: This is the same as in ar, seperate function ? */ while (optind < argc) { -#if 0 - char absolute_path[PATH_MAX]; - realpath(argv[optind], absolute_path); - tar_handle->accept = add_to_list(tar_handle->accept, absolute_path); -#endif tar_handle->accept = add_to_list(tar_handle->accept, argv[optind]); optind++; - } if ((tar_handle->accept) || (tar_handle->reject)) { @@ -744,13 +737,21 @@ int tar_main(int argc, char **argv) if ((tar_filename[0] == '-') && (tar_filename[1] == '\0')) { tar_handle->src_fd = fileno(stdin); } else { + tar_handle->seek = seek_by_jump; tar_handle->src_fd = xopen(tar_filename, O_RDONLY); } #ifdef CONFIG_FEATURE_TAR_GZIP if (get_header_ptr == get_header_tar_gz) { + tar_handle->seek = seek_by_char; get_header_tar_gz(tar_handle); } else -#endif /* CONFIG_FEATURE_TAR_CREATE */ +#endif /* CONFIG_FEATURE_TAR_GZIP */ +#ifdef CONFIG_FEATURE_TAR_BZIP2 + if (tar_handle->read == read_bz2) { + BZ2_bzReadOpen(tar_handle->src_fd, NULL, 0); + while (get_header_tar(tar_handle) == EXIT_SUCCESS); + } else +#endif /* CONFIG_FEATURE_TAR_BZIP2 */ while (get_header_tar(tar_handle) == EXIT_SUCCESS); |