Skip to content

Commit

Permalink
fix up some public methods to use new impls
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmicexplorer committed Jul 16, 2024
1 parent 3abac52 commit b463f02
Showing 1 changed file with 6 additions and 25 deletions.
31 changes: 6 additions & 25 deletions src/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ use crate::unstable::{path_to_string, LittleEndianReadExt};

use crate::crc32::non_crypto::Crc32Reader as NewCrc32Reader;
use crate::unstable::read::{
construct_decompressing_reader, find_entry_content_range, CryptoEntryReader, CryptoVariant,
ZipEntry,
construct_decompressing_reader, find_entry_content_range, ArchiveEntry, CryptoEntryReader,
CryptoVariant, ZipEntry,
};

pub use zip_archive::ZipArchive;
Expand Down Expand Up @@ -998,27 +998,8 @@ impl<R: Read + Seek> ZipArchive<R> {
&mut self,
file_number: usize,
) -> ZipResult<Option<AesInfo>> {
let (_, data) = self
.shared
.files
.get_index(file_number)
.ok_or(ZipError::FileNotFound)?;

let limit_reader = find_content(data, &mut self.reader)?;
match data.aes_mode {
None => Ok(None),
Some(AesModeInfo { aes_mode, .. }) => {
let (verification_value, salt) =
AesReader::new(limit_reader, aes_mode, data.compressed_size)
.get_verification_value_and_salt()?;
let aes_info = AesInfo {
aes_mode,
verification_value,
salt,
};
Ok(Some(aes_info))
}
}
let entry = self.by_index_raw_new(file_number)?;
entry.get_aes_verification_key_and_salt()
}

/// Read a ZIP archive, collecting the files it contains.
Expand Down Expand Up @@ -1061,7 +1042,7 @@ impl<R: Read + Seek> ZipArchive<R> {
#[cfg(unix)]
let mut files_by_unix_mode = Vec::new();
for i in 0..self.len() {
let mut file = self.by_index(i)?;
let mut file = self.by_index_new(i)?;
let filepath = file
.enclosed_name()
.ok_or(ZipError::InvalidArchive("Invalid file path"))?;
Expand Down Expand Up @@ -1117,7 +1098,7 @@ impl<R: Read + Seek> ZipArchive<R> {
}
continue;
}
let mut file = self.by_index(i)?;
let mut file = self.by_index_new(i)?;
let mut outfile = fs::File::create(&outpath)?;
io::copy(&mut file, &mut outfile)?;
#[cfg(unix)]
Expand Down

0 comments on commit b463f02

Please sign in to comment.