0

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();
}
Colonel Thirty Two
  • 23,953
  • 8
  • 45
  • 85
JamesThomasMoon
  • 6,169
  • 7
  • 37
  • 63
  • 4
    What you're asking might not be possible, see this answer, https://stackoverflow.com/a/54360738/429972 – jontro Jun 09 '22 at 21:16

1 Answers1

0

Not possible. You need to read the whole file.

Mark Adler
  • 101,978
  • 13
  • 118
  • 158