HOLY CRAP IT'S FINALLY WORKING!!!

This commit is contained in:
spuds 2023-01-14 15:08:31 +00:00
parent b20a04c907
commit f2f7d93fe2

View file

@ -92,12 +92,11 @@ impl Entry {
use io::Write; use io::Write;
match self.compression { match self.compression {
Compression::None => buf.write_all(&data)?, Compression::None => buf.write_all(&data)?,
Compression::Zlib => { Compression::Zlib => match &self.blocks {
let mut decoder = flate2::write::ZlibDecoder::new(buf); Some(blocks) => {
match &self.blocks { for block in blocks {
Some(blocks) => { io::copy(
for block in blocks { &mut flate2::read::ZlibDecoder::new(
decoder.write(
&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 => {
@ -105,13 +104,18 @@ impl Entry {
..(block.end - data_offset) as usize ..(block.end - data_offset) as usize
} }
}], }],
)?; ),
} &mut buf,
)?;
} }
None => decoder.write_all(&data)?,
} }
buf = decoder.finish()?; None => {
} io::copy(
&mut flate2::read::ZlibDecoder::new(data.as_slice()),
&mut buf,
)?;
}
},
Compression::Gzip => todo!(), Compression::Gzip => todo!(),
Compression::Oodle => todo!(), Compression::Oodle => todo!(),
} }