Update for liblzma index API changes

pull/2/head
Dave Vasilevsky 14 years ago
parent 53bc5c3c1f
commit 73e14a5272

@ -76,11 +76,12 @@ void free_file_index(void) {
void read_file_index(void) {
// find the last block
lzma_index_iter iter;
lzma_index_iter_init(&iter, gIndex);
lzma_vli loc = lzma_index_uncompressed_size(gIndex) - 1;
lzma_index_record rec;
if (lzma_index_locate(gIndex, &rec, loc))
if (lzma_index_iter_locate(&iter, loc))
die("Can't locate file index block");
void *bdata = decode_block_start(rec.stream_offset);
void *bdata = decode_block_start(iter.block.compressed_file_offset);
gFileIndexBuf = malloc(gFIBSize);
gStream.avail_out = gFIBSize;
@ -199,7 +200,8 @@ void *decode_block_start(off_t block_seek) {
die("Error seeking to block");
block_wrapper_t *bw = malloc(sizeof(block_wrapper_t));
bw->block = (lzma_block){ .check = gCheck, .filters = bw->filters };
bw->block = (lzma_block){ .check = gCheck, .filters = bw->filters,
.version = 0 };
int b = fgetc(gInFile);
if (b == EOF || b == 0)

@ -27,10 +27,12 @@ int main(int argc, char **argv) {
die("Can't open input file");
decode_index();
lzma_index_record rec;
while (!lzma_index_read(gIndex, &rec)) {
fprintf(stderr, "%9"PRIuMAX" / %9"PRIuMAX"\n", (uintmax_t)rec.unpadded_size,
(uintmax_t)rec.uncompressed_size);
lzma_index_iter iter;
lzma_index_iter_init(&iter, gIndex);
while (!lzma_index_iter_next(&iter, LZMA_INDEX_ITER_BLOCK)) {
fprintf(stderr, "%9"PRIuMAX" / %9"PRIuMAX"\n",
(uintmax_t)iter.block.unpadded_size,
(uintmax_t)iter.block.uncompressed_size);
}
if (tar) {

@ -38,21 +38,20 @@ static void extract_file(const char *target) {
off_t fstart = f->offset, fsize = f->next->offset - fstart;
// extract the data
lzma_index_record rec;
lzma_index_rewind(gIndex);
while (fsize && !lzma_index_read(gIndex, &rec)) {
off_t bstart = rec.uncompressed_offset,
bsize = rec.uncompressed_size;
if (fstart > bstart + bsize)
continue;
lzma_index_iter iter;
lzma_index_iter_init(&iter, gIndex);
if (lzma_index_iter_locate(&iter, fstart))
die("Block with file contents can't be found");
do {
off_t bstart = iter.block.uncompressed_file_offset,
bsize = iter.block.uncompressed_size;
off_t dstart = fstart > bstart ? fstart - bstart : 0;
bsize -= dstart;
off_t dsize = fsize > bsize ? bsize : fsize;
fsize -= dsize;
extract_block(rec.stream_offset, dstart, dsize);
}
extract_block(iter.block.compressed_file_offset, dstart, dsize);
} while (fsize && !lzma_index_iter_next(&iter, LZMA_INDEX_ITER_BLOCK));
if (fsize)
die("Block with file contents missing");
}

@ -119,7 +119,7 @@ int main(int argc, char **argv) {
debug("writer: start");
// pre-block setup: header, index
if (!(gIndex = lzma_index_init(NULL, NULL)))
if (!(gIndex = lzma_index_init(NULL)))
die("Error creating index");
stream_edge(LZMA_VLI_UNKNOWN);

Loading…
Cancel
Save