diff --git a/src/types.rs b/src/types.rs index ddab9928..a8b9dc3f 100644 --- a/src/types.rs +++ b/src/types.rs @@ -388,6 +388,7 @@ impl TryFrom for OffsetDateTime { } } +pub const MIN_VERSION: u8 = 10; pub const DEFAULT_VERSION: u8 = 45; /// Structure representing a ZIP file. @@ -524,7 +525,7 @@ impl ZipFileData { /// PKZIP version needed to open this file (from APPNOTE 4.4.3.2). pub fn version_needed(&self) -> u16 { let compression_version: u16 = match self.compression_method { - CompressionMethod::Stored => 10, + CompressionMethod::Stored => MIN_VERSION.into(), #[cfg(feature = "_deflate-any")] CompressionMethod::Deflated => 20, #[cfg(feature = "bzip2")] diff --git a/src/write.rs b/src/write.rs index 7f033794..84ccafb3 100644 --- a/src/write.rs +++ b/src/write.rs @@ -8,9 +8,7 @@ use crate::result::{ZipError, ZipResult}; use crate::spec::{self, Block}; #[cfg(feature = "aes-crypto")] use crate::types::AesMode; -use crate::types::{ - ffi, AesVendorVersion, DateTime, ZipFileData, ZipLocalEntryBlock, ZipRawValues, DEFAULT_VERSION, -}; +use crate::types::{ffi, AesVendorVersion, DateTime, ZipFileData, ZipLocalEntryBlock, ZipRawValues, DEFAULT_VERSION, MIN_VERSION}; use crate::write::ffi::S_IFLNK; #[cfg(any(feature = "_deflate-any", feature = "bzip2", feature = "zstd",))] use core::num::NonZeroU64; @@ -1357,7 +1355,7 @@ impl ZipWriter { fn write_central_and_footer(&mut self) -> Result { let writer = self.inner.get_plain(); - let mut version_needed = 10; // Lowest value; even an empty ZIP file needs 1.0 + let mut version_needed = MIN_VERSION as u16; let central_start = writer.stream_position()?; for file in self.files.values() { write_central_directory_header(writer, file)?;