transfer file from one zip to another, WIP (z64 broken)
This commit is contained in:
parent
8157325a02
commit
26b18bab76
4 changed files with 19 additions and 4 deletions
|
|
@ -44,7 +44,13 @@ impl Serializable for FileHeader {
|
|||
self.compressed_size.serialize(output)?;
|
||||
self.uncompressed_size.serialize(output)?;
|
||||
(self.file_name.len() as u16).serialize(output)?;
|
||||
(self.extra_field.len() as u16).serialize(output)?;
|
||||
(self
|
||||
.extra_field
|
||||
.iter()
|
||||
.map(|f| f.size() as u16)
|
||||
.sum::<u16>()
|
||||
+ self.malformed_extra_field.len() as u16)
|
||||
.serialize(output)?;
|
||||
(self.file_comment.len() as u16).serialize(output)?;
|
||||
self.disk_number_start.serialize(output)?;
|
||||
self.internal_file_attributes.serialize(output)?;
|
||||
|
|
|
|||
|
|
@ -37,7 +37,13 @@ impl Serializable for LocalFileHeader {
|
|||
self.compressed_size.serialize(output)?;
|
||||
self.uncompressed_size.serialize(output)?;
|
||||
(self.file_name.len() as u16).serialize(output)?;
|
||||
(self.extra_field.len() as u16).serialize(output)?;
|
||||
(self
|
||||
.extra_field
|
||||
.iter()
|
||||
.map(|f| f.size() as u16)
|
||||
.sum::<u16>()
|
||||
+ self.malformed_extra_field.len() as u16)
|
||||
.serialize(output)?;
|
||||
for c in &self.file_name {
|
||||
c.serialize(output)?;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,8 +37,8 @@ fn main() {
|
|||
println!("{:#?}", zip_file.get_file_info("classes.dex"));
|
||||
*/
|
||||
|
||||
let file = File::open("app-release.apk").expect("failed to open file");
|
||||
let out_file = File::create("app-release.out.zip").expect("failed to create file");
|
||||
let file = File::open("tst_64.zip").expect("failed to open file");
|
||||
let out_file = File::create("tst_64.out.zip").expect("failed to create file");
|
||||
let mut zip_file = ZipFileReader::new(file);
|
||||
let mut out_file =
|
||||
ZipFileWriter::new(out_file, zip_file.zip64_end_of_central_directory.clone());
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ use crate::{
|
|||
};
|
||||
use androscalpel_serializer::Serializable;
|
||||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub struct ZipFileReader<T: Read + Seek> {
|
||||
pub end_of_central_directory: EndCentralDirectory,
|
||||
pub zip64_end_of_central_directory: Option<Zip64EndCentralDirectory>,
|
||||
|
|
@ -44,6 +45,7 @@ impl<T: Read + Seek> ZipFileReader<T> {
|
|||
} else {
|
||||
None
|
||||
};
|
||||
//println!("{:#?}", end_of_central_directory);
|
||||
|
||||
// At this point python's ziplib recompute the location of the central directory from the
|
||||
// location of the end of central directory in case the zip was concanated after a file.
|
||||
|
|
@ -64,6 +66,7 @@ impl<T: Read + Seek> ZipFileReader<T> {
|
|||
let cd_size = zip_file.get_cd_size();
|
||||
while size_read < cd_size {
|
||||
let header = FileHeader::deserialize(&mut zip_file.data).unwrap();
|
||||
//println!("{:#?}", header);
|
||||
size_read += header.size() as u64;
|
||||
let pos_in_dir = zip_file.data.stream_position().unwrap();
|
||||
if header.general_purpose_flags & general_purpose_flags::MASK_ENCRYPTED_CENTRAL_DIR != 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue