forked from rust-lang/flate2-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support cloudfire optimized version of zlib as a backend (rust-lang#228)
* Support cloudfire optimized version of zlib as a backend * Support cloudfire optimized version of zlib as a backend
- Loading branch information
Showing
6 changed files
with
132 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
extern crate flate2; | ||
|
||
use flate2::write::GzEncoder; | ||
use flate2::Compression; | ||
use std::env::args; | ||
use std::fs::File; | ||
use std::io::copy; | ||
use std::io::BufReader; | ||
use std::time::Instant; | ||
|
||
fn main() { | ||
if args().len() != 3 { | ||
eprintln!("Usage: ./compress_file `source` `target`"); | ||
return; | ||
} | ||
let mut input = BufReader::new(File::open(args().nth(1).unwrap()).unwrap()); | ||
let output = File::create(args().nth(2).unwrap()).unwrap(); | ||
let mut encoder = GzEncoder::new(output, Compression::default()); | ||
let start = Instant::now(); | ||
copy(&mut input, &mut encoder).unwrap(); | ||
let output = encoder.finish().unwrap(); | ||
println!( | ||
"Source len: {:?}", | ||
input.get_ref().metadata().unwrap().len() | ||
); | ||
println!("Target len: {:?}", output.metadata().unwrap().len()); | ||
println!("Elapsed: {:?}", start.elapsed()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters