gzip support

This commit is contained in:
spuds 2023-01-14 15:17:24 +00:00
parent f2f7d93fe2
commit 600bbd21a1

View file

@ -90,13 +90,13 @@ impl Entry {
data.truncate(self.compressed as usize);
}
use io::Write;
match self.compression {
Compression::None => buf.write_all(&data)?,
Compression::Zlib => match &self.blocks {
macro_rules! decompress {
($decompressor: ty) => {
match &self.blocks {
Some(blocks) => {
for block in blocks {
io::copy(
&mut flate2::read::ZlibDecoder::new(
&mut <$decompressor>::new(
&data[match version >= Version::RelativeChunkOffsets {
true => block.start as usize..block.end as usize,
false => {
@ -115,8 +115,13 @@ impl Entry {
&mut buf,
)?;
}
},
Compression::Gzip => todo!(),
}
};
}
match self.compression {
Compression::None => buf.write_all(&data)?,
Compression::Zlib => decompress!(flate2::read::ZlibDecoder<&[u8]>),
Compression::Gzip => decompress!(flate2::read::GzDecoder<&[u8]>),
Compression::Oodle => todo!(),
}
buf.flush()?;