diff --git a/Cargo.toml b/Cargo.toml index b11e0ae4..c6bd89cb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,10 +12,10 @@ Library to support the reading and writing of zip files. """ [dependencies] +flate2 = { version = "1.0", default-features = false, optional = true } time = { version = "0.1", optional = true } podio = "0.1" bzip2 = { version = "0.3", optional = true } -libflate = { version = ">=0.1.21", optional = true } crc32fast = "1.0" [dev-dependencies] @@ -24,7 +24,9 @@ rand = "0.4" walkdir = "1.0" [features] -deflate = ["libflate"] +deflate = ["flate2/rust_backend"] +deflate-miniz = ["flate2/default"] +deflate-zlib = ["flate2/zlib"] default = ["bzip2", "deflate", "time"] [[bench]] diff --git a/src/lib.rs b/src/lib.rs index ef2fd049..cfe4a598 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,7 +6,7 @@ extern crate bzip2; extern crate crc32fast; #[cfg(feature = "deflate")] -extern crate libflate; +extern crate flate2; extern crate podio; #[cfg(feature = "time")] extern crate time; diff --git a/src/read.rs b/src/read.rs index e01e1edc..2eb3d83b 100644 --- a/src/read.rs +++ b/src/read.rs @@ -14,7 +14,9 @@ use types::{ZipFileData, System, DateTime}; use cp437::FromCp437; #[cfg(feature = "deflate")] -use libflate; +use flate2; +#[cfg(feature = "deflate")] +use flate2::read::DeflateDecoder; #[cfg(feature = "bzip2")] use bzip2::read::BzDecoder; @@ -64,7 +66,7 @@ enum ZipFileReader<'a> { NoReader, Stored(Crc32Reader>), #[cfg(feature = "deflate")] - Deflated(Crc32Reader>>), + Deflated(Crc32Reader>>), #[cfg(feature = "bzip2")] Bzip2(Crc32Reader>>), } @@ -97,7 +99,7 @@ fn make_reader<'a>( #[cfg(feature = "deflate")] CompressionMethod::Deflated => { - let deflate_reader = libflate::deflate::Decoder::new(reader); + let deflate_reader = DeflateDecoder::new(reader); Ok(ZipFileReader::Deflated(Crc32Reader::new( deflate_reader, crc32))) diff --git a/src/write.rs b/src/write.rs index 1c4888a8..5e4c223f 100644 --- a/src/write.rs +++ b/src/write.rs @@ -14,7 +14,9 @@ use time; use podio::{WritePodExt, LittleEndian}; #[cfg(feature = "deflate")] -use libflate; +use flate2; +#[cfg(feature = "deflate")] +use flate2::write::DeflateEncoder; #[cfg(feature = "bzip2")] use bzip2; @@ -26,7 +28,7 @@ enum GenericZipWriter Closed, Storer(W), #[cfg(feature = "deflate")] - Deflater(libflate::deflate::Encoder), + Deflater(DeflateEncoder), #[cfg(feature = "bzip2")] Bzip2(BzEncoder), } @@ -374,7 +376,7 @@ impl GenericZipWriter { GenericZipWriter::Storer(w) => w, #[cfg(feature = "deflate")] - GenericZipWriter::Deflater(w) => w.finish().into_result()?, + GenericZipWriter::Deflater(w) => w.finish()?, #[cfg(feature = "bzip2")] GenericZipWriter::Bzip2(w) => w.finish()?, GenericZipWriter::Closed => Err(io::Error::new(io::ErrorKind::BrokenPipe, "ZipWriter was already closed"))?, @@ -384,7 +386,7 @@ impl GenericZipWriter { CompressionMethod::Stored => GenericZipWriter::Storer(bare), #[cfg(feature = "deflate")] - CompressionMethod::Deflated => GenericZipWriter::Deflater(libflate::deflate::Encoder::new(bare)), + CompressionMethod::Deflated => GenericZipWriter::Deflater(DeflateEncoder::new(bare, flate2::Compression::default())), #[cfg(feature = "bzip2")] CompressionMethod::Bzip2 => GenericZipWriter::Bzip2(BzEncoder::new(bare, bzip2::Compression::Default)), CompressionMethod::Unsupported(..) => return Err(ZipError::UnsupportedArchive("Unsupported compression")),