Update to new bzip2
This commit is contained in:
parent
7db32c9165
commit
aaa49eb4f1
3 changed files with 8 additions and 8 deletions
|
@ -16,7 +16,7 @@ flate2 = "0.2"
|
||||||
time = "0.1"
|
time = "0.1"
|
||||||
podio = "0.1"
|
podio = "0.1"
|
||||||
msdos_time = "0.1"
|
msdos_time = "0.1"
|
||||||
bzip2 = { version = "0.2", optional = true }
|
bzip2 = { version = "0.3", optional = true }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["bzip2"]
|
default = ["bzip2"]
|
||||||
|
|
|
@ -15,7 +15,7 @@ use cp437::FromCp437;
|
||||||
use msdos_time::{TmMsDosExt, MsDosDateTime};
|
use msdos_time::{TmMsDosExt, MsDosDateTime};
|
||||||
|
|
||||||
#[cfg(feature = "bzip2")]
|
#[cfg(feature = "bzip2")]
|
||||||
use bzip2::reader::BzDecompressor;
|
use bzip2::read::BzDecoder;
|
||||||
|
|
||||||
/// Wrapper for reading the contents of a ZIP file.
|
/// Wrapper for reading the contents of a ZIP file.
|
||||||
///
|
///
|
||||||
|
@ -54,7 +54,7 @@ enum ZipFileReader<'a> {
|
||||||
Stored(Crc32Reader<io::Take<&'a mut Read>>),
|
Stored(Crc32Reader<io::Take<&'a mut Read>>),
|
||||||
Deflated(Crc32Reader<flate2::read::DeflateDecoder<io::Take<&'a mut Read>>>),
|
Deflated(Crc32Reader<flate2::read::DeflateDecoder<io::Take<&'a mut Read>>>),
|
||||||
#[cfg(feature = "bzip2")]
|
#[cfg(feature = "bzip2")]
|
||||||
Bzip2(Crc32Reader<BzDecompressor<io::Take<&'a mut Read>>>),
|
Bzip2(Crc32Reader<BzDecoder<io::Take<&'a mut Read>>>),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A struct for reading a zip file
|
/// A struct for reading a zip file
|
||||||
|
@ -153,7 +153,7 @@ impl<R: Read+io::Seek> ZipArchive<R>
|
||||||
#[cfg(feature = "bzip2")]
|
#[cfg(feature = "bzip2")]
|
||||||
CompressionMethod::Bzip2 =>
|
CompressionMethod::Bzip2 =>
|
||||||
{
|
{
|
||||||
let bzip2_reader = BzDecompressor::new(limit_reader);
|
let bzip2_reader = BzDecoder::new(limit_reader);
|
||||||
ZipFileReader::Bzip2(Crc32Reader::new(
|
ZipFileReader::Bzip2(Crc32Reader::new(
|
||||||
bzip2_reader,
|
bzip2_reader,
|
||||||
data.crc32))
|
data.crc32))
|
||||||
|
|
|
@ -20,7 +20,7 @@ use msdos_time::TmMsDosExt;
|
||||||
#[cfg(feature = "bzip2")]
|
#[cfg(feature = "bzip2")]
|
||||||
use bzip2;
|
use bzip2;
|
||||||
#[cfg(feature = "bzip2")]
|
#[cfg(feature = "bzip2")]
|
||||||
use bzip2::writer::BzCompressor;
|
use bzip2::write::BzEncoder;
|
||||||
|
|
||||||
enum GenericZipWriter<W: Write + io::Seek>
|
enum GenericZipWriter<W: Write + io::Seek>
|
||||||
{
|
{
|
||||||
|
@ -28,7 +28,7 @@ enum GenericZipWriter<W: Write + io::Seek>
|
||||||
Storer(W),
|
Storer(W),
|
||||||
Deflater(DeflateEncoder<W>),
|
Deflater(DeflateEncoder<W>),
|
||||||
#[cfg(feature = "bzip2")]
|
#[cfg(feature = "bzip2")]
|
||||||
Bzip2(BzCompressor<W>),
|
Bzip2(BzEncoder<W>),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Generator for ZIP files.
|
/// Generator for ZIP files.
|
||||||
|
@ -252,7 +252,7 @@ impl<W: Write+io::Seek> GenericZipWriter<W>
|
||||||
GenericZipWriter::Storer(w) => w,
|
GenericZipWriter::Storer(w) => w,
|
||||||
GenericZipWriter::Deflater(w) => try!(w.finish()),
|
GenericZipWriter::Deflater(w) => try!(w.finish()),
|
||||||
#[cfg(feature = "bzip2")]
|
#[cfg(feature = "bzip2")]
|
||||||
GenericZipWriter::Bzip2(w) => match w.into_inner() { Ok(r) => r, Err((_, err)) => try!(Err(err)) },
|
GenericZipWriter::Bzip2(w) => try!(w.finish()),
|
||||||
GenericZipWriter::Closed => try!(Err(io::Error::new(io::ErrorKind::BrokenPipe, "ZipWriter was already closed"))),
|
GenericZipWriter::Closed => try!(Err(io::Error::new(io::ErrorKind::BrokenPipe, "ZipWriter was already closed"))),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -261,7 +261,7 @@ impl<W: Write+io::Seek> GenericZipWriter<W>
|
||||||
CompressionMethod::Stored => GenericZipWriter::Storer(bare),
|
CompressionMethod::Stored => GenericZipWriter::Storer(bare),
|
||||||
CompressionMethod::Deflated => GenericZipWriter::Deflater(bare.deflate_encode(flate2::Compression::Default)),
|
CompressionMethod::Deflated => GenericZipWriter::Deflater(bare.deflate_encode(flate2::Compression::Default)),
|
||||||
#[cfg(feature = "bzip2")]
|
#[cfg(feature = "bzip2")]
|
||||||
CompressionMethod::Bzip2 => GenericZipWriter::Bzip2(BzCompressor::new(bare, bzip2::Compress::Default)),
|
CompressionMethod::Bzip2 => GenericZipWriter::Bzip2(BzEncoder::new(bare, bzip2::Compression::Default)),
|
||||||
CompressionMethod::Unsupported(..) => return Err(ZipError::UnsupportedArchive("Unsupported compression")),
|
CompressionMethod::Unsupported(..) => return Err(ZipError::UnsupportedArchive("Unsupported compression")),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue