Works without wanted files

pull/2/head
Dave Vasilevsky 14 years ago
parent 009d616db5
commit 8a05b40c53

@ -88,28 +88,31 @@ 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);
fprintf(stderr, "tar wanted: %s\n", gArWanted->name);
ssize_t off = gArWanted->start - ib->uoffset, size = gArWanted->size;
if (off < 0) {
size += off;
size_t off, size;
if (!gWantedFiles) {
off = 0;
}
if (off + size > ib->outsize) {
size = ib->outsize - off;
gArNextItem = true; // force the end of this block
size = ib->outsize;
} else {
gArWanted = gArWanted->next;
// 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;
}
}
fprintf(stderr, "tar read off = %zd, size = %zd\n", off, size);
gArLastOffset = off;
gArLastSize = size;
*bufp = ib->output + off;

Loading…
Cancel
Save