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,6 +2,12 @@
|
|
2
2
|
|
3
3
|
#include "StdAfx.h"
|
4
4
|
|
5
|
+
#ifdef _WIN32
|
6
|
+
#include <wchar.h>
|
7
|
+
#else
|
8
|
+
#include <ctype.h>
|
9
|
+
#endif
|
10
|
+
|
5
11
|
#include "../../../../C/7zCrc.h"
|
6
12
|
#include "../../../../C/CpuArch.h"
|
7
13
|
|
@@ -20,127 +26,38 @@
|
|
20
26
|
#define FORMAT_7Z_RECOVERY
|
21
27
|
#endif
|
22
28
|
|
29
|
+
using namespace NWindows;
|
30
|
+
using namespace NCOM;
|
31
|
+
|
23
32
|
namespace NArchive {
|
24
33
|
namespace N7z {
|
25
34
|
|
26
|
-
static void BoolVector_Fill_False(CBoolVector &v,
|
35
|
+
static void BoolVector_Fill_False(CBoolVector &v, unsigned size)
|
27
36
|
{
|
28
|
-
v.
|
29
|
-
v
|
30
|
-
for (
|
31
|
-
|
32
|
-
}
|
33
|
-
|
34
|
-
static bool BoolVector_GetAndSet(CBoolVector &v, UInt32 index)
|
35
|
-
{
|
36
|
-
if (index >= (UInt32)v.Size())
|
37
|
-
return true;
|
38
|
-
bool res = v[index];
|
39
|
-
v[index] = true;
|
40
|
-
return res;
|
41
|
-
}
|
42
|
-
|
43
|
-
bool CFolder::CheckStructure() const
|
44
|
-
{
|
45
|
-
const int kNumCodersMax = sizeof(UInt32) * 8; // don't change it
|
46
|
-
const int kMaskSize = sizeof(UInt32) * 8; // it must be >= kNumCodersMax
|
47
|
-
const int kNumBindsMax = 32;
|
48
|
-
|
49
|
-
if (Coders.Size() > kNumCodersMax || BindPairs.Size() > kNumBindsMax)
|
50
|
-
return false;
|
51
|
-
|
52
|
-
{
|
53
|
-
CBoolVector v;
|
54
|
-
BoolVector_Fill_False(v, BindPairs.Size() + PackStreams.Size());
|
55
|
-
|
56
|
-
int i;
|
57
|
-
for (i = 0; i < BindPairs.Size(); i++)
|
58
|
-
if (BoolVector_GetAndSet(v, BindPairs[i].InIndex))
|
59
|
-
return false;
|
60
|
-
for (i = 0; i < PackStreams.Size(); i++)
|
61
|
-
if (BoolVector_GetAndSet(v, PackStreams[i]))
|
62
|
-
return false;
|
63
|
-
|
64
|
-
BoolVector_Fill_False(v, UnpackSizes.Size());
|
65
|
-
for (i = 0; i < BindPairs.Size(); i++)
|
66
|
-
if (BoolVector_GetAndSet(v, BindPairs[i].OutIndex))
|
67
|
-
return false;
|
68
|
-
}
|
69
|
-
|
70
|
-
UInt32 mask[kMaskSize];
|
71
|
-
int i;
|
72
|
-
for (i = 0; i < kMaskSize; i++)
|
73
|
-
mask[i] = 0;
|
74
|
-
|
75
|
-
{
|
76
|
-
CIntVector inStreamToCoder, outStreamToCoder;
|
77
|
-
for (i = 0; i < Coders.Size(); i++)
|
78
|
-
{
|
79
|
-
CNum j;
|
80
|
-
const CCoderInfo &coder = Coders[i];
|
81
|
-
for (j = 0; j < coder.NumInStreams; j++)
|
82
|
-
inStreamToCoder.Add(i);
|
83
|
-
for (j = 0; j < coder.NumOutStreams; j++)
|
84
|
-
outStreamToCoder.Add(i);
|
85
|
-
}
|
86
|
-
|
87
|
-
for (i = 0; i < BindPairs.Size(); i++)
|
88
|
-
{
|
89
|
-
const CBindPair &bp = BindPairs[i];
|
90
|
-
mask[inStreamToCoder[bp.InIndex]] |= (1 << outStreamToCoder[bp.OutIndex]);
|
91
|
-
}
|
92
|
-
}
|
93
|
-
|
94
|
-
for (i = 0; i < kMaskSize; i++)
|
95
|
-
for (int j = 0; j < kMaskSize; j++)
|
96
|
-
if (((1 << j) & mask[i]) != 0)
|
97
|
-
mask[i] |= mask[j];
|
98
|
-
|
99
|
-
for (i = 0; i < kMaskSize; i++)
|
100
|
-
if (((1 << i) & mask[i]) != 0)
|
101
|
-
return false;
|
102
|
-
|
103
|
-
return true;
|
37
|
+
v.ClearAndSetSize(size);
|
38
|
+
bool *p = &v[0];
|
39
|
+
for (unsigned i = 0; i < size; i++)
|
40
|
+
p[i] = false;
|
104
41
|
}
|
105
42
|
|
106
43
|
class CInArchiveException {};
|
44
|
+
class CUnsupportedFeatureException: public CInArchiveException {};
|
107
45
|
|
108
46
|
static void ThrowException() { throw CInArchiveException(); }
|
109
47
|
static inline void ThrowEndOfData() { ThrowException(); }
|
110
|
-
static inline void ThrowUnsupported() {
|
48
|
+
static inline void ThrowUnsupported() { throw CUnsupportedFeatureException(); }
|
111
49
|
static inline void ThrowIncorrect() { ThrowException(); }
|
112
|
-
static inline void ThrowUnsupportedVersion() { ThrowException(); }
|
113
|
-
|
114
|
-
/*
|
115
|
-
class CInArchiveException
|
116
|
-
{
|
117
|
-
public:
|
118
|
-
enum CCauseType
|
119
|
-
{
|
120
|
-
kUnsupportedVersion = 0,
|
121
|
-
kUnsupported,
|
122
|
-
kIncorrect,
|
123
|
-
kEndOfData
|
124
|
-
} Cause;
|
125
|
-
CInArchiveException(CCauseType cause): Cause(cause) {};
|
126
|
-
};
|
127
|
-
|
128
|
-
static void ThrowException(CInArchiveException::CCauseType c) { throw CInArchiveException(c); }
|
129
|
-
static void ThrowEndOfData() { ThrowException(CInArchiveException::kEndOfData); }
|
130
|
-
static void ThrowUnsupported() { ThrowException(CInArchiveException::kUnsupported); }
|
131
|
-
static void ThrowIncorrect() { ThrowException(CInArchiveException::kIncorrect); }
|
132
|
-
static void ThrowUnsupportedVersion() { ThrowException(CInArchiveException::kUnsupportedVersion); }
|
133
|
-
*/
|
134
50
|
|
135
51
|
class CStreamSwitch
|
136
52
|
{
|
137
53
|
CInArchive *_archive;
|
138
54
|
bool _needRemove;
|
55
|
+
bool _needUpdatePos;
|
139
56
|
public:
|
140
|
-
CStreamSwitch(): _needRemove(false) {}
|
57
|
+
CStreamSwitch(): _needRemove(false), _needUpdatePos(false) {}
|
141
58
|
~CStreamSwitch() { Remove(); }
|
142
59
|
void Remove();
|
143
|
-
void Set(CInArchive *archive, const Byte *data, size_t size);
|
60
|
+
void Set(CInArchive *archive, const Byte *data, size_t size, bool needUpdatePos);
|
144
61
|
void Set(CInArchive *archive, const CByteBuffer &byteBuffer);
|
145
62
|
void Set(CInArchive *archive, const CObjectVector<CByteBuffer> *dataVector);
|
146
63
|
};
|
@@ -149,22 +66,25 @@ void CStreamSwitch::Remove()
|
|
149
66
|
{
|
150
67
|
if (_needRemove)
|
151
68
|
{
|
152
|
-
_archive->
|
69
|
+
if (_archive->_inByteBack->GetRem() != 0)
|
70
|
+
_archive->ThereIsHeaderError = true;
|
71
|
+
_archive->DeleteByteStream(_needUpdatePos);
|
153
72
|
_needRemove = false;
|
154
73
|
}
|
155
74
|
}
|
156
75
|
|
157
|
-
void CStreamSwitch::Set(CInArchive *archive, const Byte *data, size_t size)
|
76
|
+
void CStreamSwitch::Set(CInArchive *archive, const Byte *data, size_t size, bool needUpdatePos)
|
158
77
|
{
|
159
78
|
Remove();
|
160
79
|
_archive = archive;
|
161
80
|
_archive->AddByteStream(data, size);
|
162
81
|
_needRemove = true;
|
82
|
+
_needUpdatePos = needUpdatePos;
|
163
83
|
}
|
164
84
|
|
165
85
|
void CStreamSwitch::Set(CInArchive *archive, const CByteBuffer &byteBuffer)
|
166
86
|
{
|
167
|
-
Set(archive, byteBuffer, byteBuffer.
|
87
|
+
Set(archive, byteBuffer, byteBuffer.Size(), false);
|
168
88
|
}
|
169
89
|
|
170
90
|
void CStreamSwitch::Set(CInArchive *archive, const CObjectVector<CByteBuffer> *dataVector)
|
@@ -173,13 +93,24 @@ void CStreamSwitch::Set(CInArchive *archive, const CObjectVector<CByteBuffer> *d
|
|
173
93
|
Byte external = archive->ReadByte();
|
174
94
|
if (external != 0)
|
175
95
|
{
|
176
|
-
|
177
|
-
|
96
|
+
if (!dataVector)
|
97
|
+
ThrowIncorrect();
|
98
|
+
CNum dataIndex = archive->ReadNum();
|
99
|
+
if (dataIndex >= dataVector->Size())
|
178
100
|
ThrowIncorrect();
|
179
101
|
Set(archive, (*dataVector)[dataIndex]);
|
180
102
|
}
|
181
103
|
}
|
182
104
|
|
105
|
+
void CInArchive::AddByteStream(const Byte *buf, size_t size)
|
106
|
+
{
|
107
|
+
if (_numInByteBufs == kNumBufLevelsMax)
|
108
|
+
ThrowIncorrect();
|
109
|
+
_inByteBack = &_inByteVector[_numInByteBufs++];
|
110
|
+
_inByteBack->Init(buf, size);
|
111
|
+
}
|
112
|
+
|
113
|
+
|
183
114
|
Byte CInByte2::ReadByte()
|
184
115
|
{
|
185
116
|
if (_pos >= _size)
|
@@ -189,10 +120,12 @@ Byte CInByte2::ReadByte()
|
|
189
120
|
|
190
121
|
void CInByte2::ReadBytes(Byte *data, size_t size)
|
191
122
|
{
|
123
|
+
if (size == 0)
|
124
|
+
return;
|
192
125
|
if (size > _size - _pos)
|
193
126
|
ThrowEndOfData();
|
194
|
-
|
195
|
-
|
127
|
+
memcpy(data, _buffer + _pos, size);
|
128
|
+
_pos += size;
|
196
129
|
}
|
197
130
|
|
198
131
|
void CInByte2::SkipData(UInt64 size)
|
@@ -207,31 +140,82 @@ void CInByte2::SkipData()
|
|
207
140
|
SkipData(ReadNumber());
|
208
141
|
}
|
209
142
|
|
210
|
-
UInt64
|
143
|
+
static UInt64 ReadNumberSpec(const Byte *p, size_t size, size_t &processed)
|
211
144
|
{
|
212
|
-
if (
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
145
|
+
if (size == 0)
|
146
|
+
{
|
147
|
+
processed = 0;
|
148
|
+
return 0;
|
149
|
+
}
|
150
|
+
|
151
|
+
unsigned b = *p++;
|
152
|
+
size--;
|
153
|
+
|
154
|
+
if ((b & 0x80) == 0)
|
155
|
+
{
|
156
|
+
processed = 1;
|
157
|
+
return b;
|
158
|
+
}
|
159
|
+
|
160
|
+
if (size == 0)
|
218
161
|
{
|
219
|
-
|
162
|
+
processed = 0;
|
163
|
+
return 0;
|
164
|
+
}
|
165
|
+
|
166
|
+
UInt64 value = (UInt64)*p;
|
167
|
+
p++;
|
168
|
+
size--;
|
169
|
+
|
170
|
+
for (unsigned i = 1; i < 8; i++)
|
171
|
+
{
|
172
|
+
unsigned mask = (unsigned)0x80 >> i;
|
173
|
+
if ((b & mask) == 0)
|
220
174
|
{
|
221
|
-
UInt64
|
222
|
-
value
|
175
|
+
UInt64 high = b & (mask - 1);
|
176
|
+
value |= (high << (i * 8));
|
177
|
+
processed = i + 1;
|
223
178
|
return value;
|
224
179
|
}
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
180
|
+
|
181
|
+
if (size == 0)
|
182
|
+
{
|
183
|
+
processed = 0;
|
184
|
+
return 0;
|
185
|
+
}
|
186
|
+
|
187
|
+
value |= ((UInt64)*p << (i * 8));
|
188
|
+
p++;
|
189
|
+
size--;
|
229
190
|
}
|
191
|
+
|
192
|
+
processed = 9;
|
230
193
|
return value;
|
231
194
|
}
|
232
195
|
|
196
|
+
UInt64 CInByte2::ReadNumber()
|
197
|
+
{
|
198
|
+
size_t processed;
|
199
|
+
UInt64 res = ReadNumberSpec(_buffer + _pos, _size - _pos, processed);
|
200
|
+
if (processed == 0)
|
201
|
+
ThrowEndOfData();
|
202
|
+
_pos += processed;
|
203
|
+
return res;
|
204
|
+
}
|
205
|
+
|
233
206
|
CNum CInByte2::ReadNum()
|
234
207
|
{
|
208
|
+
/*
|
209
|
+
if (_pos < _size)
|
210
|
+
{
|
211
|
+
Byte val = _buffer[_pos];
|
212
|
+
if ((unsigned)val < 0x80)
|
213
|
+
{
|
214
|
+
_pos++;
|
215
|
+
return (unsigned)val;
|
216
|
+
}
|
217
|
+
}
|
218
|
+
*/
|
235
219
|
UInt64 value = ReadNumber();
|
236
220
|
if (value > kNumMax)
|
237
221
|
ThrowUnsupported();
|
@@ -256,48 +240,21 @@ UInt64 CInByte2::ReadUInt64()
|
|
256
240
|
return res;
|
257
241
|
}
|
258
242
|
|
259
|
-
|
260
|
-
{
|
261
|
-
const Byte *buf = _buffer + _pos;
|
262
|
-
size_t rem = (_size - _pos) / 2 * 2;
|
263
|
-
{
|
264
|
-
size_t i;
|
265
|
-
for (i = 0; i < rem; i += 2)
|
266
|
-
if (buf[i] == 0 && buf[i + 1] == 0)
|
267
|
-
break;
|
268
|
-
if (i == rem)
|
269
|
-
ThrowEndOfData();
|
270
|
-
rem = i;
|
271
|
-
}
|
272
|
-
int len = (int)(rem / 2);
|
273
|
-
if (len < 0 || (size_t)len * 2 != rem)
|
274
|
-
ThrowUnsupported();
|
275
|
-
wchar_t *p = s.GetBuffer(len);
|
276
|
-
int i;
|
277
|
-
for (i = 0; i < len; i++, buf += 2)
|
278
|
-
p[i] = (wchar_t)Get16(buf);
|
279
|
-
s.ReleaseBuffer(len);
|
280
|
-
_pos += rem + 2;
|
281
|
-
}
|
243
|
+
#define CHECK_SIGNATURE if (p[0] != '7' || p[1] != 'z' || p[2] != 0xBC || p[3] != 0xAF || p[4] != 0x27 || p[5] != 0x1C) return false;
|
282
244
|
|
283
245
|
static inline bool TestSignature(const Byte *p)
|
284
246
|
{
|
285
|
-
|
286
|
-
|
287
|
-
return false;
|
288
|
-
return CrcCalc(p + 12, 20) == GetUi32(p + 8);
|
247
|
+
CHECK_SIGNATURE
|
248
|
+
return CrcCalc(p + 12, 20) == Get32(p + 8);
|
289
249
|
}
|
290
250
|
|
291
251
|
#ifdef FORMAT_7Z_RECOVERY
|
292
252
|
static inline bool TestSignature2(const Byte *p)
|
293
253
|
{
|
294
|
-
|
295
|
-
|
296
|
-
if (p[i] != kSignature[i])
|
297
|
-
return false;
|
298
|
-
if (CrcCalc(p + 12, 20) == GetUi32(p + 8))
|
254
|
+
CHECK_SIGNATURE;
|
255
|
+
if (CrcCalc(p + 12, 20) == Get32(p + 8))
|
299
256
|
return true;
|
300
|
-
for (i = 8; i < kHeaderSize; i++)
|
257
|
+
for (unsigned i = 8; i < kHeaderSize; i++)
|
301
258
|
if (p[i] != 0)
|
302
259
|
return false;
|
303
260
|
return (p[6] != 0 || p[7] != 0);
|
@@ -312,48 +269,56 @@ HRESULT CInArchive::FindAndReadSignature(IInStream *stream, const UInt64 *search
|
|
312
269
|
|
313
270
|
if (TestSignature2(_header))
|
314
271
|
return S_OK;
|
272
|
+
if (searchHeaderSizeLimit && *searchHeaderSizeLimit == 0)
|
273
|
+
return S_FALSE;
|
315
274
|
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
memcpy(buffer, _header, kHeaderSize);
|
322
|
-
UInt64 curTestPos = _arhiveBeginStreamPosition;
|
275
|
+
const UInt32 kBufSize = 1 << 15;
|
276
|
+
CByteArr buf(kBufSize);
|
277
|
+
memcpy(buf, _header, kHeaderSize);
|
278
|
+
UInt64 offset = 0;
|
279
|
+
|
323
280
|
for (;;)
|
324
281
|
{
|
325
|
-
|
326
|
-
|
327
|
-
break;
|
328
|
-
do
|
282
|
+
UInt32 readSize = kBufSize - kHeaderSize;
|
283
|
+
if (searchHeaderSizeLimit)
|
329
284
|
{
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
if (processedSize == 0)
|
285
|
+
UInt64 rem = *searchHeaderSizeLimit - offset;
|
286
|
+
if (readSize > rem)
|
287
|
+
readSize = (UInt32)rem;
|
288
|
+
if (readSize == 0)
|
335
289
|
return S_FALSE;
|
336
290
|
}
|
337
|
-
|
338
|
-
UInt32
|
339
|
-
|
291
|
+
|
292
|
+
UInt32 processed = 0;
|
293
|
+
RINOK(stream->Read(buf + kHeaderSize, readSize, &processed));
|
294
|
+
if (processed == 0)
|
295
|
+
return S_FALSE;
|
296
|
+
|
297
|
+
for (UInt32 pos = 0;;)
|
340
298
|
{
|
341
|
-
|
342
|
-
|
299
|
+
const Byte *p = buf + pos + 1;
|
300
|
+
const Byte *lim = buf + processed;
|
301
|
+
for (; p <= lim; p += 4)
|
302
|
+
{
|
303
|
+
if (p[0] == '7') break;
|
304
|
+
if (p[1] == '7') { p += 1; break; }
|
305
|
+
if (p[2] == '7') { p += 2; break; }
|
306
|
+
if (p[3] == '7') { p += 3; break; }
|
307
|
+
};
|
308
|
+
if (p > lim)
|
343
309
|
break;
|
344
|
-
|
310
|
+
pos = (UInt32)(p - buf);
|
311
|
+
if (TestSignature(p))
|
345
312
|
{
|
346
|
-
memcpy(_header,
|
347
|
-
|
348
|
-
_arhiveBeginStreamPosition
|
349
|
-
return stream->Seek(curTestPos + kHeaderSize, STREAM_SEEK_SET, NULL);
|
313
|
+
memcpy(_header, p, kHeaderSize);
|
314
|
+
_arhiveBeginStreamPosition += offset + pos;
|
315
|
+
return stream->Seek(_arhiveBeginStreamPosition + kHeaderSize, STREAM_SEEK_SET, NULL);
|
350
316
|
}
|
351
317
|
}
|
352
|
-
|
353
|
-
|
354
|
-
memmove(
|
318
|
+
|
319
|
+
offset += processed;
|
320
|
+
memmove(buf, buf + processed, kHeaderSize);
|
355
321
|
}
|
356
|
-
return S_FALSE;
|
357
322
|
}
|
358
323
|
|
359
324
|
// S_FALSE means that file is not archive
|
@@ -362,6 +327,8 @@ HRESULT CInArchive::Open(IInStream *stream, const UInt64 *searchHeaderSizeLimit)
|
|
362
327
|
HeadersSize = 0;
|
363
328
|
Close();
|
364
329
|
RINOK(stream->Seek(0, STREAM_SEEK_CUR, &_arhiveBeginStreamPosition))
|
330
|
+
RINOK(stream->Seek(0, STREAM_SEEK_END, &_fileEndPosition))
|
331
|
+
RINOK(stream->Seek(_arhiveBeginStreamPosition, STREAM_SEEK_SET, NULL))
|
365
332
|
RINOK(FindAndReadSignature(stream, searchHeaderSizeLimit));
|
366
333
|
_stream = stream;
|
367
334
|
return S_OK;
|
@@ -369,7 +336,9 @@ HRESULT CInArchive::Open(IInStream *stream, const UInt64 *searchHeaderSizeLimit)
|
|
369
336
|
|
370
337
|
void CInArchive::Close()
|
371
338
|
{
|
339
|
+
_numInByteBufs = 0;
|
372
340
|
_stream.Release();
|
341
|
+
ThereIsHeaderError = false;
|
373
342
|
}
|
374
343
|
|
375
344
|
void CInArchive::ReadArchiveProperties(CInArchiveInfo & /* archiveInfo */)
|
@@ -382,92 +351,214 @@ void CInArchive::ReadArchiveProperties(CInArchiveInfo & /* archiveInfo */)
|
|
382
351
|
}
|
383
352
|
}
|
384
353
|
|
385
|
-
|
354
|
+
// CFolder &folder can be non empty. So we must set all fields
|
355
|
+
|
356
|
+
void CInByte2::ParseFolder(CFolder &folder)
|
386
357
|
{
|
387
|
-
|
358
|
+
UInt32 numCoders = ReadNum();
|
388
359
|
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
360
|
+
if (numCoders == 0)
|
361
|
+
ThrowUnsupported();
|
362
|
+
|
363
|
+
folder.Coders.SetSize(numCoders);
|
364
|
+
|
365
|
+
UInt32 numInStreams = 0;
|
366
|
+
UInt32 i;
|
394
367
|
for (i = 0; i < numCoders; i++)
|
395
368
|
{
|
396
|
-
folder.Coders
|
397
|
-
CCoderInfo &coder = folder.Coders.Back();
|
398
|
-
|
369
|
+
CCoderInfo &coder = folder.Coders[i];
|
399
370
|
{
|
400
371
|
Byte mainByte = ReadByte();
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
if (idSize > 8)
|
372
|
+
if ((mainByte & 0xC0) != 0)
|
373
|
+
ThrowUnsupported();
|
374
|
+
unsigned idSize = (mainByte & 0xF);
|
375
|
+
if (idSize > 8 || idSize > GetRem())
|
405
376
|
ThrowUnsupported();
|
377
|
+
const Byte *longID = GetPtr();
|
406
378
|
UInt64 id = 0;
|
407
|
-
for (
|
408
|
-
id
|
379
|
+
for (unsigned j = 0; j < idSize; j++)
|
380
|
+
id = ((id << 8) | longID[j]);
|
381
|
+
SkipDataNoCheck(idSize);
|
409
382
|
coder.MethodID = id;
|
410
383
|
|
411
384
|
if ((mainByte & 0x10) != 0)
|
412
385
|
{
|
413
|
-
coder.
|
414
|
-
|
386
|
+
coder.NumStreams = ReadNum();
|
387
|
+
/* numOutStreams = */ ReadNum();
|
415
388
|
}
|
416
389
|
else
|
417
390
|
{
|
418
|
-
coder.
|
419
|
-
coder.NumOutStreams = 1;
|
391
|
+
coder.NumStreams = 1;
|
420
392
|
}
|
393
|
+
|
421
394
|
if ((mainByte & 0x20) != 0)
|
422
395
|
{
|
423
396
|
CNum propsSize = ReadNum();
|
424
|
-
coder.Props.
|
397
|
+
coder.Props.Alloc((size_t)propsSize);
|
425
398
|
ReadBytes((Byte *)coder.Props, (size_t)propsSize);
|
426
399
|
}
|
427
|
-
|
428
|
-
|
400
|
+
else
|
401
|
+
coder.Props.Free();
|
429
402
|
}
|
430
|
-
numInStreams += coder.
|
431
|
-
numOutStreams += coder.NumOutStreams;
|
403
|
+
numInStreams += coder.NumStreams;
|
432
404
|
}
|
433
405
|
|
434
|
-
|
435
|
-
folder.
|
436
|
-
|
437
|
-
for (i = 0; i < numBindPairs; i++)
|
406
|
+
UInt32 numBonds = numCoders - 1;
|
407
|
+
folder.Bonds.SetSize(numBonds);
|
408
|
+
for (i = 0; i < numBonds; i++)
|
438
409
|
{
|
439
|
-
|
440
|
-
bp.
|
441
|
-
bp.
|
442
|
-
folder.BindPairs.Add(bp);
|
410
|
+
CBond &bp = folder.Bonds[i];
|
411
|
+
bp.PackIndex = ReadNum();
|
412
|
+
bp.UnpackIndex = ReadNum();
|
443
413
|
}
|
444
414
|
|
445
|
-
if (numInStreams <
|
415
|
+
if (numInStreams < numBonds)
|
446
416
|
ThrowUnsupported();
|
447
|
-
|
448
|
-
folder.PackStreams.
|
417
|
+
UInt32 numPackStreams = numInStreams - numBonds;
|
418
|
+
folder.PackStreams.SetSize(numPackStreams);
|
419
|
+
|
449
420
|
if (numPackStreams == 1)
|
450
421
|
{
|
451
422
|
for (i = 0; i < numInStreams; i++)
|
452
|
-
if (folder.
|
423
|
+
if (folder.FindBond_for_PackStream(i) < 0)
|
453
424
|
{
|
454
|
-
folder.PackStreams
|
425
|
+
folder.PackStreams[0] = i;
|
455
426
|
break;
|
456
427
|
}
|
457
|
-
if (
|
428
|
+
if (i == numInStreams)
|
458
429
|
ThrowUnsupported();
|
459
430
|
}
|
460
431
|
else
|
461
432
|
for (i = 0; i < numPackStreams; i++)
|
462
|
-
folder.PackStreams
|
433
|
+
folder.PackStreams[i] = ReadNum();
|
463
434
|
}
|
464
435
|
|
465
|
-
void
|
436
|
+
void CFolders::ParseFolderInfo(unsigned folderIndex, CFolder &folder) const
|
437
|
+
{
|
438
|
+
size_t startPos = FoCodersDataOffset[folderIndex];
|
439
|
+
CInByte2 inByte;
|
440
|
+
inByte.Init(CodersData + startPos, FoCodersDataOffset[folderIndex + 1] - startPos);
|
441
|
+
inByte.ParseFolder(folder);
|
442
|
+
if (inByte.GetRem() != 0)
|
443
|
+
throw 20120424;
|
444
|
+
}
|
445
|
+
|
446
|
+
|
447
|
+
void CDatabase::GetPath(unsigned index, UString &path) const
|
448
|
+
{
|
449
|
+
path.Empty();
|
450
|
+
if (!NameOffsets || !NamesBuf)
|
451
|
+
return;
|
452
|
+
|
453
|
+
size_t offset = NameOffsets[index];
|
454
|
+
size_t size = NameOffsets[index + 1] - offset;
|
455
|
+
|
456
|
+
if (size >= (1 << 28))
|
457
|
+
return;
|
458
|
+
|
459
|
+
wchar_t *s = path.GetBuf((unsigned)size - 1);
|
460
|
+
|
461
|
+
const Byte *p = ((const Byte *)NamesBuf + offset * 2);
|
462
|
+
|
463
|
+
#if defined(_WIN32) && defined(MY_CPU_LE)
|
464
|
+
|
465
|
+
wmemcpy(s, (const wchar_t *)p, size);
|
466
|
+
|
467
|
+
#else
|
468
|
+
|
469
|
+
for (size_t i = 0; i < size; i++)
|
470
|
+
{
|
471
|
+
*s = Get16(p);
|
472
|
+
p += 2;
|
473
|
+
s++;
|
474
|
+
}
|
475
|
+
|
476
|
+
#endif
|
477
|
+
|
478
|
+
path.ReleaseBuf_SetLen((unsigned)size - 1);
|
479
|
+
}
|
480
|
+
|
481
|
+
HRESULT CDatabase::GetPath_Prop(unsigned index, PROPVARIANT *path) const throw()
|
482
|
+
{
|
483
|
+
PropVariant_Clear(path);
|
484
|
+
if (!NameOffsets || !NamesBuf)
|
485
|
+
return S_OK;
|
486
|
+
|
487
|
+
size_t offset = NameOffsets[index];
|
488
|
+
size_t size = NameOffsets[index + 1] - offset;
|
489
|
+
|
490
|
+
if (size >= (1 << 14))
|
491
|
+
return S_OK;
|
492
|
+
|
493
|
+
RINOK(PropVarEm_Alloc_Bstr(path, (unsigned)size - 1));
|
494
|
+
wchar_t *s = path->bstrVal;
|
495
|
+
|
496
|
+
const Byte *p = ((const Byte *)NamesBuf + offset * 2);
|
497
|
+
|
498
|
+
for (size_t i = 0; i < size; i++)
|
499
|
+
{
|
500
|
+
wchar_t c = Get16(p);
|
501
|
+
p += 2;
|
502
|
+
#if WCHAR_PATH_SEPARATOR != L'/'
|
503
|
+
if (c == L'/')
|
504
|
+
c = WCHAR_PATH_SEPARATOR;
|
505
|
+
#endif
|
506
|
+
*s++ = c;
|
507
|
+
}
|
508
|
+
|
509
|
+
return S_OK;
|
510
|
+
|
511
|
+
/*
|
512
|
+
unsigned cur = index;
|
513
|
+
unsigned size = 0;
|
514
|
+
|
515
|
+
for (int i = 0;; i++)
|
516
|
+
{
|
517
|
+
size_t len = NameOffsets[cur + 1] - NameOffsets[cur];
|
518
|
+
size += (unsigned)len;
|
519
|
+
if (i > 256 || len > (1 << 14) || size > (1 << 14))
|
520
|
+
return PropVarEm_Set_Str(path, "[TOO-LONG]");
|
521
|
+
cur = Files[cur].Parent;
|
522
|
+
if (cur < 0)
|
523
|
+
break;
|
524
|
+
}
|
525
|
+
size--;
|
526
|
+
|
527
|
+
RINOK(PropVarEm_Alloc_Bstr(path, size));
|
528
|
+
wchar_t *s = path->bstrVal;
|
529
|
+
s += size;
|
530
|
+
*s = 0;
|
531
|
+
cur = index;
|
532
|
+
|
533
|
+
for (;;)
|
534
|
+
{
|
535
|
+
unsigned len = (unsigned)(NameOffsets[cur + 1] - NameOffsets[cur] - 1);
|
536
|
+
const Byte *p = (const Byte *)NamesBuf + (NameOffsets[cur + 1] * 2) - 2;
|
537
|
+
for (; len != 0; len--)
|
538
|
+
{
|
539
|
+
p -= 2;
|
540
|
+
--s;
|
541
|
+
wchar_t c = Get16(p);
|
542
|
+
if (c == '/')
|
543
|
+
c = WCHAR_PATH_SEPARATOR;
|
544
|
+
*s = c;
|
545
|
+
}
|
546
|
+
|
547
|
+
const CFileItem &file = Files[cur];
|
548
|
+
cur = file.Parent;
|
549
|
+
if (cur < 0)
|
550
|
+
return S_OK;
|
551
|
+
*(--s) = (file.IsAltStream ? ':' : WCHAR_PATH_SEPARATOR);
|
552
|
+
}
|
553
|
+
*/
|
554
|
+
}
|
555
|
+
|
556
|
+
void CInArchive::WaitId(UInt64 id)
|
466
557
|
{
|
467
558
|
for (;;)
|
468
559
|
{
|
469
560
|
UInt64 type = ReadID();
|
470
|
-
if (type ==
|
561
|
+
if (type == id)
|
471
562
|
return;
|
472
563
|
if (type == NID::kEnd)
|
473
564
|
ThrowIncorrect();
|
@@ -475,91 +566,223 @@ void CInArchive::WaitAttribute(UInt64 attribute)
|
|
475
566
|
}
|
476
567
|
}
|
477
568
|
|
478
|
-
void CInArchive::ReadHashDigests(
|
479
|
-
CBoolVector &digestsDefined,
|
480
|
-
CRecordVector<UInt32> &digests)
|
569
|
+
void CInArchive::ReadHashDigests(unsigned numItems, CUInt32DefVector &crcs)
|
481
570
|
{
|
482
|
-
ReadBoolVector2(numItems,
|
483
|
-
|
484
|
-
|
485
|
-
|
571
|
+
ReadBoolVector2(numItems, crcs.Defs);
|
572
|
+
crcs.Vals.ClearAndSetSize(numItems);
|
573
|
+
UInt32 *p = &crcs.Vals[0];
|
574
|
+
const bool *defs = &crcs.Defs[0];
|
575
|
+
for (unsigned i = 0; i < numItems; i++)
|
486
576
|
{
|
487
577
|
UInt32 crc = 0;
|
488
|
-
if (
|
578
|
+
if (defs[i])
|
489
579
|
crc = ReadUInt32();
|
490
|
-
|
580
|
+
p[i] = crc;
|
491
581
|
}
|
492
582
|
}
|
493
583
|
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
CRecordVector<UInt32> &packCRCs)
|
584
|
+
#define k_Scan_NumCoders_MAX 64
|
585
|
+
#define k_Scan_NumCodersStreams_in_Folder_MAX 64
|
586
|
+
|
587
|
+
void CInArchive::ReadPackInfo(CFolders &f)
|
499
588
|
{
|
500
|
-
dataOffset = ReadNumber();
|
501
589
|
CNum numPackStreams = ReadNum();
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
590
|
+
|
591
|
+
WaitId(NID::kSize);
|
592
|
+
f.PackPositions.Alloc(numPackStreams + 1);
|
593
|
+
f.NumPackStreams = numPackStreams;
|
594
|
+
UInt64 sum = 0;
|
506
595
|
for (CNum i = 0; i < numPackStreams; i++)
|
507
|
-
|
596
|
+
{
|
597
|
+
f.PackPositions[i] = sum;
|
598
|
+
UInt64 packSize = ReadNumber();
|
599
|
+
sum += packSize;
|
600
|
+
if (sum < packSize)
|
601
|
+
ThrowIncorrect();
|
602
|
+
}
|
603
|
+
f.PackPositions[numPackStreams] = sum;
|
508
604
|
|
509
605
|
UInt64 type;
|
510
606
|
for (;;)
|
511
607
|
{
|
512
608
|
type = ReadID();
|
513
609
|
if (type == NID::kEnd)
|
514
|
-
|
610
|
+
return;
|
515
611
|
if (type == NID::kCRC)
|
516
612
|
{
|
517
|
-
|
613
|
+
CUInt32DefVector PackCRCs;
|
614
|
+
ReadHashDigests(numPackStreams, PackCRCs);
|
518
615
|
continue;
|
519
616
|
}
|
520
617
|
SkipData();
|
521
618
|
}
|
522
|
-
if (packCRCsDefined.IsEmpty())
|
523
|
-
{
|
524
|
-
BoolVector_Fill_False(packCRCsDefined, numPackStreams);
|
525
|
-
packCRCs.Reserve(numPackStreams);
|
526
|
-
packCRCs.Clear();
|
527
|
-
for (CNum i = 0; i < numPackStreams; i++)
|
528
|
-
packCRCs.Add(0);
|
529
|
-
}
|
530
619
|
}
|
531
620
|
|
532
621
|
void CInArchive::ReadUnpackInfo(
|
533
622
|
const CObjectVector<CByteBuffer> *dataVector,
|
534
|
-
|
623
|
+
CFolders &folders)
|
535
624
|
{
|
536
|
-
|
625
|
+
WaitId(NID::kFolder);
|
537
626
|
CNum numFolders = ReadNum();
|
538
627
|
|
628
|
+
CNum numCodersOutStreams = 0;
|
539
629
|
{
|
540
630
|
CStreamSwitch streamSwitch;
|
541
631
|
streamSwitch.Set(this, dataVector);
|
542
|
-
|
543
|
-
folders.
|
544
|
-
|
632
|
+
const Byte *startBufPtr = _inByteBack->GetPtr();
|
633
|
+
folders.NumFolders = numFolders;
|
634
|
+
|
635
|
+
folders.FoStartPackStreamIndex.Alloc(numFolders + 1);
|
636
|
+
folders.FoToMainUnpackSizeIndex.Alloc(numFolders);
|
637
|
+
folders.FoCodersDataOffset.Alloc(numFolders + 1);
|
638
|
+
folders.FoToCoderUnpackSizes.Alloc(numFolders + 1);
|
639
|
+
|
640
|
+
CBoolVector StreamUsed;
|
641
|
+
CBoolVector CoderUsed;
|
642
|
+
|
643
|
+
CNum packStreamIndex = 0;
|
644
|
+
CNum fo;
|
645
|
+
CInByte2 *inByte = _inByteBack;
|
646
|
+
|
647
|
+
for (fo = 0; fo < numFolders; fo++)
|
545
648
|
{
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
}
|
649
|
+
UInt32 indexOfMainStream = 0;
|
650
|
+
UInt32 numPackStreams = 0;
|
651
|
+
folders.FoCodersDataOffset[fo] = _inByteBack->GetPtr() - startBufPtr;
|
550
652
|
|
551
|
-
|
653
|
+
CNum numInStreams = 0;
|
654
|
+
CNum numCoders = inByte->ReadNum();
|
655
|
+
|
656
|
+
if (numCoders == 0 || numCoders > k_Scan_NumCoders_MAX)
|
657
|
+
ThrowUnsupported();
|
552
658
|
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
659
|
+
for (CNum ci = 0; ci < numCoders; ci++)
|
660
|
+
{
|
661
|
+
Byte mainByte = inByte->ReadByte();
|
662
|
+
if ((mainByte & 0xC0) != 0)
|
663
|
+
ThrowUnsupported();
|
664
|
+
|
665
|
+
unsigned idSize = (mainByte & 0xF);
|
666
|
+
if (idSize > 8)
|
667
|
+
ThrowUnsupported();
|
668
|
+
if (idSize > inByte->GetRem())
|
669
|
+
ThrowEndOfData();
|
670
|
+
const Byte *longID = inByte->GetPtr();
|
671
|
+
UInt64 id = 0;
|
672
|
+
for (unsigned j = 0; j < idSize; j++)
|
673
|
+
id = ((id << 8) | longID[j]);
|
674
|
+
inByte->SkipDataNoCheck(idSize);
|
675
|
+
if (folders.ParsedMethods.IDs.Size() < 128)
|
676
|
+
folders.ParsedMethods.IDs.AddToUniqueSorted(id);
|
677
|
+
|
678
|
+
CNum coderInStreams = 1;
|
679
|
+
if ((mainByte & 0x10) != 0)
|
680
|
+
{
|
681
|
+
coderInStreams = inByte->ReadNum();
|
682
|
+
if (coderInStreams > k_Scan_NumCodersStreams_in_Folder_MAX)
|
683
|
+
ThrowUnsupported();
|
684
|
+
if (inByte->ReadNum() != 1)
|
685
|
+
ThrowUnsupported();
|
686
|
+
}
|
687
|
+
|
688
|
+
numInStreams += coderInStreams;
|
689
|
+
if (numInStreams > k_Scan_NumCodersStreams_in_Folder_MAX)
|
690
|
+
ThrowUnsupported();
|
691
|
+
|
692
|
+
if ((mainByte & 0x20) != 0)
|
693
|
+
{
|
694
|
+
CNum propsSize = inByte->ReadNum();
|
695
|
+
if (propsSize > inByte->GetRem())
|
696
|
+
ThrowEndOfData();
|
697
|
+
if (id == k_LZMA2 && propsSize == 1)
|
698
|
+
{
|
699
|
+
Byte v = *_inByteBack->GetPtr();
|
700
|
+
if (folders.ParsedMethods.Lzma2Prop < v)
|
701
|
+
folders.ParsedMethods.Lzma2Prop = v;
|
702
|
+
}
|
703
|
+
else if (id == k_LZMA && propsSize == 5)
|
704
|
+
{
|
705
|
+
UInt32 dicSize = GetUi32(_inByteBack->GetPtr() + 1);
|
706
|
+
if (folders.ParsedMethods.LzmaDic < dicSize)
|
707
|
+
folders.ParsedMethods.LzmaDic = dicSize;
|
708
|
+
}
|
709
|
+
inByte->SkipDataNoCheck((size_t)propsSize);
|
710
|
+
}
|
711
|
+
}
|
712
|
+
|
713
|
+
if (numCoders == 1 && numInStreams == 1)
|
714
|
+
{
|
715
|
+
indexOfMainStream = 0;
|
716
|
+
numPackStreams = 1;
|
717
|
+
}
|
718
|
+
else
|
719
|
+
{
|
720
|
+
UInt32 i;
|
721
|
+
CNum numBonds = numCoders - 1;
|
722
|
+
if (numInStreams < numBonds)
|
723
|
+
ThrowUnsupported();
|
724
|
+
|
725
|
+
BoolVector_Fill_False(StreamUsed, numInStreams);
|
726
|
+
BoolVector_Fill_False(CoderUsed, numCoders);
|
727
|
+
|
728
|
+
for (i = 0; i < numBonds; i++)
|
729
|
+
{
|
730
|
+
CNum index = ReadNum();
|
731
|
+
if (index >= numInStreams || StreamUsed[index])
|
732
|
+
ThrowUnsupported();
|
733
|
+
StreamUsed[index] = true;
|
734
|
+
|
735
|
+
index = ReadNum();
|
736
|
+
if (index >= numCoders || CoderUsed[index])
|
737
|
+
ThrowUnsupported();
|
738
|
+
CoderUsed[index] = true;
|
739
|
+
}
|
740
|
+
|
741
|
+
numPackStreams = numInStreams - numBonds;
|
742
|
+
|
743
|
+
if (numPackStreams != 1)
|
744
|
+
for (i = 0; i < numPackStreams; i++)
|
745
|
+
{
|
746
|
+
CNum index = inByte->ReadNum(); // PackStreams
|
747
|
+
if (index >= numInStreams || StreamUsed[index])
|
748
|
+
ThrowUnsupported();
|
749
|
+
StreamUsed[index] = true;
|
750
|
+
}
|
751
|
+
|
752
|
+
for (i = 0; i < numCoders; i++)
|
753
|
+
if (!CoderUsed[i])
|
754
|
+
{
|
755
|
+
indexOfMainStream = i;
|
756
|
+
break;
|
757
|
+
}
|
758
|
+
|
759
|
+
if (i == numCoders)
|
760
|
+
ThrowUnsupported();
|
761
|
+
}
|
762
|
+
|
763
|
+
folders.FoToCoderUnpackSizes[fo] = numCodersOutStreams;
|
764
|
+
numCodersOutStreams += numCoders;
|
765
|
+
folders.FoStartPackStreamIndex[fo] = packStreamIndex;
|
766
|
+
if (numPackStreams > folders.NumPackStreams - packStreamIndex)
|
767
|
+
ThrowIncorrect();
|
768
|
+
packStreamIndex += numPackStreams;
|
769
|
+
folders.FoToMainUnpackSizeIndex[fo] = (Byte)indexOfMainStream;
|
770
|
+
}
|
771
|
+
|
772
|
+
size_t dataSize = _inByteBack->GetPtr() - startBufPtr;
|
773
|
+
folders.FoToCoderUnpackSizes[fo] = numCodersOutStreams;
|
774
|
+
folders.FoStartPackStreamIndex[fo] = packStreamIndex;
|
775
|
+
folders.FoCodersDataOffset[fo] = _inByteBack->GetPtr() - startBufPtr;
|
776
|
+
folders.CodersData.CopyFrom(startBufPtr, dataSize);
|
777
|
+
|
778
|
+
// if (folders.NumPackStreams != packStreamIndex) ThrowUnsupported();
|
561
779
|
}
|
562
780
|
|
781
|
+
WaitId(NID::kCodersUnpackSize);
|
782
|
+
folders.CoderUnpackSizes.Alloc(numCodersOutStreams);
|
783
|
+
for (CNum i = 0; i < numCodersOutStreams; i++)
|
784
|
+
folders.CoderUnpackSizes[i] = ReadNumber();
|
785
|
+
|
563
786
|
for (;;)
|
564
787
|
{
|
565
788
|
UInt64 type = ReadID();
|
@@ -567,15 +790,7 @@ void CInArchive::ReadUnpackInfo(
|
|
567
790
|
return;
|
568
791
|
if (type == NID::kCRC)
|
569
792
|
{
|
570
|
-
|
571
|
-
CRecordVector<UInt32> crcs;
|
572
|
-
ReadHashDigests(numFolders, crcsDefined, crcs);
|
573
|
-
for (i = 0; i < numFolders; i++)
|
574
|
-
{
|
575
|
-
CFolder &folder = folders[i];
|
576
|
-
folder.UnpackCRCDefined = crcsDefined[i];
|
577
|
-
folder.UnpackCRC = crcs[i];
|
578
|
-
}
|
793
|
+
ReadHashDigests(numFolders, folders.FolderCRCs);
|
579
794
|
continue;
|
580
795
|
}
|
581
796
|
SkipData();
|
@@ -583,170 +798,217 @@ void CInArchive::ReadUnpackInfo(
|
|
583
798
|
}
|
584
799
|
|
585
800
|
void CInArchive::ReadSubStreamsInfo(
|
586
|
-
|
587
|
-
CRecordVector<CNum> &numUnpackStreamsInFolders,
|
801
|
+
CFolders &folders,
|
588
802
|
CRecordVector<UInt64> &unpackSizes,
|
589
|
-
|
590
|
-
CRecordVector<UInt32> &digests)
|
803
|
+
CUInt32DefVector &digests)
|
591
804
|
{
|
592
|
-
|
593
|
-
|
805
|
+
folders.NumUnpackStreamsVector.Alloc(folders.NumFolders);
|
806
|
+
CNum i;
|
807
|
+
for (i = 0; i < folders.NumFolders; i++)
|
808
|
+
folders.NumUnpackStreamsVector[i] = 1;
|
809
|
+
|
594
810
|
UInt64 type;
|
811
|
+
|
595
812
|
for (;;)
|
596
813
|
{
|
597
814
|
type = ReadID();
|
598
815
|
if (type == NID::kNumUnpackStream)
|
599
816
|
{
|
600
|
-
for (
|
601
|
-
|
817
|
+
for (i = 0; i < folders.NumFolders; i++)
|
818
|
+
folders.NumUnpackStreamsVector[i] = ReadNum();
|
602
819
|
continue;
|
603
820
|
}
|
604
|
-
if (type == NID::kCRC || type == NID::kSize)
|
605
|
-
break;
|
606
|
-
if (type == NID::kEnd)
|
821
|
+
if (type == NID::kCRC || type == NID::kSize || type == NID::kEnd)
|
607
822
|
break;
|
608
823
|
SkipData();
|
609
824
|
}
|
610
825
|
|
611
|
-
if (
|
612
|
-
for (int i = 0; i < folders.Size(); i++)
|
613
|
-
numUnpackStreamsInFolders.Add(1);
|
614
|
-
|
615
|
-
int i;
|
616
|
-
for (i = 0; i < numUnpackStreamsInFolders.Size(); i++)
|
826
|
+
if (type == NID::kSize)
|
617
827
|
{
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
828
|
+
for (i = 0; i < folders.NumFolders; i++)
|
829
|
+
{
|
830
|
+
// v3.13 incorrectly worked with empty folders
|
831
|
+
// v4.07: we check that folder is empty
|
832
|
+
CNum numSubstreams = folders.NumUnpackStreamsVector[i];
|
833
|
+
if (numSubstreams == 0)
|
834
|
+
continue;
|
835
|
+
UInt64 sum = 0;
|
836
|
+
for (CNum j = 1; j < numSubstreams; j++)
|
626
837
|
{
|
627
838
|
UInt64 size = ReadNumber();
|
628
839
|
unpackSizes.Add(size);
|
629
840
|
sum += size;
|
841
|
+
if (sum < size)
|
842
|
+
ThrowIncorrect();
|
630
843
|
}
|
631
|
-
|
632
|
-
|
633
|
-
|
844
|
+
UInt64 folderUnpackSize = folders.GetFolderUnpackSize(i);
|
845
|
+
if (folderUnpackSize < sum)
|
846
|
+
ThrowIncorrect();
|
847
|
+
unpackSizes.Add(folderUnpackSize - sum);
|
848
|
+
}
|
634
849
|
type = ReadID();
|
850
|
+
}
|
851
|
+
else
|
852
|
+
{
|
853
|
+
for (i = 0; i < folders.NumFolders; i++)
|
854
|
+
{
|
855
|
+
/* v9.26 - v9.29 incorrectly worked:
|
856
|
+
if (folders.NumUnpackStreamsVector[i] == 0), it threw error */
|
857
|
+
CNum val = folders.NumUnpackStreamsVector[i];
|
858
|
+
if (val > 1)
|
859
|
+
ThrowIncorrect();
|
860
|
+
if (val == 1)
|
861
|
+
unpackSizes.Add(folders.GetFolderUnpackSize(i));
|
862
|
+
}
|
863
|
+
}
|
635
864
|
|
636
|
-
|
637
|
-
|
638
|
-
for (i = 0; i < folders.Size(); i++)
|
865
|
+
unsigned numDigests = 0;
|
866
|
+
for (i = 0; i < folders.NumFolders; i++)
|
639
867
|
{
|
640
|
-
CNum numSubstreams =
|
641
|
-
if (numSubstreams != 1 || !folders
|
868
|
+
CNum numSubstreams = folders.NumUnpackStreamsVector[i];
|
869
|
+
if (numSubstreams != 1 || !folders.FolderCRCs.ValidAndDefined(i))
|
642
870
|
numDigests += numSubstreams;
|
643
|
-
numDigestsTotal += numSubstreams;
|
644
871
|
}
|
645
872
|
|
646
873
|
for (;;)
|
647
874
|
{
|
875
|
+
if (type == NID::kEnd)
|
876
|
+
break;
|
648
877
|
if (type == NID::kCRC)
|
649
878
|
{
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
879
|
+
// CUInt32DefVector digests2;
|
880
|
+
// ReadHashDigests(numDigests, digests2);
|
881
|
+
CBoolVector digests2;
|
882
|
+
ReadBoolVector2(numDigests, digests2);
|
883
|
+
|
884
|
+
digests.ClearAndSetSize(unpackSizes.Size());
|
885
|
+
|
886
|
+
unsigned k = 0;
|
887
|
+
unsigned k2 = 0;
|
888
|
+
|
889
|
+
for (i = 0; i < folders.NumFolders; i++)
|
655
890
|
{
|
656
|
-
CNum numSubstreams =
|
657
|
-
|
658
|
-
if (numSubstreams == 1 && folder.UnpackCRCDefined)
|
891
|
+
CNum numSubstreams = folders.NumUnpackStreamsVector[i];
|
892
|
+
if (numSubstreams == 1 && folders.FolderCRCs.ValidAndDefined(i))
|
659
893
|
{
|
660
|
-
|
661
|
-
digests.
|
894
|
+
digests.Defs[k] = true;
|
895
|
+
digests.Vals[k] = folders.FolderCRCs.Vals[i];
|
896
|
+
k++;
|
897
|
+
}
|
898
|
+
else for (CNum j = 0; j < numSubstreams; j++)
|
899
|
+
{
|
900
|
+
bool defined = digests2[k2++];
|
901
|
+
digests.Defs[k] = defined;
|
902
|
+
UInt32 crc = 0;
|
903
|
+
if (defined)
|
904
|
+
crc = ReadUInt32();
|
905
|
+
digests.Vals[k] = crc;
|
906
|
+
k++;
|
662
907
|
}
|
663
|
-
else
|
664
|
-
for (CNum j = 0; j < numSubstreams; j++, digestIndex++)
|
665
|
-
{
|
666
|
-
digestsDefined.Add(digestsDefined2[digestIndex]);
|
667
|
-
digests.Add(digests2[digestIndex]);
|
668
|
-
}
|
669
908
|
}
|
909
|
+
// if (k != unpackSizes.Size()) throw 1234567;
|
670
910
|
}
|
671
|
-
else
|
911
|
+
else
|
912
|
+
SkipData();
|
913
|
+
|
914
|
+
type = ReadID();
|
915
|
+
}
|
916
|
+
|
917
|
+
if (digests.Defs.Size() != unpackSizes.Size())
|
918
|
+
{
|
919
|
+
digests.ClearAndSetSize(unpackSizes.Size());
|
920
|
+
unsigned k = 0;
|
921
|
+
for (i = 0; i < folders.NumFolders; i++)
|
672
922
|
{
|
673
|
-
|
923
|
+
CNum numSubstreams = folders.NumUnpackStreamsVector[i];
|
924
|
+
if (numSubstreams == 1 && folders.FolderCRCs.ValidAndDefined(i))
|
674
925
|
{
|
675
|
-
|
676
|
-
digests.
|
677
|
-
|
678
|
-
|
926
|
+
digests.Defs[k] = true;
|
927
|
+
digests.Vals[k] = folders.FolderCRCs.Vals[i];
|
928
|
+
k++;
|
929
|
+
}
|
930
|
+
else for (CNum j = 0; j < numSubstreams; j++)
|
931
|
+
{
|
932
|
+
digests.Defs[k] = false;
|
933
|
+
digests.Vals[k] = 0;
|
934
|
+
k++;
|
679
935
|
}
|
680
|
-
return;
|
681
936
|
}
|
682
|
-
else
|
683
|
-
SkipData();
|
684
|
-
type = ReadID();
|
685
937
|
}
|
686
938
|
}
|
687
939
|
|
688
940
|
void CInArchive::ReadStreamsInfo(
|
689
941
|
const CObjectVector<CByteBuffer> *dataVector,
|
690
942
|
UInt64 &dataOffset,
|
691
|
-
|
692
|
-
CBoolVector &packCRCsDefined,
|
693
|
-
CRecordVector<UInt32> &packCRCs,
|
694
|
-
CObjectVector<CFolder> &folders,
|
695
|
-
CRecordVector<CNum> &numUnpackStreamsInFolders,
|
943
|
+
CFolders &folders,
|
696
944
|
CRecordVector<UInt64> &unpackSizes,
|
697
|
-
|
698
|
-
CRecordVector<UInt32> &digests)
|
945
|
+
CUInt32DefVector &digests)
|
699
946
|
{
|
700
|
-
|
947
|
+
UInt64 type = ReadID();
|
948
|
+
|
949
|
+
if (type == NID::kPackInfo)
|
701
950
|
{
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
951
|
+
dataOffset = ReadNumber();
|
952
|
+
ReadPackInfo(folders);
|
953
|
+
type = ReadID();
|
954
|
+
}
|
955
|
+
|
956
|
+
if (type == NID::kUnpackInfo)
|
957
|
+
{
|
958
|
+
ReadUnpackInfo(dataVector, folders);
|
959
|
+
type = ReadID();
|
960
|
+
}
|
961
|
+
|
962
|
+
if (folders.NumFolders != 0 && !folders.PackPositions)
|
963
|
+
{
|
964
|
+
// if there are folders, we need PackPositions also
|
965
|
+
folders.PackPositions.Alloc(1);
|
966
|
+
folders.PackPositions[0] = 0;
|
967
|
+
}
|
968
|
+
|
969
|
+
if (type == NID::kSubStreamsInfo)
|
970
|
+
{
|
971
|
+
ReadSubStreamsInfo(folders, unpackSizes, digests);
|
972
|
+
type = ReadID();
|
973
|
+
}
|
974
|
+
else
|
975
|
+
{
|
976
|
+
folders.NumUnpackStreamsVector.Alloc(folders.NumFolders);
|
977
|
+
/* If digests.Defs.Size() == 0, it means that there are no crcs.
|
978
|
+
So we don't need to fill digests with values. */
|
979
|
+
// digests.Vals.ClearAndSetSize(folders.NumFolders);
|
980
|
+
// BoolVector_Fill_False(digests.Defs, folders.NumFolders);
|
981
|
+
for (CNum i = 0; i < folders.NumFolders; i++)
|
706
982
|
{
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
{
|
711
|
-
ReadPackInfo(dataOffset, packSizes, packCRCsDefined, packCRCs);
|
712
|
-
break;
|
713
|
-
}
|
714
|
-
case NID::kUnpackInfo:
|
715
|
-
{
|
716
|
-
ReadUnpackInfo(dataVector, folders);
|
717
|
-
break;
|
718
|
-
}
|
719
|
-
case NID::kSubStreamsInfo:
|
720
|
-
{
|
721
|
-
ReadSubStreamsInfo(folders, numUnpackStreamsInFolders,
|
722
|
-
unpackSizes, digestsDefined, digests);
|
723
|
-
break;
|
724
|
-
}
|
725
|
-
default:
|
726
|
-
ThrowIncorrect();
|
983
|
+
folders.NumUnpackStreamsVector[i] = 1;
|
984
|
+
unpackSizes.Add(folders.GetFolderUnpackSize(i));
|
985
|
+
// digests.Vals[i] = 0;
|
727
986
|
}
|
728
987
|
}
|
988
|
+
|
989
|
+
if (type != NID::kEnd)
|
990
|
+
ThrowIncorrect();
|
729
991
|
}
|
730
992
|
|
731
|
-
void CInArchive::ReadBoolVector(
|
993
|
+
void CInArchive::ReadBoolVector(unsigned numItems, CBoolVector &v)
|
732
994
|
{
|
733
|
-
v.
|
734
|
-
v.Reserve(numItems);
|
995
|
+
v.ClearAndSetSize(numItems);
|
735
996
|
Byte b = 0;
|
736
997
|
Byte mask = 0;
|
737
|
-
|
998
|
+
bool *p = &v[0];
|
999
|
+
for (unsigned i = 0; i < numItems; i++)
|
738
1000
|
{
|
739
1001
|
if (mask == 0)
|
740
1002
|
{
|
741
1003
|
b = ReadByte();
|
742
1004
|
mask = 0x80;
|
743
1005
|
}
|
744
|
-
|
1006
|
+
p[i] = ((b & mask) != 0);
|
745
1007
|
mask >>= 1;
|
746
1008
|
}
|
747
1009
|
}
|
748
1010
|
|
749
|
-
void CInArchive::ReadBoolVector2(
|
1011
|
+
void CInArchive::ReadBoolVector2(unsigned numItems, CBoolVector &v)
|
750
1012
|
{
|
751
1013
|
Byte allAreDefined = ReadByte();
|
752
1014
|
if (allAreDefined == 0)
|
@@ -754,27 +1016,30 @@ void CInArchive::ReadBoolVector2(int numItems, CBoolVector &v)
|
|
754
1016
|
ReadBoolVector(numItems, v);
|
755
1017
|
return;
|
756
1018
|
}
|
757
|
-
v.
|
758
|
-
v
|
759
|
-
for (
|
760
|
-
|
1019
|
+
v.ClearAndSetSize(numItems);
|
1020
|
+
bool *p = &v[0];
|
1021
|
+
for (unsigned i = 0; i < numItems; i++)
|
1022
|
+
p[i] = true;
|
761
1023
|
}
|
762
1024
|
|
763
1025
|
void CInArchive::ReadUInt64DefVector(const CObjectVector<CByteBuffer> &dataVector,
|
764
|
-
CUInt64DefVector &v,
|
1026
|
+
CUInt64DefVector &v, unsigned numItems)
|
765
1027
|
{
|
766
|
-
ReadBoolVector2(
|
1028
|
+
ReadBoolVector2(numItems, v.Defs);
|
767
1029
|
|
768
1030
|
CStreamSwitch streamSwitch;
|
769
1031
|
streamSwitch.Set(this, &dataVector);
|
770
|
-
|
1032
|
+
|
1033
|
+
v.Vals.ClearAndSetSize(numItems);
|
1034
|
+
UInt64 *p = &v.Vals[0];
|
1035
|
+
const bool *defs = &v.Defs[0];
|
771
1036
|
|
772
|
-
for (
|
1037
|
+
for (unsigned i = 0; i < numItems; i++)
|
773
1038
|
{
|
774
1039
|
UInt64 t = 0;
|
775
|
-
if (
|
1040
|
+
if (defs[i])
|
776
1041
|
t = ReadUInt64();
|
777
|
-
|
1042
|
+
p[i] = t;
|
778
1043
|
}
|
779
1044
|
}
|
780
1045
|
|
@@ -782,97 +1047,72 @@ HRESULT CInArchive::ReadAndDecodePackedStreams(
|
|
782
1047
|
DECL_EXTERNAL_CODECS_LOC_VARS
|
783
1048
|
UInt64 baseOffset,
|
784
1049
|
UInt64 &dataOffset, CObjectVector<CByteBuffer> &dataVector
|
785
|
-
|
786
|
-
, ICryptoGetTextPassword *getTextPassword, bool &passwordIsDefined
|
787
|
-
#endif
|
1050
|
+
_7Z_DECODER_CRYPRO_VARS_DECL
|
788
1051
|
)
|
789
1052
|
{
|
790
|
-
|
791
|
-
CBoolVector packCRCsDefined;
|
792
|
-
CRecordVector<UInt32> packCRCs;
|
793
|
-
CObjectVector<CFolder> folders;
|
794
|
-
|
795
|
-
CRecordVector<CNum> numUnpackStreamsInFolders;
|
1053
|
+
CFolders folders;
|
796
1054
|
CRecordVector<UInt64> unpackSizes;
|
797
|
-
|
798
|
-
CRecordVector<UInt32> digests;
|
1055
|
+
CUInt32DefVector digests;
|
799
1056
|
|
800
1057
|
ReadStreamsInfo(NULL,
|
801
1058
|
dataOffset,
|
802
|
-
packSizes,
|
803
|
-
packCRCsDefined,
|
804
|
-
packCRCs,
|
805
1059
|
folders,
|
806
|
-
numUnpackStreamsInFolders,
|
807
1060
|
unpackSizes,
|
808
|
-
digestsDefined,
|
809
1061
|
digests);
|
810
1062
|
|
811
|
-
|
812
|
-
|
813
|
-
CNum
|
814
|
-
CDecoder decoder(
|
815
|
-
#ifdef _ST_MODE
|
816
|
-
false
|
817
|
-
#else
|
818
|
-
true
|
819
|
-
#endif
|
820
|
-
);
|
821
|
-
UInt64 dataStartPos = baseOffset + dataOffset;
|
822
|
-
for (int i = 0; i < folders.Size(); i++)
|
1063
|
+
CDecoder decoder(_useMixerMT);
|
1064
|
+
|
1065
|
+
for (CNum i = 0; i < folders.NumFolders; i++)
|
823
1066
|
{
|
824
|
-
|
825
|
-
|
826
|
-
CByteBuffer &data = dataVector.Back();
|
827
|
-
UInt64 unpackSize64 = folder.GetUnpackSize();
|
1067
|
+
CByteBuffer &data = dataVector.AddNew();
|
1068
|
+
UInt64 unpackSize64 = folders.GetFolderUnpackSize(i);
|
828
1069
|
size_t unpackSize = (size_t)unpackSize64;
|
829
1070
|
if (unpackSize != unpackSize64)
|
830
1071
|
ThrowUnsupported();
|
831
|
-
data.
|
1072
|
+
data.Alloc(unpackSize);
|
832
1073
|
|
833
1074
|
CBufPtrSeqOutStream *outStreamSpec = new CBufPtrSeqOutStream;
|
834
1075
|
CMyComPtr<ISequentialOutStream> outStream = outStreamSpec;
|
835
1076
|
outStreamSpec->Init(data, unpackSize);
|
836
1077
|
|
837
1078
|
HRESULT result = decoder.Decode(
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
1079
|
+
EXTERNAL_CODECS_LOC_VARS
|
1080
|
+
_stream, baseOffset + dataOffset,
|
1081
|
+
folders, i,
|
1082
|
+
NULL, // *unpackSize
|
1083
|
+
|
1084
|
+
outStream,
|
1085
|
+
NULL, // *compressProgress
|
1086
|
+
NULL // **inStreamMainRes
|
1087
|
+
|
1088
|
+
_7Z_DECODER_CRYPRO_VARS
|
1089
|
+
#if !defined(_7ZIP_ST) && !defined(_SFX)
|
1090
|
+
, false // mtMode
|
1091
|
+
, 1 // numThreads
|
1092
|
+
#endif
|
847
1093
|
);
|
848
1094
|
RINOK(result);
|
849
1095
|
|
850
|
-
if (
|
851
|
-
if (CrcCalc(data, unpackSize) !=
|
1096
|
+
if (folders.FolderCRCs.ValidAndDefined(i))
|
1097
|
+
if (CrcCalc(data, unpackSize) != folders.FolderCRCs.Vals[i])
|
852
1098
|
ThrowIncorrect();
|
853
|
-
for (int j = 0; j < folder.PackStreams.Size(); j++)
|
854
|
-
{
|
855
|
-
UInt64 packSize = packSizes[packIndex++];
|
856
|
-
dataStartPos += packSize;
|
857
|
-
HeadersSize += packSize;
|
858
|
-
}
|
859
1099
|
}
|
1100
|
+
if (folders.PackPositions)
|
1101
|
+
HeadersSize += folders.PackPositions[folders.NumPackStreams];
|
860
1102
|
return S_OK;
|
861
1103
|
}
|
862
1104
|
|
863
1105
|
HRESULT CInArchive::ReadHeader(
|
864
1106
|
DECL_EXTERNAL_CODECS_LOC_VARS
|
865
|
-
|
866
|
-
|
867
|
-
, ICryptoGetTextPassword *getTextPassword, bool &passwordIsDefined
|
868
|
-
#endif
|
1107
|
+
CDbEx &db
|
1108
|
+
_7Z_DECODER_CRYPRO_VARS_DECL
|
869
1109
|
)
|
870
1110
|
{
|
871
1111
|
UInt64 type = ReadID();
|
872
1112
|
|
873
1113
|
if (type == NID::kArchiveProperties)
|
874
1114
|
{
|
875
|
-
ReadArchiveProperties(db.
|
1115
|
+
ReadArchiveProperties(db.ArcInfo);
|
876
1116
|
type = ReadID();
|
877
1117
|
}
|
878
1118
|
|
@@ -882,102 +1122,105 @@ HRESULT CInArchive::ReadHeader(
|
|
882
1122
|
{
|
883
1123
|
HRESULT result = ReadAndDecodePackedStreams(
|
884
1124
|
EXTERNAL_CODECS_LOC_VARS
|
885
|
-
db.
|
886
|
-
db.
|
1125
|
+
db.ArcInfo.StartPositionAfterHeader,
|
1126
|
+
db.ArcInfo.DataStartPosition2,
|
887
1127
|
dataVector
|
888
|
-
|
889
|
-
, getTextPassword, passwordIsDefined
|
890
|
-
#endif
|
1128
|
+
_7Z_DECODER_CRYPRO_VARS
|
891
1129
|
);
|
892
1130
|
RINOK(result);
|
893
|
-
db.
|
1131
|
+
db.ArcInfo.DataStartPosition2 += db.ArcInfo.StartPositionAfterHeader;
|
894
1132
|
type = ReadID();
|
895
1133
|
}
|
896
1134
|
|
897
1135
|
CRecordVector<UInt64> unpackSizes;
|
898
|
-
|
899
|
-
CRecordVector<UInt32> digests;
|
1136
|
+
CUInt32DefVector digests;
|
900
1137
|
|
901
1138
|
if (type == NID::kMainStreamsInfo)
|
902
1139
|
{
|
903
1140
|
ReadStreamsInfo(&dataVector,
|
904
|
-
db.
|
905
|
-
db
|
906
|
-
db.PackCRCsDefined,
|
907
|
-
db.PackCRCs,
|
908
|
-
db.Folders,
|
909
|
-
db.NumUnpackStreamsVector,
|
1141
|
+
db.ArcInfo.DataStartPosition,
|
1142
|
+
(CFolders &)db,
|
910
1143
|
unpackSizes,
|
911
|
-
digestsDefined,
|
912
1144
|
digests);
|
913
|
-
db.
|
1145
|
+
db.ArcInfo.DataStartPosition += db.ArcInfo.StartPositionAfterHeader;
|
914
1146
|
type = ReadID();
|
915
1147
|
}
|
916
|
-
else
|
917
|
-
{
|
918
|
-
for (int i = 0; i < db.Folders.Size(); i++)
|
919
|
-
{
|
920
|
-
db.NumUnpackStreamsVector.Add(1);
|
921
|
-
CFolder &folder = db.Folders[i];
|
922
|
-
unpackSizes.Add(folder.GetUnpackSize());
|
923
|
-
digestsDefined.Add(folder.UnpackCRCDefined);
|
924
|
-
digests.Add(folder.UnpackCRC);
|
925
|
-
}
|
926
|
-
}
|
927
1148
|
|
928
1149
|
db.Files.Clear();
|
929
1150
|
|
930
|
-
if (type == NID::
|
931
|
-
|
932
|
-
if (type != NID::kFilesInfo)
|
933
|
-
ThrowIncorrect();
|
1151
|
+
if (type == NID::kFilesInfo)
|
1152
|
+
{
|
934
1153
|
|
935
|
-
CNum numFiles = ReadNum();
|
1154
|
+
const CNum numFiles = ReadNum();
|
1155
|
+
db.Files.ClearAndSetSize(numFiles);
|
1156
|
+
/*
|
936
1157
|
db.Files.Reserve(numFiles);
|
937
1158
|
CNum i;
|
938
1159
|
for (i = 0; i < numFiles; i++)
|
939
1160
|
db.Files.Add(CFileItem());
|
1161
|
+
*/
|
940
1162
|
|
941
|
-
db.
|
942
|
-
if (!db.PackSizes.IsEmpty())
|
943
|
-
db.
|
944
|
-
if (numFiles > 0
|
945
|
-
db.
|
1163
|
+
db.ArcInfo.FileInfoPopIDs.Add(NID::kSize);
|
1164
|
+
// if (!db.PackSizes.IsEmpty())
|
1165
|
+
db.ArcInfo.FileInfoPopIDs.Add(NID::kPackInfo);
|
1166
|
+
if (numFiles > 0 && !digests.Defs.IsEmpty())
|
1167
|
+
db.ArcInfo.FileInfoPopIDs.Add(NID::kCRC);
|
946
1168
|
|
947
1169
|
CBoolVector emptyStreamVector;
|
948
|
-
BoolVector_Fill_False(emptyStreamVector, (
|
1170
|
+
BoolVector_Fill_False(emptyStreamVector, (unsigned)numFiles);
|
949
1171
|
CBoolVector emptyFileVector;
|
950
1172
|
CBoolVector antiFileVector;
|
951
1173
|
CNum numEmptyStreams = 0;
|
952
1174
|
|
953
1175
|
for (;;)
|
954
1176
|
{
|
955
|
-
UInt64
|
956
|
-
if (
|
1177
|
+
const UInt64 type2 = ReadID();
|
1178
|
+
if (type2 == NID::kEnd)
|
957
1179
|
break;
|
958
1180
|
UInt64 size = ReadNumber();
|
959
|
-
|
1181
|
+
if (size > _inByteBack->GetRem())
|
1182
|
+
ThrowIncorrect();
|
1183
|
+
CStreamSwitch switchProp;
|
1184
|
+
switchProp.Set(this, _inByteBack->GetPtr(), (size_t)size, true);
|
960
1185
|
bool addPropIdToList = true;
|
961
1186
|
bool isKnownType = true;
|
962
|
-
if (
|
1187
|
+
if (type2 > ((UInt32)1 << 30))
|
963
1188
|
isKnownType = false;
|
964
|
-
else switch((UInt32)
|
1189
|
+
else switch ((UInt32)type2)
|
965
1190
|
{
|
966
1191
|
case NID::kName:
|
967
1192
|
{
|
968
1193
|
CStreamSwitch streamSwitch;
|
969
1194
|
streamSwitch.Set(this, &dataVector);
|
970
|
-
|
971
|
-
|
1195
|
+
size_t rem = _inByteBack->GetRem();
|
1196
|
+
db.NamesBuf.Alloc(rem);
|
1197
|
+
ReadBytes(db.NamesBuf, rem);
|
1198
|
+
db.NameOffsets.Alloc(db.Files.Size() + 1);
|
1199
|
+
size_t pos = 0;
|
1200
|
+
unsigned i;
|
1201
|
+
for (i = 0; i < db.Files.Size(); i++)
|
1202
|
+
{
|
1203
|
+
size_t curRem = (rem - pos) / 2;
|
1204
|
+
const UInt16 *buf = (const UInt16 *)(db.NamesBuf + pos);
|
1205
|
+
size_t j;
|
1206
|
+
for (j = 0; j < curRem && buf[j] != 0; j++);
|
1207
|
+
if (j == curRem)
|
1208
|
+
ThrowEndOfData();
|
1209
|
+
db.NameOffsets[i] = pos / 2;
|
1210
|
+
pos += j * 2 + 2;
|
1211
|
+
}
|
1212
|
+
db.NameOffsets[i] = pos / 2;
|
1213
|
+
if (pos != rem)
|
1214
|
+
ThereIsHeaderError = true;
|
972
1215
|
break;
|
973
1216
|
}
|
974
|
-
case NID::
|
1217
|
+
case NID::kWinAttrib:
|
975
1218
|
{
|
976
1219
|
CBoolVector boolVector;
|
977
1220
|
ReadBoolVector2(db.Files.Size(), boolVector);
|
978
1221
|
CStreamSwitch streamSwitch;
|
979
1222
|
streamSwitch.Set(this, &dataVector);
|
980
|
-
for (i = 0; i < numFiles; i++)
|
1223
|
+
for (CNum i = 0; i < numFiles; i++)
|
981
1224
|
{
|
982
1225
|
CFileItem &file = db.Files[i];
|
983
1226
|
file.AttribDefined = boolVector[i];
|
@@ -986,10 +1229,41 @@ HRESULT CInArchive::ReadHeader(
|
|
986
1229
|
}
|
987
1230
|
break;
|
988
1231
|
}
|
1232
|
+
/*
|
1233
|
+
case NID::kIsAux:
|
1234
|
+
{
|
1235
|
+
ReadBoolVector(db.Files.Size(), db.IsAux);
|
1236
|
+
break;
|
1237
|
+
}
|
1238
|
+
case NID::kParent:
|
1239
|
+
{
|
1240
|
+
db.IsTree = true;
|
1241
|
+
// CBoolVector boolVector;
|
1242
|
+
// ReadBoolVector2(db.Files.Size(), boolVector);
|
1243
|
+
// CStreamSwitch streamSwitch;
|
1244
|
+
// streamSwitch.Set(this, &dataVector);
|
1245
|
+
CBoolVector boolVector;
|
1246
|
+
ReadBoolVector2(db.Files.Size(), boolVector);
|
1247
|
+
|
1248
|
+
db.ThereAreAltStreams = false;
|
1249
|
+
for (i = 0; i < numFiles; i++)
|
1250
|
+
{
|
1251
|
+
CFileItem &file = db.Files[i];
|
1252
|
+
// file.Parent = -1;
|
1253
|
+
// if (boolVector[i])
|
1254
|
+
file.Parent = (int)ReadUInt32();
|
1255
|
+
file.IsAltStream = !boolVector[i];
|
1256
|
+
if (file.IsAltStream)
|
1257
|
+
db.ThereAreAltStreams = true;
|
1258
|
+
}
|
1259
|
+
break;
|
1260
|
+
}
|
1261
|
+
*/
|
989
1262
|
case NID::kEmptyStream:
|
990
1263
|
{
|
991
1264
|
ReadBoolVector(numFiles, emptyStreamVector);
|
992
|
-
|
1265
|
+
numEmptyStreams = 0;
|
1266
|
+
for (CNum i = 0; i < (CNum)emptyStreamVector.Size(); i++)
|
993
1267
|
if (emptyStreamVector[i])
|
994
1268
|
numEmptyStreams++;
|
995
1269
|
|
@@ -1000,54 +1274,111 @@ HRESULT CInArchive::ReadHeader(
|
|
1000
1274
|
}
|
1001
1275
|
case NID::kEmptyFile: ReadBoolVector(numEmptyStreams, emptyFileVector); break;
|
1002
1276
|
case NID::kAnti: ReadBoolVector(numEmptyStreams, antiFileVector); break;
|
1003
|
-
case NID::kStartPos: ReadUInt64DefVector(dataVector, db.StartPos, (
|
1004
|
-
case NID::kCTime: ReadUInt64DefVector(dataVector, db.CTime, (
|
1005
|
-
case NID::kATime: ReadUInt64DefVector(dataVector, db.ATime, (
|
1006
|
-
case NID::kMTime: ReadUInt64DefVector(dataVector, db.MTime, (
|
1277
|
+
case NID::kStartPos: ReadUInt64DefVector(dataVector, db.StartPos, (unsigned)numFiles); break;
|
1278
|
+
case NID::kCTime: ReadUInt64DefVector(dataVector, db.CTime, (unsigned)numFiles); break;
|
1279
|
+
case NID::kATime: ReadUInt64DefVector(dataVector, db.ATime, (unsigned)numFiles); break;
|
1280
|
+
case NID::kMTime: ReadUInt64DefVector(dataVector, db.MTime, (unsigned)numFiles); break;
|
1007
1281
|
case NID::kDummy:
|
1008
1282
|
{
|
1009
1283
|
for (UInt64 j = 0; j < size; j++)
|
1010
1284
|
if (ReadByte() != 0)
|
1011
|
-
|
1285
|
+
ThereIsHeaderError = true;
|
1012
1286
|
addPropIdToList = false;
|
1013
1287
|
break;
|
1014
1288
|
}
|
1289
|
+
/*
|
1290
|
+
case NID::kNtSecure:
|
1291
|
+
{
|
1292
|
+
try
|
1293
|
+
{
|
1294
|
+
{
|
1295
|
+
CStreamSwitch streamSwitch;
|
1296
|
+
streamSwitch.Set(this, &dataVector);
|
1297
|
+
UInt32 numDescriptors = ReadUInt32();
|
1298
|
+
size_t offset = 0;
|
1299
|
+
db.SecureOffsets.Clear();
|
1300
|
+
for (i = 0; i < numDescriptors; i++)
|
1301
|
+
{
|
1302
|
+
UInt32 size = ReadUInt32();
|
1303
|
+
db.SecureOffsets.Add(offset);
|
1304
|
+
offset += size;
|
1305
|
+
}
|
1306
|
+
// ThrowIncorrect();;
|
1307
|
+
db.SecureOffsets.Add(offset);
|
1308
|
+
db.SecureBuf.SetCapacity(offset);
|
1309
|
+
for (i = 0; i < numDescriptors; i++)
|
1310
|
+
{
|
1311
|
+
offset = db.SecureOffsets[i];
|
1312
|
+
ReadBytes(db.SecureBuf + offset, db.SecureOffsets[i + 1] - offset);
|
1313
|
+
}
|
1314
|
+
db.SecureIDs.Clear();
|
1315
|
+
for (unsigned i = 0; i < db.Files.Size(); i++)
|
1316
|
+
{
|
1317
|
+
db.SecureIDs.Add(ReadNum());
|
1318
|
+
// db.SecureIDs.Add(ReadUInt32());
|
1319
|
+
}
|
1320
|
+
// ReadUInt32();
|
1321
|
+
if (_inByteBack->GetRem() != 0)
|
1322
|
+
ThrowIncorrect();;
|
1323
|
+
}
|
1324
|
+
}
|
1325
|
+
catch(CInArchiveException &)
|
1326
|
+
{
|
1327
|
+
ThereIsHeaderError = true;
|
1328
|
+
addPropIdToList = isKnownType = false;
|
1329
|
+
db.ClearSecure();
|
1330
|
+
}
|
1331
|
+
break;
|
1332
|
+
}
|
1333
|
+
*/
|
1015
1334
|
default:
|
1016
1335
|
addPropIdToList = isKnownType = false;
|
1017
1336
|
}
|
1018
1337
|
if (isKnownType)
|
1019
1338
|
{
|
1020
|
-
if(addPropIdToList)
|
1021
|
-
db.
|
1339
|
+
if (addPropIdToList)
|
1340
|
+
db.ArcInfo.FileInfoPopIDs.Add(type2);
|
1022
1341
|
}
|
1023
1342
|
else
|
1024
|
-
|
1025
|
-
|
1026
|
-
|
1027
|
-
|
1343
|
+
{
|
1344
|
+
db.UnsupportedFeatureWarning = true;
|
1345
|
+
_inByteBack->SkipRem();
|
1346
|
+
}
|
1347
|
+
// SkipData worked incorrectly in some versions before v4.59 (7zVer <= 0.02)
|
1348
|
+
if (_inByteBack->GetRem() != 0)
|
1028
1349
|
ThrowIncorrect();
|
1029
1350
|
}
|
1030
1351
|
|
1352
|
+
type = ReadID(); // Read (NID::kEnd) end of headers
|
1353
|
+
|
1354
|
+
if (numFiles - numEmptyStreams != unpackSizes.Size())
|
1355
|
+
ThrowUnsupported();
|
1356
|
+
|
1031
1357
|
CNum emptyFileIndex = 0;
|
1032
1358
|
CNum sizeIndex = 0;
|
1033
1359
|
|
1034
1360
|
CNum numAntiItems = 0;
|
1361
|
+
|
1362
|
+
CNum i;
|
1363
|
+
|
1035
1364
|
for (i = 0; i < numEmptyStreams; i++)
|
1036
1365
|
if (antiFileVector[i])
|
1037
1366
|
numAntiItems++;
|
1038
|
-
|
1367
|
+
|
1039
1368
|
for (i = 0; i < numFiles; i++)
|
1040
1369
|
{
|
1041
1370
|
CFileItem &file = db.Files[i];
|
1042
1371
|
bool isAnti;
|
1043
1372
|
file.HasStream = !emptyStreamVector[i];
|
1373
|
+
file.Crc = 0;
|
1044
1374
|
if (file.HasStream)
|
1045
1375
|
{
|
1046
1376
|
file.IsDir = false;
|
1047
1377
|
isAnti = false;
|
1048
1378
|
file.Size = unpackSizes[sizeIndex];
|
1049
|
-
file.
|
1050
|
-
file.CrcDefined
|
1379
|
+
file.CrcDefined = digests.ValidAndDefined(sizeIndex);
|
1380
|
+
if (file.CrcDefined)
|
1381
|
+
file.Crc = digests.Vals[sizeIndex];
|
1051
1382
|
sizeIndex++;
|
1052
1383
|
}
|
1053
1384
|
else
|
@@ -1061,156 +1392,182 @@ HRESULT CInArchive::ReadHeader(
|
|
1061
1392
|
if (numAntiItems != 0)
|
1062
1393
|
db.IsAnti.Add(isAnti);
|
1063
1394
|
}
|
1064
|
-
return S_OK;
|
1065
|
-
}
|
1066
|
-
|
1067
|
-
|
1068
|
-
void CArchiveDatabaseEx::FillFolderStartPackStream()
|
1069
|
-
{
|
1070
|
-
FolderStartPackStreamIndex.Clear();
|
1071
|
-
FolderStartPackStreamIndex.Reserve(Folders.Size());
|
1072
|
-
CNum startPos = 0;
|
1073
|
-
for (int i = 0; i < Folders.Size(); i++)
|
1074
|
-
{
|
1075
|
-
FolderStartPackStreamIndex.Add(startPos);
|
1076
|
-
startPos += (CNum)Folders[i].PackStreams.Size();
|
1077
|
-
}
|
1078
|
-
}
|
1079
|
-
|
1080
|
-
void CArchiveDatabaseEx::FillStartPos()
|
1081
|
-
{
|
1082
|
-
PackStreamStartPositions.Clear();
|
1083
|
-
PackStreamStartPositions.Reserve(PackSizes.Size());
|
1084
|
-
UInt64 startPos = 0;
|
1085
|
-
for (int i = 0; i < PackSizes.Size(); i++)
|
1086
|
-
{
|
1087
|
-
PackStreamStartPositions.Add(startPos);
|
1088
|
-
startPos += PackSizes[i];
|
1089
1395
|
}
|
1396
|
+
db.FillLinks();
|
1397
|
+
/*
|
1398
|
+
if (type != NID::kEnd)
|
1399
|
+
ThrowIncorrect();
|
1400
|
+
if (_inByteBack->GetRem() != 0)
|
1401
|
+
ThrowIncorrect();
|
1402
|
+
*/
|
1403
|
+
return S_OK;
|
1090
1404
|
}
|
1091
1405
|
|
1092
|
-
void
|
1406
|
+
void CDbEx::FillLinks()
|
1093
1407
|
{
|
1094
|
-
FolderStartFileIndex.
|
1095
|
-
|
1096
|
-
FileIndexToFolderIndexMap.Clear();
|
1097
|
-
FileIndexToFolderIndexMap.Reserve(Files.Size());
|
1408
|
+
FolderStartFileIndex.Alloc(NumFolders);
|
1409
|
+
FileIndexToFolderIndexMap.Alloc(Files.Size());
|
1098
1410
|
|
1099
|
-
|
1411
|
+
CNum folderIndex = 0;
|
1100
1412
|
CNum indexInFolder = 0;
|
1101
|
-
|
1413
|
+
unsigned i;
|
1414
|
+
|
1415
|
+
for (i = 0; i < Files.Size(); i++)
|
1102
1416
|
{
|
1103
|
-
|
1104
|
-
bool emptyStream = !file.HasStream;
|
1105
|
-
if (emptyStream && indexInFolder == 0)
|
1106
|
-
{
|
1107
|
-
FileIndexToFolderIndexMap.Add(kNumNoIndex);
|
1108
|
-
continue;
|
1109
|
-
}
|
1417
|
+
bool emptyStream = !Files[i].HasStream;
|
1110
1418
|
if (indexInFolder == 0)
|
1111
1419
|
{
|
1420
|
+
if (emptyStream)
|
1421
|
+
{
|
1422
|
+
FileIndexToFolderIndexMap[i] = kNumNoIndex;
|
1423
|
+
continue;
|
1424
|
+
}
|
1112
1425
|
// v3.13 incorrectly worked with empty folders
|
1113
|
-
// v4.07:
|
1426
|
+
// v4.07: we skip empty folders
|
1114
1427
|
for (;;)
|
1115
1428
|
{
|
1116
|
-
if (folderIndex >=
|
1429
|
+
if (folderIndex >= NumFolders)
|
1117
1430
|
ThrowIncorrect();
|
1118
|
-
FolderStartFileIndex
|
1431
|
+
FolderStartFileIndex[folderIndex] = i;
|
1119
1432
|
if (NumUnpackStreamsVector[folderIndex] != 0)
|
1120
1433
|
break;
|
1121
1434
|
folderIndex++;
|
1122
1435
|
}
|
1123
1436
|
}
|
1124
|
-
FileIndexToFolderIndexMap
|
1437
|
+
FileIndexToFolderIndexMap[i] = folderIndex;
|
1125
1438
|
if (emptyStream)
|
1126
1439
|
continue;
|
1127
|
-
indexInFolder
|
1128
|
-
if (indexInFolder >= NumUnpackStreamsVector[folderIndex])
|
1440
|
+
if (++indexInFolder >= NumUnpackStreamsVector[folderIndex])
|
1129
1441
|
{
|
1130
1442
|
folderIndex++;
|
1131
1443
|
indexInFolder = 0;
|
1132
1444
|
}
|
1133
1445
|
}
|
1446
|
+
|
1447
|
+
if (indexInFolder != 0)
|
1448
|
+
folderIndex++;
|
1449
|
+
/*
|
1450
|
+
if (indexInFolder != 0)
|
1451
|
+
ThrowIncorrect();
|
1452
|
+
*/
|
1453
|
+
|
1454
|
+
for (;;)
|
1455
|
+
{
|
1456
|
+
if (folderIndex >= NumFolders)
|
1457
|
+
return;
|
1458
|
+
FolderStartFileIndex[folderIndex] = i;
|
1459
|
+
/*
|
1460
|
+
if (NumUnpackStreamsVector[folderIndex] != 0)
|
1461
|
+
ThrowIncorrect();;
|
1462
|
+
*/
|
1463
|
+
folderIndex++;
|
1464
|
+
}
|
1134
1465
|
}
|
1135
1466
|
|
1136
1467
|
HRESULT CInArchive::ReadDatabase2(
|
1137
1468
|
DECL_EXTERNAL_CODECS_LOC_VARS
|
1138
|
-
|
1139
|
-
|
1140
|
-
, ICryptoGetTextPassword *getTextPassword, bool &passwordIsDefined
|
1141
|
-
#endif
|
1469
|
+
CDbEx &db
|
1470
|
+
_7Z_DECODER_CRYPRO_VARS_DECL
|
1142
1471
|
)
|
1143
1472
|
{
|
1144
1473
|
db.Clear();
|
1145
|
-
db.
|
1474
|
+
db.ArcInfo.StartPosition = _arhiveBeginStreamPosition;
|
1146
1475
|
|
1147
|
-
db.
|
1148
|
-
db.
|
1476
|
+
db.ArcInfo.Version.Major = _header[6];
|
1477
|
+
db.ArcInfo.Version.Minor = _header[7];
|
1149
1478
|
|
1150
|
-
if (db.
|
1151
|
-
|
1479
|
+
if (db.ArcInfo.Version.Major != kMajorVersion)
|
1480
|
+
{
|
1481
|
+
// db.UnsupportedVersion = true;
|
1482
|
+
return S_FALSE;
|
1483
|
+
}
|
1152
1484
|
|
1153
|
-
|
1154
|
-
UInt64
|
1155
|
-
|
1156
|
-
UInt32 nextHeaderCRC = Get32(_header + 0x1C);
|
1157
|
-
UInt32 crc = CrcCalc(_header + 0xC, 20);
|
1485
|
+
UInt64 nextHeaderOffset = Get64(_header + 12);
|
1486
|
+
UInt64 nextHeaderSize = Get64(_header + 20);
|
1487
|
+
UInt32 nextHeaderCRC = Get32(_header + 28);
|
1158
1488
|
|
1159
1489
|
#ifdef FORMAT_7Z_RECOVERY
|
1160
|
-
|
1490
|
+
UInt32 crcFromArc = Get32(_header + 8);
|
1491
|
+
if (crcFromArc == 0 && nextHeaderOffset == 0 && nextHeaderSize == 0 && nextHeaderCRC == 0)
|
1161
1492
|
{
|
1162
|
-
UInt64 cur,
|
1493
|
+
UInt64 cur, fileSize;
|
1163
1494
|
RINOK(_stream->Seek(0, STREAM_SEEK_CUR, &cur));
|
1164
|
-
const
|
1495
|
+
const unsigned kCheckSize = 512;
|
1165
1496
|
Byte buf[kCheckSize];
|
1166
|
-
RINOK(_stream->Seek(0, STREAM_SEEK_END, &
|
1167
|
-
|
1168
|
-
|
1169
|
-
|
1170
|
-
|
1171
|
-
|
1497
|
+
RINOK(_stream->Seek(0, STREAM_SEEK_END, &fileSize));
|
1498
|
+
UInt64 rem = fileSize - cur;
|
1499
|
+
unsigned checkSize = kCheckSize;
|
1500
|
+
if (rem < kCheckSize)
|
1501
|
+
checkSize = (unsigned)(rem);
|
1502
|
+
if (checkSize < 3)
|
1503
|
+
return S_FALSE;
|
1504
|
+
RINOK(_stream->Seek(fileSize - checkSize, STREAM_SEEK_SET, NULL));
|
1172
1505
|
RINOK(ReadStream_FALSE(_stream, buf, (size_t)checkSize));
|
1173
1506
|
|
1174
|
-
|
1175
|
-
for (i = (int)checkSize - 2; i >= 0; i--)
|
1176
|
-
if (buf[i] == 0x17 && buf[i + 1] == 0x6 || buf[i] == 0x01 && buf[i + 1] == 0x04)
|
1177
|
-
break;
|
1178
|
-
if (i < 0)
|
1507
|
+
if (buf[checkSize - 1] != 0)
|
1179
1508
|
return S_FALSE;
|
1509
|
+
|
1510
|
+
unsigned i;
|
1511
|
+
for (i = checkSize - 2;; i--)
|
1512
|
+
{
|
1513
|
+
if (buf[i] == NID::kEncodedHeader && buf[i + 1] == NID::kPackInfo ||
|
1514
|
+
buf[i] == NID::kHeader && buf[i + 1] == NID::kMainStreamsInfo)
|
1515
|
+
break;
|
1516
|
+
if (i == 0)
|
1517
|
+
return S_FALSE;
|
1518
|
+
}
|
1180
1519
|
nextHeaderSize = checkSize - i;
|
1181
|
-
nextHeaderOffset =
|
1520
|
+
nextHeaderOffset = rem - nextHeaderSize;
|
1182
1521
|
nextHeaderCRC = CrcCalc(buf + i, (size_t)nextHeaderSize);
|
1183
1522
|
RINOK(_stream->Seek(cur, STREAM_SEEK_SET, NULL));
|
1523
|
+
db.StartHeaderWasRecovered = true;
|
1184
1524
|
}
|
1185
1525
|
else
|
1186
1526
|
#endif
|
1187
1527
|
{
|
1188
|
-
|
1189
|
-
|
1528
|
+
// Crc was tested already at signature check
|
1529
|
+
// if (CrcCalc(_header + 12, 20) != crcFromArchive) ThrowIncorrect();
|
1190
1530
|
}
|
1191
1531
|
|
1192
|
-
db.
|
1532
|
+
db.ArcInfo.StartPositionAfterHeader = _arhiveBeginStreamPosition + kHeaderSize;
|
1533
|
+
db.PhySize = kHeaderSize;
|
1193
1534
|
|
1535
|
+
db.IsArc = false;
|
1536
|
+
if ((Int64)nextHeaderOffset < 0 ||
|
1537
|
+
nextHeaderSize > ((UInt64)1 << 62))
|
1538
|
+
return S_FALSE;
|
1194
1539
|
if (nextHeaderSize == 0)
|
1540
|
+
{
|
1541
|
+
if (nextHeaderOffset != 0)
|
1542
|
+
return S_FALSE;
|
1543
|
+
db.IsArc = true;
|
1195
1544
|
return S_OK;
|
1196
|
-
|
1197
|
-
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1545
|
+
}
|
1546
|
+
|
1547
|
+
if (!db.StartHeaderWasRecovered)
|
1548
|
+
db.IsArc = true;
|
1549
|
+
|
1550
|
+
HeadersSize += kHeaderSize + nextHeaderSize;
|
1551
|
+
db.PhySize = kHeaderSize + nextHeaderOffset + nextHeaderSize;
|
1552
|
+
if (_fileEndPosition - db.ArcInfo.StartPositionAfterHeader < nextHeaderOffset + nextHeaderSize)
|
1553
|
+
{
|
1554
|
+
db.UnexpectedEnd = true;
|
1201
1555
|
return S_FALSE;
|
1202
|
-
|
1556
|
+
}
|
1203
1557
|
RINOK(_stream->Seek(nextHeaderOffset, STREAM_SEEK_CUR, NULL));
|
1204
1558
|
|
1205
|
-
|
1206
|
-
|
1559
|
+
size_t nextHeaderSize_t = (size_t)nextHeaderSize;
|
1560
|
+
if (nextHeaderSize_t != nextHeaderSize)
|
1561
|
+
return E_OUTOFMEMORY;
|
1562
|
+
CByteBuffer buffer2(nextHeaderSize_t);
|
1207
1563
|
|
1208
|
-
RINOK(ReadStream_FALSE(_stream, buffer2,
|
1209
|
-
HeadersSize += kHeaderSize + nextHeaderSize;
|
1210
|
-
db.PhySize = kHeaderSize + nextHeaderOffset + nextHeaderSize;
|
1564
|
+
RINOK(ReadStream_FALSE(_stream, buffer2, nextHeaderSize_t));
|
1211
1565
|
|
1212
|
-
if (CrcCalc(buffer2,
|
1566
|
+
if (CrcCalc(buffer2, nextHeaderSize_t) != nextHeaderCRC)
|
1213
1567
|
ThrowIncorrect();
|
1568
|
+
|
1569
|
+
if (!db.StartHeaderWasRecovered)
|
1570
|
+
db.PhySizeWasConfirmed = true;
|
1214
1571
|
|
1215
1572
|
CStreamSwitch streamSwitch;
|
1216
1573
|
streamSwitch.Set(this, buffer2);
|
@@ -1224,12 +1581,10 @@ HRESULT CInArchive::ReadDatabase2(
|
|
1224
1581
|
ThrowIncorrect();
|
1225
1582
|
HRESULT result = ReadAndDecodePackedStreams(
|
1226
1583
|
EXTERNAL_CODECS_LOC_VARS
|
1227
|
-
db.
|
1228
|
-
db.
|
1584
|
+
db.ArcInfo.StartPositionAfterHeader,
|
1585
|
+
db.ArcInfo.DataStartPosition2,
|
1229
1586
|
dataVector
|
1230
|
-
|
1231
|
-
, getTextPassword, passwordIsDefined
|
1232
|
-
#endif
|
1587
|
+
_7Z_DECODER_CRYPRO_VARS
|
1233
1588
|
);
|
1234
1589
|
RINOK(result);
|
1235
1590
|
if (dataVector.Size() == 0)
|
@@ -1242,35 +1597,45 @@ HRESULT CInArchive::ReadDatabase2(
|
|
1242
1597
|
ThrowIncorrect();
|
1243
1598
|
}
|
1244
1599
|
|
1600
|
+
db.IsArc = true;
|
1601
|
+
|
1245
1602
|
db.HeadersSize = HeadersSize;
|
1246
1603
|
|
1247
1604
|
return ReadHeader(
|
1248
1605
|
EXTERNAL_CODECS_LOC_VARS
|
1249
1606
|
db
|
1250
|
-
|
1251
|
-
, getTextPassword, passwordIsDefined
|
1252
|
-
#endif
|
1607
|
+
_7Z_DECODER_CRYPRO_VARS
|
1253
1608
|
);
|
1254
1609
|
}
|
1255
1610
|
|
1256
1611
|
HRESULT CInArchive::ReadDatabase(
|
1257
1612
|
DECL_EXTERNAL_CODECS_LOC_VARS
|
1258
|
-
|
1259
|
-
|
1260
|
-
, ICryptoGetTextPassword *getTextPassword, bool &passwordIsDefined
|
1261
|
-
#endif
|
1613
|
+
CDbEx &db
|
1614
|
+
_7Z_DECODER_CRYPRO_VARS_DECL
|
1262
1615
|
)
|
1263
1616
|
{
|
1264
1617
|
try
|
1265
1618
|
{
|
1266
|
-
|
1619
|
+
HRESULT res = ReadDatabase2(
|
1267
1620
|
EXTERNAL_CODECS_LOC_VARS db
|
1268
|
-
|
1269
|
-
, getTextPassword, passwordIsDefined
|
1270
|
-
#endif
|
1621
|
+
_7Z_DECODER_CRYPRO_VARS
|
1271
1622
|
);
|
1623
|
+
if (ThereIsHeaderError)
|
1624
|
+
db.ThereIsHeaderError = true;
|
1625
|
+
if (res == E_NOTIMPL)
|
1626
|
+
ThrowUnsupported();
|
1627
|
+
return res;
|
1628
|
+
}
|
1629
|
+
catch(CUnsupportedFeatureException &)
|
1630
|
+
{
|
1631
|
+
db.UnsupportedFeatureError = true;
|
1632
|
+
return S_FALSE;
|
1633
|
+
}
|
1634
|
+
catch(CInArchiveException &)
|
1635
|
+
{
|
1636
|
+
db.ThereIsHeaderError = true;
|
1637
|
+
return S_FALSE;
|
1272
1638
|
}
|
1273
|
-
catch(CInArchiveException &) { return S_FALSE; }
|
1274
1639
|
}
|
1275
1640
|
|
1276
1641
|
}}
|