| 1 | // Copyright (c) 2022-2023 Harry [Majored] [[email protected]] |
| 2 | // MIT License (https://github.com/Majored/rs-async-zip/blob/main/LICENSE) |
| 3 | |
| 4 | //! A module which supports reading ZIP files. |
| 5 | |
| 6 | pub mod memrust-analyzer cargo async_zip 0.0.18 base/read/mem/; |
| 7 | pub mod seekrust-analyzer cargo async_zip 0.0.18 base/read/seek/; |
| 8 | pub mod streamrust-analyzer cargo async_zip 0.0.18 base/read/stream/; |
| 9 | |
| 10 | pub(craterust-analyzer cargo async_zip 0.0.18 crate/) mod iorust-analyzer cargo async_zip 0.0.18 base/read/io/; |
| 11 | |
| 12 | use craterust-analyzer cargo async_zip 0.0.18 crate/::ZipStringrust-analyzer cargo async_zip 0.0.18 string/ZipString#; |
| 13 | // Re-exported as part of the public API. |
| 14 | pub use craterust-analyzer cargo async_zip 0.0.18 crate/::baserust-analyzer cargo async_zip 0.0.18 base/::readrust-analyzer cargo async_zip 0.0.18 base/read/::iorust-analyzer cargo async_zip 0.0.18 base/read/io/::entryrust-analyzer cargo async_zip 0.0.18 base/read/io/entry/::WithEntryrust-analyzer cargo async_zip 0.0.18 base/read/io/entry/WithEntry#; |
| 15 | pub use craterust-analyzer cargo async_zip 0.0.18 crate/::baserust-analyzer cargo async_zip 0.0.18 base/::readrust-analyzer cargo async_zip 0.0.18 base/read/::iorust-analyzer cargo async_zip 0.0.18 base/read/io/::entryrust-analyzer cargo async_zip 0.0.18 base/read/io/entry/::WithoutEntryrust-analyzer cargo async_zip 0.0.18 base/read/io/entry/WithoutEntry#; |
| 16 | pub use craterust-analyzer cargo async_zip 0.0.18 crate/::baserust-analyzer cargo async_zip 0.0.18 base/::readrust-analyzer cargo async_zip 0.0.18 base/read/::iorust-analyzer cargo async_zip 0.0.18 base/read/io/::entryrust-analyzer cargo async_zip 0.0.18 base/read/io/entry/::ZipEntryReaderrust-analyzer cargo async_zip 0.0.18 base/read/io/entry/ZipEntryReader#; |
| 17 | |
| 18 | use craterust-analyzer cargo async_zip 0.0.18 crate/::daterust-analyzer cargo async_zip 0.0.18 date/::ZipDateTimerust-analyzer cargo async_zip 0.0.18 date/ZipDateTime#; |
| 19 | use craterust-analyzer cargo async_zip 0.0.18 crate/::entryrust-analyzer cargo async_zip 0.0.18 entry/::{StoredZipEntryrust-analyzer cargo async_zip 0.0.18 entry/StoredZipEntry#, ZipEntryrust-analyzer cargo async_zip 0.0.18 entry/ZipEntry#}; |
| 20 | use craterust-analyzer cargo async_zip 0.0.18 crate/::errorrust-analyzer cargo async_zip 0.0.18 error/::{Resultrust-analyzer cargo async_zip 0.0.18 error/Result#, ZipErrorrust-analyzer cargo async_zip 0.0.18 error/ZipError#}; |
| 21 | use craterust-analyzer cargo async_zip 0.0.18 crate/::filerust-analyzer cargo async_zip 0.0.18 file/::ZipFilerust-analyzer cargo async_zip 0.0.18 file/ZipFile#; |
| 22 | use craterust-analyzer cargo async_zip 0.0.18 crate/::specrust-analyzer cargo async_zip 0.0.18 spec/::attributerust-analyzer cargo async_zip 0.0.18 spec/attribute/::AttributeCompatibilityrust-analyzer cargo async_zip 0.0.18 spec/attribute/AttributeCompatibility#; |
| 23 | use craterust-analyzer cargo async_zip 0.0.18 crate/::specrust-analyzer cargo async_zip 0.0.18 spec/::constsrust-analyzer cargo async_zip 0.0.18 spec/consts/::LFH_LENGTHrust-analyzer cargo async_zip 0.0.18 spec/consts/LFH_LENGTH.; |
| 24 | use craterust-analyzer cargo async_zip 0.0.18 crate/::specrust-analyzer cargo async_zip 0.0.18 spec/::constsrust-analyzer cargo async_zip 0.0.18 spec/consts/::{CDH_SIGNATURErust-analyzer cargo async_zip 0.0.18 spec/consts/CDH_SIGNATURE., LFH_SIGNATURErust-analyzer cargo async_zip 0.0.18 spec/consts/LFH_SIGNATURE., NON_ZIP64_MAX_SIZErust-analyzer cargo async_zip 0.0.18 spec/consts/NON_ZIP64_MAX_SIZE., SIGNATURE_LENGTHrust-analyzer cargo async_zip 0.0.18 spec/consts/SIGNATURE_LENGTH., ZIP64_EOCDL_LENGTHrust-analyzer cargo async_zip 0.0.18 spec/consts/ZIP64_EOCDL_LENGTH.}; |
| 25 | use craterust-analyzer cargo async_zip 0.0.18 crate/::specrust-analyzer cargo async_zip 0.0.18 spec/::headerrust-analyzer cargo async_zip 0.0.18 spec/header/::InfoZipUnicodeCommentExtraFieldrust-analyzer cargo async_zip 0.0.18 spec/header/InfoZipUnicodeCommentExtraField#; |
| 26 | use craterust-analyzer cargo async_zip 0.0.18 crate/::specrust-analyzer cargo async_zip 0.0.18 spec/::headerrust-analyzer cargo async_zip 0.0.18 spec/header/::InfoZipUnicodePathExtraFieldrust-analyzer cargo async_zip 0.0.18 spec/header/InfoZipUnicodePathExtraField#; |
| 27 | use craterust-analyzer cargo async_zip 0.0.18 crate/::specrust-analyzer cargo async_zip 0.0.18 spec/::headerrust-analyzer cargo async_zip 0.0.18 spec/header/::{ |
| 28 | CentralDirectoryRecordrust-analyzer cargo async_zip 0.0.18 spec/header/CentralDirectoryRecord#, EndOfCentralDirectoryHeaderrust-analyzer cargo async_zip 0.0.18 spec/header/EndOfCentralDirectoryHeader#, ExtraFieldrust-analyzer cargo async_zip 0.0.18 spec/header/ExtraField#, LocalFileHeaderrust-analyzer cargo async_zip 0.0.18 spec/header/LocalFileHeader#, |
| 29 | Zip64EndOfCentralDirectoryLocatorrust-analyzer cargo async_zip 0.0.18 spec/header/Zip64EndOfCentralDirectoryLocator#, Zip64EndOfCentralDirectoryRecordrust-analyzer cargo async_zip 0.0.18 spec/header/Zip64EndOfCentralDirectoryRecord#, Zip64ExtendedInformationExtraFieldrust-analyzer cargo async_zip 0.0.18 spec/header/Zip64ExtendedInformationExtraField#, |
| 30 | }; |
| 31 | use craterust-analyzer cargo async_zip 0.0.18 crate/::specrust-analyzer cargo async_zip 0.0.18 spec/::Compressionrust-analyzer cargo async_zip 0.0.18 spec/compression/Compression#; |
| 32 | use craterust-analyzer cargo async_zip 0.0.18 crate/::stringrust-analyzer cargo async_zip 0.0.18 string/::StringEncodingrust-analyzer cargo async_zip 0.0.18 string/StringEncoding#; |
| 33 | |
| 34 | use craterust-analyzer cargo async_zip 0.0.18 crate/::baserust-analyzer cargo async_zip 0.0.18 base/::readrust-analyzer cargo async_zip 0.0.18 base/read/::iorust-analyzer cargo async_zip 0.0.18 base/read/io/::CombinedCentralDirectoryRecordrust-analyzer cargo async_zip 0.0.18 base/read/io/combined_record/CombinedCentralDirectoryRecord#; |
| 35 | use craterust-analyzer cargo async_zip 0.0.18 crate/::specrust-analyzer cargo async_zip 0.0.18 spec/::parserust-analyzer cargo async_zip 0.0.18 spec/parse/::parse_extra_fieldsrust-analyzer cargo async_zip 0.0.18 spec/parse/parse_extra_fields().; |
| 36 | |
| 37 | use futures_literust-analyzer cargo futures-lite 2.1.0 crate/::iorust-analyzer cargo futures-lite 2.1.0 io/::{AsyncReadrust-analyzer cargo futures-io 0.3.25 if_std/AsyncRead#, AsyncReadExtrust-analyzer cargo futures-lite 2.1.0 io/AsyncReadExt#, AsyncSeekrust-analyzer cargo futures-io 0.3.25 if_std/AsyncSeek#, AsyncSeekExtrust-analyzer cargo futures-lite 2.1.0 io/AsyncSeekExt#, SeekFromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#}; |
| 38 | |
| 39 | pub(craterust-analyzer cargo async_zip 0.0.18 crate/) async fn filerust-analyzer cargo async_zip 0.0.18 base/read/file().<R>(mut reader: R) -> Resultrust-analyzer cargo async_zip 0.0.18 error/Result#<ZipFilerust-analyzer cargo async_zip 0.0.18 file/ZipFile#> |
| 40 | where |
| 41 | R: AsyncReadrust-analyzer cargo futures-io 0.3.25 if_std/AsyncRead# + AsyncSeekrust-analyzer cargo futures-io 0.3.25 if_std/AsyncSeek# + Unpinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Unpin#, |
| 42 | { |
| 43 | // First find and parse the EOCDR. |
| 44 | let eocdr_offset = craterust-analyzer cargo async_zip 0.0.18 crate/::baserust-analyzer cargo async_zip 0.0.18 base/::readrust-analyzer cargo async_zip 0.0.18 base/read/::iorust-analyzer cargo async_zip 0.0.18 base/read/io/::locatorrust-analyzer cargo async_zip 0.0.18 base/read/io/locator/::eocdrrust-analyzer cargo async_zip 0.0.18 base/read/io/locator/eocdr().(&mut reader).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 45 | |
| 46 | reader.seekrust-analyzer cargo futures-lite 2.1.0 io/AsyncSeekExt#seek().(SeekFromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#::Startrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#Start#(eocdr_offset)).rust-analyzer cargo futures-lite 2.1.0 io/impl#[`SeekFuture<'_, S>`][Future]poll().awaitrust-analyzer cargo futures-lite 2.1.0 io/impl#[`SeekFuture<'_, S>`][Future]poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 47 | let eocdr = EndOfCentralDirectoryHeaderrust-analyzer cargo async_zip 0.0.18 spec/header/EndOfCentralDirectoryHeader#::from_readerrust-analyzer cargo async_zip 0.0.18 spec/parse/impl#[EndOfCentralDirectoryHeader]from_reader().(&mut reader).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 48 | |
| 49 | let comment = iorust-analyzer cargo async_zip 0.0.18 base/read/io/::read_stringrust-analyzer cargo async_zip 0.0.18 base/read/io/read_string().(&mut reader, eocdr.file_comm_lengthrust-analyzer cargo async_zip 0.0.18 spec/header/EndOfCentralDirectoryHeader#file_comm_length..intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), craterust-analyzer cargo async_zip 0.0.18 crate/::StringEncodingrust-analyzer cargo async_zip 0.0.18 string/StringEncoding#::Utf8rust-analyzer cargo async_zip 0.0.18 string/StringEncoding#Utf8#).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 50 | |
| 51 | // Check the 20 bytes before the EOCDR for the Zip64 EOCDL, plus an extra 4 bytes because the offset |
| 52 | // does not include the signature. If the ECODL exists we are dealing with a Zip64 file. |
| 53 | let (eocdr, zip64) = match eocdr_offset.checked_subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u64]checked_sub().(ZIP64_EOCDL_LENGTHrust-analyzer cargo async_zip 0.0.18 spec/consts/ZIP64_EOCDL_LENGTH. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Add<Self>`]add().SIGNATURE_LENGTHrust-analyzer cargo async_zip 0.0.18 spec/consts/SIGNATURE_LENGTH. as u64) { |
| 54 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => (CombinedCentralDirectoryRecordrust-analyzer cargo async_zip 0.0.18 base/read/io/combined_record/CombinedCentralDirectoryRecord#::fromrust-analyzer cargo async_zip 0.0.18 base/read/io/combined_record/impl#[CombinedCentralDirectoryRecord][`From<&EndOfCentralDirectoryHeader>`]from().(&eocdr), false), |
| 55 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(offset) => { |
| 56 | reader.seekrust-analyzer cargo futures-lite 2.1.0 io/AsyncSeekExt#seek().(SeekFromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#::Startrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#Start#(offset)).rust-analyzer cargo futures-lite 2.1.0 io/impl#[`SeekFuture<'_, S>`][Future]poll().awaitrust-analyzer cargo futures-lite 2.1.0 io/impl#[`SeekFuture<'_, S>`][Future]poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 57 | let zip64_locator = Zip64EndOfCentralDirectoryLocatorrust-analyzer cargo async_zip 0.0.18 spec/header/Zip64EndOfCentralDirectoryLocator#::try_from_readerrust-analyzer cargo async_zip 0.0.18 spec/parse/impl#[Zip64EndOfCentralDirectoryLocator]try_from_reader().(&mut reader).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 58 | |
| 59 | match zip64_locator { |
| 60 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(locator) => { |
| 61 | reader.seekrust-analyzer cargo futures-lite 2.1.0 io/AsyncSeekExt#seek().(SeekFromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#::Startrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#Start#(locator.relative_offsetrust-analyzer cargo async_zip 0.0.18 spec/header/Zip64EndOfCentralDirectoryLocator#relative_offset. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Add<Self>`]add().SIGNATURE_LENGTHrust-analyzer cargo async_zip 0.0.18 spec/consts/SIGNATURE_LENGTH. as u64)).rust-analyzer cargo futures-lite 2.1.0 io/impl#[`SeekFuture<'_, S>`][Future]poll().awaitrust-analyzer cargo futures-lite 2.1.0 io/impl#[`SeekFuture<'_, S>`][Future]poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 62 | let zip64_eocdr = Zip64EndOfCentralDirectoryRecordrust-analyzer cargo async_zip 0.0.18 spec/header/Zip64EndOfCentralDirectoryRecord#::from_readerrust-analyzer cargo async_zip 0.0.18 spec/parse/impl#[Zip64EndOfCentralDirectoryRecord]from_reader().(&mut reader).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 63 | (CombinedCentralDirectoryRecordrust-analyzer cargo async_zip 0.0.18 base/read/io/combined_record/CombinedCentralDirectoryRecord#::combinerust-analyzer cargo async_zip 0.0.18 base/read/io/combined_record/impl#[CombinedCentralDirectoryRecord]combine().(eocdr, zip64_eocdr), true) |
| 64 | } |
| 65 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => (CombinedCentralDirectoryRecordrust-analyzer cargo async_zip 0.0.18 base/read/io/combined_record/CombinedCentralDirectoryRecord#::fromrust-analyzer cargo async_zip 0.0.18 base/read/io/combined_record/impl#[CombinedCentralDirectoryRecord][`From<&EndOfCentralDirectoryHeader>`]from().(&eocdr), false), |
| 66 | } |
| 67 | } |
| 68 | }; |
| 69 | |
| 70 | // Outdated feature so unlikely to ever make it into this crate. |
| 71 | if eocdr.disk_numberrust-analyzer cargo async_zip 0.0.18 base/read/io/combined_record/CombinedCentralDirectoryRecord#disk_number. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]ne().eocdr.disk_number_start_of_cdrust-analyzer cargo async_zip 0.0.18 base/read/io/combined_record/CombinedCentralDirectoryRecord#disk_number_start_of_cd. |
| 72 | || eocdr.num_entries_in_directoryrust-analyzer cargo async_zip 0.0.18 base/read/io/combined_record/CombinedCentralDirectoryRecord#num_entries_in_directory. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]ne().eocdr.num_entries_in_directory_on_diskrust-analyzer cargo async_zip 0.0.18 base/read/io/combined_record/CombinedCentralDirectoryRecord#num_entries_in_directory_on_disk. |
| 73 | { |
| 74 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ZipErrorrust-analyzer cargo async_zip 0.0.18 error/ZipError#::FeatureNotSupportedrust-analyzer cargo async_zip 0.0.18 error/ZipError#FeatureNotSupported#("Spanned/split files")); |
| 75 | } |
| 76 | |
| 77 | // Find and parse the central directory. |
| 78 | reader.seekrust-analyzer cargo futures-lite 2.1.0 io/AsyncSeekExt#seek().(SeekFromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#::Startrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#Start#(eocdr.offset_of_start_of_directoryrust-analyzer cargo async_zip 0.0.18 base/read/io/combined_record/CombinedCentralDirectoryRecord#offset_of_start_of_directory.)).rust-analyzer cargo futures-lite 2.1.0 io/impl#[`SeekFuture<'_, S>`][Future]poll().awaitrust-analyzer cargo futures-lite 2.1.0 io/impl#[`SeekFuture<'_, S>`][Future]poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 79 | let entries = craterust-analyzer cargo async_zip 0.0.18 crate/::baserust-analyzer cargo async_zip 0.0.18 base/::readrust-analyzer cargo async_zip 0.0.18 base/read/::cdrust-analyzer cargo async_zip 0.0.18 base/read/cd().(reader, eocdr.num_entries_in_directoryrust-analyzer cargo async_zip 0.0.18 base/read/io/combined_record/CombinedCentralDirectoryRecord#num_entries_in_directory., zip64).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 80 | |
| 81 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(ZipFilerust-analyzer cargo async_zip 0.0.18 file/ZipFile# { entriesrust-analyzer cargo async_zip 0.0.18 file/ZipFile#entries., commentrust-analyzer cargo async_zip 0.0.18 file/ZipFile#comment., zip64rust-analyzer cargo async_zip 0.0.18 file/ZipFile#zip64. }) |
| 82 | } |
| 83 | |
| 84 | pub(craterust-analyzer cargo async_zip 0.0.18 crate/) async fn cdrust-analyzer cargo async_zip 0.0.18 base/read/cd().<R>(mut reader: R, num_of_entries: u64, zip64: bool) -> Resultrust-analyzer cargo async_zip 0.0.18 error/Result#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<StoredZipEntryrust-analyzer cargo async_zip 0.0.18 entry/StoredZipEntry#>> |
| 85 | where |
| 86 | R: AsyncReadrust-analyzer cargo futures-io 0.3.25 if_std/AsyncRead# + Unpinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Unpin#, |
| 87 | { |
| 88 | let num_of_entries = num_of_entries.try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryInto<U>`]try_into().().map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|_| ZipErrorrust-analyzer cargo async_zip 0.0.18 error/ZipError#::TargetZip64NotSupportedrust-analyzer cargo async_zip 0.0.18 error/ZipError#TargetZip64NotSupported#)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 89 | let mut entries = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]with_capacity().(num_of_entries); |
| 90 | |
| 91 | for _ in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#num_of_entries { |
| 92 | let entry = cd_recordrust-analyzer cargo async_zip 0.0.18 base/read/cd_record().(&mut reader, zip64).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 93 | entries.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(entry); |
| 94 | } |
| 95 | |
| 96 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(entries) |
| 97 | } |
| 98 | |
| 99 | pub(craterust-analyzer cargo async_zip 0.0.18 crate/) fn get_zip64_extra_fieldrust-analyzer cargo async_zip 0.0.18 base/read/get_zip64_extra_field().(extra_fields: &[ExtraFieldrust-analyzer cargo async_zip 0.0.18 spec/header/ExtraField#]) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&Zip64ExtendedInformationExtraFieldrust-analyzer cargo async_zip 0.0.18 spec/header/Zip64ExtendedInformationExtraField#> { |
| 100 | for field in extra_fields { |
| 101 | if let ExtraFieldrust-analyzer cargo async_zip 0.0.18 spec/header/ExtraField#::Zip64ExtendedInformationrust-analyzer cargo async_zip 0.0.18 spec/header/ExtraField#Zip64ExtendedInformation#(zip64field) = field { |
| 102 | return Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(zip64field); |
| 103 | } |
| 104 | } |
| 105 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 106 | } |
| 107 | |
| 108 | pub(craterust-analyzer cargo async_zip 0.0.18 crate/) fn get_zip64_extra_field_mutrust-analyzer cargo async_zip 0.0.18 base/read/get_zip64_extra_field_mut().( |
| 109 | extra_fields: &mut [ExtraFieldrust-analyzer cargo async_zip 0.0.18 spec/header/ExtraField#], |
| 110 | ) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&mut Zip64ExtendedInformationExtraFieldrust-analyzer cargo async_zip 0.0.18 spec/header/Zip64ExtendedInformationExtraField#> { |
| 111 | for field in extra_fields { |
| 112 | if let ExtraFieldrust-analyzer cargo async_zip 0.0.18 spec/header/ExtraField#::Zip64ExtendedInformationrust-analyzer cargo async_zip 0.0.18 spec/header/ExtraField#Zip64ExtendedInformation#(zip64field) = field { |
| 113 | return Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(zip64field); |
| 114 | } |
| 115 | } |
| 116 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 117 | } |
| 118 | |
| 119 | fn get_combined_sizesrust-analyzer cargo async_zip 0.0.18 base/read/get_combined_sizes().( |
| 120 | uncompressed_size: u32, |
| 121 | compressed_size: u32, |
| 122 | extra_field: &Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&Zip64ExtendedInformationExtraFieldrust-analyzer cargo async_zip 0.0.18 spec/header/Zip64ExtendedInformationExtraField#>, |
| 123 | ) -> Resultrust-analyzer cargo async_zip 0.0.18 error/Result#<(u64, u64)> { |
| 124 | let mut uncompressed_size = uncompressed_size as u64; |
| 125 | let mut compressed_size = compressed_size as u64; |
| 126 | |
| 127 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(extra_field) = extra_field { |
| 128 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(s) = extra_field.uncompressed_sizerust-analyzer cargo async_zip 0.0.18 spec/header/Zip64ExtendedInformationExtraField#uncompressed_size. { |
| 129 | uncompressed_size = s; |
| 130 | } |
| 131 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(s) = extra_field.compressed_sizerust-analyzer cargo async_zip 0.0.18 spec/header/Zip64ExtendedInformationExtraField#compressed_size. { |
| 132 | compressed_size = s; |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#((uncompressed_size, compressed_size)) |
| 137 | } |
| 138 | |
| 139 | pub(craterust-analyzer cargo async_zip 0.0.18 crate/) async fn cd_recordrust-analyzer cargo async_zip 0.0.18 base/read/cd_record().<R>(mut reader: R, _zip64: bool) -> Resultrust-analyzer cargo async_zip 0.0.18 error/Result#<StoredZipEntryrust-analyzer cargo async_zip 0.0.18 entry/StoredZipEntry#> |
| 140 | where |
| 141 | R: AsyncReadrust-analyzer cargo futures-io 0.3.25 if_std/AsyncRead# + Unpinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Unpin#, |
| 142 | { |
| 143 | craterust-analyzer cargo async_zip 0.0.18 crate/::utilsrust-analyzer cargo async_zip 0.0.18 utils/::assert_signaturerust-analyzer cargo async_zip 0.0.18 utils/assert_signature().(&mut reader, CDH_SIGNATURErust-analyzer cargo async_zip 0.0.18 spec/consts/CDH_SIGNATURE.).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 144 | |
| 145 | let header = CentralDirectoryRecordrust-analyzer cargo async_zip 0.0.18 spec/header/CentralDirectoryRecord#::from_readerrust-analyzer cargo async_zip 0.0.18 spec/parse/impl#[CentralDirectoryRecord]from_reader().(&mut reader).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 146 | let header_size = (SIGNATURE_LENGTHrust-analyzer cargo async_zip 0.0.18 spec/consts/SIGNATURE_LENGTH. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().LFH_LENGTHrust-analyzer cargo async_zip 0.0.18 spec/consts/LFH_LENGTH.) as u64; |
| 147 | let trailing_size = header.file_name_lengthrust-analyzer cargo async_zip 0.0.18 spec/header/CentralDirectoryRecord#file_name_length. as u64 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Add<Self>`]add().header.extra_field_lengthrust-analyzer cargo async_zip 0.0.18 spec/header/CentralDirectoryRecord#extra_field_length. as u64; |
| 148 | let filename_basic = iorust-analyzer cargo async_zip 0.0.18 base/read/io/::read_bytesrust-analyzer cargo async_zip 0.0.18 base/read/io/read_bytes().(&mut reader, header.file_name_lengthrust-analyzer cargo async_zip 0.0.18 spec/header/CentralDirectoryRecord#file_name_length..intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 149 | let compression = Compressionrust-analyzer cargo async_zip 0.0.18 spec/compression/Compression#::try_fromrust-analyzer cargo async_zip 0.0.18 spec/compression/impl#[Compression][`TryFrom<u16>`]try_from().(header.compressionrust-analyzer cargo async_zip 0.0.18 spec/header/CentralDirectoryRecord#compression.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 150 | let extra_field = iorust-analyzer cargo async_zip 0.0.18 base/read/io/::read_bytesrust-analyzer cargo async_zip 0.0.18 base/read/io/read_bytes().(&mut reader, header.extra_field_lengthrust-analyzer cargo async_zip 0.0.18 spec/header/CentralDirectoryRecord#extra_field_length..intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 151 | let extra_fields = parse_extra_fieldsrust-analyzer cargo async_zip 0.0.18 spec/parse/parse_extra_fields().(extra_field, header.uncompressed_sizerust-analyzer cargo async_zip 0.0.18 spec/header/CentralDirectoryRecord#uncompressed_size., header.compressed_sizerust-analyzer cargo async_zip 0.0.18 spec/header/CentralDirectoryRecord#compressed_size.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 152 | let comment_basic = iorust-analyzer cargo async_zip 0.0.18 base/read/io/::read_bytesrust-analyzer cargo async_zip 0.0.18 base/read/io/read_bytes().(reader, header.file_comment_lengthrust-analyzer cargo async_zip 0.0.18 spec/header/CentralDirectoryRecord#file_comment_length..intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 153 | |
| 154 | let zip64_extra_field = get_zip64_extra_fieldrust-analyzer cargo async_zip 0.0.18 base/read/get_zip64_extra_field().(&extra_fields); |
| 155 | let (uncompressed_size, compressed_size) = |
| 156 | get_combined_sizesrust-analyzer cargo async_zip 0.0.18 base/read/get_combined_sizes().(header.uncompressed_sizerust-analyzer cargo async_zip 0.0.18 spec/header/CentralDirectoryRecord#uncompressed_size., header.compressed_sizerust-analyzer cargo async_zip 0.0.18 spec/header/CentralDirectoryRecord#compressed_size., &zip64_extra_field)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 157 | |
| 158 | let mut file_offset = header.lh_offsetrust-analyzer cargo async_zip 0.0.18 spec/header/CentralDirectoryRecord#lh_offset. as u64; |
| 159 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(zip64_extra_field) = zip64_extra_field { |
| 160 | if file_offset rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]eq().NON_ZIP64_MAX_SIZErust-analyzer cargo async_zip 0.0.18 spec/consts/NON_ZIP64_MAX_SIZE. as u64 { |
| 161 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(offset) = zip64_extra_field.relative_header_offsetrust-analyzer cargo async_zip 0.0.18 spec/header/Zip64ExtendedInformationExtraField#relative_header_offset. { |
| 162 | file_offset = offset; |
| 163 | } |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | let filename = detect_filenamerust-analyzer cargo async_zip 0.0.18 base/read/detect_filename().(filename_basic, header.flagsrust-analyzer cargo async_zip 0.0.18 spec/header/CentralDirectoryRecord#flags..filename_unicoderust-analyzer cargo async_zip 0.0.18 spec/header/GeneralPurposeFlag#filename_unicode., extra_fields.as_refrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`AsRef<[T]>`]as_ref().()); |
| 168 | let comment = detect_commentrust-analyzer cargo async_zip 0.0.18 base/read/detect_comment().(comment_basic, header.flagsrust-analyzer cargo async_zip 0.0.18 spec/header/CentralDirectoryRecord#flags..filename_unicoderust-analyzer cargo async_zip 0.0.18 spec/header/GeneralPurposeFlag#filename_unicode., extra_fields.as_refrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`AsRef<[T]>`]as_ref().()); |
| 169 | |
| 170 | let entry = ZipEntryrust-analyzer cargo async_zip 0.0.18 entry/ZipEntry# { |
| 171 | filenamerust-analyzer cargo async_zip 0.0.18 entry/ZipEntry#filename., |
| 172 | compressionrust-analyzer cargo async_zip 0.0.18 entry/ZipEntry#compression., |
| 173 | #[cfg(any( |
| 174 | feature = "deflate", |
| 175 | feature = "bzip2", |
| 176 | feature = "zstd", |
| 177 | feature = "lzma", |
| 178 | feature = "xz", |
| 179 | feature = "deflate64" |
| 180 | ))] |
| 181 | compression_levelrust-analyzer cargo async_zip 0.0.18 entry/ZipEntry#compression_level.: async_compressionrust-analyzer cargo async-compression 0.4.27 crate/::Levelrust-analyzer cargo async-compression 0.4.27 Level#::Defaultrust-analyzer cargo async-compression 0.4.27 Level#Default#, |
| 182 | attribute_compatibilityrust-analyzer cargo async_zip 0.0.18 entry/ZipEntry#attribute_compatibility.: AttributeCompatibilityrust-analyzer cargo async_zip 0.0.18 spec/attribute/AttributeCompatibility#::Unixrust-analyzer cargo async_zip 0.0.18 spec/attribute/AttributeCompatibility#Unix#, |
| 183 | // FIXME: Default to Unix for the moment |
| 184 | crc32rust-analyzer cargo async_zip 0.0.18 entry/ZipEntry#crc32.: header.crcrust-analyzer cargo async_zip 0.0.18 spec/header/CentralDirectoryRecord#crc., |
| 185 | uncompressed_sizerust-analyzer cargo async_zip 0.0.18 entry/ZipEntry#uncompressed_size., |
| 186 | compressed_sizerust-analyzer cargo async_zip 0.0.18 entry/ZipEntry#compressed_size., |
| 187 | last_modification_daterust-analyzer cargo async_zip 0.0.18 entry/ZipEntry#last_modification_date.: ZipDateTimerust-analyzer cargo async_zip 0.0.18 date/ZipDateTime# { daterust-analyzer cargo async_zip 0.0.18 date/ZipDateTime#date.: header.mod_daterust-analyzer cargo async_zip 0.0.18 spec/header/CentralDirectoryRecord#mod_date., timerust-analyzer cargo async_zip 0.0.18 date/ZipDateTime#time.: header.mod_timerust-analyzer cargo async_zip 0.0.18 spec/header/CentralDirectoryRecord#mod_time. }, |
| 188 | internal_file_attributerust-analyzer cargo async_zip 0.0.18 entry/ZipEntry#internal_file_attribute.: header.inter_attrrust-analyzer cargo async_zip 0.0.18 spec/header/CentralDirectoryRecord#inter_attr., |
| 189 | external_file_attributerust-analyzer cargo async_zip 0.0.18 entry/ZipEntry#external_file_attribute.: header.exter_attrrust-analyzer cargo async_zip 0.0.18 spec/header/CentralDirectoryRecord#exter_attr., |
| 190 | extra_fieldsrust-analyzer cargo async_zip 0.0.18 entry/ZipEntry#extra_fields., |
| 191 | commentrust-analyzer cargo async_zip 0.0.18 entry/ZipEntry#comment., |
| 192 | data_descriptorrust-analyzer cargo async_zip 0.0.18 entry/ZipEntry#data_descriptor.: header.flagsrust-analyzer cargo async_zip 0.0.18 spec/header/CentralDirectoryRecord#flags..data_descriptorrust-analyzer cargo async_zip 0.0.18 spec/header/GeneralPurposeFlag#data_descriptor., |
| 193 | }; |
| 194 | |
| 195 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(StoredZipEntryrust-analyzer cargo async_zip 0.0.18 entry/StoredZipEntry# { entryrust-analyzer cargo async_zip 0.0.18 entry/StoredZipEntry#entry., file_offsetrust-analyzer cargo async_zip 0.0.18 entry/StoredZipEntry#file_offset., header_sizerust-analyzer cargo async_zip 0.0.18 entry/StoredZipEntry#header_size.: header_size rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Add<Self>`]add().trailing_size }) |
| 196 | } |
| 197 | |
| 198 | pub(craterust-analyzer cargo async_zip 0.0.18 crate/) async fn lfhrust-analyzer cargo async_zip 0.0.18 base/read/lfh().<R>(mut reader: R) -> Resultrust-analyzer cargo async_zip 0.0.18 error/Result#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<ZipEntryrust-analyzer cargo async_zip 0.0.18 entry/ZipEntry#>> |
| 199 | where |
| 200 | R: AsyncReadrust-analyzer cargo futures-io 0.3.25 if_std/AsyncRead# + Unpinrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Unpin#, |
| 201 | { |
| 202 | let signature = { |
| 203 | let mut buffer = [0; 4]; |
| 204 | reader.read_exactrust-analyzer cargo futures-lite 2.1.0 io/AsyncReadExt#read_exact().(&mut buffer).rust-analyzer cargo futures-lite 2.1.0 io/impl#[`ReadExactFuture<'_, R>`][Future]poll().awaitrust-analyzer cargo futures-lite 2.1.0 io/impl#[`ReadExactFuture<'_, R>`][Future]poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 205 | u32::from_le_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]from_le_bytes().(buffer) |
| 206 | }; |
| 207 | match signature { |
| 208 | actual if actual rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq().LFH_SIGNATURErust-analyzer cargo async_zip 0.0.18 spec/consts/LFH_SIGNATURE. => (), |
| 209 | actual if actual rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq().CDH_SIGNATURErust-analyzer cargo async_zip 0.0.18 spec/consts/CDH_SIGNATURE. => return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#), |
| 210 | actual => return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ZipErrorrust-analyzer cargo async_zip 0.0.18 error/ZipError#::UnexpectedHeaderErrorrust-analyzer cargo async_zip 0.0.18 error/ZipError#UnexpectedHeaderError#(actual, LFH_SIGNATURErust-analyzer cargo async_zip 0.0.18 spec/consts/LFH_SIGNATURE.)), |
| 211 | }; |
| 212 | |
| 213 | let header = LocalFileHeaderrust-analyzer cargo async_zip 0.0.18 spec/header/LocalFileHeader#::from_readerrust-analyzer cargo async_zip 0.0.18 spec/parse/impl#[LocalFileHeader]from_reader().(&mut reader).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 214 | let filename_basic = iorust-analyzer cargo async_zip 0.0.18 base/read/io/::read_bytesrust-analyzer cargo async_zip 0.0.18 base/read/io/read_bytes().(&mut reader, header.file_name_lengthrust-analyzer cargo async_zip 0.0.18 spec/header/LocalFileHeader#file_name_length..intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 215 | let compression = Compressionrust-analyzer cargo async_zip 0.0.18 spec/compression/Compression#::try_fromrust-analyzer cargo async_zip 0.0.18 spec/compression/impl#[Compression][`TryFrom<u16>`]try_from().(header.compressionrust-analyzer cargo async_zip 0.0.18 spec/header/LocalFileHeader#compression.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 216 | let extra_field = iorust-analyzer cargo async_zip 0.0.18 base/read/io/::read_bytesrust-analyzer cargo async_zip 0.0.18 base/read/io/read_bytes().(&mut reader, header.extra_field_lengthrust-analyzer cargo async_zip 0.0.18 spec/header/LocalFileHeader#extra_field_length..intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 217 | let extra_fields = parse_extra_fieldsrust-analyzer cargo async_zip 0.0.18 spec/parse/parse_extra_fields().(extra_field, header.uncompressed_sizerust-analyzer cargo async_zip 0.0.18 spec/header/LocalFileHeader#uncompressed_size., header.compressed_sizerust-analyzer cargo async_zip 0.0.18 spec/header/LocalFileHeader#compressed_size.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 218 | |
| 219 | let zip64_extra_field = get_zip64_extra_fieldrust-analyzer cargo async_zip 0.0.18 base/read/get_zip64_extra_field().(&extra_fields); |
| 220 | let (uncompressed_size, compressed_size) = |
| 221 | get_combined_sizesrust-analyzer cargo async_zip 0.0.18 base/read/get_combined_sizes().(header.uncompressed_sizerust-analyzer cargo async_zip 0.0.18 spec/header/LocalFileHeader#uncompressed_size., header.compressed_sizerust-analyzer cargo async_zip 0.0.18 spec/header/LocalFileHeader#compressed_size., &zip64_extra_field)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 222 | |
| 223 | if header.flagsrust-analyzer cargo async_zip 0.0.18 spec/header/LocalFileHeader#flags..data_descriptorrust-analyzer cargo async_zip 0.0.18 spec/header/GeneralPurposeFlag#data_descriptor. && compression rust-analyzer cargo async_zip 0.0.18 spec/compression/impl#[Compression][`PartialEq<Self>`]eq().==rust-analyzer cargo async_zip 0.0.18 spec/compression/impl#[Compression][`PartialEq<Self>`]eq(). rust-analyzer cargo async_zip 0.0.18 spec/compression/impl#[Compression][`PartialEq<Self>`]eq().Compressionrust-analyzer cargo async_zip 0.0.18 spec/compression/Compression#::Storedrust-analyzer cargo async_zip 0.0.18 spec/compression/Compression#Stored# { |
| 224 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ZipErrorrust-analyzer cargo async_zip 0.0.18 error/ZipError#::FeatureNotSupportedrust-analyzer cargo async_zip 0.0.18 error/ZipError#FeatureNotSupported#( |
| 225 | "stream reading entries with data descriptors & Stored compression mode", |
| 226 | )); |
| 227 | } |
| 228 | if header.flagsrust-analyzer cargo async_zip 0.0.18 spec/header/LocalFileHeader#flags..encryptedrust-analyzer cargo async_zip 0.0.18 spec/header/GeneralPurposeFlag#encrypted. { |
| 229 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ZipErrorrust-analyzer cargo async_zip 0.0.18 error/ZipError#::FeatureNotSupportedrust-analyzer cargo async_zip 0.0.18 error/ZipError#FeatureNotSupported#("encryption")); |
| 230 | } |
| 231 | |
| 232 | let filename = detect_filenamerust-analyzer cargo async_zip 0.0.18 base/read/detect_filename().(filename_basic, header.flagsrust-analyzer cargo async_zip 0.0.18 spec/header/LocalFileHeader#flags..filename_unicoderust-analyzer cargo async_zip 0.0.18 spec/header/GeneralPurposeFlag#filename_unicode., extra_fields.as_refrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`AsRef<[T]>`]as_ref().()); |
| 233 | |
| 234 | let entry = ZipEntryrust-analyzer cargo async_zip 0.0.18 entry/ZipEntry# { |
| 235 | filenamerust-analyzer cargo async_zip 0.0.18 entry/ZipEntry#filename., |
| 236 | compressionrust-analyzer cargo async_zip 0.0.18 entry/ZipEntry#compression., |
| 237 | #[cfg(any( |
| 238 | feature = "deflate", |
| 239 | feature = "bzip2", |
| 240 | feature = "zstd", |
| 241 | feature = "lzma", |
| 242 | feature = "xz", |
| 243 | feature = "deflate64" |
| 244 | ))] |
| 245 | compression_levelrust-analyzer cargo async_zip 0.0.18 entry/ZipEntry#compression_level.: async_compressionrust-analyzer cargo async-compression 0.4.27 crate/::Levelrust-analyzer cargo async-compression 0.4.27 Level#::Defaultrust-analyzer cargo async-compression 0.4.27 Level#Default#, |
| 246 | attribute_compatibilityrust-analyzer cargo async_zip 0.0.18 entry/ZipEntry#attribute_compatibility.: AttributeCompatibilityrust-analyzer cargo async_zip 0.0.18 spec/attribute/AttributeCompatibility#::Unixrust-analyzer cargo async_zip 0.0.18 spec/attribute/AttributeCompatibility#Unix#, |
| 247 | // FIXME: Default to Unix for the moment |
| 248 | crc32rust-analyzer cargo async_zip 0.0.18 entry/ZipEntry#crc32.: header.crcrust-analyzer cargo async_zip 0.0.18 spec/header/LocalFileHeader#crc., |
| 249 | uncompressed_sizerust-analyzer cargo async_zip 0.0.18 entry/ZipEntry#uncompressed_size., |
| 250 | compressed_sizerust-analyzer cargo async_zip 0.0.18 entry/ZipEntry#compressed_size., |
| 251 | last_modification_daterust-analyzer cargo async_zip 0.0.18 entry/ZipEntry#last_modification_date.: ZipDateTimerust-analyzer cargo async_zip 0.0.18 date/ZipDateTime# { daterust-analyzer cargo async_zip 0.0.18 date/ZipDateTime#date.: header.mod_daterust-analyzer cargo async_zip 0.0.18 spec/header/LocalFileHeader#mod_date., timerust-analyzer cargo async_zip 0.0.18 date/ZipDateTime#time.: header.mod_timerust-analyzer cargo async_zip 0.0.18 spec/header/LocalFileHeader#mod_time. }, |
| 252 | internal_file_attributerust-analyzer cargo async_zip 0.0.18 entry/ZipEntry#internal_file_attribute.: 0, |
| 253 | external_file_attributerust-analyzer cargo async_zip 0.0.18 entry/ZipEntry#external_file_attribute.: 0, |
| 254 | extra_fieldsrust-analyzer cargo async_zip 0.0.18 entry/ZipEntry#extra_fields., |
| 255 | commentrust-analyzer cargo async_zip 0.0.18 entry/ZipEntry#comment.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]new().().intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), |
| 256 | data_descriptorrust-analyzer cargo async_zip 0.0.18 entry/ZipEntry#data_descriptor.: header.flagsrust-analyzer cargo async_zip 0.0.18 spec/header/LocalFileHeader#flags..data_descriptorrust-analyzer cargo async_zip 0.0.18 spec/header/GeneralPurposeFlag#data_descriptor., |
| 257 | }; |
| 258 | |
| 259 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(entry)) |
| 260 | } |
| 261 | |
| 262 | fn detect_commentrust-analyzer cargo async_zip 0.0.18 base/read/detect_comment().(basic: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>, basic_is_utf8: bool, extra_fields: &[ExtraFieldrust-analyzer cargo async_zip 0.0.18 spec/header/ExtraField#]) -> ZipStringrust-analyzer cargo async_zip 0.0.18 string/ZipString# { |
| 263 | if basic_is_utf8 { |
| 264 | ZipStringrust-analyzer cargo async_zip 0.0.18 string/ZipString#::newrust-analyzer cargo async_zip 0.0.18 string/impl#[ZipString]new().(basic, StringEncodingrust-analyzer cargo async_zip 0.0.18 string/StringEncoding#::Utf8rust-analyzer cargo async_zip 0.0.18 string/StringEncoding#Utf8#) |
| 265 | } else { |
| 266 | let unicode_extra = extra_fields.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().find_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]find_map().(|field| match field { |
| 267 | ExtraFieldrust-analyzer cargo async_zip 0.0.18 spec/header/ExtraField#::InfoZipUnicodeCommentrust-analyzer cargo async_zip 0.0.18 spec/header/ExtraField#InfoZipUnicodeComment#(InfoZipUnicodeCommentExtraFieldrust-analyzer cargo async_zip 0.0.18 spec/header/InfoZipUnicodeCommentExtraField#::V1rust-analyzer cargo async_zip 0.0.18 spec/header/InfoZipUnicodeCommentExtraField#V1# { crc32rust-analyzer cargo async_zip 0.0.18 spec/header/InfoZipUnicodeCommentExtraField#V1#crc32., unicoderust-analyzer cargo async_zip 0.0.18 spec/header/InfoZipUnicodeCommentExtraField#V1#unicode. }) => { |
| 268 | if *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().crc32 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq().crc32fastrust-analyzer cargo crc32fast 1.4.2 crate/::hashrust-analyzer cargo crc32fast 1.4.2 hash().(&basic) { |
| 269 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/::Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::from_utf8rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]from_utf8().(unicode.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][Clone]clone().())) |
| 270 | } else { |
| 271 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 272 | } |
| 273 | } |
| 274 | _ => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 275 | }); |
| 276 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(s)) = unicode_extra { |
| 277 | ZipStringrust-analyzer cargo async_zip 0.0.18 string/ZipString#::new_with_alternativerust-analyzer cargo async_zip 0.0.18 string/impl#[ZipString]new_with_alternative().(s, basic) |
| 278 | } else { |
| 279 | // Do not treat as UTF-8 if UTF-8 flags are not set, |
| 280 | // some string in MBCS may be valid UTF-8 in form, but they are not in truth. |
| 281 | if basic.is_asciirust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/ascii/impl#[`[u8]`]is_ascii().() { |
| 282 | // SAFETY: |
| 283 | // a valid ASCII string is always a valid UTF-8 string |
| 284 | unsafe { stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/::Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::from_utf8_uncheckedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]from_utf8_unchecked().(basic).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().() } |
| 285 | } else { |
| 286 | ZipStringrust-analyzer cargo async_zip 0.0.18 string/ZipString#::newrust-analyzer cargo async_zip 0.0.18 string/impl#[ZipString]new().(basic, StringEncodingrust-analyzer cargo async_zip 0.0.18 string/StringEncoding#::Rawrust-analyzer cargo async_zip 0.0.18 string/StringEncoding#Raw#) |
| 287 | } |
| 288 | } |
| 289 | } |
| 290 | } |
| 291 | |
| 292 | fn detect_filenamerust-analyzer cargo async_zip 0.0.18 base/read/detect_filename().(basic: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>, basic_is_utf8: bool, extra_fields: &[ExtraFieldrust-analyzer cargo async_zip 0.0.18 spec/header/ExtraField#]) -> ZipStringrust-analyzer cargo async_zip 0.0.18 string/ZipString# { |
| 293 | if basic_is_utf8 { |
| 294 | ZipStringrust-analyzer cargo async_zip 0.0.18 string/ZipString#::newrust-analyzer cargo async_zip 0.0.18 string/impl#[ZipString]new().(basic, StringEncodingrust-analyzer cargo async_zip 0.0.18 string/StringEncoding#::Utf8rust-analyzer cargo async_zip 0.0.18 string/StringEncoding#Utf8#) |
| 295 | } else { |
| 296 | let unicode_extra = extra_fields.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().find_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]find_map().(|field| match field { |
| 297 | ExtraFieldrust-analyzer cargo async_zip 0.0.18 spec/header/ExtraField#::InfoZipUnicodePathrust-analyzer cargo async_zip 0.0.18 spec/header/ExtraField#InfoZipUnicodePath#(InfoZipUnicodePathExtraFieldrust-analyzer cargo async_zip 0.0.18 spec/header/InfoZipUnicodePathExtraField#::V1rust-analyzer cargo async_zip 0.0.18 spec/header/InfoZipUnicodePathExtraField#V1# { crc32rust-analyzer cargo async_zip 0.0.18 spec/header/InfoZipUnicodePathExtraField#V1#crc32., unicoderust-analyzer cargo async_zip 0.0.18 spec/header/InfoZipUnicodePathExtraField#V1#unicode. }) => { |
| 298 | if *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().crc32 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq().crc32fastrust-analyzer cargo crc32fast 1.4.2 crate/::hashrust-analyzer cargo crc32fast 1.4.2 hash().(&basic) { |
| 299 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/::Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::from_utf8rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]from_utf8().(unicode.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][Clone]clone().())) |
| 300 | } else { |
| 301 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 302 | } |
| 303 | } |
| 304 | _ => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 305 | }); |
| 306 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(s)) = unicode_extra { |
| 307 | ZipStringrust-analyzer cargo async_zip 0.0.18 string/ZipString#::new_with_alternativerust-analyzer cargo async_zip 0.0.18 string/impl#[ZipString]new_with_alternative().(s, basic) |
| 308 | } else { |
| 309 | // Do not treat as UTF-8 if UTF-8 flags are not set, |
| 310 | // some string in MBCS may be valid UTF-8 in form, but they are not in truth. |
| 311 | if basic.is_asciirust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/ascii/impl#[`[u8]`]is_ascii().() { |
| 312 | // SAFETY: |
| 313 | // a valid ASCII string is always a valid UTF-8 string |
| 314 | unsafe { stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/::Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::from_utf8_uncheckedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]from_utf8_unchecked().(basic).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().() } |
| 315 | } else { |
| 316 | ZipStringrust-analyzer cargo async_zip 0.0.18 string/ZipString#::newrust-analyzer cargo async_zip 0.0.18 string/impl#[ZipString]new().(basic, StringEncodingrust-analyzer cargo async_zip 0.0.18 string/StringEncoding#::Rawrust-analyzer cargo async_zip 0.0.18 string/StringEncoding#Raw#) |
| 317 | } |
| 318 | } |
| 319 | } |
| 320 | } |