Properly write 'version needed' in local file header
'version made by' was used instead of version needed by accident. Resolves #72
This commit is contained in:
parent
806147ac9e
commit
ab9667aa5c
3 changed files with 10 additions and 3 deletions
|
@ -79,6 +79,14 @@ impl ZipFileData {
|
||||||
path
|
path
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn version_needed(&self) -> u16 {
|
||||||
|
match self.compression_method {
|
||||||
|
#[cfg(feature = "bzip2")]
|
||||||
|
::compression::CompressionMethod::Bzip2 => 46,
|
||||||
|
_ => 20,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
|
@ -424,8 +424,7 @@ fn write_local_file_header<T: Write>(writer: &mut T, file: &ZipFileData) -> ZipR
|
||||||
// local file header signature
|
// local file header signature
|
||||||
try!(writer.write_u32::<LittleEndian>(spec::LOCAL_FILE_HEADER_SIGNATURE));
|
try!(writer.write_u32::<LittleEndian>(spec::LOCAL_FILE_HEADER_SIGNATURE));
|
||||||
// version needed to extract
|
// version needed to extract
|
||||||
let version_made_by = (file.system as u16) << 8 | (file.version_made_by as u16);
|
try!(writer.write_u16::<LittleEndian>(file.version_needed()));
|
||||||
try!(writer.write_u16::<LittleEndian>(version_made_by));
|
|
||||||
// general purpose bit flag
|
// general purpose bit flag
|
||||||
let flag = if !file.file_name.is_ascii() { 1u16 << 11 } else { 0 };
|
let flag = if !file.file_name.is_ascii() { 1u16 << 11 } else { 0 };
|
||||||
try!(writer.write_u16::<LittleEndian>(flag));
|
try!(writer.write_u16::<LittleEndian>(flag));
|
||||||
|
@ -472,7 +471,7 @@ fn write_central_directory_header<T: Write>(writer: &mut T, file: &ZipFileData)
|
||||||
let version_made_by = (file.system as u16) << 8 | (file.version_made_by as u16);
|
let version_made_by = (file.system as u16) << 8 | (file.version_made_by as u16);
|
||||||
try!(writer.write_u16::<LittleEndian>(version_made_by));
|
try!(writer.write_u16::<LittleEndian>(version_made_by));
|
||||||
// version needed to extract
|
// version needed to extract
|
||||||
try!(writer.write_u16::<LittleEndian>(20));
|
try!(writer.write_u16::<LittleEndian>(file.version_needed()));
|
||||||
// general puprose bit flag
|
// general puprose bit flag
|
||||||
let flag = if !file.file_name.is_ascii() { 1u16 << 11 } else { 0 };
|
let flag = if !file.file_name.is_ascii() { 1u16 << 11 } else { 0 };
|
||||||
try!(writer.write_u16::<LittleEndian>(flag));
|
try!(writer.write_u16::<LittleEndian>(flag));
|
||||||
|
|
Binary file not shown.
Loading…
Add table
Reference in a new issue