summaryrefslogtreecommitdiff
path: root/archival/tar.c
diff options
context:
space:
mode:
authorGlenn L McGrath <bug1@ihug.co.nz>2002-11-03 14:05:15 +0000
committerGlenn L McGrath <bug1@ihug.co.nz>2002-11-03 14:05:15 +0000
commit237ae42fc96ede945d28d9054f045b73e419d089 (patch)
tree3fb6a9c10150303aca3c218b47aaf327a186382a /archival/tar.c
parent2fc54a9258c3aa5dad2ce9807ba85cf29af2668e (diff)
downloadbusybox-w32-237ae42fc96ede945d28d9054f045b73e419d089.tar.gz
busybox-w32-237ae42fc96ede945d28d9054f045b73e419d089.tar.bz2
busybox-w32-237ae42fc96ede945d28d9054f045b73e419d089.zip
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.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/archival/tar.c b/archival/tar.c
index 48d6ce22e..e1e121a09 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -627,7 +627,7 @@ int tar_main(int argc, char **argv)
627 tar_handle = init_handle(); 627 tar_handle = init_handle();
628 tar_handle->flags = ARCHIVE_CREATE_LEADING_DIRS; 628 tar_handle->flags = ARCHIVE_CREATE_LEADING_DIRS;
629 629
630 while ((opt = getopt(argc, argv, "ctxT:X:C:f:Opvz")) != -1) { 630 while ((opt = getopt(argc, argv, "cjtxT:X:C:f:Opvz")) != -1) {
631 switch (opt) { 631 switch (opt) {
632 /* One and only one of these is required */ 632 /* One and only one of these is required */
633#ifdef CONFIG_FEATURE_TAR_CREATE 633#ifdef CONFIG_FEATURE_TAR_CREATE
@@ -684,9 +684,8 @@ int tar_main(int argc, char **argv)
684 break; 684 break;
685#endif 685#endif
686#ifdef CONFIG_FEATURE_TAR_BZIP2 686#ifdef CONFIG_FEATURE_TAR_BZIP2
687 /* Not enabled yet */
688 case 'j': 687 case 'j':
689 archive_handle->archive_action = bunzip2; 688 tar_handle->read = read_bz2;
690 break; 689 break;
691#endif 690#endif
692 default: 691 default:
@@ -703,14 +702,8 @@ int tar_main(int argc, char **argv)
703 /* Setup an array of filenames to work with */ 702 /* Setup an array of filenames to work with */
704 /* TODO: This is the same as in ar, seperate function ? */ 703 /* TODO: This is the same as in ar, seperate function ? */
705 while (optind < argc) { 704 while (optind < argc) {
706#if 0
707 char absolute_path[PATH_MAX];
708 realpath(argv[optind], absolute_path);
709 tar_handle->accept = add_to_list(tar_handle->accept, absolute_path);
710#endif
711 tar_handle->accept = add_to_list(tar_handle->accept, argv[optind]); 705 tar_handle->accept = add_to_list(tar_handle->accept, argv[optind]);
712 optind++; 706 optind++;
713
714 } 707 }
715 708
716 if ((tar_handle->accept) || (tar_handle->reject)) { 709 if ((tar_handle->accept) || (tar_handle->reject)) {
@@ -744,13 +737,21 @@ int tar_main(int argc, char **argv)
744 if ((tar_filename[0] == '-') && (tar_filename[1] == '\0')) { 737 if ((tar_filename[0] == '-') && (tar_filename[1] == '\0')) {
745 tar_handle->src_fd = fileno(stdin); 738 tar_handle->src_fd = fileno(stdin);
746 } else { 739 } else {
740 tar_handle->seek = seek_by_jump;
747 tar_handle->src_fd = xopen(tar_filename, O_RDONLY); 741 tar_handle->src_fd = xopen(tar_filename, O_RDONLY);
748 } 742 }
749#ifdef CONFIG_FEATURE_TAR_GZIP 743#ifdef CONFIG_FEATURE_TAR_GZIP
750 if (get_header_ptr == get_header_tar_gz) { 744 if (get_header_ptr == get_header_tar_gz) {
745 tar_handle->seek = seek_by_char;
751 get_header_tar_gz(tar_handle); 746 get_header_tar_gz(tar_handle);
752 } else 747 } else
753#endif /* CONFIG_FEATURE_TAR_CREATE */ 748#endif /* CONFIG_FEATURE_TAR_GZIP */
749#ifdef CONFIG_FEATURE_TAR_BZIP2
750 if (tar_handle->read == read_bz2) {
751 BZ2_bzReadOpen(tar_handle->src_fd, NULL, 0);
752 while (get_header_tar(tar_handle) == EXIT_SUCCESS);
753 } else
754#endif /* CONFIG_FEATURE_TAR_BZIP2 */
754 755
755 while (get_header_tar(tar_handle) == EXIT_SUCCESS); 756 while (get_header_tar(tar_handle) == EXIT_SUCCESS);
756 757