Enable decompression when file has been chunked stdout and display progress only when expected size is known.

This commit is contained in:
Con Kolivas 2011-03-13 17:52:23 +11:00
parent a023420cdc
commit 8756fe91e2
3 changed files with 15 additions and 12 deletions

View file

@ -401,7 +401,7 @@ void decompress_file(rzip_control *control)
}
if (!STDOUT)
print_progress("Output filename is: %s...Decompressing...\n", control->outfile);
print_progress("Output filename is: %s\n", control->outfile);
}
if (STDIN) {
@ -465,7 +465,7 @@ void decompress_file(rzip_control *control)
print_verbose("CRC32 ");
print_verbose("being used for integrity testing.\n");
print_progress("Decompressing...");
print_progress("Decompressing...\n");
runzip_fd(control, fd_in, fd_out, fd_hist, expected_size);

View file

@ -202,9 +202,9 @@ static i64 runzip_chunk(rzip_control *control, int fd_in, int fd_out, int fd_his
if (unlikely(read(fd_in, &chunk_bytes, 1) != 1))
fatal("Failed to read chunk_bytes size in runzip_chunk\n");
}
if (!tally)
print_maxverbose("\nExpected size: %lld", expected_size);
print_maxverbose("\nChunk byte width: %d\n", chunk_bytes);
if (!tally && expected_size)
print_maxverbose("Expected size: %lld\n", expected_size);
print_maxverbose("Chunk byte width: %d\n", chunk_bytes);
ofs = lseek(fd_in, 0, SEEK_CUR);
if (unlikely(ofs == -1))
@ -227,12 +227,14 @@ static i64 runzip_chunk(rzip_control *control, int fd_in, int fd_out, int fd_his
total += unzip_match(control, ss, len, fd_out, fd_hist, &cksum, chunk_bytes);
break;
}
p = 100 * ((double)(tally + total) / (double)expected_size);
if (p / 10 != l / 10) {
prog_done = (double)(tally + total) / (double)divisor[divisor_index];
print_progress("%3d%% %9.2f / %9.2f %s\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b",
p, prog_done, prog_tsize, suffix[divisor_index] );
l = p;
if (expected_size) {
p = 100 * ((double)(tally + total) / (double)expected_size);
if (p / 10 != l / 10) {
prog_done = (double)(tally + total) / (double)divisor[divisor_index];
print_progress("%3d%% %9.2f / %9.2f %s\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b",
p, prog_done, prog_tsize, suffix[divisor_index] );
l = p;
}
}
}
@ -263,7 +265,7 @@ i64 runzip_fd(rzip_control *control, int fd_in, int fd_out, int fd_hist, i64 exp
md5_init_ctx (&control->ctx);
gettimeofday(&start,NULL);
while (total < expected_size) {
while (total < expected_size || !control->eof) {
total += runzip_chunk(control, fd_in, fd_out, fd_hist, expected_size, total);
if (STDOUT)
dump_tmpoutfile(control, fd_out);

View file

@ -972,6 +972,7 @@ void *open_stream_in(rzip_control *control, int f, int n)
print_err("Failed to read in chunk size in open_stream_in\n");
goto failed;
}
print_maxverbose("Chunk size: %lld\n", sinfo->size);
}
sinfo->initial_pos = lseek(f, 0, SEEK_CUR);