seven-zip 1.4.2 → 1.7.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +49 -0
- data/.github/workflows/release.yml +21 -0
- data/README.md +13 -2
- data/Rakefile +2 -0
- data/ext/p7zip/C/7zBuf.h +4 -8
- data/ext/p7zip/C/7zBuf2.c +9 -3
- data/ext/p7zip/C/7zCrc.c +84 -32
- data/ext/p7zip/C/7zCrc.h +2 -2
- data/ext/p7zip/C/7zCrcOpt.c +89 -8
- data/ext/p7zip/C/7zStream.c +4 -2
- data/ext/p7zip/C/{Types.h → 7zTypes.h} +8 -6
- data/ext/p7zip/C/7zVersion.h +21 -6
- data/ext/p7zip/C/Aes.c +28 -15
- data/ext/p7zip/C/Aes.h +2 -2
- data/ext/p7zip/C/Alloc.c +60 -12
- data/ext/p7zip/C/Alloc.h +6 -7
- data/ext/p7zip/C/Bcj2.c +256 -0
- data/ext/p7zip/C/Bcj2.h +146 -0
- data/ext/p7zip/C/Bcj2Enc.c +312 -0
- data/ext/p7zip/C/Blake2.h +48 -0
- data/ext/p7zip/C/Blake2s.c +244 -0
- data/ext/p7zip/C/Bra.c +2 -0
- data/ext/p7zip/C/Bra.h +4 -8
- data/ext/p7zip/C/Bra86.c +48 -51
- data/ext/p7zip/C/BraIA64.c +3 -1
- data/ext/p7zip/C/BwtSort.c +3 -4
- data/ext/p7zip/C/BwtSort.h +4 -8
- data/ext/p7zip/C/Compiler.h +32 -0
- data/ext/p7zip/C/CpuArch.c +50 -7
- data/ext/p7zip/C/CpuArch.h +112 -41
- data/ext/p7zip/C/Delta.c +2 -0
- data/ext/p7zip/C/Delta.h +4 -8
- data/ext/p7zip/C/HuffEnc.c +8 -6
- data/ext/p7zip/C/HuffEnc.h +4 -8
- data/ext/p7zip/C/LzFind.c +391 -108
- data/ext/p7zip/C/LzFind.h +20 -18
- data/ext/p7zip/C/LzFindMt.c +100 -90
- data/ext/p7zip/C/LzFindMt.h +4 -8
- data/ext/p7zip/C/LzHash.h +23 -20
- data/ext/p7zip/C/Lzma2Dec.c +48 -26
- data/ext/p7zip/C/Lzma2Dec.h +4 -8
- data/ext/p7zip/C/Lzma2Enc.c +58 -15
- data/ext/p7zip/C/Lzma2Enc.h +3 -7
- data/ext/p7zip/C/{LzmaUtil/Lzma86Enc.h → Lzma86.h} +47 -14
- data/ext/p7zip/C/{LzmaUtil/Lzma86Dec.c → Lzma86Dec.c} +6 -13
- data/ext/p7zip/C/{LzmaUtil/Lzma86Enc.c → Lzma86Enc.c} +8 -15
- data/ext/p7zip/C/LzmaDec.c +180 -79
- data/ext/p7zip/C/LzmaDec.h +4 -8
- data/ext/p7zip/C/LzmaEnc.c +230 -147
- data/ext/p7zip/C/LzmaEnc.h +6 -8
- data/ext/p7zip/C/MtCoder.c +3 -3
- data/ext/p7zip/C/Ppmd.h +5 -5
- data/ext/p7zip/C/Ppmd7.c +9 -7
- data/ext/p7zip/C/Ppmd7.h +3 -3
- data/ext/p7zip/C/Ppmd7Dec.c +2 -0
- data/ext/p7zip/C/Ppmd7Enc.c +4 -2
- data/ext/p7zip/C/Ppmd8.c +34 -31
- data/ext/p7zip/C/Ppmd8.h +5 -1
- data/ext/p7zip/C/Ppmd8Dec.c +2 -0
- data/ext/p7zip/C/Ppmd8Enc.c +2 -0
- data/ext/p7zip/C/Precomp.h +10 -0
- data/ext/p7zip/C/RotateDefs.h +11 -1
- data/ext/p7zip/C/Sha1.c +340 -0
- data/ext/p7zip/C/Sha1.h +38 -0
- data/ext/p7zip/C/Sha256.c +107 -63
- data/ext/p7zip/C/Sha256.h +2 -2
- data/ext/p7zip/C/Sort.c +59 -11
- data/ext/p7zip/C/Sort.h +8 -10
- data/ext/p7zip/C/Threads.h +1 -1
- data/ext/p7zip/C/Xz.c +7 -5
- data/ext/p7zip/C/Xz.h +40 -17
- data/ext/p7zip/C/XzCrc64.c +69 -16
- data/ext/p7zip/C/XzCrc64.h +2 -2
- data/ext/p7zip/C/XzCrc64Opt.c +69 -0
- data/ext/p7zip/C/XzDec.c +93 -55
- data/ext/p7zip/C/XzEnc.c +206 -165
- data/ext/p7zip/C/XzEnc.h +23 -9
- data/ext/p7zip/C/XzIn.c +50 -43
- data/ext/p7zip/CPP/7zip/Archive/7z/7zCompressionMode.h +37 -13
- data/ext/p7zip/CPP/7zip/Archive/7z/7zDecode.cpp +392 -181
- data/ext/p7zip/CPP/7zip/Archive/7z/7zDecode.h +29 -29
- data/ext/p7zip/CPP/7zip/Archive/7z/7zEncode.cpp +424 -212
- data/ext/p7zip/CPP/7zip/Archive/7z/7zEncode.h +53 -16
- data/ext/p7zip/CPP/7zip/Archive/7z/7zExtract.cpp +312 -174
- data/ext/p7zip/CPP/7zip/Archive/7z/7zFolderInStream.cpp +74 -61
- data/ext/p7zip/CPP/7zip/Archive/7z/7zFolderInStream.h +22 -19
- data/ext/p7zip/CPP/7zip/Archive/7z/7zHandler.cpp +505 -232
- data/ext/p7zip/CPP/7zip/Archive/7z/7zHandler.h +70 -16
- data/ext/p7zip/CPP/7zip/Archive/7z/7zHandlerOut.cpp +602 -172
- data/ext/p7zip/CPP/7zip/Archive/7z/7zHeader.cpp +5 -0
- data/ext/p7zip/CPP/7zip/Archive/7z/7zHeader.h +54 -3
- data/ext/p7zip/CPP/7zip/Archive/7z/7zIn.cpp +981 -616
- data/ext/p7zip/CPP/7zip/Archive/7z/7zIn.h +275 -89
- data/ext/p7zip/CPP/7zip/Archive/7z/7zItem.h +77 -162
- data/ext/p7zip/CPP/7zip/Archive/7z/7zOut.cpp +288 -238
- data/ext/p7zip/CPP/7zip/Archive/7z/7zOut.h +189 -20
- data/ext/p7zip/CPP/7zip/Archive/7z/7zProperties.cpp +59 -49
- data/ext/p7zip/CPP/7zip/Archive/7z/7zRegister.cpp +12 -9
- data/ext/p7zip/CPP/7zip/Archive/7z/7zSpecStream.cpp +4 -6
- data/ext/p7zip/CPP/7zip/Archive/7z/7zSpecStream.h +5 -5
- data/ext/p7zip/CPP/7zip/Archive/7z/7zUpdate.cpp +1743 -447
- data/ext/p7zip/CPP/7zip/Archive/7z/7zUpdate.h +61 -10
- data/ext/p7zip/CPP/7zip/Archive/ApmHandler.cpp +84 -120
- data/ext/p7zip/CPP/7zip/Archive/ArHandler.cpp +854 -0
- data/ext/p7zip/CPP/7zip/Archive/ArchiveExports.cpp +48 -32
- data/ext/p7zip/CPP/7zip/Archive/ArjHandler.cpp +519 -340
- data/ext/p7zip/CPP/7zip/Archive/Bz2Handler.cpp +223 -203
- data/ext/p7zip/CPP/7zip/Archive/Cab/CabBlockInStream.cpp +50 -139
- data/ext/p7zip/CPP/7zip/Archive/Cab/CabBlockInStream.h +17 -18
- data/ext/p7zip/CPP/7zip/Archive/Cab/CabHandler.cpp +566 -234
- data/ext/p7zip/CPP/7zip/Archive/Cab/CabHandler.h +10 -1
- data/ext/p7zip/CPP/7zip/Archive/Cab/CabHeader.cpp +2 -2
- data/ext/p7zip/CPP/7zip/Archive/Cab/CabHeader.h +12 -15
- data/ext/p7zip/CPP/7zip/Archive/Cab/CabIn.cpp +341 -122
- data/ext/p7zip/CPP/7zip/Archive/Cab/CabIn.h +81 -66
- data/ext/p7zip/CPP/7zip/Archive/Cab/CabItem.h +17 -14
- data/ext/p7zip/CPP/7zip/Archive/Cab/CabRegister.cpp +10 -4
- data/ext/p7zip/CPP/7zip/Archive/Chm/ChmHandler.cpp +190 -83
- data/ext/p7zip/CPP/7zip/Archive/Chm/ChmHandler.h +7 -1
- data/ext/p7zip/CPP/7zip/Archive/Chm/ChmIn.cpp +292 -174
- data/ext/p7zip/CPP/7zip/Archive/Chm/ChmIn.h +73 -47
- data/ext/p7zip/CPP/7zip/Archive/ComHandler.cpp +886 -0
- data/ext/p7zip/CPP/7zip/Archive/Common/CoderMixer2.cpp +994 -71
- data/ext/p7zip/CPP/7zip/Archive/Common/CoderMixer2.h +364 -101
- data/ext/p7zip/CPP/7zip/Archive/Common/DummyOutStream.cpp +7 -12
- data/ext/p7zip/CPP/7zip/Archive/Common/DummyOutStream.h +4 -3
- data/ext/p7zip/CPP/7zip/Archive/Common/FindSignature.cpp +6 -6
- data/ext/p7zip/CPP/7zip/Archive/Common/FindSignature.h +2 -2
- data/ext/p7zip/CPP/7zip/Archive/Common/HandlerOut.cpp +77 -543
- data/ext/p7zip/CPP/7zip/Archive/Common/HandlerOut.h +31 -51
- data/ext/p7zip/CPP/7zip/Archive/Common/InStreamWithCRC.cpp +18 -14
- data/ext/p7zip/CPP/7zip/Archive/Common/ItemNameUtils.cpp +34 -7
- data/ext/p7zip/CPP/7zip/Archive/Common/ItemNameUtils.h +5 -2
- data/ext/p7zip/CPP/7zip/Archive/Common/MultiStream.cpp +25 -24
- data/ext/p7zip/CPP/7zip/Archive/Common/MultiStream.h +8 -3
- data/ext/p7zip/CPP/7zip/Archive/Common/OutStreamWithCRC.h +1 -0
- data/ext/p7zip/CPP/7zip/Archive/Common/OutStreamWithSha1.cpp +2 -2
- data/ext/p7zip/CPP/7zip/Archive/Common/OutStreamWithSha1.h +5 -5
- data/ext/p7zip/CPP/7zip/Archive/Common/ParseProperties.cpp +0 -174
- data/ext/p7zip/CPP/7zip/Archive/Common/ParseProperties.h +2 -14
- data/ext/p7zip/CPP/7zip/Archive/CpioHandler.cpp +506 -335
- data/ext/p7zip/CPP/7zip/Archive/CramfsHandler.cpp +227 -84
- data/ext/p7zip/CPP/7zip/Archive/DeflateProps.cpp +0 -115
- data/ext/p7zip/CPP/7zip/Archive/DeflateProps.h +0 -29
- data/ext/p7zip/CPP/7zip/Archive/DllExports2.cpp +63 -17
- data/ext/p7zip/CPP/7zip/Archive/DmgHandler.cpp +1007 -339
- data/ext/p7zip/CPP/7zip/Archive/ElfHandler.cpp +618 -177
- data/ext/p7zip/CPP/7zip/Archive/ExtHandler.cpp +2867 -0
- data/ext/p7zip/CPP/7zip/Archive/FatHandler.cpp +136 -76
- data/ext/p7zip/CPP/7zip/Archive/FlvHandler.cpp +132 -150
- data/ext/p7zip/CPP/7zip/Archive/GptHandler.cpp +405 -0
- data/ext/p7zip/CPP/7zip/Archive/GzHandler.cpp +560 -214
- data/ext/p7zip/CPP/7zip/Archive/HandlerCont.cpp +288 -0
- data/ext/p7zip/CPP/7zip/Archive/HandlerCont.h +116 -0
- data/ext/p7zip/CPP/7zip/Archive/HfsHandler.cpp +1880 -0
- data/ext/p7zip/CPP/7zip/Archive/IArchive.h +415 -51
- data/ext/p7zip/CPP/7zip/Archive/IhexHandler.cpp +497 -0
- data/ext/p7zip/CPP/7zip/Archive/Iso/IsoHandler.cpp +158 -71
- data/ext/p7zip/CPP/7zip/Archive/Iso/IsoHandler.h +2 -1
- data/ext/p7zip/CPP/7zip/Archive/Iso/IsoHeader.cpp +0 -9
- data/ext/p7zip/CPP/7zip/Archive/Iso/IsoHeader.h +8 -5
- data/ext/p7zip/CPP/7zip/Archive/Iso/IsoIn.cpp +311 -91
- data/ext/p7zip/CPP/7zip/Archive/Iso/IsoIn.h +101 -83
- data/ext/p7zip/CPP/7zip/Archive/Iso/IsoItem.h +48 -39
- data/ext/p7zip/CPP/7zip/Archive/Iso/IsoRegister.cpp +12 -4
- data/ext/p7zip/CPP/7zip/Archive/LzhHandler.cpp +127 -114
- data/ext/p7zip/CPP/7zip/Archive/LzmaHandler.cpp +264 -121
- data/ext/p7zip/CPP/7zip/Archive/MachoHandler.cpp +402 -242
- data/ext/p7zip/CPP/7zip/Archive/MbrHandler.cpp +56 -114
- data/ext/p7zip/CPP/7zip/Archive/MslzHandler.cpp +230 -90
- data/ext/p7zip/CPP/7zip/Archive/MubHandler.cpp +129 -153
- data/ext/p7zip/CPP/7zip/Archive/Nsis/NsisDecode.cpp +179 -58
- data/ext/p7zip/CPP/7zip/Archive/Nsis/NsisDecode.h +36 -7
- data/ext/p7zip/CPP/7zip/Archive/Nsis/NsisHandler.cpp +407 -237
- data/ext/p7zip/CPP/7zip/Archive/Nsis/NsisHandler.h +9 -16
- data/ext/p7zip/CPP/7zip/Archive/Nsis/NsisIn.cpp +5535 -1098
- data/ext/p7zip/CPP/7zip/Archive/Nsis/NsisIn.h +345 -81
- data/ext/p7zip/CPP/7zip/Archive/Nsis/NsisRegister.cpp +11 -4
- data/ext/p7zip/CPP/7zip/Archive/NtfsHandler.cpp +1424 -434
- data/ext/p7zip/CPP/7zip/Archive/PeHandler.cpp +1831 -521
- data/ext/p7zip/CPP/7zip/Archive/PpmdHandler.cpp +50 -35
- data/ext/p7zip/CPP/7zip/Archive/QcowHandler.cpp +615 -0
- data/ext/p7zip/CPP/7zip/Archive/Rar/Rar5Handler.cpp +2746 -0
- data/ext/p7zip/CPP/7zip/Archive/Rar/Rar5Handler.h +411 -0
- data/ext/p7zip/CPP/7zip/Archive/Rar/RarHandler.cpp +1241 -355
- data/ext/p7zip/CPP/7zip/Archive/Rar/RarHandler.h +70 -20
- data/ext/p7zip/CPP/7zip/Archive/Rar/RarHeader.h +38 -34
- data/ext/p7zip/CPP/7zip/Archive/Rar/RarItem.h +34 -16
- data/ext/p7zip/CPP/7zip/Archive/Rar/RarVol.h +129 -0
- data/ext/p7zip/CPP/7zip/Archive/RpmHandler.cpp +641 -194
- data/ext/p7zip/CPP/7zip/Archive/SplitHandler.cpp +174 -181
- data/ext/p7zip/CPP/7zip/Archive/SquashfsHandler.cpp +237 -174
- data/ext/p7zip/CPP/7zip/Archive/SwfHandler.cpp +471 -192
- data/ext/p7zip/CPP/7zip/Archive/Tar/TarHandler.cpp +350 -59
- data/ext/p7zip/CPP/7zip/Archive/Tar/TarHandler.h +24 -7
- data/ext/p7zip/CPP/7zip/Archive/Tar/TarHandlerOut.cpp +79 -27
- data/ext/p7zip/CPP/7zip/Archive/Tar/TarHeader.cpp +5 -7
- data/ext/p7zip/CPP/7zip/Archive/Tar/TarHeader.h +20 -44
- data/ext/p7zip/CPP/7zip/Archive/Tar/TarIn.cpp +279 -64
- data/ext/p7zip/CPP/7zip/Archive/Tar/TarIn.h +10 -1
- data/ext/p7zip/CPP/7zip/Archive/Tar/TarItem.h +34 -8
- data/ext/p7zip/CPP/7zip/Archive/Tar/TarOut.cpp +145 -87
- data/ext/p7zip/CPP/7zip/Archive/Tar/TarOut.h +13 -5
- data/ext/p7zip/CPP/7zip/Archive/Tar/TarRegister.cpp +14 -9
- data/ext/p7zip/CPP/7zip/Archive/Tar/TarUpdate.cpp +154 -27
- data/ext/p7zip/CPP/7zip/Archive/Tar/TarUpdate.h +10 -6
- data/ext/p7zip/CPP/7zip/Archive/Udf/UdfHandler.cpp +53 -128
- data/ext/p7zip/CPP/7zip/Archive/Udf/UdfHandler.h +6 -5
- data/ext/p7zip/CPP/7zip/Archive/Udf/UdfIn.cpp +384 -119
- data/ext/p7zip/CPP/7zip/Archive/Udf/UdfIn.h +40 -21
- data/ext/p7zip/CPP/7zip/Archive/UefiHandler.cpp +1618 -0
- data/ext/p7zip/CPP/7zip/Archive/VdiHandler.cpp +362 -0
- data/ext/p7zip/CPP/7zip/Archive/VhdHandler.cpp +438 -247
- data/ext/p7zip/CPP/7zip/Archive/VmdkHandler.cpp +1518 -0
- data/ext/p7zip/CPP/7zip/Archive/Wim/WimHandler.cpp +837 -249
- data/ext/p7zip/CPP/7zip/Archive/Wim/WimHandler.h +73 -47
- data/ext/p7zip/CPP/7zip/Archive/Wim/WimHandlerOut.cpp +1614 -351
- data/ext/p7zip/CPP/7zip/Archive/Wim/WimIn.cpp +1519 -513
- data/ext/p7zip/CPP/7zip/Archive/Wim/WimIn.h +498 -139
- data/ext/p7zip/CPP/7zip/Archive/Wim/WimRegister.cpp +13 -9
- data/ext/p7zip/CPP/7zip/Archive/XarHandler.cpp +272 -128
- data/ext/p7zip/CPP/7zip/Archive/XzHandler.cpp +502 -253
- data/ext/p7zip/CPP/7zip/Archive/XzHandler.h +65 -0
- data/ext/p7zip/CPP/7zip/Archive/ZHandler.cpp +114 -39
- data/ext/p7zip/CPP/7zip/Archive/Zip/ZipAddCommon.cpp +118 -134
- data/ext/p7zip/CPP/7zip/Archive/Zip/ZipAddCommon.h +6 -0
- data/ext/p7zip/CPP/7zip/Archive/Zip/ZipCompressionMode.h +40 -20
- data/ext/p7zip/CPP/7zip/Archive/Zip/ZipHandler.cpp +541 -274
- data/ext/p7zip/CPP/7zip/Archive/Zip/ZipHandler.h +13 -40
- data/ext/p7zip/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp +165 -254
- data/ext/p7zip/CPP/7zip/Archive/Zip/ZipHeader.h +70 -178
- data/ext/p7zip/CPP/7zip/Archive/Zip/ZipIn.cpp +1934 -550
- data/ext/p7zip/CPP/7zip/Archive/Zip/ZipIn.h +294 -63
- data/ext/p7zip/CPP/7zip/Archive/Zip/ZipItem.cpp +160 -86
- data/ext/p7zip/CPP/7zip/Archive/Zip/ZipItem.h +139 -110
- data/ext/p7zip/CPP/7zip/Archive/Zip/ZipOut.cpp +177 -154
- data/ext/p7zip/CPP/7zip/Archive/Zip/ZipOut.h +50 -18
- data/ext/p7zip/CPP/7zip/Archive/Zip/ZipRegister.cpp +18 -9
- data/ext/p7zip/CPP/7zip/Archive/Zip/ZipUpdate.cpp +367 -201
- data/ext/p7zip/CPP/7zip/Archive/Zip/ZipUpdate.h +11 -10
- data/ext/p7zip/CPP/7zip/Bundles/Format7zFree/makefile +2 -319
- data/ext/p7zip/CPP/7zip/Bundles/Format7zFree/makefile.depend +0 -4962
- data/ext/p7zip/CPP/7zip/Bundles/Format7zFree/makefile.list +1004 -259
- data/ext/p7zip/CPP/7zip/Common/CWrappers.cpp +26 -22
- data/ext/p7zip/CPP/7zip/Common/CWrappers.h +19 -14
- data/ext/p7zip/CPP/7zip/Common/CreateCoder.cpp +298 -130
- data/ext/p7zip/CPP/7zip/Common/CreateCoder.h +118 -34
- data/ext/p7zip/CPP/7zip/Common/FilePathAutoRename.cpp +24 -28
- data/ext/p7zip/CPP/7zip/Common/FilePathAutoRename.h +5 -5
- data/ext/p7zip/CPP/7zip/Common/FileStreams.cpp +268 -65
- data/ext/p7zip/CPP/7zip/Common/FileStreams.h +70 -33
- data/ext/p7zip/CPP/7zip/Common/FilterCoder.cpp +302 -131
- data/ext/p7zip/CPP/7zip/Common/FilterCoder.h +141 -43
- data/ext/p7zip/CPP/7zip/Common/InBuffer.cpp +87 -35
- data/ext/p7zip/CPP/7zip/Common/InBuffer.h +54 -45
- data/ext/p7zip/CPP/7zip/Common/InOutTempBuffer.cpp +22 -17
- data/ext/p7zip/CPP/7zip/Common/InOutTempBuffer.h +5 -5
- data/ext/p7zip/CPP/7zip/Common/LimitedStreams.cpp +256 -43
- data/ext/p7zip/CPP/7zip/Common/LimitedStreams.h +135 -8
- data/ext/p7zip/CPP/7zip/Common/MemBlocks.cpp +5 -5
- data/ext/p7zip/CPP/7zip/Common/MemBlocks.h +3 -3
- data/ext/p7zip/CPP/7zip/Common/MethodId.cpp +0 -24
- data/ext/p7zip/CPP/7zip/Common/MethodId.h +1 -1
- data/ext/p7zip/CPP/7zip/Common/MethodProps.cpp +430 -71
- data/ext/p7zip/CPP/7zip/Common/MethodProps.h +170 -17
- data/ext/p7zip/CPP/7zip/Common/OffsetStream.cpp +8 -4
- data/ext/p7zip/CPP/7zip/Common/OffsetStream.h +4 -3
- data/ext/p7zip/CPP/7zip/Common/OutBuffer.cpp +26 -31
- data/ext/p7zip/CPP/7zip/Common/OutBuffer.h +17 -18
- data/ext/p7zip/CPP/7zip/Common/OutMemStream.cpp +5 -5
- data/ext/p7zip/CPP/7zip/Common/OutMemStream.h +5 -4
- data/ext/p7zip/CPP/7zip/Common/ProgressUtils.cpp +22 -13
- data/ext/p7zip/CPP/7zip/Common/ProgressUtils.h +4 -3
- data/ext/p7zip/CPP/7zip/Common/PropId.cpp +108 -0
- data/ext/p7zip/CPP/7zip/Common/RegisterArc.h +63 -17
- data/ext/p7zip/CPP/7zip/Common/RegisterCodec.h +79 -6
- data/ext/p7zip/CPP/7zip/Common/StreamBinder.cpp +95 -90
- data/ext/p7zip/CPP/7zip/Common/StreamBinder.h +46 -23
- data/ext/p7zip/CPP/7zip/Common/StreamObjects.cpp +88 -24
- data/ext/p7zip/CPP/7zip/Common/StreamObjects.h +36 -14
- data/ext/p7zip/CPP/7zip/Common/StreamUtils.cpp +4 -4
- data/ext/p7zip/CPP/7zip/Common/StreamUtils.h +6 -6
- data/ext/p7zip/CPP/7zip/Common/UniqBlocks.cpp +57 -0
- data/ext/p7zip/CPP/7zip/Common/UniqBlocks.h +26 -0
- data/ext/p7zip/CPP/7zip/Common/VirtThread.cpp +8 -6
- data/ext/p7zip/CPP/7zip/Common/VirtThread.h +6 -5
- data/ext/p7zip/CPP/7zip/Compress/BZip2Const.h +13 -12
- data/ext/p7zip/CPP/7zip/Compress/BZip2Crc.h +1 -1
- data/ext/p7zip/CPP/7zip/Compress/BZip2Decoder.cpp +198 -147
- data/ext/p7zip/CPP/7zip/Compress/BZip2Decoder.h +60 -27
- data/ext/p7zip/CPP/7zip/Compress/BZip2Encoder.cpp +111 -116
- data/ext/p7zip/CPP/7zip/Compress/BZip2Encoder.h +53 -59
- data/ext/p7zip/CPP/7zip/Compress/BZip2Register.cpp +12 -7
- data/ext/p7zip/CPP/7zip/Compress/Bcj2Coder.cpp +554 -282
- data/ext/p7zip/CPP/7zip/Compress/Bcj2Coder.h +73 -71
- data/ext/p7zip/CPP/7zip/Compress/Bcj2Register.cpp +10 -5
- data/ext/p7zip/CPP/7zip/Compress/BcjCoder.cpp +13 -4
- data/ext/p7zip/CPP/7zip/Compress/BcjCoder.h +17 -5
- data/ext/p7zip/CPP/7zip/Compress/BcjRegister.cpp +7 -9
- data/ext/p7zip/CPP/7zip/Compress/BitlDecoder.cpp +2 -2
- data/ext/p7zip/CPP/7zip/Compress/BitlDecoder.h +58 -61
- data/ext/p7zip/CPP/7zip/Compress/BitlEncoder.h +24 -25
- data/ext/p7zip/CPP/7zip/Compress/BitmDecoder.h +46 -17
- data/ext/p7zip/CPP/7zip/Compress/BitmEncoder.h +18 -19
- data/ext/p7zip/CPP/7zip/Compress/BranchMisc.cpp +14 -28
- data/ext/p7zip/CPP/7zip/Compress/BranchMisc.h +27 -6
- data/ext/p7zip/CPP/7zip/Compress/BranchRegister.cpp +26 -15
- data/ext/p7zip/CPP/7zip/Compress/ByteSwap.cpp +45 -26
- data/ext/p7zip/CPP/7zip/Compress/CodecExports.cpp +254 -70
- data/ext/p7zip/CPP/7zip/Compress/CopyCoder.cpp +65 -17
- data/ext/p7zip/CPP/7zip/Compress/CopyCoder.h +15 -3
- data/ext/p7zip/CPP/7zip/Compress/CopyRegister.cpp +5 -4
- data/ext/p7zip/CPP/7zip/Compress/Deflate64Register.cpp +12 -6
- data/ext/p7zip/CPP/7zip/Compress/DeflateConst.h +43 -46
- data/ext/p7zip/CPP/7zip/Compress/DeflateDecoder.cpp +145 -81
- data/ext/p7zip/CPP/7zip/Compress/DeflateDecoder.h +31 -33
- data/ext/p7zip/CPP/7zip/Compress/DeflateEncoder.cpp +179 -162
- data/ext/p7zip/CPP/7zip/Compress/DeflateEncoder.h +35 -30
- data/ext/p7zip/CPP/7zip/Compress/DeflateRegister.cpp +11 -7
- data/ext/p7zip/CPP/7zip/Compress/DeltaFilter.cpp +55 -39
- data/ext/p7zip/CPP/7zip/Compress/{DllExports2.cpp → DllExports2Compress.cpp} +8 -8
- data/ext/p7zip/CPP/7zip/Compress/DllExportsCompress.cpp +48 -0
- data/ext/p7zip/CPP/7zip/Compress/HuffmanDecoder.h +220 -49
- data/ext/p7zip/CPP/7zip/Compress/ImplodeDecoder.cpp +14 -9
- data/ext/p7zip/CPP/7zip/Compress/ImplodeDecoder.h +2 -3
- data/ext/p7zip/CPP/7zip/Compress/ImplodeHuffmanDecoder.cpp +7 -7
- data/ext/p7zip/CPP/7zip/Compress/ImplodeHuffmanDecoder.h +1 -1
- data/ext/p7zip/CPP/7zip/Compress/LzOutWindow.cpp +1 -1
- data/ext/p7zip/CPP/7zip/Compress/LzOutWindow.h +21 -18
- data/ext/p7zip/CPP/7zip/Compress/LzhDecoder.cpp +171 -141
- data/ext/p7zip/CPP/7zip/Compress/LzhDecoder.h +32 -64
- data/ext/p7zip/CPP/7zip/Compress/Lzham/LICENSE +22 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/LzhamRegister.cpp +783 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/README.md +211 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/include/lzham.h +803 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/include/lzham_dynamic_lib.h +156 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/include/lzham_exports.inc +31 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/include/lzham_static_lib.h +59 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/include/zlib.h +2 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamcomp/CMakeLists.txt +69 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamcomp/lzham_comp.h +38 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamcomp/lzham_lzbase.cpp +244 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamcomp/lzham_lzbase.h +46 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamcomp/lzham_lzcomp.cpp +750 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamcomp/lzham_lzcomp_internal.cpp +2240 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamcomp/lzham_lzcomp_internal.h +503 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamcomp/lzham_lzcomp_state.cpp +1684 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamcomp/lzham_match_accel.cpp +947 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamcomp/lzham_match_accel.h +164 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamcomp/lzham_null_threading.h +98 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamcomp/lzham_pthreads_threading.cpp +214 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamcomp/lzham_pthreads_threading.h +535 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamcomp/lzham_threading.h +12 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamcomp/lzham_win32_threading.cpp +232 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamcomp/lzham_win32_threading.h +387 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamcomp/lzhamcomp.vcxproj +208 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/CMakeLists.txt +86 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_assert.cpp +80 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_assert.h +58 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_checksum.cpp +73 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_checksum.h +13 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_config.h +25 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_core.h +303 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_decomp.h +37 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_helpers.h +54 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_huffman_codes.cpp +286 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_huffman_codes.h +32 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_lzdecomp.cpp +1586 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_lzdecompbase.cpp +131 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_lzdecompbase.h +89 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_math.h +142 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_mem.cpp +463 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_mem.h +115 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_platform.cpp +159 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_platform.h +284 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_prefix_coding.cpp +431 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_prefix_coding.h +157 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_symbol_codec.cpp +1527 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_symbol_codec.h +494 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_timer.cpp +147 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_timer.h +99 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_traits.h +141 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_types.h +72 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_utils.h +58 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_vector.cpp +83 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_vector.h +628 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzhamdecomp.vcxproj +224 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamlib/lzham_lib.cpp +179 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamlib/lzhamlib.vcxproj +187 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/makefile +10 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/makefile.depend +0 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzham/makefile.list +129 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzma2Decoder.cpp +123 -46
- data/ext/p7zip/CPP/7zip/Compress/Lzma2Decoder.h +29 -14
- data/ext/p7zip/CPP/7zip/Compress/Lzma2Encoder.cpp +14 -9
- data/ext/p7zip/CPP/7zip/Compress/Lzma2Encoder.h +1 -1
- data/ext/p7zip/CPP/7zip/Compress/Lzma2Register.cpp +9 -7
- data/ext/p7zip/CPP/7zip/Compress/LzmaDecoder.cpp +24 -8
- data/ext/p7zip/CPP/7zip/Compress/LzmaDecoder.h +8 -1
- data/ext/p7zip/CPP/7zip/Compress/LzmaEncoder.cpp +30 -27
- data/ext/p7zip/CPP/7zip/Compress/LzmaEncoder.h +3 -1
- data/ext/p7zip/CPP/7zip/Compress/LzmaRegister.cpp +9 -7
- data/ext/p7zip/CPP/7zip/Compress/LzmsDecoder.cpp +576 -0
- data/ext/p7zip/CPP/7zip/Compress/LzmsDecoder.h +271 -0
- data/ext/p7zip/CPP/7zip/Compress/Lzx.h +32 -36
- data/ext/p7zip/CPP/7zip/Compress/LzxDecoder.cpp +380 -238
- data/ext/p7zip/CPP/7zip/Compress/LzxDecoder.h +170 -83
- data/ext/p7zip/CPP/7zip/Compress/Mtf8.h +7 -9
- data/ext/p7zip/CPP/7zip/Compress/PpmdDecoder.cpp +1 -5
- data/ext/p7zip/CPP/7zip/Compress/PpmdEncoder.cpp +51 -18
- data/ext/p7zip/CPP/7zip/Compress/PpmdEncoder.h +18 -8
- data/ext/p7zip/CPP/7zip/Compress/PpmdRegister.cpp +9 -8
- data/ext/p7zip/CPP/7zip/Compress/PpmdZip.cpp +61 -25
- data/ext/p7zip/CPP/7zip/Compress/PpmdZip.h +21 -6
- data/ext/p7zip/CPP/7zip/Compress/QuantumDecoder.cpp +122 -102
- data/ext/p7zip/CPP/7zip/Compress/QuantumDecoder.h +68 -157
- data/ext/p7zip/CPP/7zip/Compress/Rar/makefile +33 -18
- data/ext/p7zip/CPP/7zip/Compress/Rar/makefile.depend +0 -158
- data/ext/p7zip/CPP/7zip/Compress/Rar/makefile.list +105 -56
- data/ext/p7zip/CPP/7zip/Compress/Rar1Decoder.cpp +34 -21
- data/ext/p7zip/CPP/7zip/Compress/Rar1Decoder.h +2 -0
- data/ext/p7zip/CPP/7zip/Compress/Rar2Decoder.cpp +77 -67
- data/ext/p7zip/CPP/7zip/Compress/Rar2Decoder.h +12 -10
- data/ext/p7zip/CPP/7zip/Compress/Rar3Decoder.cpp +139 -118
- data/ext/p7zip/CPP/7zip/Compress/Rar3Decoder.h +48 -33
- data/ext/p7zip/CPP/7zip/Compress/Rar3Vm.cpp +148 -113
- data/ext/p7zip/CPP/7zip/Compress/Rar3Vm.h +35 -19
- data/ext/p7zip/CPP/7zip/Compress/Rar5Decoder.cpp +961 -0
- data/ext/p7zip/CPP/7zip/Compress/Rar5Decoder.h +335 -0
- data/ext/p7zip/CPP/7zip/Compress/RarCodecsRegister.cpp +13 -6
- data/ext/p7zip/CPP/7zip/Compress/ShrinkDecoder.cpp +91 -71
- data/ext/p7zip/CPP/7zip/Compress/ShrinkDecoder.h +2 -4
- data/ext/p7zip/CPP/7zip/Compress/XpressDecoder.cpp +129 -0
- data/ext/p7zip/CPP/7zip/Compress/XpressDecoder.h +13 -0
- data/ext/p7zip/CPP/7zip/Compress/ZDecoder.cpp +98 -20
- data/ext/p7zip/CPP/7zip/Compress/ZDecoder.h +19 -7
- data/ext/p7zip/CPP/7zip/Compress/ZlibDecoder.cpp +14 -11
- data/ext/p7zip/CPP/7zip/Compress/ZlibDecoder.h +32 -1
- data/ext/p7zip/CPP/7zip/Crypto/7zAes.cpp +137 -101
- data/ext/p7zip/CPP/7zip/Crypto/7zAes.h +31 -30
- data/ext/p7zip/CPP/7zip/Crypto/7zAesRegister.cpp +8 -9
- data/ext/p7zip/CPP/7zip/Crypto/HmacSha1.cpp +39 -28
- data/ext/p7zip/CPP/7zip/Crypto/HmacSha1.h +3 -3
- data/ext/p7zip/CPP/7zip/Crypto/HmacSha256.cpp +62 -0
- data/ext/p7zip/CPP/7zip/Crypto/HmacSha256.h +27 -0
- data/ext/p7zip/CPP/7zip/Crypto/MyAes.cpp +73 -7
- data/ext/p7zip/CPP/7zip/Crypto/MyAes.h +25 -8
- data/ext/p7zip/CPP/7zip/Crypto/MyAesReg.cpp +16 -0
- data/ext/p7zip/CPP/7zip/Crypto/Pbkdf2HmacSha1.cpp +29 -15
- data/ext/p7zip/CPP/7zip/Crypto/Pbkdf2HmacSha1.h +2 -1
- data/ext/p7zip/CPP/7zip/Crypto/RandGen.cpp +49 -34
- data/ext/p7zip/CPP/7zip/Crypto/RandGen.h +2 -2
- data/ext/p7zip/CPP/7zip/Crypto/Rar20Crypto.cpp +36 -39
- data/ext/p7zip/CPP/7zip/Crypto/Rar20Crypto.h +15 -17
- data/ext/p7zip/CPP/7zip/Crypto/Rar5Aes.cpp +257 -0
- data/ext/p7zip/CPP/7zip/Crypto/Rar5Aes.h +84 -0
- data/ext/p7zip/CPP/7zip/Crypto/RarAes.cpp +70 -71
- data/ext/p7zip/CPP/7zip/Crypto/RarAes.h +24 -19
- data/ext/p7zip/CPP/7zip/Crypto/Sha1Cls.h +51 -0
- data/ext/p7zip/CPP/7zip/Crypto/WzAes.cpp +68 -54
- data/ext/p7zip/CPP/7zip/Crypto/WzAes.h +37 -27
- data/ext/p7zip/CPP/7zip/Crypto/ZipCrypto.cpp +60 -34
- data/ext/p7zip/CPP/7zip/Crypto/ZipCrypto.h +28 -11
- data/ext/p7zip/CPP/7zip/Crypto/ZipStrong.cpp +90 -28
- data/ext/p7zip/CPP/7zip/Crypto/ZipStrong.h +13 -2
- data/ext/p7zip/CPP/7zip/Guid.txt +57 -11
- data/ext/p7zip/CPP/7zip/ICoder.h +202 -17
- data/ext/p7zip/CPP/7zip/IDecl.h +16 -3
- data/ext/p7zip/CPP/7zip/IPassword.h +1 -2
- data/ext/p7zip/CPP/7zip/IProgress.h +2 -16
- data/ext/p7zip/CPP/7zip/IStream.h +82 -13
- data/ext/p7zip/CPP/7zip/MyVersion.h +2 -11
- data/ext/p7zip/CPP/7zip/PropID.h +60 -9
- data/ext/p7zip/CPP/Common/C_FileIO.cpp +5 -1
- data/ext/p7zip/CPP/Common/C_FileIO.h +7 -1
- data/ext/p7zip/CPP/Common/CommandLineParser.cpp +122 -148
- data/ext/p7zip/CPP/Common/CommandLineParser.h +20 -29
- data/ext/p7zip/CPP/Common/Common.h +13 -0
- data/ext/p7zip/CPP/Common/CrcReg.cpp +98 -0
- data/ext/p7zip/CPP/Common/Defs.h +5 -10
- data/ext/p7zip/CPP/Common/DynLimBuf.cpp +93 -0
- data/ext/p7zip/CPP/Common/DynLimBuf.h +40 -0
- data/ext/p7zip/CPP/Common/DynamicBuffer.h +45 -31
- data/ext/p7zip/CPP/Common/IntToString.cpp +109 -40
- data/ext/p7zip/CPP/Common/IntToString.h +14 -9
- data/ext/p7zip/CPP/Common/Lang.cpp +120 -87
- data/ext/p7zip/CPP/Common/Lang.h +10 -15
- data/ext/p7zip/CPP/Common/ListFileUtils.cpp +82 -40
- data/ext/p7zip/CPP/Common/ListFileUtils.h +7 -4
- data/ext/p7zip/CPP/Common/MyBuffer.h +244 -0
- data/ext/p7zip/CPP/Common/MyCom.h +65 -28
- data/ext/p7zip/CPP/Common/MyGuidDef.h +1 -1
- data/ext/p7zip/CPP/Common/MyInitGuid.h +23 -0
- data/ext/p7zip/CPP/Common/MyLinux.h +42 -0
- data/ext/p7zip/CPP/Common/MyMap.cpp +8 -8
- data/ext/p7zip/CPP/Common/MyMap.h +2 -2
- data/ext/p7zip/CPP/Common/MyString.cpp +1643 -117
- data/ext/p7zip/CPP/Common/MyString.h +677 -486
- data/ext/p7zip/CPP/Common/MyTypes.h +38 -0
- data/ext/p7zip/CPP/Common/MyUnknown.h +4 -0
- data/ext/p7zip/CPP/Common/MyVector.cpp +0 -84
- data/ext/p7zip/CPP/Common/MyVector.h +472 -112
- data/ext/p7zip/CPP/Common/MyWindows.cpp +18 -1
- data/ext/p7zip/CPP/Common/MyWindows.h +8 -0
- data/ext/p7zip/CPP/Common/MyXml.cpp +169 -118
- data/ext/p7zip/CPP/Common/MyXml.h +14 -11
- data/ext/p7zip/CPP/Common/NewHandler.cpp +39 -0
- data/ext/p7zip/CPP/Common/NewHandler.h +55 -2
- data/ext/p7zip/CPP/Common/Random.h +14 -0
- data/ext/p7zip/CPP/Common/Sha1Reg.cpp +40 -0
- data/ext/p7zip/CPP/Common/Sha256Reg.cpp +40 -0
- data/ext/p7zip/CPP/Common/StdInStream.cpp +46 -27
- data/ext/p7zip/CPP/Common/StdInStream.h +11 -10
- data/ext/p7zip/CPP/Common/StdOutStream.cpp +48 -35
- data/ext/p7zip/CPP/Common/StdOutStream.h +44 -17
- data/ext/p7zip/CPP/Common/StringConvert.cpp +56 -17
- data/ext/p7zip/CPP/Common/StringConvert.h +7 -3
- data/ext/p7zip/CPP/Common/StringToInt.cpp +102 -48
- data/ext/p7zip/CPP/Common/StringToInt.h +13 -10
- data/ext/p7zip/CPP/Common/TextConfig.cpp +33 -47
- data/ext/p7zip/CPP/Common/TextConfig.h +3 -6
- data/ext/p7zip/CPP/Common/UTFConvert.cpp +218 -75
- data/ext/p7zip/CPP/Common/UTFConvert.h +4 -3
- data/ext/p7zip/CPP/Common/Wildcard.cpp +345 -125
- data/ext/p7zip/CPP/Common/Wildcard.h +82 -13
- data/ext/p7zip/CPP/Common/XzCrc64Reg.cpp +42 -0
- data/ext/p7zip/CPP/Windows/FileDir.cpp +427 -475
- data/ext/p7zip/CPP/Windows/FileDir.h +94 -72
- data/ext/p7zip/CPP/Windows/FileFind.cpp +235 -244
- data/ext/p7zip/CPP/Windows/FileFind.h +63 -59
- data/ext/p7zip/CPP/Windows/FileIO.cpp +29 -46
- data/ext/p7zip/CPP/Windows/FileIO.h +40 -42
- data/ext/p7zip/CPP/Windows/FileName.cpp +696 -17
- data/ext/p7zip/CPP/Windows/FileName.h +11 -3
- data/ext/p7zip/CPP/Windows/NtCheck.h +2 -0
- data/ext/p7zip/CPP/Windows/PropVariant.cpp +134 -30
- data/ext/p7zip/CPP/Windows/PropVariant.h +80 -24
- data/ext/p7zip/CPP/Windows/PropVariantUtils.cpp +89 -18
- data/ext/p7zip/CPP/Windows/PropVariantUtils.h +12 -7
- data/ext/p7zip/CPP/Windows/System.cpp +20 -15
- data/ext/p7zip/CPP/Windows/System.h +3 -2
- data/ext/p7zip/CPP/Windows/TimeUtils.cpp +203 -0
- data/ext/p7zip/CPP/Windows/TimeUtils.h +24 -0
- data/ext/p7zip/CPP/include_windows/basetyps.h +4 -4
- data/ext/p7zip/CPP/include_windows/windows.h +17 -11
- data/ext/p7zip/CPP/myWindows/StdAfx.h +97 -5
- data/ext/p7zip/CPP/myWindows/config.h +20 -5
- data/ext/p7zip/CPP/myWindows/myPrivate.h +8 -0
- data/ext/p7zip/CPP/myWindows/wine_date_and_time.cpp +34 -0
- data/ext/p7zip/ChangeLog +283 -35
- data/ext/p7zip/{DOCS → DOC}/7zC.txt +6 -13
- data/ext/p7zip/{DOCS → DOC}/License.txt +3 -2
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/commands/add.htm +93 -87
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/commands/bench.htm +88 -79
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/commands/delete.htm +62 -59
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/commands/extract.htm +96 -91
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/commands/extract_full.htm +73 -68
- data/ext/p7zip/DOC/MANUAL/cmdline/commands/hash.htm +65 -0
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/commands/index.htm +36 -33
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/commands/list.htm +78 -77
- data/ext/p7zip/DOC/MANUAL/cmdline/commands/rename.htm +51 -0
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/commands/style.css +232 -232
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/commands/test.htm +47 -46
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/commands/update.htm +71 -66
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/exit_codes.htm +27 -27
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/index.htm +29 -29
- data/ext/p7zip/{DOCS/MANUAL/switches → DOC/MANUAL/cmdline}/style.css +232 -232
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/ar_exclude.htm +56 -56
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/ar_include.htm +80 -83
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/ar_no.htm +52 -52
- data/ext/p7zip/DOC/MANUAL/cmdline/switches/bb.htm +61 -0
- data/ext/p7zip/DOC/MANUAL/cmdline/switches/bs.htm +67 -0
- data/ext/p7zip/DOC/MANUAL/cmdline/switches/charset.htm +61 -0
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/exclude.htm +71 -60
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/include.htm +89 -87
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/index.htm +95 -64
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/large_pages.htm +59 -50
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/list_tech.htm +36 -36
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/method.htm +738 -625
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/output_dir.htm +53 -53
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/overwrite.htm +56 -56
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/password.htm +55 -54
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/recurse.htm +85 -83
- data/ext/p7zip/DOC/MANUAL/cmdline/switches/sa.htm +58 -0
- data/ext/p7zip/DOC/MANUAL/cmdline/switches/scc.htm +42 -0
- data/ext/p7zip/DOC/MANUAL/cmdline/switches/scrc.htm +53 -0
- data/ext/p7zip/DOC/MANUAL/cmdline/switches/sdel.htm +39 -0
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/sfx.htm +153 -156
- data/ext/p7zip/DOC/MANUAL/cmdline/switches/shared.htm +40 -0
- data/ext/p7zip/DOC/MANUAL/cmdline/switches/sni.htm +56 -0
- data/ext/p7zip/DOC/MANUAL/cmdline/switches/sns.htm +77 -0
- data/ext/p7zip/DOC/MANUAL/cmdline/switches/spf.htm +80 -0
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/ssc.htm +50 -50
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/stdin.htm +56 -55
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/stdout.htm +54 -50
- data/ext/p7zip/DOC/MANUAL/cmdline/switches/stl.htm +39 -0
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/stop_switch.htm +31 -31
- data/ext/p7zip/DOC/MANUAL/cmdline/switches/stx.htm +50 -0
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline/switches}/style.css +232 -232
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/type.htm +121 -83
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/update.htm +177 -176
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/volume.htm +49 -49
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/working_dir.htm +56 -55
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/yes.htm +48 -48
- data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/syntax.htm +120 -120
- data/ext/p7zip/DOC/MANUAL/fm/about.htm +21 -0
- data/ext/p7zip/DOC/MANUAL/fm/benchmark.htm +56 -0
- data/ext/p7zip/DOC/MANUAL/fm/index.htm +54 -0
- data/ext/p7zip/DOC/MANUAL/fm/menu.htm +154 -0
- data/ext/p7zip/DOC/MANUAL/fm/options.htm +152 -0
- data/ext/p7zip/DOC/MANUAL/fm/plugins/7-zip/add.htm +311 -0
- data/ext/p7zip/DOC/MANUAL/fm/plugins/7-zip/extract.htm +78 -0
- data/ext/p7zip/DOC/MANUAL/fm/plugins/7-zip/index.htm +63 -0
- data/ext/p7zip/DOC/MANUAL/fm/plugins/7-zip/style.css +232 -0
- data/ext/p7zip/DOC/MANUAL/fm/plugins/index.htm +22 -0
- data/ext/p7zip/DOC/MANUAL/fm/plugins/style.css +232 -0
- data/ext/p7zip/DOC/MANUAL/fm/style.css +232 -0
- data/ext/p7zip/DOC/MANUAL/general/7z.htm +117 -0
- data/ext/p7zip/DOC/MANUAL/general/faq.htm +125 -0
- data/ext/p7zip/DOC/MANUAL/general/formats.htm +100 -0
- data/ext/p7zip/DOC/MANUAL/general/index.htm +27 -0
- data/ext/p7zip/DOC/MANUAL/general/license.htm +30 -0
- data/ext/p7zip/DOC/MANUAL/general/performance.htm +98 -0
- data/ext/p7zip/DOC/MANUAL/general/style.css +232 -0
- data/ext/p7zip/DOC/MANUAL/general/thanks.htm +43 -0
- data/ext/p7zip/DOC/MANUAL/start.htm +37 -0
- data/ext/p7zip/DOC/MANUAL/style.css +232 -0
- data/ext/p7zip/DOC/Methods.txt +158 -0
- data/ext/p7zip/{DOCS → DOC}/copying.txt +9 -11
- data/ext/p7zip/DOC/lzma.txt +328 -0
- data/ext/p7zip/{DOCS → DOC}/readme.txt +42 -65
- data/ext/p7zip/{DOCS/history.txt → DOC/src-history.txt} +88 -2
- data/ext/p7zip/README +117 -91
- data/ext/p7zip/TODO +0 -2
- data/ext/p7zip/install.sh +31 -29
- data/ext/p7zip/last_error +1 -0
- data/ext/p7zip/makefile +29 -125
- data/ext/p7zip/makefile.afl +23 -0
- data/ext/p7zip/makefile.aix_gcc +5 -4
- data/ext/p7zip/makefile.android_arm +49 -0
- data/ext/p7zip/makefile.beos +5 -4
- data/ext/p7zip/makefile.common +150 -0
- data/ext/p7zip/makefile.crc32 +3 -3
- data/ext/p7zip/makefile.cygwin +5 -4
- data/ext/p7zip/makefile.cygwin64 +21 -0
- data/ext/p7zip/makefile.cygwin64_asm +22 -0
- data/ext/p7zip/makefile.cygwin_asm +6 -4
- data/ext/p7zip/makefile.cygwin_clang +21 -0
- data/ext/p7zip/makefile.cygwin_clang_asm +23 -0
- data/ext/p7zip/{makefile.djgpp_old → makefile.djgpp} +5 -4
- data/ext/p7zip/makefile.djgpp_watt +7 -5
- data/ext/p7zip/makefile.freebsd5 +5 -4
- data/ext/p7zip/{makefile.freebsd6 → makefile.freebsd6+} +6 -5
- data/ext/p7zip/makefile.glb +27 -18
- data/ext/p7zip/makefile.gprof +3 -2
- data/ext/p7zip/makefile.haiku +19 -0
- data/ext/p7zip/makefile.hpux-acc +3 -2
- data/ext/p7zip/makefile.hpux-acc_64 +3 -2
- data/ext/p7zip/makefile.hpux-gcc +5 -4
- data/ext/p7zip/makefile.linux_amd64 +5 -4
- data/ext/p7zip/makefile.linux_amd64_asm +12 -5
- data/ext/p7zip/makefile.linux_amd64_asm_icc +5 -3
- data/ext/p7zip/makefile.linux_amd64_sanitizer +26 -0
- data/ext/p7zip/makefile.linux_any_cpu +5 -4
- data/ext/p7zip/makefile.linux_any_cpu_gcc_4.X +7 -4
- data/ext/p7zip/makefile.linux_clang_amd64_asm +25 -0
- data/ext/p7zip/makefile.linux_clang_amd64_asm_sanitize +27 -0
- data/ext/p7zip/makefile.linux_cross_aarch64 +25 -0
- data/ext/p7zip/makefile.linux_cross_arm +7 -4
- data/ext/p7zip/makefile.linux_cross_djgpp +27 -0
- data/ext/p7zip/makefile.linux_cross_m68k +26 -0
- data/ext/p7zip/makefile.linux_cross_mipsel +27 -0
- data/ext/p7zip/makefile.linux_cross_ppc +25 -0
- data/ext/p7zip/makefile.linux_cross_ppc64 +25 -0
- data/ext/p7zip/makefile.linux_cross_ppc64le +25 -0
- data/ext/p7zip/makefile.linux_cross_s390x +25 -0
- data/ext/p7zip/makefile.linux_cross_sparc64 +25 -0
- data/ext/p7zip/makefile.linux_gcc6_sanitize +23 -0
- data/ext/p7zip/makefile.linux_gcc_2.95_no_need_for_libstdc +6 -4
- data/ext/p7zip/makefile.linux_other +6 -5
- data/ext/p7zip/makefile.linux_s390x +5 -4
- data/ext/p7zip/{makefile.machine_base → makefile.linux_scan-build} +5 -4
- data/ext/p7zip/makefile.linux_valgrind +25 -0
- data/ext/p7zip/{makefile.linux_clang_amd64 → makefile.linux_x32} +6 -5
- data/ext/p7zip/makefile.linux_x86_asm_gcc_4.X +10 -5
- data/ext/p7zip/makefile.linux_x86_asm_gcc_4.X_fltk +8 -4
- data/ext/p7zip/makefile.linux_x86_asm_gcc_mudflap_4.X +4 -2
- data/ext/p7zip/makefile.linux_x86_asm_icc +4 -2
- data/ext/p7zip/makefile.linux_x86_icc +3 -2
- data/ext/p7zip/makefile.macosx_arm64 +17 -0
- data/ext/p7zip/{makefile.macosx_32bits → makefile.macosx_gcc_32bits} +3 -2
- data/ext/p7zip/{makefile.macosx_32bits_asm → makefile.macosx_gcc_32bits_asm} +5 -3
- data/ext/p7zip/{makefile.macosx_32bits_ppc → makefile.macosx_gcc_32bits_ppc} +3 -2
- data/ext/p7zip/{makefile.macosx_64bits → makefile.macosx_gcc_64bits} +3 -2
- data/ext/p7zip/makefile.macosx_llvm_64bits +9 -3
- data/ext/p7zip/makefile.netbsd +5 -4
- data/ext/p7zip/makefile.netware_asm_gcc_3.X +6 -4
- data/ext/p7zip/makefile.oldmake +41 -130
- data/ext/p7zip/makefile.openbsd +7 -3
- data/ext/p7zip/makefile.openbsd_no_port +9 -5
- data/ext/p7zip/makefile.qnx_shared.bin +5 -4
- data/ext/p7zip/makefile.qnx_static +5 -4
- data/ext/p7zip/makefile.solaris_sparc_CC_32 +5 -4
- data/ext/p7zip/makefile.solaris_sparc_CC_64 +6 -4
- data/ext/p7zip/makefile.solaris_sparc_gcc +7 -6
- data/ext/p7zip/makefile.solaris_x86 +5 -4
- data/ext/p7zip/makefile.tru64 +5 -4
- data/ext/seven_zip_ruby/extconf.rb +92 -6
- data/ext/seven_zip_ruby/seven_zip_archive.cpp +40 -17
- data/ext/seven_zip_ruby/seven_zip_archive.h +1 -1
- data/ext/seven_zip_ruby/utils.cpp +267 -124
- data/ext/seven_zip_ruby/utils.h +2 -0
- data/lib/seven_zip_ruby/7z.dll +0 -0
- data/lib/seven_zip_ruby/7z.sfx +0 -0
- data/lib/seven_zip_ruby/7z64.dll +0 -0
- data/lib/seven_zip_ruby/7zCon.sfx +0 -0
- data/lib/seven_zip_ruby/seven_zip_reader.rb +16 -1
- data/lib/seven_zip_ruby/version.rb +1 -1
- data/p7zip/.gitignore +7 -0
- data/p7zip/README.txt +29 -0
- data/p7zip/extract.sh +134 -0
- data/spec/seven_zip_ruby_spec.rb +22 -13
- data/test/res/The Flying Spaghetti Monster.txt +3 -0
- data/test/res/The Three Little Pigs.txt +5 -0
- data/test/res/UTF_content.txt +3 -0
- data/test/res/test_reader_data.7z +0 -0
- data/test/res/test_reader_filename_cp932.7z +0 -0
- data/test/res/test_reader_files.7z +0 -0
- data/test/test_seven_zip_reader.rb +187 -0
- data/test/test_seven_zip_writer.rb +184 -0
- metadata +267 -219
- data/.github/workflows/test-and-release.yml +0 -43
- data/ext/C/Types.h +0 -254
- data/ext/CPP/7zip/Archive/IArchive.h +0 -234
- data/ext/CPP/7zip/IDecl.h +0 -15
- data/ext/CPP/7zip/IPassword.h +0 -24
- data/ext/CPP/7zip/IProgress.h +0 -33
- data/ext/CPP/7zip/IStream.h +0 -58
- data/ext/CPP/7zip/PropID.h +0 -76
- data/ext/CPP/Common/MyCom.h +0 -225
- data/ext/CPP/Common/MyGuidDef.h +0 -54
- data/ext/CPP/Common/MyInitGuid.h +0 -22
- data/ext/CPP/Common/MyUnknown.h +0 -13
- data/ext/CPP/Common/MyWindows.h +0 -204
- data/ext/CPP/Common/Types.h +0 -11
- data/ext/CPP/Windows/PropVariant.h +0 -56
- data/ext/CPP/include_windows/basetyps.h +0 -19
- data/ext/CPP/include_windows/tchar.h +0 -89
- data/ext/CPP/include_windows/windows.h +0 -194
- data/ext/p7zip/Asm/x64/7zCrcT8U.asm +0 -103
- data/ext/p7zip/Asm/x86/7zCrcT8U.asm +0 -101
- data/ext/p7zip/C/7zCrcT8.c +0 -43
- data/ext/p7zip/C/Alloc.back3 +0 -238
- data/ext/p7zip/C/Alloc.c.back +0 -243
- data/ext/p7zip/C/Alloc.c.back2 +0 -222
- data/ext/p7zip/C/LzmaUtil/Lzma86Dec.h +0 -51
- data/ext/p7zip/CPP/7zip/Archive/7z/7zFolderOutStream.cpp +0 -149
- data/ext/p7zip/CPP/7zip/Archive/7z/7zFolderOutStream.h +0 -58
- data/ext/p7zip/CPP/7zip/Archive/Chm/ChmHeader.cpp +0 -24
- data/ext/p7zip/CPP/7zip/Archive/Chm/ChmHeader.h +0 -28
- data/ext/p7zip/CPP/7zip/Archive/Chm/ChmRegister.cpp +0 -13
- data/ext/p7zip/CPP/7zip/Archive/Com/ComHandler.cpp +0 -239
- data/ext/p7zip/CPP/7zip/Archive/Com/ComHandler.h +0 -28
- data/ext/p7zip/CPP/7zip/Archive/Com/ComIn.cpp +0 -389
- data/ext/p7zip/CPP/7zip/Archive/Com/ComIn.h +0 -119
- data/ext/p7zip/CPP/7zip/Archive/Com/ComRegister.cpp +0 -13
- data/ext/p7zip/CPP/7zip/Archive/Common/CoderMixer2MT.cpp +0 -240
- data/ext/p7zip/CPP/7zip/Archive/Common/CoderMixer2MT.h +0 -80
- data/ext/p7zip/CPP/7zip/Archive/Common/CoderMixer2ST.cpp +0 -239
- data/ext/p7zip/CPP/7zip/Archive/Common/CoderMixer2ST.h +0 -88
- data/ext/p7zip/CPP/7zip/Archive/Common/CrossThreadProgress.cpp +0 -15
- data/ext/p7zip/CPP/7zip/Archive/Common/CrossThreadProgress.h +0 -37
- data/ext/p7zip/CPP/7zip/Archive/DebHandler.cpp +0 -413
- data/ext/p7zip/CPP/7zip/Archive/Hfs/HfsHandler.cpp +0 -243
- data/ext/p7zip/CPP/7zip/Archive/Hfs/HfsHandler.h +0 -26
- data/ext/p7zip/CPP/7zip/Archive/Hfs/HfsIn.cpp +0 -480
- data/ext/p7zip/CPP/7zip/Archive/Hfs/HfsIn.h +0 -154
- data/ext/p7zip/CPP/7zip/Archive/Hfs/HfsRegister.cpp +0 -13
- data/ext/p7zip/CPP/7zip/Archive/Rar/RarHeader.cpp +0 -21
- data/ext/p7zip/CPP/7zip/Archive/Rar/RarIn.cpp +0 -478
- data/ext/p7zip/CPP/7zip/Archive/Rar/RarIn.h +0 -123
- data/ext/p7zip/CPP/7zip/Archive/Rar/RarItem.cpp +0 -55
- data/ext/p7zip/CPP/7zip/Archive/Rar/RarRegister.cpp +0 -13
- data/ext/p7zip/CPP/7zip/Archive/Rar/RarVolumeInStream.cpp +0 -78
- data/ext/p7zip/CPP/7zip/Archive/Rar/RarVolumeInStream.h +0 -49
- data/ext/p7zip/CPP/7zip/Archive/Udf/UdfRegister.cpp +0 -13
- data/ext/p7zip/CPP/7zip/Archive/Zip/ZipHeader.cpp +0 -36
- data/ext/p7zip/CPP/7zip/Archive/Zip/ZipItemEx.h +0 -34
- data/ext/p7zip/CPP/7zip/CMAKE/CMakeLists_7zFM.txt +0 -163
- data/ext/p7zip/CPP/7zip/CMAKE/CMakeLists_7zG.txt +0 -131
- data/ext/p7zip/CPP/7zip/CMAKE/CMakeLists_7za.txt +0 -253
- data/ext/p7zip/CPP/7zip/CMAKE/CMakeLists_ALL.txt +0 -32
- data/ext/p7zip/CPP/7zip/CMAKE/CMakeLists_Format7zFree.txt +0 -290
- data/ext/p7zip/CPP/7zip/CMAKE/generate.sh +0 -37
- data/ext/p7zip/CPP/7zip/CMAKE/generate_xcode.sh +0 -32
- data/ext/p7zip/CPP/7zip/Common/LockedStream.cpp +0 -23
- data/ext/p7zip/CPP/7zip/Common/LockedStream.h +0 -38
- data/ext/p7zip/CPP/7zip/Compress/ArjDecoder1.cpp +0 -309
- data/ext/p7zip/CPP/7zip/Compress/ArjDecoder1.h +0 -98
- data/ext/p7zip/CPP/7zip/Compress/ArjDecoder2.cpp +0 -90
- data/ext/p7zip/CPP/7zip/Compress/ArjDecoder2.h +0 -59
- data/ext/p7zip/CPP/7zip/Compress/BranchCoder.cpp +0 -19
- data/ext/p7zip/CPP/7zip/Compress/BranchCoder.h +0 -44
- data/ext/p7zip/CPP/7zip/Compress/DllExports.cpp +0 -39
- data/ext/p7zip/CPP/7zip/Compress/LZMA_Alone/LzmaAlone.cpp +0 -531
- data/ext/p7zip/CPP/7zip/Compress/LZMA_Alone/LzmaBench.cpp +0 -1018
- data/ext/p7zip/CPP/7zip/Compress/LZMA_Alone/LzmaBench.h +0 -48
- data/ext/p7zip/CPP/7zip/Compress/LZMA_Alone/LzmaBenchCon.cpp +0 -311
- data/ext/p7zip/CPP/7zip/Compress/LZMA_Alone/LzmaBenchCon.h +0 -20
- data/ext/p7zip/CPP/7zip/Compress/LZMA_Alone/makefile +0 -173
- data/ext/p7zip/CPP/7zip/Compress/Lzx86Converter.cpp +0 -90
- data/ext/p7zip/CPP/7zip/Compress/Lzx86Converter.h +0 -46
- data/ext/p7zip/CPP/7zip/Compress/RangeCoder.h +0 -205
- data/ext/p7zip/CPP/7zip/Compress/RangeCoderBit.h +0 -114
- data/ext/p7zip/CPP/7zip/Crypto/Sha1.cpp +0 -229
- data/ext/p7zip/CPP/7zip/Crypto/Sha1.h +0 -68
- data/ext/p7zip/CPP/7zip/PREMAKE/generate.sh +0 -18
- data/ext/p7zip/CPP/7zip/PREMAKE/premake4.lua +0 -263
- data/ext/p7zip/CPP/7zip/QMAKE/7ZA/7ZA.pro +0 -228
- data/ext/p7zip/CPP/7zip/QMAKE/7ZA/7ZA_osx.pro +0 -228
- data/ext/p7zip/CPP/7zip/QMAKE/test_emul/test_emul.pro +0 -26
- data/ext/p7zip/CPP/7zip/TEST/TestUI/TestUI.cpp +0 -560
- data/ext/p7zip/CPP/7zip/TEST/TestUI/makefile +0 -33
- data/ext/p7zip/CPP/7zip/TEST/TestUI/makefile.depend +0 -577
- data/ext/p7zip/CPP/7zip/TEST/TestUI/makefile.list +0 -16
- data/ext/p7zip/CPP/Common/Buffer.h +0 -77
- data/ext/p7zip/CPP/Common/Types.h +0 -11
- data/ext/p7zip/CPP/Windows/COM.cpp +0 -37
- data/ext/p7zip/CPP/Windows/COM.h +0 -69
- data/ext/p7zip/CPP/Windows/Clipboard.cpp +0 -160
- data/ext/p7zip/CPP/Windows/Clipboard.h +0 -28
- data/ext/p7zip/CPP/Windows/CommonDialog.h +0 -19
- data/ext/p7zip/CPP/Windows/Control/ComboBox.h +0 -82
- data/ext/p7zip/CPP/Windows/Control/Controls.cpp +0 -515
- data/ext/p7zip/CPP/Windows/Control/Dialog.cpp +0 -560
- data/ext/p7zip/CPP/Windows/Control/Dialog.h +0 -179
- data/ext/p7zip/CPP/Windows/Control/DialogImpl.h +0 -73
- data/ext/p7zip/CPP/Windows/Control/Edit.h +0 -24
- data/ext/p7zip/CPP/Windows/Control/ListView.h +0 -164
- data/ext/p7zip/CPP/Windows/Control/ProgressBar.h +0 -34
- data/ext/p7zip/CPP/Windows/Control/Static.h +0 -23
- data/ext/p7zip/CPP/Windows/Control/StatusBar.h +0 -56
- data/ext/p7zip/CPP/Windows/Control/Window2.cpp +0 -211
- data/ext/p7zip/CPP/Windows/Control/Window2.h +0 -111
- data/ext/p7zip/CPP/Windows/DLL.cpp +0 -193
- data/ext/p7zip/CPP/Windows/DLL.h +0 -48
- data/ext/p7zip/CPP/Windows/Error.cpp +0 -58
- data/ext/p7zip/CPP/Windows/Error.h +0 -33
- data/ext/p7zip/CPP/Windows/Menu.h +0 -4
- data/ext/p7zip/CPP/Windows/PropVariantConversions.cpp +0 -142
- data/ext/p7zip/CPP/Windows/PropVariantConversions.h +0 -14
- data/ext/p7zip/CPP/Windows/Registry.cpp +0 -313
- data/ext/p7zip/CPP/Windows/Registry.h +0 -113
- data/ext/p7zip/CPP/Windows/ResourceString.h +0 -22
- data/ext/p7zip/CPP/Windows/Shell.h +0 -21
- data/ext/p7zip/CPP/Windows/Time.cpp +0 -88
- data/ext/p7zip/CPP/Windows/Time.h +0 -21
- data/ext/p7zip/CPP/Windows/Window.cpp +0 -101
- data/ext/p7zip/CPP/Windows/Window.h +0 -43
- data/ext/p7zip/CPP/myWindows/initguid.h +0 -4
- data/ext/p7zip/CPP/myWindows/makefile +0 -21
- data/ext/p7zip/CPP/myWindows/makefile.depend +0 -32
- data/ext/p7zip/CPP/myWindows/makefile.list +0 -28
- data/ext/p7zip/CPP/myWindows/myAddExeFlag.cpp +0 -20
- data/ext/p7zip/CPP/myWindows/myGetTickCount.cpp +0 -8
- data/ext/p7zip/CPP/myWindows/mySplitCommandLine.cpp +0 -82
- data/ext/p7zip/CPP/myWindows/test_emul.cpp +0 -745
- data/ext/p7zip/CPP/myWindows/wine_GetXXXDefaultLangID.cpp +0 -741
- data/ext/p7zip/DOCS/MANUAL/switches/charset.htm +0 -49
- data/ext/p7zip/DOCS/Methods.txt +0 -152
- data/ext/p7zip/DOCS/lzma.txt +0 -598
- data/ext/p7zip/contrib/VirtualFileSystemForMidnightCommander/ChangeLog +0 -41
- data/ext/p7zip/contrib/VirtualFileSystemForMidnightCommander/readme +0 -21
- data/ext/p7zip/contrib/VirtualFileSystemForMidnightCommander/readme.u7z +0 -30
- data/ext/p7zip/contrib/VirtualFileSystemForMidnightCommander/u7z +0 -133
- data/ext/p7zip/contrib/gzip-like_CLI_wrapper_for_7z/README +0 -21
- data/ext/p7zip/contrib/gzip-like_CLI_wrapper_for_7z/check/check.sh +0 -117
- data/ext/p7zip/contrib/gzip-like_CLI_wrapper_for_7z/check/files.tar +0 -0
- data/ext/p7zip/contrib/gzip-like_CLI_wrapper_for_7z/man1/p7zip.1 +0 -33
- data/ext/p7zip/contrib/gzip-like_CLI_wrapper_for_7z/p7zip +0 -144
- data/ext/p7zip/contrib/qnx630sp3/qnx630sp3-shared +0 -14
- data/ext/p7zip/contrib/qnx630sp3/qnx630sp3-static +0 -10
- data/ext/p7zip/integration_context_menu.txt +0 -51
- data/ext/p7zip/makefile.rules +0 -661
- /data/ext/p7zip/{DOCS → DOC}/7zFormat.txt +0 -0
- /data/ext/p7zip/{DOCS → DOC}/unRarLicense.txt +0 -0
@@ -2,115 +2,488 @@
|
|
2
2
|
|
3
3
|
#include "StdAfx.h"
|
4
4
|
|
5
|
-
#include
|
5
|
+
// #include <stdio.h>
|
6
6
|
|
7
|
-
#include "Common/DynamicBuffer.h"
|
7
|
+
#include "../../../Common/DynamicBuffer.h"
|
8
|
+
#include "../../../Common/IntToString.h"
|
9
|
+
#include "../../../Common/StringToInt.h"
|
10
|
+
|
11
|
+
#include "../../../Windows/PropVariant.h"
|
8
12
|
|
9
|
-
#include "../../Common/LimitedStreams.h"
|
10
13
|
#include "../../Common/StreamUtils.h"
|
11
14
|
|
15
|
+
#include "../IArchive.h"
|
16
|
+
|
12
17
|
#include "ZipIn.h"
|
13
18
|
|
14
19
|
#define Get16(p) GetUi16(p)
|
15
20
|
#define Get32(p) GetUi32(p)
|
16
21
|
#define Get64(p) GetUi64(p)
|
17
22
|
|
23
|
+
#define G16(offs, v) v = Get16(p + (offs))
|
24
|
+
#define G32(offs, v) v = Get32(p + (offs))
|
25
|
+
#define G64(offs, v) v = Get64(p + (offs))
|
26
|
+
|
18
27
|
namespace NArchive {
|
19
28
|
namespace NZip {
|
20
|
-
|
21
|
-
|
29
|
+
|
30
|
+
struct CEcd
|
22
31
|
{
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
32
|
+
UInt16 ThisDisk;
|
33
|
+
UInt16 CdDisk;
|
34
|
+
UInt16 NumEntries_in_ThisDisk;
|
35
|
+
UInt16 NumEntries;
|
36
|
+
UInt32 Size;
|
37
|
+
UInt32 Offset;
|
38
|
+
UInt16 CommentSize;
|
39
|
+
|
40
|
+
bool IsEmptyArc() const
|
41
|
+
{
|
42
|
+
return ThisDisk == 0
|
43
|
+
&& CdDisk == 0
|
44
|
+
&& NumEntries_in_ThisDisk == 0
|
45
|
+
&& NumEntries == 0
|
46
|
+
&& Size == 0
|
47
|
+
&& Offset == 0 // test it
|
48
|
+
;
|
49
|
+
}
|
50
|
+
|
51
|
+
void Parse(const Byte *p); // (p) doesn't include signature
|
52
|
+
};
|
53
|
+
|
54
|
+
void CEcd::Parse(const Byte *p)
|
55
|
+
{
|
56
|
+
// (p) doesn't include signature
|
57
|
+
G16(0, ThisDisk);
|
58
|
+
G16(2, CdDisk);
|
59
|
+
G16(4, NumEntries_in_ThisDisk);
|
60
|
+
G16(6, NumEntries);
|
61
|
+
G32(8, Size);
|
62
|
+
G32(12, Offset);
|
63
|
+
G16(16, CommentSize);
|
64
|
+
}
|
65
|
+
|
66
|
+
|
67
|
+
void CCdInfo::ParseEcd32(const Byte *p)
|
68
|
+
{
|
69
|
+
// (p) includes signature
|
70
|
+
p += 4;
|
71
|
+
G16(0, ThisDisk);
|
72
|
+
G16(2, CdDisk);
|
73
|
+
G16(4, NumEntries_in_ThisDisk);
|
74
|
+
G16(6, NumEntries);
|
75
|
+
G32(8, Size);
|
76
|
+
G32(12, Offset);
|
77
|
+
G16(16, CommentSize);
|
78
|
+
}
|
79
|
+
|
80
|
+
void CCdInfo::ParseEcd64e(const Byte *p)
|
81
|
+
{
|
82
|
+
// (p) exclude signature
|
83
|
+
G16(0, VersionMade);
|
84
|
+
G16(2, VersionNeedExtract);
|
85
|
+
G32(4, ThisDisk);
|
86
|
+
G32(8, CdDisk);
|
87
|
+
|
88
|
+
G64(12, NumEntries_in_ThisDisk);
|
89
|
+
G64(20, NumEntries);
|
90
|
+
G64(28, Size);
|
91
|
+
G64(36, Offset);
|
92
|
+
}
|
93
|
+
|
94
|
+
|
95
|
+
struct CLocator
|
96
|
+
{
|
97
|
+
UInt32 Ecd64Disk;
|
98
|
+
UInt32 NumDisks;
|
99
|
+
UInt64 Ecd64Offset;
|
100
|
+
|
101
|
+
CLocator(): Ecd64Disk(0), NumDisks(0), Ecd64Offset(0) {}
|
102
|
+
|
103
|
+
void Parse(const Byte *p)
|
104
|
+
{
|
105
|
+
G32(0, Ecd64Disk);
|
106
|
+
G64(4, Ecd64Offset);
|
107
|
+
G32(12, NumDisks);
|
108
|
+
}
|
109
|
+
};
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
void CInArchive::ClearRefs()
|
115
|
+
{
|
116
|
+
StreamRef.Release();
|
117
|
+
Stream = NULL;
|
118
|
+
StartStream = NULL;
|
119
|
+
Callback = NULL;
|
120
|
+
|
121
|
+
Vols.Clear();
|
31
122
|
}
|
32
123
|
|
33
124
|
void CInArchive::Close()
|
34
125
|
{
|
35
|
-
|
36
|
-
|
126
|
+
_processedCnt = 0;
|
127
|
+
IsArc = false;
|
128
|
+
IsArcOpen = false;
|
129
|
+
IsMultiVol = false;
|
130
|
+
UseDisk_in_SingleVol = false;
|
131
|
+
EcdVolIndex = 0;
|
132
|
+
HeadersError = false;
|
133
|
+
HeadersWarning = false;
|
134
|
+
ExtraMinorError = false;
|
135
|
+
UnexpectedEnd = false;
|
136
|
+
NoCentralDir = false;
|
137
|
+
IsZip64 = false;
|
138
|
+
MarkerIsFound = false;
|
139
|
+
|
140
|
+
ClearRefs();
|
37
141
|
}
|
38
142
|
|
143
|
+
|
39
144
|
HRESULT CInArchive::Seek(UInt64 offset)
|
40
145
|
{
|
41
|
-
return
|
146
|
+
return Stream->Seek(offset, STREAM_SEEK_SET, NULL);
|
42
147
|
}
|
43
148
|
|
44
|
-
//////////////////////////////////////
|
45
|
-
// Markers
|
46
149
|
|
47
|
-
static
|
150
|
+
static bool CheckDosTime(UInt32 dosTime)
|
48
151
|
{
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
152
|
+
if (dosTime == 0)
|
153
|
+
return true;
|
154
|
+
unsigned month = (dosTime >> 21) & 0xF;
|
155
|
+
unsigned day = (dosTime >> 16) & 0x1F;
|
156
|
+
unsigned hour = (dosTime >> 11) & 0x1F;
|
157
|
+
unsigned min = (dosTime >> 5) & 0x3F;
|
158
|
+
unsigned sec = (dosTime & 0x1F) * 2;
|
159
|
+
if (month < 1 || month > 12 || day < 1 || day > 31 || hour > 23 || min > 59 || sec > 59)
|
160
|
+
return false;
|
161
|
+
return true;
|
53
162
|
}
|
54
163
|
|
55
|
-
|
56
|
-
static inline bool TestMarkerCandidate2(const Byte *p, UInt32 &value)
|
164
|
+
API_FUNC_IsArc IsArc_Zip(const Byte *p, size_t size)
|
57
165
|
{
|
166
|
+
if (size < 8)
|
167
|
+
return k_IsArc_Res_NEED_MORE;
|
168
|
+
if (p[0] != 'P')
|
169
|
+
return k_IsArc_Res_NO;
|
170
|
+
|
171
|
+
UInt32 value = Get32(p);
|
172
|
+
|
173
|
+
if (value == NSignature::kNoSpan
|
174
|
+
|| value == NSignature::kSpan)
|
175
|
+
{
|
176
|
+
p += 4;
|
177
|
+
size -= 4;
|
178
|
+
}
|
179
|
+
|
58
180
|
value = Get32(p);
|
59
|
-
|
60
|
-
|
61
|
-
|
181
|
+
|
182
|
+
if (value == NSignature::kEcd)
|
183
|
+
{
|
184
|
+
if (size < kEcdSize)
|
185
|
+
return k_IsArc_Res_NEED_MORE;
|
186
|
+
CEcd ecd;
|
187
|
+
ecd.Parse(p + 4);
|
188
|
+
// if (ecd.cdSize != 0)
|
189
|
+
if (!ecd.IsEmptyArc())
|
190
|
+
return k_IsArc_Res_NO;
|
191
|
+
return k_IsArc_Res_YES; // k_IsArc_Res_YES_2;
|
192
|
+
}
|
193
|
+
|
194
|
+
if (value != NSignature::kLocalFileHeader)
|
195
|
+
return k_IsArc_Res_NO;
|
196
|
+
|
197
|
+
if (size < kLocalHeaderSize)
|
198
|
+
return k_IsArc_Res_NEED_MORE;
|
199
|
+
|
200
|
+
p += 4;
|
201
|
+
|
202
|
+
{
|
203
|
+
const unsigned kPureHeaderSize = kLocalHeaderSize - 4;
|
204
|
+
unsigned i;
|
205
|
+
for (i = 0; i < kPureHeaderSize && p[i] == 0; i++);
|
206
|
+
if (i == kPureHeaderSize)
|
207
|
+
return k_IsArc_Res_NEED_MORE;
|
208
|
+
}
|
209
|
+
|
210
|
+
/*
|
211
|
+
if (p[0] >= 128) // ExtractVersion.Version;
|
212
|
+
return k_IsArc_Res_NO;
|
213
|
+
*/
|
214
|
+
|
215
|
+
// ExtractVersion.Version = p[0];
|
216
|
+
// ExtractVersion.HostOS = p[1];
|
217
|
+
// Flags = Get16(p + 2);
|
218
|
+
// Method = Get16(p + 4);
|
219
|
+
/*
|
220
|
+
// 9.33: some zip archives contain incorrect value in timestamp. So we don't check it now
|
221
|
+
UInt32 dosTime = Get32(p + 6);
|
222
|
+
if (!CheckDosTime(dosTime))
|
223
|
+
return k_IsArc_Res_NO;
|
224
|
+
*/
|
225
|
+
// Crc = Get32(p + 10);
|
226
|
+
// PackSize = Get32(p + 14);
|
227
|
+
// Size = Get32(p + 18);
|
228
|
+
const unsigned nameSize = Get16(p + 22);
|
229
|
+
unsigned extraSize = Get16(p + 24);
|
230
|
+
const UInt32 extraOffset = kLocalHeaderSize + (UInt32)nameSize;
|
231
|
+
if (extraOffset + extraSize > (1 << 16))
|
232
|
+
return k_IsArc_Res_NO;
|
233
|
+
|
234
|
+
p -= 4;
|
235
|
+
|
236
|
+
{
|
237
|
+
size_t rem = size - kLocalHeaderSize;
|
238
|
+
if (rem > nameSize)
|
239
|
+
rem = nameSize;
|
240
|
+
const Byte *p2 = p + kLocalHeaderSize;
|
241
|
+
for (size_t i = 0; i < rem; i++)
|
242
|
+
if (p2[i] == 0)
|
243
|
+
if (i != nameSize - 1)
|
244
|
+
return k_IsArc_Res_NO;
|
245
|
+
}
|
246
|
+
|
247
|
+
if (size < extraOffset)
|
248
|
+
return k_IsArc_Res_NEED_MORE;
|
249
|
+
|
250
|
+
if (extraSize > 0)
|
251
|
+
{
|
252
|
+
p += extraOffset;
|
253
|
+
size -= extraOffset;
|
254
|
+
while (extraSize != 0)
|
255
|
+
{
|
256
|
+
if (extraSize < 4)
|
257
|
+
{
|
258
|
+
// 7-Zip before 9.31 created incorrect WsAES Extra in folder's local headers.
|
259
|
+
// so we return k_IsArc_Res_YES to support such archives.
|
260
|
+
// return k_IsArc_Res_NO; // do we need to support such extra ?
|
261
|
+
return k_IsArc_Res_YES;
|
262
|
+
}
|
263
|
+
if (size < 4)
|
264
|
+
return k_IsArc_Res_NEED_MORE;
|
265
|
+
unsigned dataSize = Get16(p + 2);
|
266
|
+
size -= 4;
|
267
|
+
extraSize -= 4;
|
268
|
+
p += 4;
|
269
|
+
if (dataSize > extraSize)
|
270
|
+
return k_IsArc_Res_NO;
|
271
|
+
if (dataSize > size)
|
272
|
+
return k_IsArc_Res_NEED_MORE;
|
273
|
+
size -= dataSize;
|
274
|
+
extraSize -= dataSize;
|
275
|
+
p += dataSize;
|
276
|
+
}
|
277
|
+
}
|
278
|
+
|
279
|
+
return k_IsArc_Res_YES;
|
62
280
|
}
|
63
281
|
|
64
|
-
|
282
|
+
static UInt32 IsArc_Zip_2(const Byte *p, size_t size, bool isFinal)
|
65
283
|
{
|
66
|
-
|
67
|
-
|
284
|
+
UInt32 res = IsArc_Zip(p, size);
|
285
|
+
if (res == k_IsArc_Res_NEED_MORE && isFinal)
|
286
|
+
return k_IsArc_Res_NO;
|
287
|
+
return res;
|
288
|
+
}
|
68
289
|
|
69
|
-
Byte marker[NSignature::kMarkerSize];
|
70
|
-
RINOK(ReadStream_FALSE(stream, marker, NSignature::kMarkerSize));
|
71
|
-
m_Position += NSignature::kMarkerSize;
|
72
|
-
if (TestMarkerCandidate(marker, m_Signature))
|
73
|
-
return S_OK;
|
74
290
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
291
|
+
|
292
|
+
HRESULT CInArchive::FindMarker(IInStream *stream, const UInt64 *searchLimit)
|
293
|
+
{
|
294
|
+
ArcInfo.MarkerPos = m_Position;
|
295
|
+
ArcInfo.MarkerPos2 = m_Position;
|
296
|
+
|
297
|
+
if (searchLimit && *searchLimit == 0)
|
298
|
+
{
|
299
|
+
Byte startBuf[kMarkerSize];
|
300
|
+
{
|
301
|
+
size_t processed = kMarkerSize;
|
302
|
+
RINOK(ReadStream(stream, startBuf, &processed));
|
303
|
+
m_Position += processed;
|
304
|
+
if (processed != kMarkerSize)
|
305
|
+
return S_FALSE;
|
306
|
+
}
|
307
|
+
|
308
|
+
m_Signature = Get32(startBuf);
|
309
|
+
|
310
|
+
if (m_Signature != NSignature::kEcd &&
|
311
|
+
m_Signature != NSignature::kLocalFileHeader)
|
312
|
+
{
|
313
|
+
if (m_Signature != NSignature::kNoSpan)
|
314
|
+
{
|
315
|
+
if (m_Signature != NSignature::kSpan)
|
316
|
+
return S_FALSE;
|
317
|
+
if (m_Position != 4) // we don't support multivol archives with sfx stub
|
318
|
+
return S_FALSE;
|
319
|
+
ArcInfo.IsSpanMode = true;
|
320
|
+
}
|
321
|
+
size_t processed = kMarkerSize;
|
322
|
+
RINOK(ReadStream(stream, startBuf, &processed));
|
323
|
+
m_Position += processed;
|
324
|
+
if (processed != kMarkerSize)
|
325
|
+
return S_FALSE;
|
326
|
+
m_Signature = Get32(startBuf);
|
327
|
+
if (m_Signature != NSignature::kEcd &&
|
328
|
+
m_Signature != NSignature::kLocalFileHeader)
|
329
|
+
return S_FALSE;
|
330
|
+
ArcInfo.MarkerPos2 += 4;
|
331
|
+
}
|
332
|
+
|
333
|
+
// we use weak test in case of (*searchLimit == 0)
|
334
|
+
// since error will be detected later in Open function
|
335
|
+
return S_OK; // maybe we need to search backward.
|
336
|
+
}
|
337
|
+
|
338
|
+
const size_t kBufSize = (size_t)1 << 18; // must be larger than kCheckSize
|
339
|
+
const size_t kCheckSize = (size_t)1 << 16; // must be smaller than kBufSize
|
340
|
+
CByteArr buffer(kBufSize);
|
341
|
+
|
342
|
+
size_t numBytesInBuffer = 0;
|
343
|
+
UInt64 curScanPos = 0;
|
344
|
+
|
82
345
|
for (;;)
|
83
346
|
{
|
84
|
-
|
85
|
-
|
86
|
-
break;
|
87
|
-
size_t numReadBytes = kSearchMarkerBufferSize - numBytesPrev;
|
88
|
-
RINOK(ReadStream(stream, buffer + numBytesPrev, &numReadBytes));
|
347
|
+
size_t numReadBytes = kBufSize - numBytesInBuffer;
|
348
|
+
RINOK(ReadStream(stream, buffer + numBytesInBuffer, &numReadBytes));
|
89
349
|
m_Position += numReadBytes;
|
90
|
-
|
91
|
-
const
|
92
|
-
|
350
|
+
numBytesInBuffer += numReadBytes;
|
351
|
+
const bool isFinished = (numBytesInBuffer != kBufSize);
|
352
|
+
|
353
|
+
size_t limit = numBytesInBuffer;;
|
354
|
+
if (isFinished)
|
355
|
+
{
|
356
|
+
if (limit == 0)
|
357
|
+
break;
|
358
|
+
limit--;
|
359
|
+
}
|
360
|
+
else
|
361
|
+
limit -= kCheckSize;
|
362
|
+
|
363
|
+
if (searchLimit && curScanPos + limit > *searchLimit)
|
364
|
+
limit = (size_t)(*searchLimit - curScanPos + 1);
|
365
|
+
|
366
|
+
if (limit < 1)
|
93
367
|
break;
|
94
|
-
|
95
|
-
|
368
|
+
|
369
|
+
const Byte *buf = buffer;
|
370
|
+
for (size_t pos = 0; pos < limit; pos++)
|
96
371
|
{
|
97
|
-
if (
|
372
|
+
if (buf[pos] != 0x50)
|
98
373
|
continue;
|
99
|
-
if (
|
374
|
+
if (buf[pos + 1] != 0x4B)
|
375
|
+
continue;
|
376
|
+
size_t rem = numBytesInBuffer - pos;
|
377
|
+
UInt32 res = IsArc_Zip_2(buf + pos, rem, isFinished);
|
378
|
+
if (res != k_IsArc_Res_NO)
|
100
379
|
{
|
101
|
-
|
102
|
-
|
103
|
-
|
380
|
+
if (rem < kMarkerSize)
|
381
|
+
return S_FALSE;
|
382
|
+
m_Signature = Get32(buf + pos);
|
383
|
+
ArcInfo.MarkerPos += curScanPos + pos;
|
384
|
+
ArcInfo.MarkerPos2 = ArcInfo.MarkerPos;
|
385
|
+
if (m_Signature == NSignature::kNoSpan
|
386
|
+
|| m_Signature == NSignature::kSpan)
|
387
|
+
{
|
388
|
+
m_Signature = Get32(buf + pos + 4);
|
389
|
+
ArcInfo.MarkerPos2 += 4;
|
390
|
+
}
|
391
|
+
m_Position = ArcInfo.MarkerPos2 + kMarkerSize;
|
104
392
|
return S_OK;
|
105
393
|
}
|
106
394
|
}
|
107
|
-
|
108
|
-
|
109
|
-
|
395
|
+
|
396
|
+
if (isFinished)
|
397
|
+
break;
|
398
|
+
|
399
|
+
curScanPos += limit;
|
400
|
+
numBytesInBuffer -= limit;
|
401
|
+
memmove(buffer, buffer + limit, numBytesInBuffer);
|
110
402
|
}
|
403
|
+
|
111
404
|
return S_FALSE;
|
112
405
|
}
|
113
406
|
|
407
|
+
|
408
|
+
HRESULT CInArchive::IncreaseRealPosition(Int64 addValue, bool &isFinished)
|
409
|
+
{
|
410
|
+
isFinished = false;
|
411
|
+
if (!IsMultiVol)
|
412
|
+
return Stream->Seek(addValue, STREAM_SEEK_CUR, &m_Position);
|
413
|
+
|
414
|
+
for (;;)
|
415
|
+
{
|
416
|
+
if (addValue == 0)
|
417
|
+
return S_OK;
|
418
|
+
if (addValue > 0)
|
419
|
+
{
|
420
|
+
if (Vols.StreamIndex < 0)
|
421
|
+
return S_FALSE;
|
422
|
+
if ((unsigned)Vols.StreamIndex >= Vols.Streams.Size())
|
423
|
+
{
|
424
|
+
isFinished = true;
|
425
|
+
return S_OK;
|
426
|
+
}
|
427
|
+
{
|
428
|
+
const CVols::CSubStreamInfo &s = Vols.Streams[Vols.StreamIndex];
|
429
|
+
if (!s.Stream)
|
430
|
+
{
|
431
|
+
isFinished = true;
|
432
|
+
return S_OK;
|
433
|
+
}
|
434
|
+
if (m_Position > s.Size)
|
435
|
+
return S_FALSE;
|
436
|
+
UInt64 rem = s.Size - m_Position;
|
437
|
+
if ((UInt64)addValue <= rem)
|
438
|
+
return Stream->Seek(addValue, STREAM_SEEK_CUR, &m_Position);
|
439
|
+
RINOK(Stream->Seek(s.Size, STREAM_SEEK_SET, &m_Position));
|
440
|
+
addValue -= rem;
|
441
|
+
Stream = NULL;
|
442
|
+
Vols.StreamIndex++;
|
443
|
+
if ((unsigned)Vols.StreamIndex >= Vols.Streams.Size())
|
444
|
+
{
|
445
|
+
isFinished = true;
|
446
|
+
return S_OK;
|
447
|
+
}
|
448
|
+
}
|
449
|
+
const CVols::CSubStreamInfo &s2 = Vols.Streams[Vols.StreamIndex];
|
450
|
+
if (!s2.Stream)
|
451
|
+
{
|
452
|
+
isFinished = true;
|
453
|
+
return S_OK;
|
454
|
+
}
|
455
|
+
Stream = s2.Stream;
|
456
|
+
m_Position = 0;
|
457
|
+
RINOK(Stream->Seek(0, STREAM_SEEK_SET, &m_Position));
|
458
|
+
}
|
459
|
+
else
|
460
|
+
{
|
461
|
+
if (!Stream)
|
462
|
+
return S_FALSE;
|
463
|
+
{
|
464
|
+
if (m_Position >= (UInt64)(-addValue))
|
465
|
+
return Stream->Seek(addValue, STREAM_SEEK_CUR, &m_Position);
|
466
|
+
addValue += m_Position;
|
467
|
+
RINOK(Stream->Seek(0, STREAM_SEEK_SET, &m_Position));
|
468
|
+
m_Position = 0;
|
469
|
+
Stream = NULL;
|
470
|
+
if (--Vols.StreamIndex < 0)
|
471
|
+
return S_FALSE;
|
472
|
+
}
|
473
|
+
const CVols::CSubStreamInfo &s2 = Vols.Streams[Vols.StreamIndex];
|
474
|
+
if (!s2.Stream)
|
475
|
+
return S_FALSE;
|
476
|
+
Stream = s2.Stream;
|
477
|
+
m_Position = s2.Size;
|
478
|
+
RINOK(Stream->Seek(s2.Size, STREAM_SEEK_SET, &m_Position));
|
479
|
+
}
|
480
|
+
}
|
481
|
+
}
|
482
|
+
|
483
|
+
|
484
|
+
class CUnexpectEnd {};
|
485
|
+
|
486
|
+
|
114
487
|
HRESULT CInArchive::ReadBytes(void *data, UInt32 size, UInt32 *processedSize)
|
115
488
|
{
|
116
489
|
size_t realProcessedSize = size;
|
@@ -121,42 +494,63 @@ HRESULT CInArchive::ReadBytes(void *data, UInt32 size, UInt32 *processedSize)
|
|
121
494
|
catch (const CInBufferException &e) { return e.ErrorCode; }
|
122
495
|
}
|
123
496
|
else
|
124
|
-
result = ReadStream(
|
125
|
-
if (processedSize
|
497
|
+
result = ReadStream(Stream, data, &realProcessedSize);
|
498
|
+
if (processedSize)
|
126
499
|
*processedSize = (UInt32)realProcessedSize;
|
127
500
|
m_Position += realProcessedSize;
|
128
501
|
return result;
|
129
502
|
}
|
130
503
|
|
131
|
-
void CInArchive::
|
504
|
+
void CInArchive::SafeReadBytes(void *data, unsigned size)
|
132
505
|
{
|
133
|
-
|
134
|
-
|
135
|
-
|
506
|
+
size_t processed = size;
|
507
|
+
|
508
|
+
HRESULT result = S_OK;
|
136
509
|
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
510
|
+
if (!_inBufMode)
|
511
|
+
result = ReadStream(Stream, data, &processed);
|
512
|
+
else
|
513
|
+
{
|
514
|
+
for (;;)
|
515
|
+
{
|
516
|
+
processed = _inBuffer.ReadBytes((Byte *)data, size);
|
517
|
+
if (processed != 0
|
518
|
+
|| IsMultiVol
|
519
|
+
|| !CanStartNewVol
|
520
|
+
|| Vols.StreamIndex < 0
|
521
|
+
|| (unsigned)Vols.StreamIndex >= Vols.Streams.Size())
|
522
|
+
break;
|
523
|
+
Vols.StreamIndex++;
|
524
|
+
const CVols::CSubStreamInfo &s = Vols.Streams[Vols.StreamIndex];
|
525
|
+
if (!s.Stream)
|
526
|
+
break;
|
527
|
+
// if (Vols.NeedSeek)
|
528
|
+
{
|
529
|
+
result = s.Stream->Seek(0, STREAM_SEEK_SET, NULL);
|
530
|
+
m_Position = 0;
|
531
|
+
if (result != S_OK)
|
532
|
+
break;
|
533
|
+
Vols.NeedSeek = false;
|
534
|
+
}
|
535
|
+
_inBuffer.SetStream(s.Stream);
|
536
|
+
_inBuffer.Init();
|
537
|
+
}
|
538
|
+
CanStartNewVol = false;
|
539
|
+
}
|
142
540
|
|
143
|
-
|
144
|
-
|
145
|
-
UInt32 realProcessedSize;
|
146
|
-
if (ReadBytes(data, size, &realProcessedSize) != S_OK)
|
147
|
-
throw CInArchiveException(CInArchiveException::kReadStreamError);
|
148
|
-
return (realProcessedSize == size);
|
149
|
-
}
|
541
|
+
m_Position += processed;
|
542
|
+
_processedCnt += processed;
|
150
543
|
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
544
|
+
if (result != S_OK)
|
545
|
+
throw CSystemException(result);
|
546
|
+
|
547
|
+
if (processed != size)
|
548
|
+
throw CUnexpectEnd();
|
155
549
|
}
|
156
550
|
|
157
|
-
void CInArchive::ReadBuffer(CByteBuffer &buffer,
|
551
|
+
void CInArchive::ReadBuffer(CByteBuffer &buffer, unsigned size)
|
158
552
|
{
|
159
|
-
buffer.
|
553
|
+
buffer.Alloc(size);
|
160
554
|
if (size > 0)
|
161
555
|
SafeReadBytes(buffer, size);
|
162
556
|
}
|
@@ -168,65 +562,77 @@ Byte CInArchive::ReadByte()
|
|
168
562
|
return b;
|
169
563
|
}
|
170
564
|
|
171
|
-
UInt16 CInArchive::ReadUInt16()
|
172
|
-
{
|
173
|
-
|
174
|
-
SafeReadBytes(buf, 2);
|
175
|
-
return Get16(buf);
|
176
|
-
}
|
565
|
+
UInt16 CInArchive::ReadUInt16() { Byte buf[2]; SafeReadBytes(buf, 2); return Get16(buf); }
|
566
|
+
UInt32 CInArchive::ReadUInt32() { Byte buf[4]; SafeReadBytes(buf, 4); return Get32(buf); }
|
567
|
+
UInt64 CInArchive::ReadUInt64() { Byte buf[8]; SafeReadBytes(buf, 8); return Get64(buf); }
|
177
568
|
|
178
|
-
|
179
|
-
{
|
180
|
-
Byte buf[4];
|
181
|
-
SafeReadBytes(buf, 4);
|
182
|
-
return Get32(buf);
|
183
|
-
}
|
569
|
+
// we use Skip() inside headers only, so no need for stream change in multivol.
|
184
570
|
|
185
|
-
|
571
|
+
void CInArchive::Skip(unsigned num)
|
186
572
|
{
|
187
|
-
|
188
|
-
|
189
|
-
|
573
|
+
if (_inBufMode)
|
574
|
+
{
|
575
|
+
size_t skip = _inBuffer.Skip(num);
|
576
|
+
m_Position += skip;
|
577
|
+
_processedCnt += skip;
|
578
|
+
if (skip != num)
|
579
|
+
throw CUnexpectEnd();
|
580
|
+
}
|
581
|
+
else
|
582
|
+
{
|
583
|
+
for (unsigned i = 0; i < num; i++)
|
584
|
+
ReadByte();
|
585
|
+
}
|
190
586
|
}
|
191
587
|
|
192
|
-
|
588
|
+
void CInArchive::Skip64(UInt64 num)
|
193
589
|
{
|
194
|
-
|
195
|
-
|
196
|
-
return false;
|
197
|
-
value = Get32(buf);
|
198
|
-
return true;
|
590
|
+
for (UInt64 i = 0; i < num; i++)
|
591
|
+
ReadByte();
|
199
592
|
}
|
200
593
|
|
201
|
-
|
594
|
+
|
595
|
+
void CInArchive::ReadFileName(unsigned size, AString &s)
|
202
596
|
{
|
203
|
-
if (
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
597
|
+
if (size == 0)
|
598
|
+
{
|
599
|
+
s.Empty();
|
600
|
+
return;
|
601
|
+
}
|
602
|
+
SafeReadBytes(s.GetBuf(size), size);
|
603
|
+
s.ReleaseBuf_CalcLen(size);
|
209
604
|
}
|
210
605
|
|
211
|
-
|
606
|
+
|
607
|
+
bool CInArchive::ReadExtra(unsigned extraSize, CExtraBlock &extraBlock,
|
212
608
|
UInt64 &unpackSize, UInt64 &packSize, UInt64 &localHeaderOffset, UInt32 &diskStartNumber)
|
213
609
|
{
|
214
610
|
extraBlock.Clear();
|
611
|
+
|
215
612
|
UInt32 remain = extraSize;
|
216
|
-
|
613
|
+
|
614
|
+
while (remain >= 4)
|
217
615
|
{
|
218
616
|
CExtraSubBlock subBlock;
|
219
617
|
subBlock.ID = ReadUInt16();
|
220
|
-
|
618
|
+
unsigned dataSize = ReadUInt16();
|
221
619
|
remain -= 4;
|
222
620
|
if (dataSize > remain) // it's bug
|
223
|
-
|
621
|
+
{
|
622
|
+
HeadersWarning = true;
|
623
|
+
Skip(remain);
|
624
|
+
return false;
|
625
|
+
}
|
224
626
|
if (subBlock.ID == NFileHeader::NExtraID::kZip64)
|
225
627
|
{
|
226
628
|
if (unpackSize == 0xFFFFFFFF)
|
227
629
|
{
|
228
630
|
if (dataSize < 8)
|
229
|
-
|
631
|
+
{
|
632
|
+
HeadersWarning = true;
|
633
|
+
Skip(remain);
|
634
|
+
return false;
|
635
|
+
}
|
230
636
|
unpackSize = ReadUInt64();
|
231
637
|
remain -= 8;
|
232
638
|
dataSize -= 8;
|
@@ -255,8 +661,7 @@ void CInArchive::ReadExtra(UInt32 extraSize, CExtraBlock &extraBlock,
|
|
255
661
|
remain -= 4;
|
256
662
|
dataSize -= 4;
|
257
663
|
}
|
258
|
-
|
259
|
-
ReadByte();
|
664
|
+
Skip(dataSize);
|
260
665
|
}
|
261
666
|
else
|
262
667
|
{
|
@@ -265,155 +670,301 @@ void CInArchive::ReadExtra(UInt32 extraSize, CExtraBlock &extraBlock,
|
|
265
670
|
}
|
266
671
|
remain -= dataSize;
|
267
672
|
}
|
673
|
+
|
674
|
+
if (remain != 0)
|
675
|
+
{
|
676
|
+
ExtraMinorError = true;
|
677
|
+
// 7-Zip before 9.31 created incorrect WsAES Extra in folder's local headers.
|
678
|
+
// so we don't return false, but just set warning flag
|
679
|
+
// return false;
|
680
|
+
}
|
681
|
+
|
268
682
|
Skip(remain);
|
683
|
+
return true;
|
269
684
|
}
|
270
685
|
|
271
|
-
|
686
|
+
|
687
|
+
bool CInArchive::ReadLocalItem(CItemEx &item)
|
272
688
|
{
|
273
|
-
|
274
|
-
|
275
|
-
|
689
|
+
item.Disk = 0;
|
690
|
+
if (IsMultiVol && Vols.StreamIndex >= 0)
|
691
|
+
item.Disk = Vols.StreamIndex;
|
692
|
+
const unsigned kPureHeaderSize = kLocalHeaderSize - 4;
|
693
|
+
Byte p[kPureHeaderSize];
|
694
|
+
SafeReadBytes(p, kPureHeaderSize);
|
695
|
+
{
|
696
|
+
unsigned i;
|
697
|
+
for (i = 0; i < kPureHeaderSize && p[i] == 0; i++);
|
698
|
+
if (i == kPureHeaderSize)
|
699
|
+
return false;
|
700
|
+
}
|
276
701
|
|
277
702
|
item.ExtractVersion.Version = p[0];
|
278
703
|
item.ExtractVersion.HostOS = p[1];
|
279
|
-
item.Flags
|
280
|
-
item.
|
281
|
-
item.Time
|
282
|
-
item.
|
283
|
-
item.PackSize
|
284
|
-
item.
|
285
|
-
|
286
|
-
|
287
|
-
ReadFileName(
|
288
|
-
item.
|
289
|
-
|
704
|
+
G16(2, item.Flags);
|
705
|
+
G16(4, item.Method);
|
706
|
+
G32(6, item.Time);
|
707
|
+
G32(10, item.Crc);
|
708
|
+
G32(14, item.PackSize);
|
709
|
+
G32(18, item.Size);
|
710
|
+
const unsigned nameSize = Get16(p + 22);
|
711
|
+
const unsigned extraSize = Get16(p + 24);
|
712
|
+
ReadFileName(nameSize, item.Name);
|
713
|
+
item.LocalFullHeaderSize = kLocalHeaderSize + (UInt32)nameSize + extraSize;
|
714
|
+
|
715
|
+
/*
|
716
|
+
if (item.IsDir())
|
717
|
+
item.Size = 0; // check It
|
718
|
+
*/
|
719
|
+
|
720
|
+
if (extraSize > 0)
|
290
721
|
{
|
291
722
|
UInt64 localHeaderOffset = 0;
|
292
723
|
UInt32 diskStartNumber = 0;
|
293
|
-
ReadExtra(
|
294
|
-
|
724
|
+
if (!ReadExtra(extraSize, item.LocalExtra, item.Size, item.PackSize,
|
725
|
+
localHeaderOffset, diskStartNumber))
|
726
|
+
{
|
727
|
+
/* Most of archives are OK for Extra. But there are some rare cases
|
728
|
+
that have error. And if error in first item, it can't open archive.
|
729
|
+
So we ignore that error */
|
730
|
+
// return false;
|
731
|
+
}
|
295
732
|
}
|
296
|
-
|
297
|
-
if (item.
|
298
|
-
|
299
|
-
|
300
|
-
|
733
|
+
|
734
|
+
if (!CheckDosTime(item.Time))
|
735
|
+
{
|
736
|
+
HeadersWarning = true;
|
737
|
+
// return false;
|
738
|
+
}
|
739
|
+
|
740
|
+
if (item.Name.Len() != nameSize)
|
741
|
+
{
|
742
|
+
// we support "bad" archives with null-terminated name.
|
743
|
+
if (item.Name.Len() + 1 != nameSize)
|
744
|
+
return false;
|
745
|
+
HeadersWarning = true;
|
746
|
+
}
|
747
|
+
|
748
|
+
return item.LocalFullHeaderSize <= ((UInt32)1 << 16);
|
301
749
|
}
|
302
750
|
|
303
|
-
|
751
|
+
|
752
|
+
static bool FlagsAreSame(const CItem &i1, const CItem &i2)
|
304
753
|
{
|
305
|
-
if (i1.
|
754
|
+
if (i1.Method != i2.Method)
|
306
755
|
return false;
|
307
|
-
// i1.Time
|
308
|
-
|
309
756
|
if (i1.Flags == i2.Flags)
|
310
757
|
return true;
|
311
758
|
UInt32 mask = 0xFFFF;
|
312
|
-
switch(i1.
|
759
|
+
switch (i1.Method)
|
313
760
|
{
|
314
761
|
case NFileHeader::NCompressionMethod::kDeflated:
|
315
762
|
mask = 0x7FF9;
|
316
763
|
break;
|
317
764
|
default:
|
318
|
-
if (i1.
|
765
|
+
if (i1.Method <= NFileHeader::NCompressionMethod::kImploded)
|
319
766
|
mask = 0x7FFF;
|
320
767
|
}
|
768
|
+
|
769
|
+
// we can ignore utf8 flag, if name is ascii
|
770
|
+
if ((i1.Flags ^ i2.Flags) & NFileHeader::NFlags::kUtf8)
|
771
|
+
if (i1.Name.IsAscii() && i2.Name.IsAscii())
|
772
|
+
mask &= ~NFileHeader::NFlags::kUtf8;
|
773
|
+
|
321
774
|
return ((i1.Flags & mask) == (i2.Flags & mask));
|
322
775
|
}
|
323
776
|
|
324
|
-
|
777
|
+
|
778
|
+
// #ifdef _WIN32
|
779
|
+
static bool AreEqualPaths_IgnoreSlashes(const char *s1, const char *s2)
|
325
780
|
{
|
326
|
-
|
327
|
-
return S_OK;
|
328
|
-
try
|
781
|
+
for (;;)
|
329
782
|
{
|
330
|
-
|
331
|
-
|
332
|
-
if (
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
) ||
|
345
|
-
item.Name.Length() != localItem.Name.Length()
|
346
|
-
)
|
347
|
-
return S_FALSE;
|
348
|
-
item.FileHeaderWithNameSize = localItem.FileHeaderWithNameSize;
|
349
|
-
item.LocalExtraSize = localItem.LocalExtraSize;
|
350
|
-
item.LocalExtra = localItem.LocalExtra;
|
351
|
-
item.FromLocal = true;
|
783
|
+
char c1 = *s1++;
|
784
|
+
char c2 = *s2++;
|
785
|
+
if (c1 == c2)
|
786
|
+
{
|
787
|
+
if (c1 == 0)
|
788
|
+
return true;
|
789
|
+
}
|
790
|
+
else
|
791
|
+
{
|
792
|
+
if (c1 == '\\') c1 = '/';
|
793
|
+
if (c2 == '\\') c2 = '/';
|
794
|
+
if (c1 != c2)
|
795
|
+
return false;
|
796
|
+
}
|
352
797
|
}
|
353
|
-
catch(...) { return S_FALSE; }
|
354
|
-
return S_OK;
|
355
798
|
}
|
799
|
+
// #endif
|
356
800
|
|
357
|
-
|
801
|
+
|
802
|
+
static bool AreItemsEqual(const CItemEx &localItem, const CItemEx &cdItem)
|
358
803
|
{
|
359
|
-
if (
|
804
|
+
if (!FlagsAreSame(cdItem, localItem))
|
805
|
+
return false;
|
806
|
+
if (!localItem.HasDescriptor())
|
360
807
|
{
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
808
|
+
if (cdItem.Crc != localItem.Crc ||
|
809
|
+
cdItem.PackSize != localItem.PackSize ||
|
810
|
+
cdItem.Size != localItem.Size)
|
811
|
+
return false;
|
812
|
+
}
|
813
|
+
/* pkzip 2.50 creates incorrect archives. It uses
|
814
|
+
- WIN encoding for name in local header
|
815
|
+
- OEM encoding for name in central header
|
816
|
+
We don't support these strange items. */
|
817
|
+
|
818
|
+
/* if (cdItem.Name.Len() != localItem.Name.Len())
|
819
|
+
return false;
|
820
|
+
*/
|
821
|
+
if (cdItem.Name != localItem.Name)
|
822
|
+
{
|
823
|
+
// #ifdef _WIN32
|
824
|
+
// some xap files use backslash in central dir items.
|
825
|
+
// we can ignore such errors in windows, where all slashes are converted to backslashes
|
826
|
+
unsigned hostOs = cdItem.GetHostOS();
|
827
|
+
|
828
|
+
if (hostOs == NFileHeader::NHostOS::kFAT ||
|
829
|
+
hostOs == NFileHeader::NHostOS::kNTFS)
|
830
|
+
{
|
831
|
+
if (!AreEqualPaths_IgnoreSlashes(cdItem.Name, localItem.Name))
|
832
|
+
{
|
833
|
+
// pkzip 2.50 uses DOS encoding in central dir and WIN encoding in local header.
|
834
|
+
// so we ignore that error
|
835
|
+
if (hostOs != NFileHeader::NHostOS::kFAT
|
836
|
+
|| cdItem.MadeByVersion.Version != 25)
|
837
|
+
return false;
|
838
|
+
}
|
839
|
+
}
|
840
|
+
/*
|
841
|
+
else
|
842
|
+
#endif
|
843
|
+
return false;
|
844
|
+
*/
|
845
|
+
}
|
846
|
+
return true;
|
847
|
+
}
|
848
|
+
|
849
|
+
|
850
|
+
HRESULT CInArchive::ReadLocalItemAfterCdItem(CItemEx &item, bool &isAvail)
|
851
|
+
{
|
852
|
+
isAvail = true;
|
853
|
+
if (item.FromLocal)
|
854
|
+
return S_OK;
|
855
|
+
try
|
856
|
+
{
|
857
|
+
UInt64 offset = item.LocalHeaderPos;
|
858
|
+
|
859
|
+
if (IsMultiVol)
|
860
|
+
{
|
861
|
+
if (item.Disk >= Vols.Streams.Size())
|
862
|
+
{
|
863
|
+
isAvail = false;
|
374
864
|
return S_FALSE;
|
375
|
-
|
376
|
-
|
865
|
+
}
|
866
|
+
IInStream *str2 = Vols.Streams[item.Disk].Stream;
|
867
|
+
if (!str2)
|
377
868
|
{
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
869
|
+
isAvail = false;
|
870
|
+
return S_FALSE;
|
871
|
+
}
|
872
|
+
RINOK(str2->Seek(offset, STREAM_SEEK_SET, NULL));
|
873
|
+
Stream = str2;
|
874
|
+
Vols.StreamIndex = item.Disk;
|
875
|
+
}
|
876
|
+
else
|
877
|
+
{
|
878
|
+
if (UseDisk_in_SingleVol && item.Disk != EcdVolIndex)
|
879
|
+
{
|
880
|
+
isAvail = false;
|
881
|
+
return S_FALSE;
|
882
|
+
}
|
883
|
+
Stream = StreamRef;
|
884
|
+
|
885
|
+
offset += ArcInfo.Base;
|
886
|
+
if (ArcInfo.Base < 0 && (Int64)offset < 0)
|
887
|
+
{
|
888
|
+
isAvail = false;
|
889
|
+
return S_FALSE;
|
890
|
+
}
|
891
|
+
RINOK(Seek(offset));
|
892
|
+
}
|
893
|
+
|
894
|
+
|
895
|
+
CItemEx localItem;
|
896
|
+
if (ReadUInt32() != NSignature::kLocalFileHeader)
|
897
|
+
return S_FALSE;
|
898
|
+
ReadLocalItem(localItem);
|
899
|
+
if (!AreItemsEqual(localItem, item))
|
900
|
+
return S_FALSE;
|
901
|
+
item.LocalFullHeaderSize = localItem.LocalFullHeaderSize;
|
902
|
+
item.LocalExtra = localItem.LocalExtra;
|
903
|
+
item.FromLocal = true;
|
904
|
+
}
|
905
|
+
catch(...) { return S_FALSE; }
|
906
|
+
return S_OK;
|
907
|
+
}
|
908
|
+
|
909
|
+
|
910
|
+
HRESULT CInArchive::ReadLocalItemDescriptor(CItemEx &item)
|
911
|
+
{
|
912
|
+
const unsigned kBufSize = (1 << 12);
|
913
|
+
Byte buf[kBufSize];
|
914
|
+
|
915
|
+
UInt32 numBytesInBuffer = 0;
|
916
|
+
UInt32 packedSize = 0;
|
917
|
+
|
918
|
+
for (;;)
|
919
|
+
{
|
920
|
+
UInt32 processedSize;
|
921
|
+
RINOK(ReadBytes(buf + numBytesInBuffer, kBufSize - numBytesInBuffer, &processedSize));
|
922
|
+
numBytesInBuffer += processedSize;
|
923
|
+
if (numBytesInBuffer < kDataDescriptorSize)
|
924
|
+
return S_FALSE;
|
925
|
+
|
926
|
+
UInt32 i;
|
927
|
+
for (i = 0; i <= numBytesInBuffer - kDataDescriptorSize; i++)
|
928
|
+
{
|
929
|
+
// descriptor signature field is Info-ZIP's extension to pkware Zip specification.
|
930
|
+
// New ZIP specification also allows descriptorSignature.
|
931
|
+
if (buf[i] != 0x50)
|
932
|
+
continue;
|
933
|
+
// !!!! It must be fixed for Zip64 archives
|
934
|
+
if (Get32(buf + i) == NSignature::kDataDescriptor)
|
935
|
+
{
|
936
|
+
UInt32 descriptorPackSize = Get32(buf + i + 8);
|
937
|
+
if (descriptorPackSize == packedSize + i)
|
385
938
|
{
|
386
|
-
|
387
|
-
item.FileCRC = Get32(buffer + i + 4);
|
939
|
+
item.Crc = Get32(buf + i + 4);
|
388
940
|
item.PackSize = descriptorPackSize;
|
389
|
-
item.
|
390
|
-
|
391
|
-
|
941
|
+
item.Size = Get32(buf + i + 12);
|
942
|
+
bool isFinished;
|
943
|
+
return IncreaseRealPosition((Int64)(Int32)(0 - (numBytesInBuffer - i - kDataDescriptorSize)), isFinished);
|
392
944
|
}
|
393
945
|
}
|
394
|
-
if (descriptorWasFound)
|
395
|
-
break;
|
396
|
-
packedSize += i;
|
397
|
-
int j;
|
398
|
-
for (j = 0; i < numBytesInBuffer; i++, j++)
|
399
|
-
buffer[j] = buffer[i];
|
400
|
-
numBytesInBuffer = j;
|
401
946
|
}
|
947
|
+
|
948
|
+
packedSize += i;
|
949
|
+
unsigned j;
|
950
|
+
for (j = 0; i < numBytesInBuffer; i++, j++)
|
951
|
+
buf[j] = buf[i];
|
952
|
+
numBytesInBuffer = j;
|
402
953
|
}
|
403
|
-
else
|
404
|
-
IncreaseRealPosition(item.PackSize);
|
405
|
-
return S_OK;
|
406
954
|
}
|
407
955
|
|
956
|
+
|
408
957
|
HRESULT CInArchive::ReadLocalItemAfterCdItemFull(CItemEx &item)
|
409
958
|
{
|
410
959
|
if (item.FromLocal)
|
411
960
|
return S_OK;
|
412
961
|
try
|
413
962
|
{
|
414
|
-
|
963
|
+
bool isAvail = true;
|
964
|
+
RINOK(ReadLocalItemAfterCdItem(item, isAvail));
|
415
965
|
if (item.HasDescriptor())
|
416
966
|
{
|
967
|
+
// pkzip's version without descriptor is not supported
|
417
968
|
RINOK(Seek(ArcInfo.Base + item.GetDataPosition() + item.PackSize));
|
418
969
|
if (ReadUInt32() != NSignature::kDataDescriptor)
|
419
970
|
return S_FALSE;
|
@@ -433,7 +984,7 @@ HRESULT CInArchive::ReadLocalItemAfterCdItemFull(CItemEx &item)
|
|
433
984
|
unpackSize = ReadUInt32();
|
434
985
|
}
|
435
986
|
|
436
|
-
if (crc != item.
|
987
|
+
if (crc != item.Crc || item.PackSize != packSize || item.Size != unpackSize)
|
437
988
|
return S_FALSE;
|
438
989
|
}
|
439
990
|
}
|
@@ -441,453 +992,1286 @@ HRESULT CInArchive::ReadLocalItemAfterCdItemFull(CItemEx &item)
|
|
441
992
|
return S_OK;
|
442
993
|
}
|
443
994
|
|
995
|
+
|
444
996
|
HRESULT CInArchive::ReadCdItem(CItemEx &item)
|
445
997
|
{
|
446
998
|
item.FromCentral = true;
|
447
|
-
|
448
|
-
|
449
|
-
|
999
|
+
Byte p[kCentralHeaderSize - 4];
|
1000
|
+
SafeReadBytes(p, kCentralHeaderSize - 4);
|
1001
|
+
|
450
1002
|
item.MadeByVersion.Version = p[0];
|
451
1003
|
item.MadeByVersion.HostOS = p[1];
|
452
1004
|
item.ExtractVersion.Version = p[2];
|
453
1005
|
item.ExtractVersion.HostOS = p[3];
|
454
|
-
item.Flags
|
455
|
-
item.
|
456
|
-
item.Time
|
457
|
-
item.
|
458
|
-
item.PackSize
|
459
|
-
item.
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
item.
|
465
|
-
item.
|
466
|
-
item.
|
467
|
-
ReadFileName(
|
468
|
-
|
469
|
-
if (headerExtraSize > 0)
|
470
|
-
{
|
471
|
-
ReadExtra(headerExtraSize, item.CentralExtra, item.UnPackSize, item.PackSize,
|
472
|
-
item.LocalHeaderPosition, headerDiskNumberStart);
|
473
|
-
}
|
474
|
-
|
475
|
-
if (headerDiskNumberStart != 0)
|
476
|
-
throw CInArchiveException(CInArchiveException::kMultiVolumeArchiveAreNotSupported);
|
1006
|
+
G16(4, item.Flags);
|
1007
|
+
G16(6, item.Method);
|
1008
|
+
G32(8, item.Time);
|
1009
|
+
G32(12, item.Crc);
|
1010
|
+
G32(16, item.PackSize);
|
1011
|
+
G32(20, item.Size);
|
1012
|
+
const unsigned nameSize = Get16(p + 24);
|
1013
|
+
const unsigned extraSize = Get16(p + 26);
|
1014
|
+
const unsigned commentSize = Get16(p + 28);
|
1015
|
+
G16(30, item.Disk);
|
1016
|
+
G16(32, item.InternalAttrib);
|
1017
|
+
G32(34, item.ExternalAttrib);
|
1018
|
+
G32(38, item.LocalHeaderPos);
|
1019
|
+
ReadFileName(nameSize, item.Name);
|
477
1020
|
|
1021
|
+
if (extraSize > 0)
|
1022
|
+
ReadExtra(extraSize, item.CentralExtra, item.Size, item.PackSize, item.LocalHeaderPos, item.Disk);
|
1023
|
+
|
478
1024
|
// May be these strings must be deleted
|
479
1025
|
/*
|
480
1026
|
if (item.IsDir())
|
481
|
-
item.
|
1027
|
+
item.Size = 0;
|
482
1028
|
*/
|
483
1029
|
|
484
|
-
ReadBuffer(item.Comment,
|
1030
|
+
ReadBuffer(item.Comment, commentSize);
|
485
1031
|
return S_OK;
|
486
1032
|
}
|
487
1033
|
|
1034
|
+
|
488
1035
|
HRESULT CInArchive::TryEcd64(UInt64 offset, CCdInfo &cdInfo)
|
489
1036
|
{
|
1037
|
+
if (offset >= ((UInt64)1 << 63))
|
1038
|
+
return S_FALSE;
|
490
1039
|
RINOK(Seek(offset));
|
491
|
-
|
492
|
-
|
493
|
-
|
1040
|
+
Byte buf[kEcd64_FullSize];
|
1041
|
+
|
1042
|
+
RINOK(ReadStream_FALSE(Stream, buf, kEcd64_FullSize));
|
1043
|
+
|
1044
|
+
if (Get32(buf) != NSignature::kEcd64)
|
494
1045
|
return S_FALSE;
|
495
|
-
|
1046
|
+
UInt64 mainSize = Get64(buf + 4);
|
1047
|
+
if (mainSize < kEcd64_MainSize || mainSize > ((UInt64)1 << 32))
|
496
1048
|
return S_FALSE;
|
497
|
-
|
498
|
-
cdInfo.Size = Get64(buf + 40);
|
499
|
-
cdInfo.Offset = Get64(buf + 48);
|
1049
|
+
cdInfo.ParseEcd64e(buf + 12);
|
500
1050
|
return S_OK;
|
501
1051
|
}
|
502
1052
|
|
503
|
-
|
1053
|
+
|
1054
|
+
HRESULT CInArchive::FindCd(bool checkOffsetMode)
|
504
1055
|
{
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
UInt32
|
1056
|
+
CCdInfo &cdInfo = Vols.ecd;
|
1057
|
+
|
1058
|
+
UInt64 endPos;
|
1059
|
+
|
1060
|
+
RINOK(Stream->Seek(0, STREAM_SEEK_END, &endPos));
|
1061
|
+
|
1062
|
+
const UInt32 kBufSizeMax = ((UInt32)1 << 16) + kEcdSize + kEcd64Locator_Size + kEcd64_FullSize;
|
1063
|
+
const UInt32 bufSize = (endPos < kBufSizeMax) ? (UInt32)endPos : kBufSizeMax;
|
512
1064
|
if (bufSize < kEcdSize)
|
513
1065
|
return S_FALSE;
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
if (
|
1066
|
+
CByteArr byteBuffer(bufSize);
|
1067
|
+
|
1068
|
+
const UInt64 startPos = endPos - bufSize;
|
1069
|
+
RINOK(Stream->Seek(startPos, STREAM_SEEK_SET, &m_Position));
|
1070
|
+
if (m_Position != startPos)
|
519
1071
|
return S_FALSE;
|
520
|
-
|
1072
|
+
|
1073
|
+
RINOK(ReadStream_FALSE(Stream, byteBuffer, bufSize));
|
1074
|
+
|
1075
|
+
for (UInt32 i = bufSize - kEcdSize + 1;;)
|
521
1076
|
{
|
522
|
-
if (
|
1077
|
+
if (i == 0)
|
1078
|
+
return S_FALSE;
|
1079
|
+
|
1080
|
+
const Byte *buf = byteBuffer;
|
1081
|
+
|
1082
|
+
for (;;)
|
1083
|
+
{
|
1084
|
+
i--;
|
1085
|
+
if (buf[i] == 0x50)
|
1086
|
+
break;
|
1087
|
+
if (i == 0)
|
1088
|
+
return S_FALSE;
|
1089
|
+
}
|
1090
|
+
|
1091
|
+
if (Get32(buf + i) != NSignature::kEcd)
|
1092
|
+
continue;
|
1093
|
+
|
1094
|
+
cdInfo.ParseEcd32(buf + i);
|
1095
|
+
|
1096
|
+
if (i >= kEcd64Locator_Size)
|
523
1097
|
{
|
524
|
-
|
1098
|
+
const Byte *locatorPtr = buf + i - kEcd64Locator_Size;
|
1099
|
+
if (Get32(locatorPtr) == NSignature::kEcd64Locator)
|
525
1100
|
{
|
526
|
-
|
527
|
-
|
1101
|
+
CLocator locator;
|
1102
|
+
locator.Parse(locatorPtr + 4);
|
1103
|
+
if ((cdInfo.ThisDisk == locator.NumDisks - 1 || cdInfo.ThisDisk == 0xFFFF)
|
1104
|
+
&& locator.Ecd64Disk < locator.NumDisks)
|
528
1105
|
{
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
1106
|
+
if (locator.Ecd64Disk != cdInfo.ThisDisk && cdInfo.ThisDisk != 0xFFFF)
|
1107
|
+
return E_NOTIMPL;
|
1108
|
+
|
1109
|
+
// Most of the zip64 use fixed size Zip64 ECD
|
1110
|
+
// we try relative backward reading.
|
1111
|
+
|
1112
|
+
UInt64 absEcd64 = endPos - bufSize + i - (kEcd64Locator_Size + kEcd64_FullSize);
|
1113
|
+
if (checkOffsetMode || absEcd64 == locator.Ecd64Offset)
|
1114
|
+
{
|
1115
|
+
const Byte *ecd64 = locatorPtr - kEcd64_FullSize;
|
1116
|
+
if (Get32(ecd64) == NSignature::kEcd64)
|
1117
|
+
{
|
1118
|
+
UInt64 mainEcd64Size = Get64(ecd64 + 4);
|
1119
|
+
if (mainEcd64Size == kEcd64_MainSize)
|
1120
|
+
{
|
1121
|
+
cdInfo.ParseEcd64e(ecd64 + 12);
|
1122
|
+
ArcInfo.Base = absEcd64 - locator.Ecd64Offset;
|
1123
|
+
// ArcInfo.BaseVolIndex = cdInfo.ThisDisk;
|
1124
|
+
return S_OK;
|
1125
|
+
}
|
1126
|
+
}
|
1127
|
+
}
|
1128
|
+
|
1129
|
+
// some zip64 use variable size Zip64 ECD.
|
1130
|
+
// we try to use absolute offset from locator.
|
1131
|
+
|
1132
|
+
if (absEcd64 != locator.Ecd64Offset)
|
1133
|
+
{
|
1134
|
+
if (TryEcd64(locator.Ecd64Offset, cdInfo) == S_OK)
|
1135
|
+
{
|
1136
|
+
ArcInfo.Base = 0;
|
1137
|
+
// ArcInfo.BaseVolIndex = cdInfo.ThisDisk;
|
1138
|
+
return S_OK;
|
1139
|
+
}
|
1140
|
+
}
|
1141
|
+
|
1142
|
+
// for variable Zip64 ECD with for archives with offset != 0.
|
1143
|
+
|
1144
|
+
if (checkOffsetMode
|
1145
|
+
&& ArcInfo.MarkerPos != 0
|
1146
|
+
&& ArcInfo.MarkerPos + locator.Ecd64Offset != absEcd64)
|
533
1147
|
{
|
534
|
-
ArcInfo.
|
535
|
-
|
1148
|
+
if (TryEcd64(ArcInfo.MarkerPos + locator.Ecd64Offset, cdInfo) == S_OK)
|
1149
|
+
{
|
1150
|
+
ArcInfo.Base = ArcInfo.MarkerPos;
|
1151
|
+
// ArcInfo.BaseVolIndex = cdInfo.ThisDisk;
|
1152
|
+
return S_OK;
|
1153
|
+
}
|
536
1154
|
}
|
537
1155
|
}
|
538
1156
|
}
|
539
|
-
|
1157
|
+
}
|
1158
|
+
|
1159
|
+
// bool isVolMode = (Vols.EndVolIndex != -1);
|
1160
|
+
// UInt32 searchDisk = (isVolMode ? Vols.EndVolIndex : 0);
|
1161
|
+
|
1162
|
+
if (/* searchDisk == thisDisk && */ cdInfo.CdDisk <= cdInfo.ThisDisk)
|
1163
|
+
{
|
1164
|
+
// if (isVolMode)
|
540
1165
|
{
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
1166
|
+
if (cdInfo.CdDisk != cdInfo.ThisDisk)
|
1167
|
+
return S_OK;
|
1168
|
+
}
|
1169
|
+
|
1170
|
+
UInt64 absEcdPos = endPos - bufSize + i;
|
1171
|
+
UInt64 cdEnd = cdInfo.Size + cdInfo.Offset;
|
1172
|
+
ArcInfo.Base = 0;
|
1173
|
+
// ArcInfo.BaseVolIndex = cdInfo.ThisDisk;
|
1174
|
+
if (absEcdPos != cdEnd)
|
1175
|
+
{
|
1176
|
+
/*
|
1177
|
+
if (cdInfo.Offset <= 16 && cdInfo.Size != 0)
|
547
1178
|
{
|
548
|
-
|
549
|
-
|
550
|
-
{
|
551
|
-
// here we support some rare ZIP files with Central directory at the start
|
552
|
-
ArcInfo.Base = 0;
|
553
|
-
}
|
554
|
-
else
|
555
|
-
*/
|
556
|
-
ArcInfo.Base = curPos - cdEnd;
|
1179
|
+
// here we support some rare ZIP files with Central directory at the start
|
1180
|
+
ArcInfo.Base = 0;
|
557
1181
|
}
|
558
|
-
|
1182
|
+
else
|
1183
|
+
*/
|
1184
|
+
ArcInfo.Base = absEcdPos - cdEnd;
|
559
1185
|
}
|
1186
|
+
return S_OK;
|
560
1187
|
}
|
561
1188
|
}
|
562
|
-
return S_FALSE;
|
563
1189
|
}
|
564
1190
|
|
565
|
-
|
1191
|
+
|
1192
|
+
HRESULT CInArchive::TryReadCd(CObjectVector<CItemEx> &items, const CCdInfo &cdInfo, UInt64 cdOffset, UInt64 cdSize)
|
566
1193
|
{
|
567
1194
|
items.Clear();
|
568
|
-
RINOK(m_Stream->Seek(cdOffset, STREAM_SEEK_SET, &m_Position));
|
569
|
-
if (m_Position != cdOffset)
|
570
|
-
return S_FALSE;
|
571
1195
|
|
572
|
-
|
573
|
-
|
574
|
-
|
1196
|
+
ISequentialInStream *stream;
|
1197
|
+
|
1198
|
+
if (!IsMultiVol)
|
1199
|
+
{
|
1200
|
+
stream = this->StartStream;
|
1201
|
+
Vols.StreamIndex = -1;
|
1202
|
+
RINOK(this->StartStream->Seek(cdOffset, STREAM_SEEK_SET, &m_Position));
|
1203
|
+
if (m_Position != cdOffset)
|
1204
|
+
return S_FALSE;
|
1205
|
+
}
|
1206
|
+
else
|
1207
|
+
{
|
1208
|
+
if (cdInfo.CdDisk >= Vols.Streams.Size())
|
1209
|
+
return S_FALSE;
|
1210
|
+
IInStream *str2 = Vols.Streams[cdInfo.CdDisk].Stream;
|
1211
|
+
if (!str2)
|
1212
|
+
return S_FALSE;
|
1213
|
+
RINOK(str2->Seek(cdOffset, STREAM_SEEK_SET, NULL));
|
1214
|
+
stream = str2;
|
1215
|
+
Vols.NeedSeek = false;
|
1216
|
+
Vols.StreamIndex = cdInfo.CdDisk;
|
1217
|
+
m_Position = cdOffset;
|
1218
|
+
}
|
1219
|
+
|
1220
|
+
_inBuffer.SetStream(stream);
|
1221
|
+
|
575
1222
|
_inBuffer.Init();
|
576
1223
|
_inBufMode = true;
|
577
1224
|
|
578
|
-
|
1225
|
+
_processedCnt = 0;
|
1226
|
+
|
1227
|
+
while (_processedCnt < cdSize)
|
579
1228
|
{
|
1229
|
+
CanStartNewVol = true;
|
580
1230
|
if (ReadUInt32() != NSignature::kCentralFileHeader)
|
581
1231
|
return S_FALSE;
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
1232
|
+
{
|
1233
|
+
CItemEx cdItem;
|
1234
|
+
RINOK(ReadCdItem(cdItem));
|
1235
|
+
items.Add(cdItem);
|
1236
|
+
}
|
1237
|
+
if (Callback && (items.Size() & 0xFFF) == 0)
|
1238
|
+
{
|
1239
|
+
const UInt64 numFiles = items.Size();
|
1240
|
+
RINOK(Callback->SetCompleted(&numFiles, NULL));
|
1241
|
+
}
|
587
1242
|
}
|
588
|
-
|
1243
|
+
|
1244
|
+
CanStartNewVol = true;
|
1245
|
+
|
1246
|
+
return (_processedCnt == cdSize) ? S_OK : S_FALSE;
|
589
1247
|
}
|
590
1248
|
|
591
|
-
|
1249
|
+
|
1250
|
+
HRESULT CInArchive::ReadCd(CObjectVector<CItemEx> &items, UInt32 &cdDisk, UInt64 &cdOffset, UInt64 &cdSize)
|
592
1251
|
{
|
593
|
-
|
594
|
-
|
595
|
-
|
1252
|
+
bool checkOffsetMode = true;
|
1253
|
+
|
1254
|
+
if (IsMultiVol)
|
1255
|
+
{
|
1256
|
+
if (Vols.EndVolIndex == -1)
|
1257
|
+
return S_FALSE;
|
1258
|
+
Stream = Vols.Streams[Vols.EndVolIndex].Stream;
|
1259
|
+
if (!Vols.StartIsZip)
|
1260
|
+
checkOffsetMode = false;
|
1261
|
+
}
|
1262
|
+
else
|
1263
|
+
Stream = StartStream;
|
1264
|
+
|
1265
|
+
if (!Vols.ecd_wasRead)
|
1266
|
+
{
|
1267
|
+
RINOK(FindCd(checkOffsetMode));
|
1268
|
+
}
|
1269
|
+
|
1270
|
+
CCdInfo &cdInfo = Vols.ecd;
|
1271
|
+
|
596
1272
|
HRESULT res = S_FALSE;
|
1273
|
+
|
597
1274
|
cdSize = cdInfo.Size;
|
598
1275
|
cdOffset = cdInfo.Offset;
|
599
|
-
|
600
|
-
|
1276
|
+
cdDisk = cdInfo.CdDisk;
|
1277
|
+
|
1278
|
+
if (Callback)
|
1279
|
+
{
|
1280
|
+
RINOK(Callback->SetTotal(&cdInfo.NumEntries, NULL));
|
1281
|
+
}
|
1282
|
+
|
1283
|
+
const UInt64 base = (IsMultiVol ? 0 : ArcInfo.Base);
|
1284
|
+
res = TryReadCd(items, cdInfo, base + cdOffset, cdSize);
|
1285
|
+
|
1286
|
+
if (res == S_FALSE && !IsMultiVol && base != ArcInfo.MarkerPos)
|
601
1287
|
{
|
602
|
-
|
1288
|
+
// do we need that additional attempt to read cd?
|
1289
|
+
res = TryReadCd(items, cdInfo, ArcInfo.MarkerPos + cdOffset, cdSize);
|
603
1290
|
if (res == S_OK)
|
604
|
-
ArcInfo.Base = ArcInfo.
|
1291
|
+
ArcInfo.Base = ArcInfo.MarkerPos;
|
605
1292
|
}
|
606
|
-
|
607
|
-
return S_FALSE;
|
1293
|
+
|
608
1294
|
return res;
|
609
1295
|
}
|
610
1296
|
|
611
|
-
|
1297
|
+
|
1298
|
+
static int FindItem(const CObjectVector<CItemEx> &items, const CItemEx &item)
|
612
1299
|
{
|
613
|
-
items.
|
614
|
-
|
615
|
-
while (m_Signature == NSignature::kLocalFileHeader)
|
1300
|
+
unsigned left = 0, right = items.Size();
|
1301
|
+
for (;;)
|
616
1302
|
{
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
if (
|
626
|
-
|
627
|
-
if (
|
628
|
-
|
1303
|
+
if (left >= right)
|
1304
|
+
return -1;
|
1305
|
+
unsigned index = (left + right) / 2;
|
1306
|
+
const CItemEx &item2 = items[index];
|
1307
|
+
if (item.Disk < item2.Disk)
|
1308
|
+
right = index;
|
1309
|
+
else if (item.Disk > item2.Disk)
|
1310
|
+
left = index + 1;
|
1311
|
+
else if (item.LocalHeaderPos == item2.LocalHeaderPos)
|
1312
|
+
return index;
|
1313
|
+
else if (item.LocalHeaderPos < item2.LocalHeaderPos)
|
1314
|
+
right = index;
|
1315
|
+
else
|
1316
|
+
left = index + 1;
|
629
1317
|
}
|
630
|
-
|
631
|
-
int i;
|
632
|
-
for (i = 0; i < items.Size(); i++, numCdItems++)
|
633
|
-
{
|
634
|
-
if (progress && i % 1000 == 0)
|
635
|
-
RINOK(progress->SetCompleted(items.Size()));
|
636
|
-
if (m_Signature == NSignature::kEndOfCentralDir)
|
637
|
-
break;
|
1318
|
+
}
|
638
1319
|
|
639
|
-
|
640
|
-
|
1320
|
+
static bool IsStrangeItem(const CItem &item)
|
1321
|
+
{
|
1322
|
+
return item.Name.Len() > (1 << 14) || item.Method > (1 << 8);
|
1323
|
+
}
|
641
1324
|
|
642
|
-
CItemEx cdItem;
|
643
|
-
RINOK(ReadCdItem(cdItem));
|
644
1325
|
|
645
|
-
|
1326
|
+
HRESULT CInArchive::ReadLocals(CObjectVector<CItemEx> &items)
|
1327
|
+
{
|
1328
|
+
items.Clear();
|
1329
|
+
|
1330
|
+
while (m_Signature == NSignature::kLocalFileHeader)
|
1331
|
+
{
|
1332
|
+
CItemEx item;
|
1333
|
+
item.LocalHeaderPos = m_Position - 4;
|
1334
|
+
if (!IsMultiVol)
|
1335
|
+
item.LocalHeaderPos -= ArcInfo.MarkerPos;
|
1336
|
+
|
1337
|
+
// we write ralative LocalHeaderPos here. Later we can correct it to real Base.
|
1338
|
+
|
1339
|
+
try
|
646
1340
|
{
|
647
|
-
|
648
|
-
|
1341
|
+
ReadLocalItem(item);
|
1342
|
+
item.FromLocal = true;
|
1343
|
+
bool isFinished = false;
|
1344
|
+
|
1345
|
+
if (item.HasDescriptor())
|
1346
|
+
ReadLocalItemDescriptor(item);
|
1347
|
+
else
|
649
1348
|
{
|
650
|
-
|
651
|
-
if (
|
1349
|
+
/*
|
1350
|
+
if (IsMultiVol)
|
652
1351
|
{
|
653
|
-
|
654
|
-
|
1352
|
+
const int kStep = 10000;
|
1353
|
+
RINOK(IncreaseRealPosition(-kStep, isFinished));
|
1354
|
+
RINOK(IncreaseRealPosition(item.PackSize + kStep, isFinished));
|
655
1355
|
}
|
1356
|
+
else
|
1357
|
+
*/
|
1358
|
+
RINOK(IncreaseRealPosition(item.PackSize, isFinished));
|
656
1359
|
}
|
657
|
-
|
658
|
-
|
1360
|
+
|
1361
|
+
items.Add(item);
|
1362
|
+
|
1363
|
+
if (isFinished)
|
1364
|
+
throw CUnexpectEnd();
|
1365
|
+
|
1366
|
+
m_Signature = ReadUInt32();
|
659
1367
|
}
|
660
|
-
|
661
|
-
int index;
|
662
|
-
int left = 0, right = items.Size();
|
663
|
-
for (;;)
|
1368
|
+
catch (CUnexpectEnd &)
|
664
1369
|
{
|
665
|
-
if (
|
1370
|
+
if (items.IsEmpty() || items.Size() == 1 && IsStrangeItem(items[0]))
|
666
1371
|
return S_FALSE;
|
667
|
-
|
668
|
-
UInt64 position = items[index].LocalHeaderPosition - ArcInfo.Base;
|
669
|
-
if (cdItem.LocalHeaderPosition == position)
|
670
|
-
break;
|
671
|
-
if (cdItem.LocalHeaderPosition < position)
|
672
|
-
right = index;
|
673
|
-
else
|
674
|
-
left = index + 1;
|
1372
|
+
throw;
|
675
1373
|
}
|
676
|
-
CItemEx &item = items[index];
|
677
|
-
// item.LocalHeaderPosition = cdItem.LocalHeaderPosition;
|
678
|
-
item.MadeByVersion = cdItem.MadeByVersion;
|
679
|
-
item.CentralExtra = cdItem.CentralExtra;
|
680
1374
|
|
681
|
-
if (
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
1375
|
+
if (Callback && (items.Size() & 0xFF) == 0)
|
1376
|
+
{
|
1377
|
+
const UInt64 numFiles = items.Size();
|
1378
|
+
UInt64 numBytes = 0;
|
1379
|
+
// if (!sMultiVol)
|
1380
|
+
numBytes = item.LocalHeaderPos;
|
1381
|
+
RINOK(Callback->SetCompleted(&numFiles, &numBytes));
|
1382
|
+
}
|
1383
|
+
}
|
686
1384
|
|
687
|
-
|
688
|
-
|
689
|
-
item.UnPackSize != cdItem.UnPackSize
|
690
|
-
)
|
691
|
-
return S_FALSE;
|
692
|
-
item.Name = cdItem.Name;
|
693
|
-
item.InternalAttributes = cdItem.InternalAttributes;
|
694
|
-
item.ExternalAttributes = cdItem.ExternalAttributes;
|
695
|
-
item.Comment = cdItem.Comment;
|
696
|
-
item.FromCentral = cdItem.FromCentral;
|
697
|
-
if (!ReadUInt32(m_Signature))
|
1385
|
+
if (items.Size() == 1 && m_Signature != NSignature::kCentralFileHeader)
|
1386
|
+
if (IsStrangeItem(items[0]))
|
698
1387
|
return S_FALSE;
|
699
|
-
|
700
|
-
for (i = 0; i < items.Size(); i++)
|
701
|
-
items[i].LocalHeaderPosition -= ArcInfo.Base;
|
1388
|
+
|
702
1389
|
return S_OK;
|
703
1390
|
}
|
704
1391
|
|
705
|
-
struct CEcd
|
706
|
-
{
|
707
|
-
UInt16 thisDiskNumber;
|
708
|
-
UInt16 startCDDiskNumber;
|
709
|
-
UInt16 numEntriesInCDOnThisDisk;
|
710
|
-
UInt16 numEntriesInCD;
|
711
|
-
UInt32 cdSize;
|
712
|
-
UInt32 cdStartOffset;
|
713
|
-
UInt16 commentSize;
|
714
|
-
void Parse(const Byte *p);
|
715
|
-
};
|
716
1392
|
|
717
|
-
void CEcd::Parse(const Byte *p)
|
718
|
-
{
|
719
|
-
thisDiskNumber = Get16(p);
|
720
|
-
startCDDiskNumber = Get16(p + 2);
|
721
|
-
numEntriesInCDOnThisDisk = Get16(p + 4);
|
722
|
-
numEntriesInCD = Get16(p + 6);
|
723
|
-
cdSize = Get32(p + 8);
|
724
|
-
cdStartOffset = Get32(p + 12);
|
725
|
-
commentSize = Get16(p + 16);
|
726
|
-
}
|
727
|
-
|
728
|
-
struct CEcd64
|
729
|
-
{
|
730
|
-
UInt16 versionMade;
|
731
|
-
UInt16 versionNeedExtract;
|
732
|
-
UInt32 thisDiskNumber;
|
733
|
-
UInt32 startCDDiskNumber;
|
734
|
-
UInt64 numEntriesInCDOnThisDisk;
|
735
|
-
UInt64 numEntriesInCD;
|
736
|
-
UInt64 cdSize;
|
737
|
-
UInt64 cdStartOffset;
|
738
|
-
void Parse(const Byte *p);
|
739
|
-
CEcd64() { memset(this, 0, sizeof(*this)); }
|
740
|
-
};
|
741
1393
|
|
742
|
-
|
1394
|
+
HRESULT CVols::ParseArcName(IArchiveOpenVolumeCallback *volCallback)
|
743
1395
|
{
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
}
|
1396
|
+
UString name;
|
1397
|
+
{
|
1398
|
+
NWindows::NCOM::CPropVariant prop;
|
1399
|
+
RINOK(volCallback->GetProperty(kpidName, &prop));
|
1400
|
+
if (prop.vt != VT_BSTR)
|
1401
|
+
return S_OK;
|
1402
|
+
name = prop.bstrVal;
|
1403
|
+
}
|
753
1404
|
|
754
|
-
|
755
|
-
|
1405
|
+
UString base = name;
|
1406
|
+
int dotPos = name.ReverseFind_Dot();
|
756
1407
|
|
757
|
-
|
758
|
-
|
759
|
-
// m_Signature must be kLocalFileHeaderSignature or
|
760
|
-
// kEndOfCentralDirSignature
|
761
|
-
// m_Position points to next byte after signature
|
1408
|
+
if (dotPos < 0)
|
1409
|
+
return S_OK;
|
762
1410
|
|
763
|
-
|
764
|
-
items.Clear();
|
1411
|
+
base.DeleteFrom(dotPos + 1);
|
765
1412
|
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
catch(CInArchiveException &)
|
1413
|
+
const UString ext = name.Ptr(dotPos + 1);
|
1414
|
+
StartVolIndex = (Int32)(-1);
|
1415
|
+
|
1416
|
+
if (ext.IsEmpty())
|
1417
|
+
return S_OK;
|
1418
|
+
else
|
773
1419
|
{
|
774
|
-
|
1420
|
+
wchar_t c = ext[0];
|
1421
|
+
IsUpperCase = (c >= 'A' && c <= 'Z');
|
1422
|
+
if (ext.IsEqualTo_Ascii_NoCase("zip"))
|
1423
|
+
{
|
1424
|
+
BaseName = base;
|
1425
|
+
StartIsZ = true;
|
1426
|
+
StartIsZip = true;
|
1427
|
+
return S_OK;
|
1428
|
+
}
|
1429
|
+
else if (ext.IsEqualTo_Ascii_NoCase("exe"))
|
1430
|
+
{
|
1431
|
+
StartIsExe = true;
|
1432
|
+
BaseName = base;
|
1433
|
+
StartVolIndex = 0;
|
1434
|
+
}
|
1435
|
+
else if (ext[0] == 'z' || ext[0] == 'Z')
|
1436
|
+
{
|
1437
|
+
if (ext.Len() < 3)
|
1438
|
+
return S_OK;
|
1439
|
+
const wchar_t *end = NULL;
|
1440
|
+
UInt32 volNum = ConvertStringToUInt32(ext.Ptr(1), &end);
|
1441
|
+
if (*end != 0 || volNum < 1 || volNum > ((UInt32)1 << 30))
|
1442
|
+
return S_OK;
|
1443
|
+
StartVolIndex = volNum - 1;
|
1444
|
+
BaseName = base;
|
1445
|
+
StartIsZ = true;
|
1446
|
+
}
|
1447
|
+
else
|
1448
|
+
return S_OK;
|
775
1449
|
}
|
776
|
-
if (res != S_FALSE && res != S_OK)
|
777
|
-
return res;
|
778
|
-
|
779
|
-
/*
|
780
|
-
if (res != S_OK)
|
781
|
-
return res;
|
782
|
-
res = S_FALSE;
|
783
|
-
*/
|
784
1450
|
|
785
|
-
|
786
|
-
|
1451
|
+
UString volName = BaseName;
|
1452
|
+
volName.AddAscii(IsUpperCase ? "ZIP" : "zip");
|
1453
|
+
HRESULT result = volCallback->GetStream(volName, &ZipStream);
|
1454
|
+
if (result == S_FALSE || !ZipStream)
|
787
1455
|
{
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
if (m_Position != ArcInfo.StartPosition)
|
792
|
-
return S_FALSE;
|
793
|
-
if (!ReadUInt32(m_Signature))
|
794
|
-
return S_FALSE;
|
795
|
-
RINOK(ReadLocalsAndCd(items, progress, cdStartOffset, numCdItems));
|
796
|
-
cdSize = (m_Position - 4) - cdStartOffset;
|
797
|
-
cdStartOffset -= ArcInfo.Base;
|
1456
|
+
if (MissingName.IsEmpty())
|
1457
|
+
MissingName = volName;
|
1458
|
+
return S_OK;
|
798
1459
|
}
|
799
1460
|
|
800
|
-
|
801
|
-
|
802
|
-
UInt64 zip64EcdStartOffset = m_Position - 4 - ArcInfo.Base;
|
803
|
-
if (m_Signature == NSignature::kZip64EndOfCentralDir)
|
804
|
-
{
|
805
|
-
IsZip64 = isZip64 = true;
|
806
|
-
UInt64 recordSize = ReadUInt64();
|
1461
|
+
return result;
|
1462
|
+
}
|
807
1463
|
|
808
|
-
const int kBufSize = kZip64EcdSize;
|
809
|
-
Byte buf[kBufSize];
|
810
|
-
SafeReadBytes(buf, kBufSize);
|
811
|
-
ecd64.Parse(buf);
|
812
1464
|
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
ecd64.numEntriesInCD != numCdItems ||
|
820
|
-
ecd64.cdSize != cdSize ||
|
821
|
-
(ecd64.cdStartOffset != cdStartOffset &&
|
822
|
-
(!items.IsEmpty())))
|
823
|
-
return S_FALSE;
|
824
|
-
}
|
825
|
-
if (m_Signature == NSignature::kZip64EndOfCentralDirLocator)
|
1465
|
+
HRESULT CInArchive::ReadVols2(IArchiveOpenVolumeCallback *volCallback,
|
1466
|
+
unsigned start, int lastDisk, int zipDisk, unsigned numMissingVolsMax, unsigned &numMissingVols)
|
1467
|
+
{
|
1468
|
+
numMissingVols = 0;
|
1469
|
+
|
1470
|
+
for (unsigned i = start;; i++)
|
826
1471
|
{
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
if (
|
831
|
-
|
832
|
-
|
833
|
-
return S_FALSE;
|
834
|
-
}
|
835
|
-
if (m_Signature != NSignature::kEndOfCentralDir)
|
836
|
-
return S_FALSE;
|
1472
|
+
if (lastDisk >= 0 && i >= (unsigned)lastDisk)
|
1473
|
+
break;
|
1474
|
+
|
1475
|
+
if (i < Vols.Streams.Size())
|
1476
|
+
if (Vols.Streams[i].Stream)
|
1477
|
+
continue;
|
837
1478
|
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
1479
|
+
CMyComPtr<IInStream> stream;
|
1480
|
+
|
1481
|
+
if ((int)i == zipDisk)
|
1482
|
+
{
|
1483
|
+
stream = Vols.ZipStream;
|
1484
|
+
}
|
1485
|
+
else if ((int)i == Vols.StartVolIndex)
|
1486
|
+
{
|
1487
|
+
stream = StartStream;
|
1488
|
+
}
|
1489
|
+
else
|
1490
|
+
{
|
1491
|
+
UString volName = Vols.BaseName;
|
1492
|
+
{
|
1493
|
+
volName += (wchar_t)(Vols.IsUpperCase ? 'Z' : 'z');
|
1494
|
+
{
|
1495
|
+
char s[32];
|
1496
|
+
ConvertUInt32ToString(i + 1, s);
|
1497
|
+
unsigned len = (unsigned)strlen(s);
|
1498
|
+
while (len < 2)
|
1499
|
+
{
|
1500
|
+
volName += (wchar_t)'0';
|
1501
|
+
len++;
|
1502
|
+
}
|
1503
|
+
volName.AddAscii(s);
|
1504
|
+
}
|
1505
|
+
}
|
1506
|
+
|
1507
|
+
HRESULT result = volCallback->GetStream(volName, &stream);
|
1508
|
+
if (result != S_OK && result != S_FALSE)
|
1509
|
+
return result;
|
1510
|
+
if (result == S_FALSE || !stream)
|
1511
|
+
{
|
1512
|
+
if (Vols.MissingName.IsEmpty())
|
1513
|
+
Vols.MissingName = volName;
|
1514
|
+
numMissingVols++;
|
1515
|
+
if (numMissingVols > numMissingVolsMax)
|
1516
|
+
return S_OK;
|
1517
|
+
if (lastDisk == -1 && numMissingVols != 0)
|
1518
|
+
return S_OK;
|
1519
|
+
continue;
|
1520
|
+
}
|
1521
|
+
}
|
1522
|
+
|
1523
|
+
UInt64 size;
|
1524
|
+
|
1525
|
+
UInt64 pos;
|
1526
|
+
RINOK(stream->Seek(0, STREAM_SEEK_CUR, &pos));
|
1527
|
+
RINOK(stream->Seek(0, STREAM_SEEK_END, &size));
|
1528
|
+
RINOK(stream->Seek(pos, STREAM_SEEK_SET, NULL));
|
1529
|
+
|
1530
|
+
while (i >= Vols.Streams.Size())
|
1531
|
+
Vols.Streams.AddNew();
|
1532
|
+
|
1533
|
+
CVols::CSubStreamInfo &ss = Vols.Streams[i];
|
1534
|
+
Vols.NumVols++;
|
1535
|
+
ss.Stream = stream;
|
1536
|
+
ss.Size = size;
|
1537
|
+
|
1538
|
+
if ((int)i == zipDisk)
|
1539
|
+
{
|
1540
|
+
Vols.EndVolIndex = Vols.Streams.Size() - 1;
|
1541
|
+
break;
|
1542
|
+
}
|
1543
|
+
}
|
1544
|
+
|
1545
|
+
return S_OK;
|
1546
|
+
}
|
1547
|
+
|
1548
|
+
|
1549
|
+
HRESULT CInArchive::ReadVols()
|
1550
|
+
{
|
1551
|
+
CMyComPtr<IArchiveOpenVolumeCallback> volCallback;
|
1552
|
+
|
1553
|
+
Callback->QueryInterface(IID_IArchiveOpenVolumeCallback, (void **)&volCallback);
|
1554
|
+
if (!volCallback)
|
1555
|
+
return S_OK;
|
1556
|
+
|
1557
|
+
RINOK(Vols.ParseArcName(volCallback));
|
1558
|
+
|
1559
|
+
int startZIndex = Vols.StartVolIndex;
|
1560
|
+
|
1561
|
+
if (!Vols.StartIsZ)
|
1562
|
+
{
|
1563
|
+
// if (!Vols.StartIsExe)
|
1564
|
+
return S_OK;
|
1565
|
+
}
|
1566
|
+
|
1567
|
+
int zipDisk = -1;
|
1568
|
+
int cdDisk = -1;
|
1569
|
+
|
1570
|
+
if (Vols.StartIsZip)
|
1571
|
+
Vols.ZipStream = StartStream;
|
1572
|
+
|
1573
|
+
// bool cdOK = false;
|
1574
|
+
|
1575
|
+
if (Vols.ZipStream)
|
1576
|
+
{
|
1577
|
+
Stream = Vols.ZipStream;
|
1578
|
+
HRESULT res = FindCd(true);
|
1579
|
+
CCdInfo &ecd = Vols.ecd;
|
1580
|
+
if (res == S_OK)
|
1581
|
+
{
|
1582
|
+
zipDisk = ecd.ThisDisk;
|
1583
|
+
Vols.ecd_wasRead = true;
|
1584
|
+
if (ecd.ThisDisk == 0
|
1585
|
+
|| ecd.ThisDisk >= ((UInt32)1 << 30)
|
1586
|
+
|| ecd.ThisDisk < ecd.CdDisk)
|
1587
|
+
return S_OK;
|
1588
|
+
cdDisk = ecd.CdDisk;
|
1589
|
+
if (Vols.StartVolIndex < 0)
|
1590
|
+
Vols.StartVolIndex = ecd.ThisDisk;
|
1591
|
+
// Vols.StartVolIndex = ecd.ThisDisk;
|
1592
|
+
// Vols.EndVolIndex = ecd.ThisDisk;
|
1593
|
+
unsigned numMissingVols;
|
1594
|
+
if (cdDisk == zipDisk)
|
1595
|
+
{
|
1596
|
+
// cdOK = true;
|
1597
|
+
}
|
1598
|
+
else
|
1599
|
+
{
|
1600
|
+
RINOK(ReadVols2(volCallback, cdDisk, zipDisk, zipDisk, 0, numMissingVols));
|
1601
|
+
if (numMissingVols == 0)
|
1602
|
+
{
|
1603
|
+
// cdOK = false;
|
1604
|
+
}
|
1605
|
+
}
|
1606
|
+
}
|
1607
|
+
else if (res != S_FALSE)
|
1608
|
+
return res;
|
1609
|
+
}
|
1610
|
+
|
1611
|
+
if (Vols.Streams.Size() > 0)
|
1612
|
+
IsMultiVol = true;
|
861
1613
|
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
1614
|
+
if (Vols.StartVolIndex < 0)
|
1615
|
+
return S_OK;
|
1616
|
+
|
1617
|
+
unsigned numMissingVols;
|
1618
|
+
|
1619
|
+
if (cdDisk != 0)
|
1620
|
+
{
|
1621
|
+
RINOK(ReadVols2(volCallback, 0, cdDisk < 0 ? -1 : cdDisk, zipDisk, 1 << 10, numMissingVols));
|
1622
|
+
}
|
1623
|
+
|
1624
|
+
if (Vols.ZipStream)
|
1625
|
+
{
|
1626
|
+
if (Vols.Streams.IsEmpty())
|
1627
|
+
if (zipDisk > (1 << 10))
|
1628
|
+
return S_OK;
|
1629
|
+
RINOK(ReadVols2(volCallback, zipDisk, zipDisk + 1, zipDisk, 0, numMissingVols));
|
1630
|
+
}
|
1631
|
+
|
1632
|
+
if (!Vols.Streams.IsEmpty())
|
1633
|
+
{
|
1634
|
+
IsMultiVol = true;
|
1635
|
+
/*
|
1636
|
+
if (cdDisk)
|
1637
|
+
IsMultiVol = true;
|
1638
|
+
*/
|
1639
|
+
if (startZIndex >= 0)
|
1640
|
+
{
|
1641
|
+
if (Vols.Streams.Size() >= (unsigned)startZIndex)
|
1642
|
+
{
|
1643
|
+
for (unsigned i = 0; i < (unsigned)startZIndex; i++)
|
1644
|
+
if (!Vols.Streams[i].Stream)
|
1645
|
+
{
|
1646
|
+
Vols.StartParsingVol = startZIndex;
|
1647
|
+
break;
|
1648
|
+
}
|
1649
|
+
}
|
1650
|
+
}
|
1651
|
+
}
|
1652
|
+
|
866
1653
|
return S_OK;
|
867
1654
|
}
|
868
1655
|
|
869
|
-
|
1656
|
+
|
1657
|
+
|
1658
|
+
|
1659
|
+
|
1660
|
+
|
1661
|
+
|
1662
|
+
HRESULT CVols::Read(void *data, UInt32 size, UInt32 *processedSize)
|
870
1663
|
{
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
1664
|
+
if (processedSize)
|
1665
|
+
*processedSize = 0;
|
1666
|
+
if (size == 0)
|
1667
|
+
return S_OK;
|
1668
|
+
|
1669
|
+
for (;;)
|
1670
|
+
{
|
1671
|
+
if (StreamIndex < 0)
|
1672
|
+
return S_OK;
|
1673
|
+
if ((unsigned)StreamIndex >= Streams.Size())
|
1674
|
+
return S_OK;
|
1675
|
+
const CVols::CSubStreamInfo &s = Streams[StreamIndex];
|
1676
|
+
if (!s.Stream)
|
1677
|
+
return S_FALSE;
|
1678
|
+
if (NeedSeek)
|
1679
|
+
{
|
1680
|
+
RINOK(s.Stream->Seek(0, STREAM_SEEK_SET, NULL));
|
1681
|
+
NeedSeek = false;
|
1682
|
+
}
|
1683
|
+
UInt32 realProcessedSize = 0;
|
1684
|
+
HRESULT res = s.Stream->Read(data, size, &realProcessedSize);
|
1685
|
+
if (processedSize)
|
1686
|
+
*processedSize = realProcessedSize;
|
1687
|
+
if (res != S_OK)
|
1688
|
+
return res;
|
1689
|
+
if (realProcessedSize != 0)
|
1690
|
+
return res;
|
1691
|
+
StreamIndex++;
|
1692
|
+
NeedSeek = true;
|
1693
|
+
}
|
877
1694
|
}
|
878
1695
|
|
879
|
-
|
1696
|
+
STDMETHODIMP CVolStream::Read(void *data, UInt32 size, UInt32 *processedSize)
|
880
1697
|
{
|
881
|
-
|
882
|
-
return stream.Detach();
|
1698
|
+
return Vols->Read(data, size, processedSize);
|
883
1699
|
}
|
884
1700
|
|
885
|
-
|
1701
|
+
|
1702
|
+
|
1703
|
+
|
1704
|
+
#define COPY_ECD_ITEM_16(n) if (!isZip64 || ecd. n != 0xFFFF) ecd64. n = ecd. n;
|
1705
|
+
#define COPY_ECD_ITEM_32(n) if (!isZip64 || ecd. n != 0xFFFFFFFF) ecd64. n = ecd. n;
|
1706
|
+
|
1707
|
+
|
1708
|
+
HRESULT CInArchive::ReadHeaders2(CObjectVector<CItemEx> &items)
|
886
1709
|
{
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
1710
|
+
HRESULT res = S_OK;
|
1711
|
+
|
1712
|
+
bool localsWereRead = false;
|
1713
|
+
UInt64 cdSize = 0, cdRelatOffset = 0, cdAbsOffset = 0;
|
1714
|
+
UInt32 cdDisk = 0;
|
1715
|
+
|
1716
|
+
if (!_inBuffer.Create(1 << 15))
|
1717
|
+
return E_OUTOFMEMORY;
|
1718
|
+
|
1719
|
+
if (!MarkerIsFound)
|
1720
|
+
{
|
1721
|
+
IsArc = true;
|
1722
|
+
res = ReadCd(items, cdDisk, cdRelatOffset, cdSize);
|
1723
|
+
if (res == S_OK)
|
1724
|
+
m_Signature = ReadUInt32();
|
1725
|
+
}
|
1726
|
+
else
|
1727
|
+
{
|
1728
|
+
|
1729
|
+
// m_Signature must be kLocalFileHeader or kEcd
|
1730
|
+
// m_Position points to next byte after signature
|
1731
|
+
RINOK(Stream->Seek(m_Position, STREAM_SEEK_SET, NULL));
|
1732
|
+
|
1733
|
+
_inBuffer.SetStream(Stream);
|
1734
|
+
|
1735
|
+
bool needReadCd = true;
|
1736
|
+
|
1737
|
+
if (m_Signature == NSignature::kEcd)
|
1738
|
+
{
|
1739
|
+
// It must be empty archive or backware archive
|
1740
|
+
// we don't support backware archive still
|
1741
|
+
|
1742
|
+
const unsigned kBufSize = kEcdSize - 4;
|
1743
|
+
Byte buf[kBufSize];
|
1744
|
+
SafeReadBytes(buf, kBufSize);
|
1745
|
+
CEcd ecd;
|
1746
|
+
ecd.Parse(buf);
|
1747
|
+
// if (ecd.cdSize != 0)
|
1748
|
+
// Do we need also to support the case where empty zip archive with PK00 uses cdOffset = 4 ??
|
1749
|
+
if (!ecd.IsEmptyArc())
|
1750
|
+
return S_FALSE;
|
1751
|
+
|
1752
|
+
ArcInfo.Base = ArcInfo.MarkerPos;
|
1753
|
+
needReadCd = false;
|
1754
|
+
IsArc = true; // check it: we need more tests?
|
1755
|
+
RINOK(Stream->Seek(ArcInfo.MarkerPos2 + 4, STREAM_SEEK_SET, &m_Position));
|
1756
|
+
}
|
1757
|
+
|
1758
|
+
if (needReadCd)
|
1759
|
+
{
|
1760
|
+
CItemEx firstItem;
|
1761
|
+
// try
|
1762
|
+
{
|
1763
|
+
try
|
1764
|
+
{
|
1765
|
+
if (!ReadLocalItem(firstItem))
|
1766
|
+
return S_FALSE;
|
1767
|
+
}
|
1768
|
+
catch(CUnexpectEnd &)
|
1769
|
+
{
|
1770
|
+
return S_FALSE;
|
1771
|
+
}
|
1772
|
+
|
1773
|
+
IsArc = true;
|
1774
|
+
res = ReadCd(items, cdDisk, cdRelatOffset, cdSize);
|
1775
|
+
if (res == S_OK)
|
1776
|
+
m_Signature = ReadUInt32();
|
1777
|
+
}
|
1778
|
+
// catch() { res = S_FALSE; }
|
1779
|
+
if (res != S_FALSE && res != S_OK)
|
1780
|
+
return res;
|
1781
|
+
|
1782
|
+
if (res == S_OK && items.Size() == 0)
|
1783
|
+
res = S_FALSE;
|
1784
|
+
|
1785
|
+
if (res == S_OK)
|
1786
|
+
{
|
1787
|
+
// we can't read local items here to keep _inBufMode state
|
1788
|
+
if ((Int64)ArcInfo.MarkerPos2 < ArcInfo.Base)
|
1789
|
+
res = S_FALSE;
|
1790
|
+
else
|
1791
|
+
{
|
1792
|
+
firstItem.LocalHeaderPos = ArcInfo.MarkerPos2 - ArcInfo.Base;
|
1793
|
+
int index = FindItem(items, firstItem);
|
1794
|
+
if (index == -1)
|
1795
|
+
res = S_FALSE;
|
1796
|
+
else if (!AreItemsEqual(firstItem, items[index]))
|
1797
|
+
res = S_FALSE;
|
1798
|
+
else
|
1799
|
+
{
|
1800
|
+
ArcInfo.CdWasRead = true;
|
1801
|
+
ArcInfo.FirstItemRelatOffset = items[0].LocalHeaderPos;
|
1802
|
+
}
|
1803
|
+
}
|
1804
|
+
}
|
1805
|
+
}
|
1806
|
+
}
|
1807
|
+
|
1808
|
+
|
1809
|
+
|
1810
|
+
CObjectVector<CItemEx> cdItems;
|
1811
|
+
|
1812
|
+
bool needSetBase = false;
|
1813
|
+
unsigned numCdItems = items.Size();
|
1814
|
+
|
1815
|
+
if (res == S_FALSE)
|
1816
|
+
{
|
1817
|
+
// CD doesn't match firstItem,
|
1818
|
+
// so we clear items and read Locals.
|
1819
|
+
items.Clear();
|
1820
|
+
localsWereRead = true;
|
1821
|
+
_inBufMode = false;
|
1822
|
+
ArcInfo.Base = ArcInfo.MarkerPos;
|
1823
|
+
|
1824
|
+
if (IsMultiVol)
|
1825
|
+
{
|
1826
|
+
Vols.StreamIndex = Vols.StartParsingVol;
|
1827
|
+
if (Vols.StartParsingVol >= (int)Vols.Streams.Size())
|
1828
|
+
return S_FALSE;
|
1829
|
+
Stream = Vols.Streams[Vols.StartParsingVol].Stream;
|
1830
|
+
if (!Stream)
|
1831
|
+
return S_FALSE;
|
1832
|
+
}
|
1833
|
+
|
1834
|
+
RINOK(Stream->Seek(ArcInfo.MarkerPos2, STREAM_SEEK_SET, &m_Position));
|
1835
|
+
m_Signature = ReadUInt32();
|
1836
|
+
|
1837
|
+
RINOK(ReadLocals(items));
|
1838
|
+
|
1839
|
+
if (m_Signature != NSignature::kCentralFileHeader)
|
1840
|
+
{
|
1841
|
+
// if (!UnexpectedEnd)
|
1842
|
+
m_Position -= 4;
|
1843
|
+
NoCentralDir = true;
|
1844
|
+
HeadersError = true;
|
1845
|
+
return S_OK;
|
1846
|
+
}
|
1847
|
+
|
1848
|
+
_inBufMode = true;
|
1849
|
+
_inBuffer.Init();
|
1850
|
+
|
1851
|
+
cdAbsOffset = m_Position - 4;
|
1852
|
+
cdDisk = Vols.StreamIndex;
|
1853
|
+
|
1854
|
+
for (;;)
|
1855
|
+
{
|
1856
|
+
CItemEx cdItem;
|
1857
|
+
CanStartNewVol = true;
|
1858
|
+
|
1859
|
+
RINOK(ReadCdItem(cdItem));
|
1860
|
+
|
1861
|
+
cdItems.Add(cdItem);
|
1862
|
+
if (Callback && (cdItems.Size() & 0xFFF) == 0)
|
1863
|
+
{
|
1864
|
+
const UInt64 numFiles = items.Size();
|
1865
|
+
RINOK(Callback->SetCompleted(&numFiles, NULL));
|
1866
|
+
}
|
1867
|
+
CanStartNewVol = true;
|
1868
|
+
m_Signature = ReadUInt32();
|
1869
|
+
if (m_Signature != NSignature::kCentralFileHeader)
|
1870
|
+
break;
|
1871
|
+
}
|
1872
|
+
|
1873
|
+
cdSize = (m_Position - 4) - cdAbsOffset;
|
1874
|
+
needSetBase = true;
|
1875
|
+
numCdItems = cdItems.Size();
|
1876
|
+
|
1877
|
+
if (!cdItems.IsEmpty())
|
1878
|
+
{
|
1879
|
+
ArcInfo.CdWasRead = true;
|
1880
|
+
ArcInfo.FirstItemRelatOffset = cdItems[0].LocalHeaderPos;
|
1881
|
+
}
|
1882
|
+
}
|
1883
|
+
|
1884
|
+
|
1885
|
+
|
1886
|
+
CCdInfo ecd64;
|
1887
|
+
CLocator locator;
|
1888
|
+
bool isZip64 = false;
|
1889
|
+
const UInt64 ecd64AbsOffset = m_Position - 4;
|
1890
|
+
int ecd64Disk = -1;
|
1891
|
+
|
1892
|
+
if (m_Signature == NSignature::kEcd64)
|
1893
|
+
{
|
1894
|
+
ecd64Disk = Vols.StreamIndex;
|
1895
|
+
|
1896
|
+
IsZip64 = isZip64 = true;
|
1897
|
+
|
1898
|
+
{
|
1899
|
+
const UInt64 recordSize = ReadUInt64();
|
1900
|
+
if (recordSize < kEcd64_MainSize)
|
1901
|
+
{
|
1902
|
+
HeadersError = true;
|
1903
|
+
return S_OK;
|
1904
|
+
}
|
1905
|
+
|
1906
|
+
{
|
1907
|
+
const unsigned kBufSize = kEcd64_MainSize;
|
1908
|
+
Byte buf[kBufSize];
|
1909
|
+
SafeReadBytes(buf, kBufSize);
|
1910
|
+
ecd64.ParseEcd64e(buf);
|
1911
|
+
}
|
1912
|
+
|
1913
|
+
Skip64(recordSize - kEcd64_MainSize);
|
1914
|
+
}
|
1915
|
+
|
1916
|
+
|
1917
|
+
m_Signature = ReadUInt32();
|
1918
|
+
|
1919
|
+
if (m_Signature != NSignature::kEcd64Locator)
|
1920
|
+
{
|
1921
|
+
HeadersError = true;
|
1922
|
+
return S_OK;
|
1923
|
+
}
|
1924
|
+
|
1925
|
+
{
|
1926
|
+
const unsigned kBufSize = 16;
|
1927
|
+
Byte buf[kBufSize];
|
1928
|
+
SafeReadBytes(buf, kBufSize);
|
1929
|
+
locator.Parse(buf);
|
1930
|
+
}
|
1931
|
+
|
1932
|
+
m_Signature = ReadUInt32();
|
1933
|
+
}
|
1934
|
+
|
1935
|
+
|
1936
|
+
if (m_Signature != NSignature::kEcd)
|
1937
|
+
{
|
1938
|
+
HeadersError = true;
|
1939
|
+
return S_OK;
|
1940
|
+
}
|
1941
|
+
|
1942
|
+
|
1943
|
+
// ---------- ECD ----------
|
1944
|
+
|
1945
|
+
CEcd ecd;
|
1946
|
+
{
|
1947
|
+
const unsigned kBufSize = kEcdSize - 4;
|
1948
|
+
Byte buf[kBufSize];
|
1949
|
+
SafeReadBytes(buf, kBufSize);
|
1950
|
+
ecd.Parse(buf);
|
1951
|
+
}
|
1952
|
+
|
1953
|
+
COPY_ECD_ITEM_16(ThisDisk);
|
1954
|
+
COPY_ECD_ITEM_16(CdDisk);
|
1955
|
+
COPY_ECD_ITEM_16(NumEntries_in_ThisDisk);
|
1956
|
+
COPY_ECD_ITEM_16(NumEntries);
|
1957
|
+
COPY_ECD_ITEM_32(Size);
|
1958
|
+
COPY_ECD_ITEM_32(Offset);
|
1959
|
+
|
1960
|
+
if (IsMultiVol)
|
1961
|
+
{
|
1962
|
+
if (cdDisk != (int)ecd64.CdDisk)
|
1963
|
+
HeadersError = true;
|
1964
|
+
}
|
1965
|
+
else if (needSetBase)
|
1966
|
+
{
|
1967
|
+
if (isZip64)
|
1968
|
+
{
|
1969
|
+
if (ecd64Disk == Vols.StartVolIndex)
|
1970
|
+
{
|
1971
|
+
ArcInfo.Base = ecd64AbsOffset - locator.Ecd64Offset;
|
1972
|
+
// cdRelatOffset = ecd64.Offset;
|
1973
|
+
needSetBase = false;
|
1974
|
+
}
|
1975
|
+
}
|
1976
|
+
else
|
1977
|
+
{
|
1978
|
+
if ((int)cdDisk == Vols.StartVolIndex)
|
1979
|
+
{
|
1980
|
+
ArcInfo.Base = cdAbsOffset - ecd64.Offset;
|
1981
|
+
cdRelatOffset = ecd64.Offset;
|
1982
|
+
needSetBase = false;
|
1983
|
+
}
|
1984
|
+
}
|
1985
|
+
}
|
1986
|
+
|
1987
|
+
EcdVolIndex = ecd64.ThisDisk;
|
1988
|
+
|
1989
|
+
if (!IsMultiVol)
|
1990
|
+
{
|
1991
|
+
UseDisk_in_SingleVol = true;
|
1992
|
+
|
1993
|
+
if (localsWereRead)
|
1994
|
+
{
|
1995
|
+
if ((UInt64)ArcInfo.Base != ArcInfo.MarkerPos)
|
1996
|
+
{
|
1997
|
+
const UInt64 delta = ArcInfo.MarkerPos - ArcInfo.Base;
|
1998
|
+
FOR_VECTOR (i, items)
|
1999
|
+
items[i].LocalHeaderPos += delta;
|
2000
|
+
}
|
2001
|
+
|
2002
|
+
if (EcdVolIndex != 0)
|
2003
|
+
{
|
2004
|
+
FOR_VECTOR (i, items)
|
2005
|
+
items[i].Disk = EcdVolIndex;
|
2006
|
+
}
|
2007
|
+
}
|
2008
|
+
}
|
2009
|
+
|
2010
|
+
if (isZip64)
|
2011
|
+
{
|
2012
|
+
if (ecd64.ThisDisk == 0 && ecd64AbsOffset != ArcInfo.Base + locator.Ecd64Offset
|
2013
|
+
// || ecd64.NumEntries_in_ThisDisk != numCdItems
|
2014
|
+
|| ecd64.NumEntries != numCdItems
|
2015
|
+
|| ecd64.Size != cdSize
|
2016
|
+
|| (ecd64.Offset != cdRelatOffset && !items.IsEmpty()))
|
2017
|
+
{
|
2018
|
+
HeadersError = true;
|
2019
|
+
return S_OK;
|
2020
|
+
}
|
2021
|
+
}
|
2022
|
+
|
2023
|
+
// ---------- merge Central Directory Items ----------
|
2024
|
+
|
2025
|
+
if (!cdItems.IsEmpty())
|
2026
|
+
{
|
2027
|
+
CObjectVector<CItemEx> items2;
|
2028
|
+
|
2029
|
+
FOR_VECTOR (i, cdItems)
|
2030
|
+
{
|
2031
|
+
const CItemEx &cdItem = cdItems[i];
|
2032
|
+
int index = FindItem(items, cdItem);
|
2033
|
+
if (index == -1)
|
2034
|
+
{
|
2035
|
+
items2.Add(cdItem);
|
2036
|
+
HeadersError = true;
|
2037
|
+
continue;
|
2038
|
+
}
|
2039
|
+
CItemEx &item = items[index];
|
2040
|
+
if (item.Name != cdItem.Name
|
2041
|
+
// || item.Name.Len() != cdItem.Name.Len()
|
2042
|
+
|| item.PackSize != cdItem.PackSize
|
2043
|
+
|| item.Size != cdItem.Size
|
2044
|
+
// item.ExtractVersion != cdItem.ExtractVersion
|
2045
|
+
|| !FlagsAreSame(item, cdItem)
|
2046
|
+
|| item.Crc != cdItem.Crc)
|
2047
|
+
{
|
2048
|
+
HeadersError = true;
|
2049
|
+
continue;
|
2050
|
+
}
|
2051
|
+
|
2052
|
+
// item.Name = cdItem.Name;
|
2053
|
+
item.MadeByVersion = cdItem.MadeByVersion;
|
2054
|
+
item.CentralExtra = cdItem.CentralExtra;
|
2055
|
+
item.InternalAttrib = cdItem.InternalAttrib;
|
2056
|
+
item.ExternalAttrib = cdItem.ExternalAttrib;
|
2057
|
+
item.Comment = cdItem.Comment;
|
2058
|
+
item.FromCentral = cdItem.FromCentral;
|
2059
|
+
}
|
2060
|
+
|
2061
|
+
items += items2;
|
2062
|
+
}
|
2063
|
+
|
2064
|
+
|
2065
|
+
if (ecd.NumEntries < ecd.NumEntries_in_ThisDisk)
|
2066
|
+
HeadersError = true;
|
2067
|
+
|
2068
|
+
if (ecd.ThisDisk == 0)
|
2069
|
+
{
|
2070
|
+
// if (isZip64)
|
2071
|
+
{
|
2072
|
+
if (ecd.NumEntries != ecd.NumEntries_in_ThisDisk)
|
2073
|
+
HeadersError = true;
|
2074
|
+
}
|
2075
|
+
}
|
2076
|
+
|
2077
|
+
if (ecd.NumEntries > items.Size())
|
2078
|
+
HeadersError = true;
|
2079
|
+
|
2080
|
+
if (isZip64)
|
2081
|
+
{
|
2082
|
+
if (ecd64.NumEntries != items.Size())
|
2083
|
+
HeadersError = true;
|
2084
|
+
}
|
2085
|
+
else
|
2086
|
+
{
|
2087
|
+
// old 7-zip could store 32-bit number of CD items to 16-bit field.
|
2088
|
+
/*
|
2089
|
+
if ((UInt16)ecd64.NumEntries == (UInt16)items.Size())
|
2090
|
+
HeadersError = true;
|
2091
|
+
*/
|
2092
|
+
}
|
2093
|
+
|
2094
|
+
ReadBuffer(ArcInfo.Comment, ecd.CommentSize);
|
2095
|
+
_inBufMode = false;
|
2096
|
+
_inBuffer.Free();
|
2097
|
+
|
2098
|
+
if ((UInt16)ecd64.NumEntries != (UInt16)numCdItems
|
2099
|
+
|| (UInt32)ecd64.Size != (UInt32)cdSize
|
2100
|
+
|| ((UInt32)ecd64.Offset != (UInt32)cdRelatOffset && !items.IsEmpty()))
|
2101
|
+
{
|
2102
|
+
// return S_FALSE;
|
2103
|
+
HeadersError = true;
|
2104
|
+
}
|
2105
|
+
|
2106
|
+
// printf("\nOpen OK");
|
2107
|
+
return S_OK;
|
2108
|
+
}
|
2109
|
+
|
2110
|
+
|
2111
|
+
|
2112
|
+
HRESULT CInArchive::Open(IInStream *stream, const UInt64 *searchLimit,
|
2113
|
+
IArchiveOpenCallback *callback, CObjectVector<CItemEx> &items)
|
2114
|
+
{
|
2115
|
+
_inBufMode = false;
|
2116
|
+
items.Clear();
|
2117
|
+
|
2118
|
+
Close();
|
2119
|
+
ArcInfo.Clear();
|
2120
|
+
|
2121
|
+
UInt64 startPos;
|
2122
|
+
RINOK(stream->Seek(0, STREAM_SEEK_CUR, &startPos));
|
2123
|
+
RINOK(stream->Seek(0, STREAM_SEEK_END, &ArcInfo.FileEndPos));
|
2124
|
+
m_Position = ArcInfo.FileEndPos;
|
2125
|
+
|
2126
|
+
StartStream = stream;
|
2127
|
+
Callback = callback;
|
2128
|
+
|
2129
|
+
bool volWasRequested = false;
|
2130
|
+
|
2131
|
+
if (callback
|
2132
|
+
&& (startPos == 0 || !searchLimit || *searchLimit != 0))
|
2133
|
+
{
|
2134
|
+
volWasRequested = true;
|
2135
|
+
RINOK(ReadVols());
|
2136
|
+
}
|
2137
|
+
|
2138
|
+
if (IsMultiVol && Vols.StartVolIndex != 0)
|
2139
|
+
{
|
2140
|
+
Stream = Vols.Streams[0].Stream;
|
2141
|
+
if (Stream)
|
2142
|
+
{
|
2143
|
+
m_Position = 0;
|
2144
|
+
RINOK(Stream->Seek(0, STREAM_SEEK_SET, NULL));
|
2145
|
+
UInt64 limit = 0;
|
2146
|
+
HRESULT res = FindMarker(Stream, &limit);
|
2147
|
+
if (res == S_OK)
|
2148
|
+
MarkerIsFound = true;
|
2149
|
+
else if (res != S_FALSE)
|
2150
|
+
return res;
|
2151
|
+
}
|
2152
|
+
}
|
2153
|
+
else
|
2154
|
+
{
|
2155
|
+
// printf("\nOpen offset = %u\n", (unsigned)startPos);
|
2156
|
+
RINOK(stream->Seek(startPos, STREAM_SEEK_SET, NULL));
|
2157
|
+
m_Position = startPos;
|
2158
|
+
HRESULT res = FindMarker(stream, searchLimit);
|
2159
|
+
UInt64 curPos = m_Position;
|
2160
|
+
if (res == S_OK)
|
2161
|
+
MarkerIsFound = true;
|
2162
|
+
else
|
2163
|
+
{
|
2164
|
+
// if (res != S_FALSE)
|
2165
|
+
return res;
|
2166
|
+
}
|
2167
|
+
|
2168
|
+
MarkerIsFound = true;
|
2169
|
+
|
2170
|
+
if (ArcInfo.IsSpanMode && !volWasRequested)
|
2171
|
+
{
|
2172
|
+
RINOK(ReadVols());
|
2173
|
+
}
|
2174
|
+
|
2175
|
+
if (IsMultiVol && (unsigned)Vols.StartVolIndex < Vols.Streams.Size())
|
2176
|
+
{
|
2177
|
+
Stream = Vols.Streams[Vols.StartVolIndex].Stream;
|
2178
|
+
if (!Stream)
|
2179
|
+
IsMultiVol = false;
|
2180
|
+
else
|
2181
|
+
{
|
2182
|
+
RINOK(Stream->Seek(curPos, STREAM_SEEK_SET, NULL));
|
2183
|
+
m_Position = curPos;
|
2184
|
+
}
|
2185
|
+
}
|
2186
|
+
else
|
2187
|
+
IsMultiVol = false;
|
2188
|
+
|
2189
|
+
if (!IsMultiVol)
|
2190
|
+
{
|
2191
|
+
RINOK(stream->Seek(curPos, STREAM_SEEK_SET, NULL));
|
2192
|
+
m_Position = curPos;
|
2193
|
+
StreamRef = stream;
|
2194
|
+
Stream = stream;
|
2195
|
+
}
|
2196
|
+
}
|
2197
|
+
|
2198
|
+
|
2199
|
+
{
|
2200
|
+
HRESULT res;
|
2201
|
+
try
|
2202
|
+
{
|
2203
|
+
res = ReadHeaders2(items);
|
2204
|
+
}
|
2205
|
+
catch (const CInBufferException &e) { res = e.ErrorCode; }
|
2206
|
+
catch (const CUnexpectEnd &)
|
2207
|
+
{
|
2208
|
+
if (items.IsEmpty())
|
2209
|
+
return S_FALSE;
|
2210
|
+
UnexpectedEnd = true;
|
2211
|
+
res = S_OK;
|
2212
|
+
}
|
2213
|
+
catch (...)
|
2214
|
+
{
|
2215
|
+
_inBufMode = false;
|
2216
|
+
throw;
|
2217
|
+
}
|
2218
|
+
|
2219
|
+
if (IsMultiVol)
|
2220
|
+
{
|
2221
|
+
ArcInfo.FinishPos = ArcInfo.FileEndPos;
|
2222
|
+
if ((unsigned)Vols.StreamIndex < Vols.Streams.Size())
|
2223
|
+
if (m_Position < Vols.Streams[Vols.StreamIndex].Size)
|
2224
|
+
ArcInfo.ThereIsTail = true;
|
2225
|
+
}
|
2226
|
+
else
|
2227
|
+
{
|
2228
|
+
ArcInfo.FinishPos = m_Position;
|
2229
|
+
ArcInfo.ThereIsTail = (ArcInfo.FileEndPos > m_Position);
|
2230
|
+
}
|
2231
|
+
|
2232
|
+
_inBufMode = false;
|
2233
|
+
IsArcOpen = true;
|
2234
|
+
if (!IsMultiVol)
|
2235
|
+
Vols.Streams.Clear();
|
2236
|
+
return res;
|
2237
|
+
}
|
2238
|
+
}
|
2239
|
+
|
2240
|
+
|
2241
|
+
HRESULT CInArchive::GetItemStream(const CItemEx &item, bool seekPackData, CMyComPtr<ISequentialInStream> &stream)
|
2242
|
+
{
|
2243
|
+
stream.Release();
|
2244
|
+
|
2245
|
+
UInt64 pos = item.LocalHeaderPos;
|
2246
|
+
if (seekPackData)
|
2247
|
+
pos += item.LocalFullHeaderSize;
|
2248
|
+
|
2249
|
+
if (!IsMultiVol)
|
2250
|
+
{
|
2251
|
+
if (UseDisk_in_SingleVol && item.Disk != EcdVolIndex)
|
2252
|
+
return S_OK;
|
2253
|
+
pos += ArcInfo.Base;
|
2254
|
+
RINOK(StreamRef->Seek(pos, STREAM_SEEK_SET, NULL));
|
2255
|
+
stream = StreamRef;
|
2256
|
+
return S_OK;
|
2257
|
+
}
|
2258
|
+
|
2259
|
+
if (item.Disk >= Vols.Streams.Size())
|
2260
|
+
return S_OK;
|
2261
|
+
|
2262
|
+
IInStream *str2 = Vols.Streams[item.Disk].Stream;
|
2263
|
+
if (!str2)
|
2264
|
+
return S_OK;
|
2265
|
+
RINOK(str2->Seek(pos, STREAM_SEEK_SET, NULL));
|
2266
|
+
|
2267
|
+
Vols.NeedSeek = false;
|
2268
|
+
Vols.StreamIndex = item.Disk;
|
2269
|
+
|
2270
|
+
CVolStream *volsStreamSpec = new CVolStream;
|
2271
|
+
volsStreamSpec->Vols = &Vols;
|
2272
|
+
stream = volsStreamSpec;
|
2273
|
+
|
2274
|
+
return S_OK;
|
891
2275
|
}
|
892
2276
|
|
893
2277
|
}}
|