Use deflate as feature name

This commit is contained in:
jonpas 2019-06-17 21:36:38 +02:00
parent b171b915f8
commit 14f77b390a
6 changed files with 24 additions and 24 deletions

View file

@ -24,9 +24,9 @@ rand = "0.4"
walkdir = "1.0"
[features]
deflate = ["flate2", "flate2/default"]
deflate-zlib = ["flate2", "flate2/zlib"]
deflate-rust = ["flate2", "flate2/rust_backend"]
deflate = ["flate2/default"]
deflate-zlib = ["flate2/zlib"]
deflate-rust = ["flate2/rust_backend"]
default = ["bzip2", "deflate", "time"]
[[bench]]

View file

@ -17,9 +17,9 @@ fn main() {
const METHOD_STORED : Option<zip::CompressionMethod> = Some(zip::CompressionMethod::Stored);
#[cfg(feature = "flate2")]
#[cfg(feature = "deflate")]
const METHOD_DEFLATED : Option<zip::CompressionMethod> = Some(zip::CompressionMethod::Deflated);
#[cfg(not(feature = "flate2"))]
#[cfg(not(feature = "deflate"))]
const METHOD_DEFLATED : Option<zip::CompressionMethod> = None;
#[cfg(feature = "bzip2")]

View file

@ -9,7 +9,7 @@ pub enum CompressionMethod
/// The file is stored (no compression)
Stored,
/// Deflate in pure rust
#[cfg(feature = "flate2")]
#[cfg(feature = "deflate")]
Deflated,
/// File is compressed using BZIP2 algorithm
#[cfg(feature = "bzip2")]
@ -23,7 +23,7 @@ impl CompressionMethod {
pub fn from_u16(val: u16) -> CompressionMethod {
match val {
0 => CompressionMethod::Stored,
#[cfg(feature = "flate2")]
#[cfg(feature = "deflate")]
8 => CompressionMethod::Deflated,
#[cfg(feature = "bzip2")]
12 => CompressionMethod::Bzip2,
@ -35,7 +35,7 @@ impl CompressionMethod {
pub fn to_u16(self) -> u16 {
match self {
CompressionMethod::Stored => 0,
#[cfg(feature = "flate2")]
#[cfg(feature = "deflate")]
CompressionMethod::Deflated => 8,
#[cfg(feature = "bzip2")]
CompressionMethod::Bzip2 => 12,

View file

@ -5,7 +5,7 @@
#[cfg(feature = "bzip2")]
extern crate bzip2;
extern crate crc32fast;
#[cfg(feature = "flate2")]
#[cfg(feature = "deflate")]
extern crate flate2;
extern crate podio;
#[cfg(feature = "time")]

View file

@ -13,9 +13,9 @@ use podio::{ReadPodExt, LittleEndian};
use types::{ZipFileData, System, DateTime};
use cp437::FromCp437;
#[cfg(feature = "flate2")]
#[cfg(feature = "deflate")]
use flate2;
#[cfg(feature = "flate2")]
#[cfg(feature = "deflate")]
use flate2::read::DeflateDecoder;
#[cfg(feature = "bzip2")]
@ -65,7 +65,7 @@ pub struct ZipArchive<R: Read + io::Seek>
enum ZipFileReader<'a> {
NoReader,
Stored(Crc32Reader<io::Take<&'a mut Read>>),
#[cfg(feature = "flate2")]
#[cfg(feature = "deflate")]
Deflated(Crc32Reader<flate2::read::DeflateDecoder<io::Take<&'a mut Read>>>),
#[cfg(feature = "bzip2")]
Bzip2(Crc32Reader<BzDecoder<io::Take<&'a mut Read>>>),
@ -96,7 +96,7 @@ fn make_reader<'a>(
reader,
crc32)))
},
#[cfg(feature = "flate2")]
#[cfg(feature = "deflate")]
CompressionMethod::Deflated =>
{
let deflate_reader = DeflateDecoder::new(reader);
@ -418,7 +418,7 @@ fn get_reader<'a>(reader: &'a mut ZipFileReader) -> &'a mut Read {
match *reader {
ZipFileReader::NoReader => panic!("ZipFileReader was in an invalid state"),
ZipFileReader::Stored(ref mut r) => r as &mut Read,
#[cfg(feature = "flate2")]
#[cfg(feature = "deflate")]
ZipFileReader::Deflated(ref mut r) => r as &mut Read,
#[cfg(feature = "bzip2")]
ZipFileReader::Bzip2(ref mut r) => r as &mut Read,
@ -530,7 +530,7 @@ impl<'a> Drop for ZipFile<'a> {
let mut reader = match innerreader {
ZipFileReader::NoReader => panic!("ZipFileReader was in an invalid state"),
ZipFileReader::Stored(crcreader) => crcreader.into_inner(),
#[cfg(feature = "flate2")]
#[cfg(feature = "deflate")]
ZipFileReader::Deflated(crcreader) => crcreader.into_inner().into_inner(),
#[cfg(feature = "bzip2")]
ZipFileReader::Bzip2(crcreader) => crcreader.into_inner().into_inner(),

View file

@ -13,9 +13,9 @@ use std::mem;
use time;
use podio::{WritePodExt, LittleEndian};
#[cfg(feature = "flate2")]
#[cfg(feature = "deflate")]
use flate2;
#[cfg(feature = "flate2")]
#[cfg(feature = "deflate")]
use flate2::write::DeflateEncoder;
#[cfg(feature = "bzip2")]
@ -27,7 +27,7 @@ enum GenericZipWriter<W: Write + io::Seek>
{
Closed,
Storer(W),
#[cfg(feature = "flate2")]
#[cfg(feature = "deflate")]
Deflater(DeflateEncoder<W>),
#[cfg(feature = "bzip2")]
Bzip2(BzEncoder<W>),
@ -85,8 +85,8 @@ impl FileOptions {
/// Construct a new FileOptions object
pub fn default() -> FileOptions {
FileOptions {
#[cfg(feature = "flate2")] compression_method: CompressionMethod::Deflated,
#[cfg(not(feature = "flate2"))] compression_method: CompressionMethod::Stored,
#[cfg(feature = "deflate")] compression_method: CompressionMethod::Deflated,
#[cfg(not(feature = "deflate"))] compression_method: CompressionMethod::Stored,
#[cfg(feature = "time")] last_modified_time: DateTime::from_time(time::now()).unwrap_or(DateTime::default()),
#[cfg(not(feature = "time"))] last_modified_time: DateTime::default(),
permissions: None,
@ -369,7 +369,7 @@ impl<W: Write+io::Seek> GenericZipWriter<W>
let bare = match mem::replace(self, GenericZipWriter::Closed)
{
GenericZipWriter::Storer(w) => w,
#[cfg(feature = "flate2")]
#[cfg(feature = "deflate")]
GenericZipWriter::Deflater(w) => w.finish()?,
#[cfg(feature = "bzip2")]
GenericZipWriter::Bzip2(w) => w.finish()?,
@ -379,7 +379,7 @@ impl<W: Write+io::Seek> GenericZipWriter<W>
*self = match compression
{
CompressionMethod::Stored => GenericZipWriter::Storer(bare),
#[cfg(feature = "flate2")]
#[cfg(feature = "deflate")]
CompressionMethod::Deflated => GenericZipWriter::Deflater(DeflateEncoder::new(bare, flate2::Compression::default())),
#[cfg(feature = "bzip2")]
CompressionMethod::Bzip2 => GenericZipWriter::Bzip2(BzEncoder::new(bare, bzip2::Compression::Default)),
@ -392,7 +392,7 @@ impl<W: Write+io::Seek> GenericZipWriter<W>
fn ref_mut(&mut self) -> Option<&mut Write> {
match *self {
GenericZipWriter::Storer(ref mut w) => Some(w as &mut Write),
#[cfg(feature = "flate2")]
#[cfg(feature = "deflate")]
GenericZipWriter::Deflater(ref mut w) => Some(w as &mut Write),
#[cfg(feature = "bzip2")]
GenericZipWriter::Bzip2(ref mut w) => Some(w as &mut Write),
@ -421,7 +421,7 @@ impl<W: Write+io::Seek> GenericZipWriter<W>
fn current_compression(&self) -> Option<CompressionMethod> {
match *self {
GenericZipWriter::Storer(..) => Some(CompressionMethod::Stored),
#[cfg(feature = "flate2")]
#[cfg(feature = "deflate")]
GenericZipWriter::Deflater(..) => Some(CompressionMethod::Deflated),
#[cfg(feature = "bzip2")]
GenericZipWriter::Bzip2(..) => Some(CompressionMethod::Bzip2),