You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm working on decompressing a heap of zlib compressed streams. Each one has a defined chunk size.
The first chunk is always valid, but the second chunk is always invalid.
Is there an easy way to expand multi-stream Zlib blobs?
I'm attempting to manually leverage zlib on each chunk.. I don't think a reset is needed since i'm controlling the ZlibDecoder invocation... however the data seemingly isn't decompressed as the input is identical to the output.
read_to_end seems to read to the end of the zlib stream instead of the end of the file per the documentation (maybe a mistake?)
use flate2::read::ZlibDecoder;../// Inflate the heap section of a hpkg for later processingfninflate_heap(&mutself) -> Result<usize,Box<dyn error::Error>>{let chunks = self.heap_chunk_count()?;let header = self.header.as_ref().unwrap();let filename = self.filename.as_ref().unwrap();println!("Heap chunk size: {}", header.heap_chunk_size);println!("Heap chunk count: {}", chunks);println!("Heap compressed size: {}", header.heap_size_compressed);println!("Heap uncompressed size: {}", header.heap_size_uncompressed);println!("Heap compression: {}", header.heap_compression);// Each chunk is compressed individually so each represents a separate zlib stream.letmut pos:u64 = 0;while pos < header.heap_size_compressed{println!("Read {} - {}...", pos, pos + header.heap_chunk_size asu64);letmut f = File::open(filename)?;&f.seek(SeekFrom::Start(header.header_sizeasu64 + pos))?;letmut reader:Box<dynRead> = match header.heap_compression{0 => Box::new(f),1 => Box::new(ZlibDecoder::new(f)),
_ => returnErr(From::from(format!("Unknown hpkg heap compression: {}", header.heap_compression)))};let len = reader.read_to_end(&mutself.heap_data)? asu64;
pos = pos + len + 1;println!("Uncompressed heap: {}",self.heap_data.len());}//println!("Heap: Decompressed Length: {} vs header length: {}", heap_pos, header.heap_size_uncompressed);Ok(0)}
I'm working on decompressing a heap of zlib compressed streams. Each one has a defined chunk size.
The first chunk is always valid, but the second chunk is always invalid.
Is there an easy way to expand multi-stream Zlib blobs?
I'm attempting to manually leverage zlib on each chunk.. I don't think a reset is needed since i'm controlling the ZlibDecoder invocation... however the data seemingly isn't decompressed as the input is identical to the output.
read_to_end seems to read to the end of the zlib stream instead of the end of the file per the documentation (maybe a mistake?)
The text was updated successfully, but these errors were encountered: