Update for new bzip2

This commit is contained in:
Mathijs van de Nes 2015-02-25 12:13:13 +01:00
parent f88349104a
commit bfc370eda3
2 changed files with 4 additions and 7 deletions

View file

@ -11,8 +11,5 @@ Library to support the reading and writing of zip files.
[dependencies] [dependencies]
flate2 = "*" flate2 = "*"
bzip2 = "*"
time = "*" time = "*"
[dependencies.bzip2]
git = "https://github.com/mvdnes/bzip2-rs"
branch = "new_io"

View file

@ -15,7 +15,7 @@ use flate2::write::DeflateEncoder;
use bzip2; use bzip2;
use bzip2::writer::BzCompressor; use bzip2::writer::BzCompressor;
enum GenericZipWriter<W> enum GenericZipWriter<W: Write + io::Seek>
{ {
Closed, Closed,
Storer(W), Storer(W),
@ -46,7 +46,7 @@ enum GenericZipWriter<W>
/// ///
/// println!("Result: {:?}", doit()); /// println!("Result: {:?}", doit());
/// ``` /// ```
pub struct ZipWriter<W> pub struct ZipWriter<W: Write + io::Seek>
{ {
inner: GenericZipWriter<W>, inner: GenericZipWriter<W>,
files: Vec<ZipFile>, files: Vec<ZipFile>,
@ -243,7 +243,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)),
CompressionMethod::Bzip2 => GenericZipWriter::Bzip2(BzCompressor::new(bare, bzip2::CompressionLevel::Default)), CompressionMethod::Bzip2 => GenericZipWriter::Bzip2(BzCompressor::new(bare, bzip2::Compress::Default)),
_ => return Err(ZipError::UnsupportedZipFile("Unsupported compression")), _ => return Err(ZipError::UnsupportedZipFile("Unsupported compression")),
}; };