How to get size of uncompressed gzip file using flate2

476 views Asked by At

I want the uncompressed size of a gzipped file using rust crate flate2.

How do I ask a GzDecoder or MultiGzDecoder for the uncompressed file size without reading the entire file?

I'm hoping for a simple function call like header.filesz():

use std::io::prelude::*;
use std::fs::File;

extern crate flate2;
use flate2::read::GzDecoder;

fn main() -> {
    let file1 = File::open("file1.gz").unwrap();
    let mut decoder = GzDecoder::new(file1);
    let header = decoder.header().unwrap();
    let filesz = header.filesz();
}
1

There are 1 answers

0
Mark Adler On

Not possible. You need to read the whole file.