bzip2-rs icon indicating copy to clipboard operation
bzip2-rs copied to clipboard

Way to know how many compressed bytes were read when decompressing

Open alexgagnon opened this issue 2 years ago • 0 comments

This is more for user feedback than anything, but I was looking for a way to know how many bytes of the compressed source had been read, rather than the number of decompressed bytes, so that I can get accurate ETA's.

For example:

let input = File::open(input.expect("Could not get path"))?;
let size = input.metadata()?.len();
let reader = BufReader::new(input);
let mut md = MultiBzDecoder::new(reader);
let mut buffer = [0; BUFFER_LENGTH];
let mut n = md.read(&mut buffer)?;

n appears to me to be how many uncompressed bytes were read, How do I know how far along in the file I've read and how it compares to size?

alexgagnon avatar Dec 01 '22 22:12 alexgagnon