mirror of
https://github.com/vasi/pixz
synced 2024-11-16 21:26:04 +00:00
Don't read index unless necessary
This commit is contained in:
parent
9d0c5e314a
commit
2c5c33120a
9
common.c
9
common.c
@ -140,10 +140,11 @@ lzma_vli find_file_index(void **bdatap) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
lzma_vli read_file_index(void) {
|
||||
void *bdata;
|
||||
lzma_vli offset = find_file_index(&bdata);
|
||||
if (!bdata)
|
||||
lzma_vli read_file_index(lzma_vli offset) {
|
||||
void *bdata = NULL;
|
||||
if (!offset)
|
||||
offset = find_file_index(&bdata);
|
||||
if (!offset)
|
||||
return 0;
|
||||
|
||||
while (true) {
|
||||
|
2
list.c
2
list.c
@ -40,7 +40,7 @@ int main(int argc, char **argv) {
|
||||
(uintmax_t)iter.block.uncompressed_size);
|
||||
}
|
||||
|
||||
if (tar && read_file_index()) {
|
||||
if (tar && read_file_index(0)) {
|
||||
printf("\n");
|
||||
dump_file_index(stdout);
|
||||
free_file_index();
|
||||
|
2
pixz.h
2
pixz.h
@ -57,7 +57,7 @@ bool is_multi_header(const char *name);
|
||||
void decode_index(void);
|
||||
|
||||
lzma_vli find_file_index(void **bdatap);
|
||||
lzma_vli read_file_index(void);
|
||||
lzma_vli read_file_index(lzma_vli offset);
|
||||
void dump_file_index(FILE *out);
|
||||
void free_file_index(void);
|
||||
|
||||
|
11
pread.c
11
pread.c
@ -6,8 +6,8 @@
|
||||
#include <getopt.h>
|
||||
|
||||
/* TODO
|
||||
* - Don't read index unless necessary?
|
||||
* - Check sizes of files vs index
|
||||
* - Test against "normal" xz, txz files
|
||||
*/
|
||||
|
||||
#define DEBUG 0
|
||||
@ -94,8 +94,9 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: ONly read index if necessary?
|
||||
gFileIndexOffset = read_file_index();
|
||||
decode_index();
|
||||
if (verify)
|
||||
gFileIndexOffset = read_file_index(0);
|
||||
wanted_files(argc - optind, argv + optind);
|
||||
#if DEBUG
|
||||
for (wanted_t *w = gWantedFiles; w; w = w->next)
|
||||
@ -122,8 +123,8 @@ int main(int argc, char **argv) {
|
||||
die("Error reading archive entry");
|
||||
}
|
||||
const char *path = archive_entry_pathname(entry);
|
||||
if (is_multi_header(path))
|
||||
continue;
|
||||
// if (is_multi_header(path))
|
||||
// continue;
|
||||
|
||||
size_t size = archive_entry_size(entry);
|
||||
if (!w)
|
||||
|
Loading…
Reference in New Issue
Block a user