From 7fb3234f93eb2cdccc363dcdf0168d6da7326081 Mon Sep 17 00:00:00 2001 From: Dave Vasilevsky Date: Wed, 13 Oct 2010 22:40:11 -0400 Subject: [PATCH] Work again without file index --- pread.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/pread.c b/pread.c index deaee3f..a58ef70 100644 --- a/pread.c +++ b/pread.c @@ -95,17 +95,24 @@ static ssize_t tar_read(struct archive *ar, void *ref, const void **bufp) { if (!tar_next_block()) return 0; + size_t off, size; io_block_t *ib = (io_block_t*)(gArItem->data); - ssize_t off = gArWanted->start - ib->uoffset, size = gArWanted->size; - if (off < 0) { - size += off; - off = 0; - } - if (off + size > ib->outsize) { - size = ib->outsize - off; - gArNextItem = true; // force the end of this block + if (gWantedFiles) { + off = gArWanted->start - ib->uoffset; + size = gArWanted->size; + if (off < 0) { + size += off; + off = 0; + } + if (off + size > ib->outsize) { + size = ib->outsize - off; + gArNextItem = true; // force the end of this block + } else { + gArWanted = gArWanted->next; + } } else { - gArWanted = gArWanted->next; + off = 0; + size = ib->outsize; } gArLastOffset = off;