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