Skip to content

Commit

Permalink
Removed legacy-zip feature.
Browse files Browse the repository at this point in the history
  • Loading branch information
mkrueger committed May 13, 2024
1 parent 4e090d7 commit 266e438
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 38 deletions.
2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ deflate-zlib = ["flate2/zlib", "_deflate-any"]
deflate-zlib-ng = ["flate2/zlib-ng", "_deflate-any"]
deflate-zopfli = ["zopfli", "_deflate-any"]
lzma = ["lzma-rs/stream"]
legacy-zip = []
unreserved = []
default = [
"aes-crypto",
Expand All @@ -84,7 +83,6 @@ default = [
"lzma",
"time",
"zstd",
"legacy-zip",
]

[[bench]]
Expand Down
18 changes: 0 additions & 18 deletions src/compression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,10 @@ pub enum CompressionMethod {
Lzma,

/// Legacy format
#[cfg(feature = "legacy-zip")]
Shrink,
/// Reduce (Method 2-5)
#[cfg(feature = "legacy-zip")]
Reduce(u8),
/// Method 6 Implode/explode
#[cfg(feature = "legacy-zip")]
Implode,
/// Unsupported compression method
#[cfg_attr(
Expand All @@ -59,17 +56,11 @@ pub enum CompressionMethod {
/// All compression methods defined for the ZIP format
impl CompressionMethod {
pub const STORE: Self = CompressionMethod::Stored;
#[cfg(feature = "legacy-zip")]
pub const SHRINK: Self = CompressionMethod::Shrink;
#[cfg(feature = "legacy-zip")]
pub const REDUCE_1: Self = CompressionMethod::Unsupported(2);
#[cfg(feature = "legacy-zip")]
pub const REDUCE_2: Self = CompressionMethod::Unsupported(3);
#[cfg(feature = "legacy-zip")]
pub const REDUCE_3: Self = CompressionMethod::Unsupported(4);
#[cfg(feature = "legacy-zip")]
pub const REDUCE_4: Self = CompressionMethod::Unsupported(5);
#[cfg(feature = "legacy-zip")]
pub const IMPLODE: Self = CompressionMethod::Unsupported(6);
#[cfg(feature = "_deflate-any")]
pub const DEFLATE: Self = CompressionMethod::Deflated;
Expand Down Expand Up @@ -115,17 +106,11 @@ impl CompressionMethod {
#[allow(deprecated)]
match val {
0 => CompressionMethod::Stored,
#[cfg(feature = "legacy-zip")]
1 => CompressionMethod::Shrink,
#[cfg(feature = "legacy-zip")]
2 => CompressionMethod::Reduce(1),
#[cfg(feature = "legacy-zip")]
3 => CompressionMethod::Reduce(2),
#[cfg(feature = "legacy-zip")]
4 => CompressionMethod::Reduce(3),
#[cfg(feature = "legacy-zip")]
5 => CompressionMethod::Reduce(4),
#[cfg(feature = "legacy-zip")]
6 => CompressionMethod::Implode,
#[cfg(feature = "_deflate-any")]
8 => CompressionMethod::Deflated,
Expand Down Expand Up @@ -153,11 +138,8 @@ impl CompressionMethod {
#[allow(deprecated)]
match self {
CompressionMethod::Stored => 0,
#[cfg(feature = "legacy-zip")]
CompressionMethod::Shrink => 1,
#[cfg(feature = "legacy-zip")]
CompressionMethod::Reduce(n) => 1 + n as u16,
#[cfg(feature = "legacy-zip")]
CompressionMethod::Implode => 6,

#[cfg(feature = "_deflate-any")]
Expand Down
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ mod types;
pub mod write;
mod zipcrypto;
pub use extra_fields::ExtraField;
#[cfg(feature = "legacy-zip")]
mod legacy;

#[doc = "Unstable APIs\n\
Expand Down
14 changes: 0 additions & 14 deletions src/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ use crate::compression::CompressionMethod;
use crate::cp437::FromCp437;
use crate::crc32::Crc32Reader;
use crate::extra_fields::{ExtendedTimestamp, ExtraField};
#[cfg(feature = "legacy-zip")]
use crate::legacy::ShrinkDecoder;
#[cfg(feature = "legacy-zip")]
use crate::legacy::{ImplodeDecoder, ReduceDecoder};
use crate::read::zip_archive::Shared;
use crate::result::{ZipError, ZipResult};
Expand Down Expand Up @@ -144,11 +142,8 @@ pub(crate) enum ZipFileReader<'a> {
NoReader,
Raw(io::Take<&'a mut dyn Read>),
Stored(Crc32Reader<CryptoReader<'a>>),
#[cfg(feature = "legacy-zip")]
Shrink(Crc32Reader<ShrinkDecoder<CryptoReader<'a>>>),
#[cfg(feature = "legacy-zip")]
Reduce(Crc32Reader<ReduceDecoder<CryptoReader<'a>>>),
#[cfg(feature = "legacy-zip")]
Implode(Crc32Reader<ImplodeDecoder<CryptoReader<'a>>>),
#[cfg(feature = "_deflate-any")]
Deflated(Crc32Reader<DeflateDecoder<CryptoReader<'a>>>),
Expand All @@ -168,11 +163,8 @@ impl<'a> Read for ZipFileReader<'a> {
ZipFileReader::NoReader => panic!("ZipFileReader was in an invalid state"),
ZipFileReader::Raw(r) => r.read(buf),
ZipFileReader::Stored(r) => r.read(buf),
#[cfg(feature = "legacy-zip")]
ZipFileReader::Shrink(r) => r.read(buf),
#[cfg(feature = "legacy-zip")]
ZipFileReader::Reduce(r) => r.read(buf),
#[cfg(feature = "legacy-zip")]
ZipFileReader::Implode(r) => r.read(buf),
#[cfg(feature = "_deflate-any")]
ZipFileReader::Deflated(r) => r.read(buf),
Expand All @@ -195,7 +187,6 @@ impl<'a> ZipFileReader<'a> {
ZipFileReader::NoReader => panic!("ZipFileReader was in an invalid state"),
ZipFileReader::Raw(r) => r,
ZipFileReader::Stored(r) => r.into_inner().into_inner(),
#[cfg(feature = "legacy-zip")]
ZipFileReader::Shrink(r) => {
// Lzma reader owns its buffer rather than mutably borrowing it, so we have to drop
// it separately
Expand All @@ -204,7 +195,6 @@ impl<'a> ZipFileReader<'a> {
}
return;
}
#[cfg(feature = "legacy-zip")]
ZipFileReader::Reduce(r) => {
// Lzma reader owns its buffer rather than mutably borrowing it, so we have to drop
// it separately
Expand All @@ -213,7 +203,6 @@ impl<'a> ZipFileReader<'a> {
}
return;
}
#[cfg(feature = "legacy-zip")]
ZipFileReader::Implode(r) => {
// Lzma reader owns its buffer rather than mutably borrowing it, so we have to drop
// it separately
Expand Down Expand Up @@ -341,7 +330,6 @@ pub(crate) fn make_reader(
crc32,
ae2_encrypted,
))),
#[cfg(feature = "legacy-zip")]
CompressionMethod::Shrink => {
let reader = ShrinkDecoder::new(reader, uncompressed_size);
Ok(ZipFileReader::Shrink(Crc32Reader::new(
Expand All @@ -350,7 +338,6 @@ pub(crate) fn make_reader(
ae2_encrypted,
)))
}
#[cfg(feature = "legacy-zip")]
CompressionMethod::Reduce(comp_factor) => {
let reader = ReduceDecoder::new(reader, uncompressed_size, comp_factor);
Ok(ZipFileReader::Reduce(Crc32Reader::new(
Expand All @@ -359,7 +346,6 @@ pub(crate) fn make_reader(
ae2_encrypted,
)))
}
#[cfg(feature = "legacy-zip")]
CompressionMethod::Implode => {
let reader = ImplodeDecoder::new(reader, uncompressed_size, flags);
Ok(ZipFileReader::Implode(Crc32Reader::new(
Expand Down
3 changes: 0 additions & 3 deletions src/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1514,15 +1514,12 @@ impl<W: Write + Seek> GenericZipWriter<W> {
Ok(Box::new(|bare| Storer(bare)))
}
}
#[cfg(feature = "legacy-zip")]
CompressionMethod::Shrink => Err(ZipError::UnsupportedArchive(
"Shrink compression unsupported",
)),
#[cfg(feature = "legacy-zip")]
CompressionMethod::Reduce(_) => Err(ZipError::UnsupportedArchive(
"Reduce compression unsupported",
)),
#[cfg(feature = "legacy-zip")]
CompressionMethod::Implode => Err(ZipError::UnsupportedArchive(
"Implode compression unsupported",
)),
Expand Down

0 comments on commit 266e438

Please sign in to comment.