diff options
Diffstat (limited to 'src/zip/file')
| -rw-r--r-- | src/zip/file/info.rs | 12 | ||||
| -rw-r--r-- | src/zip/file/read.rs | 17 |
2 files changed, 14 insertions, 15 deletions
diff --git a/src/zip/file/info.rs b/src/zip/file/info.rs index ff6e8d2..90d257d 100644 --- a/src/zip/file/info.rs +++ b/src/zip/file/info.rs | |||
| @@ -123,7 +123,9 @@ impl BitFlag { | |||
| 123 | pub struct ZipFileInfo { | 123 | pub struct ZipFileInfo { |
| 124 | pub compression_method: CompressionMethod, | 124 | pub compression_method: CompressionMethod, |
| 125 | pub bit_flag: BitFlag, | 125 | pub bit_flag: BitFlag, |
| 126 | pub datetime: DateTime<Local>, | 126 | pub mtime: DateTime<Local>, |
| 127 | pub atime: Option<DateTime<Local>>, | ||
| 128 | pub ctime: Option<DateTime<Local>>, | ||
| 127 | pub crc: u32, | 129 | pub crc: u32, |
| 128 | pub compressed_size: u64, | 130 | pub compressed_size: u64, |
| 129 | pub size: u64, | 131 | pub size: u64, |
| @@ -136,7 +138,9 @@ impl ZipFileInfo { | |||
| 136 | pub fn new( | 138 | pub fn new( |
| 137 | compression_method: CompressionMethod, | 139 | compression_method: CompressionMethod, |
| 138 | bit_flag: BitFlag, | 140 | bit_flag: BitFlag, |
| 139 | datetime: DateTime<Local>, | 141 | mtime: DateTime<Local>, |
| 142 | atime: Option<DateTime<Local>>, | ||
| 143 | ctime: Option<DateTime<Local>>, | ||
| 140 | crc: u32, | 144 | crc: u32, |
| 141 | compressed_size: u64, | 145 | compressed_size: u64, |
| 142 | size: u64, | 146 | size: u64, |
| @@ -147,7 +151,9 @@ impl ZipFileInfo { | |||
| 147 | Self { | 151 | Self { |
| 148 | compression_method, | 152 | compression_method, |
| 149 | bit_flag, | 153 | bit_flag, |
| 150 | datetime, | 154 | mtime, |
| 155 | atime, | ||
| 156 | ctime, | ||
| 151 | crc, | 157 | crc, |
| 152 | compressed_size, | 158 | compressed_size, |
| 153 | size, | 159 | size, |
diff --git a/src/zip/file/read.rs b/src/zip/file/read.rs index 6ec7db7..7d683db 100644 --- a/src/zip/file/read.rs +++ b/src/zip/file/read.rs | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | use crate::driver::FileDriver; | 1 | use crate::driver::FileDriver; |
| 2 | use crate::utils::ReadUtils; | ||
| 2 | use crate::zip::{CompressionMethod, ZipError, ZipFileInfo, ZipResult}; | 3 | use crate::zip::{CompressionMethod, ZipError, ZipFileInfo, ZipResult}; |
| 3 | use bzip2::read::BzDecoder; | 4 | use bzip2::read::BzDecoder; |
| 4 | use flate2::read::DeflateDecoder; | 5 | use flate2::read::DeflateDecoder; |
| @@ -35,11 +36,7 @@ impl<'d, Io: Read> FileDriver for ZipFileReader<'d, Io> { | |||
| 35 | impl<'d, Io: Read + Seek> ZipFileReader<'d, Io> { | 36 | impl<'d, Io: Read + Seek> ZipFileReader<'d, Io> { |
| 36 | pub fn new(io: &'d mut Io, info: &'d ZipFileInfo) -> ZipResult<Self> { | 37 | pub fn new(io: &'d mut Io, info: &'d ZipFileInfo) -> ZipResult<Self> { |
| 37 | io.seek(SeekFrom::Start(info.header_pointer))?; | 38 | io.seek(SeekFrom::Start(info.header_pointer))?; |
| 38 | let buf = { | 39 | let buf = io.read_arr::<30>()?; |
| 39 | let mut buf = [0; 30]; | ||
| 40 | io.read(&mut buf)?; | ||
| 41 | buf | ||
| 42 | }; | ||
| 43 | 40 | ||
| 44 | if u32::from_le_bytes(buf[..4].try_into().unwrap()) != 0x04034b50 { | 41 | if u32::from_le_bytes(buf[..4].try_into().unwrap()) != 0x04034b50 { |
| 45 | return Err(ZipError::InvalidFileHeaderSignature.into()); | 42 | return Err(ZipError::InvalidFileHeaderSignature.into()); |
| @@ -56,12 +53,8 @@ impl<'d, Io: Read + Seek> ZipFileReader<'d, Io> { | |||
| 56 | CompressionMethod::Deflate => IoProxy::Deflate(DeflateDecoder::new(io)), | 53 | CompressionMethod::Deflate => IoProxy::Deflate(DeflateDecoder::new(io)), |
| 57 | CompressionMethod::BZip2 => IoProxy::BZip2(BzDecoder::new(io)), | 54 | CompressionMethod::BZip2 => IoProxy::BZip2(BzDecoder::new(io)), |
| 58 | CompressionMethod::Lzma => { | 55 | CompressionMethod::Lzma => { |
| 59 | let buf = { | 56 | let buf = io.read_arr::<9>()?; |
| 60 | let mut buf = [0; 9]; | 57 | cursor += 9; |
| 61 | io.read(&mut buf)?; | ||
| 62 | cursor += 9; | ||
| 63 | buf | ||
| 64 | }; | ||
| 65 | IoProxy::Xz(XzDecoder::new_stream( | 58 | IoProxy::Xz(XzDecoder::new_stream( |
| 66 | io, | 59 | io, |
| 67 | Stream::new_raw_decoder( | 60 | Stream::new_raw_decoder( |
| @@ -71,7 +64,7 @@ impl<'d, Io: Read + Seek> ZipFileReader<'d, Io> { | |||
| 71 | .literal_position_bits((buf[4] / 9 % 5) as u32) | 64 | .literal_position_bits((buf[4] / 9 % 5) as u32) |
| 72 | .position_bits((buf[4] / 45) as u32) | 65 | .position_bits((buf[4] / 45) as u32) |
| 73 | .dict_size( | 66 | .dict_size( |
| 74 | u32::from_le_bytes(buf[5..9].try_into().unwrap()).min(4096), | 67 | u32::from_le_bytes(buf[5..9].try_into().unwrap()).max(4096), |
| 75 | ), | 68 | ), |
| 76 | ), | 69 | ), |
| 77 | ) | 70 | ) |
