Closed jsen- closed 7 years ago
Looks like it's not the compression ... I tried something crazy and used a super naive replacement of compression algo
[package]
name = "compression_test2"
version = "0.1.0"
[dependencies]
libflate = "0.1"
deflate = "0.5"
extern crate libflate;
extern crate deflate;
use std::fs::File;
use std::io::copy;
use libflate::deflate::{Encoder, EncodeOptions};
struct MyEncoder { vec: Vec<u8> }
impl libflate::lz77::Lz77Encode for MyEncoder {
fn encode<S>(&mut self, buf: &[u8], mut _sink: S)
where S: libflate::lz77::Sink
{
self.vec.extend_from_slice(buf);
}
fn flush<S>(&mut self, mut sink: S)
where S: libflate::lz77::Sink
{
for c in &self.vec {
sink.consume(libflate::lz77::Code::Literal(*c));
}
}
}
fn main() {
let out_file = File::create("foo.tar.gz").unwrap();
let mut encoder = Encoder::with_options(out_file, EncodeOptions::with_lz77(MyEncoder { vec: Vec::new() }));
let mut in_file = File::open("mingw-w64-install.exe").unwrap();
copy(&mut in_file, &mut encoder).unwrap();
encoder.finish().into_result().unwrap();
}
but ...
Running "cargo run":
Finished debug [unoptimized + debuginfo] target(s) in 0.0 secs
Running `target\debug\compression_test2.exe`
thread 'main' panicked at 'symbol:17, table:17', C:\Users\root\.cargo\registry\src\github.com-1ecc6299db9ec823\libflate-0.1.0\src\huffman.rs:188
stack backtrace:
0: 0x46d914 - <unknown>
1: 0x46a1d9 - <unknown>
...
16: 0x4014e7 - <unknown>
17: 0x7ffa91a08363 - <unknown>
error: process didn't exit successfully: `target\debug\compression_test2.exe` (exit code: 101)
"cargo run" completed with code 101
It took approximately 0.354 seconds
Thank you for your report. I fixed the bug in https://github.com/sile/libflate/commit/bc68c99af4663be979e9bf1c6da1fa2c2ccf58ae .
Please ignore the
<unknown>
stack frames, this is known issue with*-pc-windows-gnu
target. The file I'm testing with is mingw-w64-install.exe but happened on basically any binary file I tried.