From 5850a103015a275b9be1d469bf38c2ce07721007 Mon Sep 17 00:00:00 2001 From: Dave Vasilevsky Date: Wed, 13 Oct 2010 22:33:28 -0400 Subject: [PATCH] Revert "Works without wanted files" This reverts commit 8a05b40c5313f1f87bd69a0ababdc88f7d93fd21. --- pread.c | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/pread.c b/pread.c index 11da62d..60bc790 100644 --- a/pread.c +++ b/pread.c @@ -88,31 +88,28 @@ static ssize_t tar_read(struct archive *ar, void *ref, const void **bufp) { io_block_t *ib = (io_block_t*)(gArItem->data); fwrite(ib->output + gArLastOffset, gArLastSize, 1, gOutFile); } - + + // TODO: don't assume we have wanted files!!! + + // Write the first wanted file if (!tar_next_block()) return 0; io_block_t *ib = (io_block_t*)(gArItem->data); - size_t off, size; - if (!gWantedFiles) { + fprintf(stderr, "tar wanted: %s\n", gArWanted->name); + ssize_t off = gArWanted->start - ib->uoffset, size = gArWanted->size; + if (off < 0) { + size += off; off = 0; - size = ib->outsize; + } + if (off + size > ib->outsize) { + size = ib->outsize - off; + gArNextItem = true; // force the end of this block } else { - // Write the first wanted file - fprintf(stderr, "tar wanted: %s\n", gArWanted->name); - 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 - } else { - gArWanted = gArWanted->next; - } + gArWanted = gArWanted->next; } + fprintf(stderr, "tar read off = %zd, size = %zd\n", off, size); gArLastOffset = off; gArLastSize = size; *bufp = ib->output + off;