Skip to content

Commit

Permalink
None of the lzo libraries work
Browse files Browse the repository at this point in the history
  • Loading branch information
widberg committed Oct 24, 2023
1 parent e4b84b7 commit a1b5628
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 13 deletions.
31 changes: 26 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bff/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ impl-trait-for-tuples = "0.2.2"
indexmap = { version = "2.0.0", features = ["serde"] }
itertools = { version = "0.11.0", features = [] }
lz4 = "1.24.0"
minilzo-rs = "0.6.0"
minilzo3 = "0.1.0"
num-traits = "0.2.15"
once_cell = { version = "1.18.0", features = [] }
rayon = { version = "1.8.0", features = [] }
Expand Down
2 changes: 1 addition & 1 deletion bff/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,5 @@ pub enum Error {
UnimplementedClass(UnimplementedClassError),
UnimplementedVersionPlatform(UnimplementedVersionPlatformError),
Utf8(std::string::FromUtf8Error),
MiniLzo(minilzo_rs::Error),
MiniLzo3(minilzo3::Error),
}
12 changes: 6 additions & 6 deletions bff/src/lz/lzo.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
use std::io::{Read, Write};

use binrw::Endian;
use minilzo_rs::LZO;
use minilzo3::{compress, decompress};

use crate::BffResult;

pub fn lzo_compress<W: Write>(data: &[u8], writer: &mut W, _endian: Endian) -> BffResult<()> {
let mut lzo = LZO::init()?;
let compressed = lzo.compress(data)?;
let mut compressed = vec![0; 0x00105800];
compress(&data, &mut compressed, false)?;
writer.write_all(&compressed)?;
Ok(())
}

pub fn lzo_decompress<R: Read>(reader: &mut R, _endian: Endian) -> BffResult<Vec<u8>> {
let lzo = LZO::init()?;
let mut compressed: Vec<u8> = Vec::new();
let mut compressed = Vec::new();
reader.read_to_end(&mut compressed)?;
let decompressed = lzo.decompress_safe(&compressed, 0x1000000)?;
let mut decompressed = vec![0; 0x00105800];
let _decompressed_length = decompress(&compressed, &mut decompressed)?;
Ok(decompressed)
}

0 comments on commit a1b5628

Please sign in to comment.