Skip to content

Commit

Permalink
employ bufreader in zstd binary
Browse files Browse the repository at this point in the history
  • Loading branch information
KillingSpark committed Oct 23, 2024
1 parent ade1b3d commit c497e42
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/bin/zstd.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
extern crate ruzstd;
use std::fs::File;
use std::io::BufReader;
use std::io::Read;
use std::io::Seek;
use std::io::SeekFrom;
Expand Down Expand Up @@ -133,12 +134,13 @@ fn main() {

if flags.is_empty() {
for path in file_paths {
let mut file = std::fs::File::open(&path).unwrap();
let file = std::fs::File::open(&path).unwrap();
let input_len = file.metadata().unwrap().len() as usize;
let file = BufReader::new(file);
let mut output = Vec::new();
let mut encoder =
FrameCompressor::new(&mut file, &mut output, CompressionLevel::Fastest);
FrameCompressor::new(file, &mut output, CompressionLevel::Fastest);
encoder.compress();
let input_len = file.metadata().unwrap().len() as usize;
println!(
"Compressed {path:} from {} to {} ({}%)",
input_len,
Expand Down

0 comments on commit c497e42

Please sign in to comment.