aboutsummaryrefslogtreecommitdiff
path: root/archival
diff options
context:
space:
mode:
authorbug1 <bug1@69ca8d6d-28ef-0310-b511-8ec308f3f277>2003-11-14 08:26:25 +0000
committerbug1 <bug1@69ca8d6d-28ef-0310-b511-8ec308f3f277>2003-11-14 08:26:25 +0000
commite02590e4724e01beef82939eca6480fc7ebc2e8d (patch)
tree487386c7cc0c62abbff34938e8bb6f2110c7d770 /archival
parenta0282b33763f109688c79617558e5b0c2b307232 (diff)
downloadbusybox-w32-e02590e4724e01beef82939eca6480fc7ebc2e8d.tar.gz
busybox-w32-e02590e4724e01beef82939eca6480fc7ebc2e8d.tar.bz2
busybox-w32-e02590e4724e01beef82939eca6480fc7ebc2e8d.zip
Read in blocks rather than one char at a time, greatly improves speed
git-svn-id: svn://busybox.net/trunk/busybox@7907 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'archival')
-rw-r--r--archival/libunarchive/seek_by_char.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/archival/libunarchive/seek_by_char.c b/archival/libunarchive/seek_by_char.c
index f33935cb5..77da4ef2e 100644
--- a/archival/libunarchive/seek_by_char.c
+++ b/archival/libunarchive/seek_by_char.c
@@ -14,12 +14,31 @@
14 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 14 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15 */ 15 */
16 16
17#include <stdlib.h>
18
17#include "unarchive.h" 19#include "unarchive.h"
20#include "busybox.h"
18 21
19extern void seek_by_char(const archive_handle_t *archive_handle, const unsigned int amount) 22/* If we are reading through a pipe(), or from stdin then we cant lseek,
23 * we must read and discard the data to skip over it.
24 *
25 * TODO: rename to seek_by_read
26 */
27extern void seek_by_char(const archive_handle_t *archive_handle, const unsigned int jump_size)
20{ 28{
21 unsigned int i; 29 unsigned int remaining = jump_size;
22 for (i = 0; i < amount; i++) { 30 unsigned int read_amount;
23 archive_xread_char(archive_handle); 31 RESERVE_CONFIG_BUFFER(buf, BUFSIZ);
32
33 while (remaining > 0) {
34 if (remaining > BUFSIZ) {
35 read_amount = BUFSIZ;
36 } else {
37 read_amount = remaining;
38 }
39 read_amount = archive_xread(archive_handle, buf, read_amount);
40 remaining -= read_amount;
24 } 41 }
42
43 RELEASE_CONFIG_BUFFER(buf);
25} 44}