-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
decompress a .lz4
file?
#158
Comments
Can you retry using |
Thanks @PSeitz . I got this working. I was not setting the length of the passed buffer (see rust-lang/rust#96915). This code works (notice the call to use std::fs::File;
use std::fs::OpenOptions;
use std::io::prelude::Read;
use std::io::BufReader;
use std::path::Path;
use ::lz4_flex;
fn main() {
let mut open_options = OpenOptions::new();
let path = String::from("/tmp/file.lz4");
let path_std = Path::new(&path);
let file_lz: File = match open_options.read(true).open(path_std) {
Ok(val) => val,
Err(err) => panic!("{}", err),
};
let bufreader = BufReader::<File>::new(file_lz);
let mut lz4_decoder = lz4_flex::frame::FrameDecoder::new(bufreader);
let mut buffer = Vec::<u8>::with_capacity(1024);
buffer.resize(1024, 0);
let sz = match lz4_decoder.read(&mut buffer) {
Ok(sz) => sz,
Err(err) => panic!("{}", err),
};
eprintln!("buffer: {:?}", &buffer[..sz]);
} If you're interested, I can submit a PR for this at |
Yeah a PR would be nice, e.g. |
I'm trying to use
lz4_flex
to decompress a small.lz4
file. The file was compressed usinglz4c
on Ubuntu 22.However, my various attempts at reading the file
file.lz4
using alz4_flex::frame::FrameDecoder
and calls to.read
or.read_exact
do returnOk
. However they do not appear to write anything to the passedVec<u8>
.My code is
Could you provide an example for decompressing an
.lz4
file?Reviewing the examples, it was not obvious to me how to go about this as the examples only use "live" stdin streaming.
The text was updated successfully, but these errors were encountered: