diff options
author | bug1 <bug1@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2002-11-03 14:05:15 +0000 |
---|---|---|
committer | bug1 <bug1@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2002-11-03 14:05:15 +0000 |
commit | 2967488be46c8e0454faf05f966826f9cfb9b746 (patch) | |
tree | 3fb6a9c10150303aca3c218b47aaf327a186382a /archival/ar.c | |
parent | 76351c0a9c44f998dd9be624435bf96392c4e088 (diff) | |
download | busybox-w32-2967488be46c8e0454faf05f966826f9cfb9b746.tar.gz busybox-w32-2967488be46c8e0454faf05f966826f9cfb9b746.tar.bz2 busybox-w32-2967488be46c8e0454faf05f966826f9cfb9b746.zip |
Abstract read and seek in unarchiving code, convert bunzip to file descriptors, support tar -j
git-svn-id: svn://busybox.net/trunk/busybox@5787 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'archival/ar.c')
-rw-r--r-- | archival/ar.c | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/archival/ar.c b/archival/ar.c index 997927346..71cde4ebe 100644 --- a/archival/ar.c +++ b/archival/ar.c | |||
@@ -50,7 +50,7 @@ static void header_verbose_list_ar(const file_header_t *file_header) | |||
50 | printf("%s %d/%d%7d %s %s\n", &mode[1], file_header->uid, file_header->gid, (int) file_header->size, &mtime[4], file_header->name); | 50 | printf("%s %d/%d%7d %s %s\n", &mode[1], file_header->uid, file_header->gid, (int) file_header->size, &mtime[4], file_header->name); |
51 | } | 51 | } |
52 | 52 | ||
53 | #if defined CONFIG_TAR | defined CONFIG_DPKG_DEB | defined CONFIG_CPIO | 53 | #if !defined CONFIG_TAR && !defined CONFIG_DPKG_DEB && !defined CONFIG_CPIO |
54 | /* This is simpler than data_extract_all */ | 54 | /* This is simpler than data_extract_all */ |
55 | static void data_extract_regular_file(archive_handle_t *archive_handle) | 55 | static void data_extract_regular_file(archive_handle_t *archive_handle) |
56 | { | 56 | { |
@@ -59,7 +59,7 @@ static void data_extract_regular_file(archive_handle_t *archive_handle) | |||
59 | 59 | ||
60 | file_header = archive_handle->file_header; | 60 | file_header = archive_handle->file_header; |
61 | dst_fd = xopen(file_header->name, O_WRONLY | O_CREAT); | 61 | dst_fd = xopen(file_header->name, O_WRONLY | O_CREAT); |
62 | copy_file_chunk_fd(archive_handle->src_fd, dst_fd, file_header->size); | 62 | archive_copy_file(archive_handle, dst_fd); |
63 | close(dst_fd); | 63 | close(dst_fd); |
64 | 64 | ||
65 | chmod(file_header->name, file_header->mode); | 65 | chmod(file_header->name, file_header->mode); |
@@ -80,18 +80,10 @@ extern int ar_main(int argc, char **argv) | |||
80 | archive_handle_t *archive_handle; | 80 | archive_handle_t *archive_handle; |
81 | int opt; | 81 | int opt; |
82 | 82 | ||
83 | #ifndef CONFIG_DPKG_DEB | 83 | #if !defined CONFIG_DPKG_DEB && !defined CONFIG_DPKG |
84 | char magic[8]; | 84 | char magic[8]; |
85 | #endif | 85 | #endif |
86 | #if defined CONFIG_TAR | defined CONFIG_DPKG_DEB | defined CONFIG_CPIO | ||
87 | archive_handle = init_handle(); | 86 | archive_handle = init_handle(); |
88 | #else | ||
89 | archive_handle = xcalloc(1, sizeof(archive_handle_t)); | ||
90 | archive_handle->filter = filter_accept_all; | ||
91 | archive_handle->action_data = data_skip; | ||
92 | archive_handle->action_header = header_skip; | ||
93 | archive_handle->file_header =xmalloc(sizeof(file_header_t)); | ||
94 | #endif | ||
95 | 87 | ||
96 | while ((opt = getopt(argc, argv, "covtpxX")) != -1) { | 88 | while ((opt = getopt(argc, argv, "covtpxX")) != -1) { |
97 | switch (opt) { | 89 | switch (opt) { |
@@ -104,7 +96,7 @@ extern int ar_main(int argc, char **argv) | |||
104 | case 'X': | 96 | case 'X': |
105 | archive_handle->action_header = header_verbose_list_ar; | 97 | archive_handle->action_header = header_verbose_list_ar; |
106 | case 'x': /* extract */ | 98 | case 'x': /* extract */ |
107 | #if defined CONFIG_TAR | defined CONFIG_DPKG_DEB | defined CONFIG_CPIO | 99 | #if defined CONFIG_TAR || defined CONFIG_DPKG_DEB || defined CONFIG_CPIO |
108 | archive_handle->action_data = data_extract_all; | 100 | archive_handle->action_data = data_extract_all; |
109 | #else | 101 | #else |
110 | archive_handle->action_data = data_extract_regular_file; | 102 | archive_handle->action_data = data_extract_regular_file; |
@@ -136,10 +128,10 @@ extern int ar_main(int argc, char **argv) | |||
136 | optind++; | 128 | optind++; |
137 | } | 129 | } |
138 | 130 | ||
139 | #if defined CONFIG_DPKG_DEB | 131 | #if defined CONFIG_DPKG_DEB || defined CONFIG_DPKG |
140 | unpack_ar_archive(archive_handle); | 132 | unpack_ar_archive(archive_handle); |
141 | #else | 133 | #else |
142 | xread_all(archive_handle->src_fd, magic, 7); | 134 | archive_xread_all(archive_handle, magic, 7); |
143 | if (strncmp(magic, "!<arch>", 7) != 0) { | 135 | if (strncmp(magic, "!<arch>", 7) != 0) { |
144 | error_msg_and_die("Invalid ar magic"); | 136 | error_msg_and_die("Invalid ar magic"); |
145 | } | 137 | } |