mirror of
https://github.com/xavo95/repak.git
synced 2025-01-18 19:04:07 +00:00
gzip support
This commit is contained in:
parent
f2f7d93fe2
commit
600bbd21a1
1 changed files with 27 additions and 22 deletions
17
src/entry.rs
17
src/entry.rs
|
@ -90,13 +90,13 @@ impl Entry {
|
||||||
data.truncate(self.compressed as usize);
|
data.truncate(self.compressed as usize);
|
||||||
}
|
}
|
||||||
use io::Write;
|
use io::Write;
|
||||||
match self.compression {
|
macro_rules! decompress {
|
||||||
Compression::None => buf.write_all(&data)?,
|
($decompressor: ty) => {
|
||||||
Compression::Zlib => match &self.blocks {
|
match &self.blocks {
|
||||||
Some(blocks) => {
|
Some(blocks) => {
|
||||||
for block in blocks {
|
for block in blocks {
|
||||||
io::copy(
|
io::copy(
|
||||||
&mut flate2::read::ZlibDecoder::new(
|
&mut <$decompressor>::new(
|
||||||
&data[match version >= Version::RelativeChunkOffsets {
|
&data[match version >= Version::RelativeChunkOffsets {
|
||||||
true => block.start as usize..block.end as usize,
|
true => block.start as usize..block.end as usize,
|
||||||
false => {
|
false => {
|
||||||
|
@ -115,8 +115,13 @@ impl Entry {
|
||||||
&mut buf,
|
&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!(),
|
Compression::Oodle => todo!(),
|
||||||
}
|
}
|
||||||
buf.flush()?;
|
buf.flush()?;
|
||||||
|
|
Loading…
Reference in a new issue