seven-zip 1.4.1 → 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 +15 -30
- data/README.md +16 -3
- 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 +42 -19
- 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 +266 -219
- data/.github/workflows/ci.yml +0 -31
- 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
@@ -0,0 +1,2867 @@
|
|
1
|
+
// ExtHandler.cpp
|
2
|
+
|
3
|
+
#include "StdAfx.h"
|
4
|
+
|
5
|
+
// #define SHOW_DEBUG_INFO
|
6
|
+
|
7
|
+
// #include <stdio.h>
|
8
|
+
// #define PRF2(x) x
|
9
|
+
|
10
|
+
#define PRF2(x)
|
11
|
+
|
12
|
+
#ifdef SHOW_DEBUG_INFO
|
13
|
+
#include <stdio.h>
|
14
|
+
#define PRF(x) x
|
15
|
+
#else
|
16
|
+
#define PRF(x)
|
17
|
+
#endif
|
18
|
+
|
19
|
+
#include "../../../C/Alloc.h"
|
20
|
+
#include "../../../C/CpuArch.h"
|
21
|
+
|
22
|
+
#include "../../Common/ComTry.h"
|
23
|
+
#include "../../Common/IntToString.h"
|
24
|
+
#include "../../Common/MyLinux.h"
|
25
|
+
#include "../../Common/StringConvert.h"
|
26
|
+
#include "../../Common/UTFConvert.h"
|
27
|
+
|
28
|
+
#include "../../Windows/PropVariantUtils.h"
|
29
|
+
#include "../../Windows/TimeUtils.h"
|
30
|
+
|
31
|
+
#include "../Common/ProgressUtils.h"
|
32
|
+
#include "../Common/RegisterArc.h"
|
33
|
+
#include "../Common/StreamObjects.h"
|
34
|
+
#include "../Common/StreamUtils.h"
|
35
|
+
|
36
|
+
#include "../Compress/CopyCoder.h"
|
37
|
+
|
38
|
+
using namespace NWindows;
|
39
|
+
|
40
|
+
namespace NArchive {
|
41
|
+
namespace NExt {
|
42
|
+
|
43
|
+
#define Get16(p) GetUi16(p)
|
44
|
+
#define Get32(p) GetUi32(p)
|
45
|
+
#define Get64(p) GetUi64(p)
|
46
|
+
|
47
|
+
#define LE_16(offs, dest) dest = Get16(p + (offs));
|
48
|
+
#define LE_32(offs, dest) dest = Get32(p + (offs));
|
49
|
+
#define LE_64(offs, dest) dest = Get64(p + (offs));
|
50
|
+
|
51
|
+
#define HI_16(offs, dest) dest |= (((UInt32)Get16(p + (offs))) << 16);
|
52
|
+
#define HI_32(offs, dest) dest |= (((UInt64)Get32(p + (offs))) << 32);
|
53
|
+
|
54
|
+
/*
|
55
|
+
static UInt32 g_Crc32CTable[256];
|
56
|
+
|
57
|
+
static struct CInitCrc32C
|
58
|
+
{
|
59
|
+
CInitCrc32C()
|
60
|
+
{
|
61
|
+
for (unsigned i = 0; i < 256; i++)
|
62
|
+
{
|
63
|
+
UInt32 r = i;
|
64
|
+
unsigned j;
|
65
|
+
for (j = 0; j < 8; j++)
|
66
|
+
r = (r >> 1) ^ (0x82F63B78 & ~((r & 1) - 1));
|
67
|
+
g_Crc32CTable[i] = r;
|
68
|
+
}
|
69
|
+
}
|
70
|
+
} g_InitCrc32C;
|
71
|
+
|
72
|
+
#define CRC32C_INIT_VAL 0xFFFFFFFF
|
73
|
+
#define CRC32C_GET_DIGEST(crc) ((crc) ^ CRC_INIT_VAL)
|
74
|
+
#define CRC32C_UPDATE_BYTE(crc, b) (g_Crc32CTable[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8))
|
75
|
+
|
76
|
+
static UInt32 Crc32C_Update(UInt32 crc, Byte const *data, size_t size)
|
77
|
+
{
|
78
|
+
for (size_t i = 0; i < size; i++)
|
79
|
+
crc = CRC32C_UPDATE_BYTE(crc, data[i]);
|
80
|
+
return crc;
|
81
|
+
}
|
82
|
+
|
83
|
+
static UInt32 Crc32C_Calc(Byte const *data, size_t size)
|
84
|
+
{
|
85
|
+
return Crc32C_Update(CRC32C_INIT_VAL, data, size);
|
86
|
+
}
|
87
|
+
*/
|
88
|
+
|
89
|
+
|
90
|
+
// CRC-16-ANSI. The poly is 0x8005 (x^16 + x^15 + x^2 + 1)
|
91
|
+
static UInt16 g_Crc16Table[256];
|
92
|
+
|
93
|
+
static struct CInitCrc16
|
94
|
+
{
|
95
|
+
CInitCrc16()
|
96
|
+
{
|
97
|
+
for (unsigned i = 0; i < 256; i++)
|
98
|
+
{
|
99
|
+
UInt32 r = i;
|
100
|
+
unsigned j;
|
101
|
+
for (j = 0; j < 8; j++)
|
102
|
+
r = (r >> 1) ^ (0xA001 & ~((r & 1) - 1));
|
103
|
+
g_Crc16Table[i] = (UInt16)r;
|
104
|
+
}
|
105
|
+
}
|
106
|
+
} g_InitCrc16;
|
107
|
+
|
108
|
+
#define CRC16_UPDATE_BYTE(crc, b) (g_Crc16Table[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8))
|
109
|
+
#define CRC16_INIT_VAL 0xFFFF
|
110
|
+
|
111
|
+
static UInt32 Crc16Update(UInt32 crc, Byte const *data, size_t size)
|
112
|
+
{
|
113
|
+
for (size_t i = 0; i < size; i++)
|
114
|
+
crc = CRC16_UPDATE_BYTE(crc, data[i]);
|
115
|
+
return crc;
|
116
|
+
}
|
117
|
+
|
118
|
+
static UInt32 Crc16Calc(Byte const *data, size_t size)
|
119
|
+
{
|
120
|
+
return Crc16Update(CRC16_INIT_VAL, data, size);
|
121
|
+
}
|
122
|
+
|
123
|
+
|
124
|
+
#define EXT4_GOOD_OLD_INODE_SIZE 128
|
125
|
+
|
126
|
+
// inodes numbers
|
127
|
+
|
128
|
+
// #define k_INODE_BAD 1 // Bad blocks
|
129
|
+
#define k_INODE_ROOT 2 // Root dir
|
130
|
+
// #define k_INODE_USR_QUOTA 3 // User quota
|
131
|
+
// #define k_INODE_GRP_QUOTA 4 // Group quota
|
132
|
+
// #define k_INODE_BOOT_LOADER 5 // Boot loader
|
133
|
+
// #define k_INODE_UNDEL_DIR 6 // Undelete dir
|
134
|
+
#define k_INODE_RESIZE 7 // Reserved group descriptors
|
135
|
+
// #define k_INODE_JOURNAL 8 // Journal
|
136
|
+
|
137
|
+
// First non-reserved inode for old ext4 filesystems
|
138
|
+
#define k_INODE_GOOD_OLD_FIRST 11
|
139
|
+
|
140
|
+
static const char * const k_SysInode_Names[] =
|
141
|
+
{
|
142
|
+
"0"
|
143
|
+
, "Bad"
|
144
|
+
, "Root"
|
145
|
+
, "UserQuota"
|
146
|
+
, "GroupQuota"
|
147
|
+
, "BootLoader"
|
148
|
+
, "Undelete"
|
149
|
+
, "Resize"
|
150
|
+
, "Journal"
|
151
|
+
, "Exclude"
|
152
|
+
, "Replica"
|
153
|
+
};
|
154
|
+
|
155
|
+
static const char * const kHostOS[] =
|
156
|
+
{
|
157
|
+
"Linux"
|
158
|
+
, "Hurd"
|
159
|
+
, "Masix"
|
160
|
+
, "FreeBSD"
|
161
|
+
, "Lites"
|
162
|
+
};
|
163
|
+
|
164
|
+
static const CUInt32PCharPair g_FeatureCompat_Flags[] =
|
165
|
+
{
|
166
|
+
{ 0, "DIR_PREALLOC" },
|
167
|
+
{ 1, "IMAGIC_INODES" },
|
168
|
+
{ 2, "HAS_JOURNAL" },
|
169
|
+
{ 3, "EXT_ATTR" },
|
170
|
+
{ 4, "RESIZE_INODE" },
|
171
|
+
{ 5, "DIR_INDEX" },
|
172
|
+
{ 6, "LAZY_BG" }, // not in Linux
|
173
|
+
// { 7, "EXCLUDE_INODE" }, // not used
|
174
|
+
// { 8, "EXCLUDE_BITMAP" }, // not in kernel
|
175
|
+
{ 9, "SPARSE_SUPER2" }
|
176
|
+
};
|
177
|
+
|
178
|
+
|
179
|
+
#define EXT4_FEATURE_INCOMPAT_FILETYPE (1 << 1)
|
180
|
+
#define EXT4_FEATURE_INCOMPAT_64BIT (1 << 7)
|
181
|
+
|
182
|
+
static const CUInt32PCharPair g_FeatureIncompat_Flags[] =
|
183
|
+
{
|
184
|
+
{ 0, "COMPRESSION" },
|
185
|
+
{ 1, "FILETYPE" },
|
186
|
+
{ 2, "RECOVER" }, /* Needs recovery */
|
187
|
+
{ 3, "JOURNAL_DEV" }, /* Journal device */
|
188
|
+
{ 4, "META_BG" },
|
189
|
+
|
190
|
+
{ 6, "EXTENTS" }, /* extents support */
|
191
|
+
{ 7, "64BIT" },
|
192
|
+
{ 8, "MMP" },
|
193
|
+
{ 9, "FLEX_BG" },
|
194
|
+
{ 10, "EA_INODE" }, /* EA in inode */
|
195
|
+
|
196
|
+
{ 12, "DIRDATA" }, /* data in dirent */
|
197
|
+
{ 13, "BG_USE_META_CSUM" }, /* use crc32c for bg */
|
198
|
+
{ 14, "LARGEDIR" }, /* >2GB or 3-lvl htree */
|
199
|
+
{ 15, "INLINE_DATA" }, /* data in inode */
|
200
|
+
{ 16, "ENCRYPT" }
|
201
|
+
};
|
202
|
+
|
203
|
+
|
204
|
+
static const UInt32 RO_COMPAT_GDT_CSUM = 1 << 4;
|
205
|
+
static const UInt32 RO_COMPAT_METADATA_CSUM = 1 << 10;
|
206
|
+
|
207
|
+
static const CUInt32PCharPair g_FeatureRoCompat_Flags[] =
|
208
|
+
{
|
209
|
+
{ 0, "SPARSE_SUPER" },
|
210
|
+
{ 1, "LARGE_FILE" },
|
211
|
+
{ 2, "BTREE_DIR" },
|
212
|
+
{ 3, "HUGE_FILE" },
|
213
|
+
{ 4, "GDT_CSUM" },
|
214
|
+
{ 5, "DIR_NLINK" },
|
215
|
+
{ 6, "EXTRA_ISIZE" },
|
216
|
+
{ 7, "HAS_SNAPSHOT" },
|
217
|
+
{ 8, "QUOTA" },
|
218
|
+
{ 9, "BIGALLOC" },
|
219
|
+
{ 10, "METADATA_CSUM" },
|
220
|
+
{ 11, "REPLICA" },
|
221
|
+
{ 12, "READONLY" }
|
222
|
+
};
|
223
|
+
|
224
|
+
|
225
|
+
|
226
|
+
static const UInt32 k_NodeFlags_HUGE = (UInt32)1 << 18;
|
227
|
+
static const UInt32 k_NodeFlags_EXTENTS = (UInt32)1 << 19;
|
228
|
+
|
229
|
+
|
230
|
+
static const CUInt32PCharPair g_NodeFlags[] =
|
231
|
+
{
|
232
|
+
{ 0, "SECRM" },
|
233
|
+
{ 1, "UNRM" },
|
234
|
+
{ 2, "COMPR" },
|
235
|
+
{ 3, "SYNC" },
|
236
|
+
{ 4, "IMMUTABLE" },
|
237
|
+
{ 5, "APPEND" },
|
238
|
+
{ 6, "NODUMP" },
|
239
|
+
{ 7, "NOATIME" },
|
240
|
+
{ 8, "DIRTY" },
|
241
|
+
{ 9, "COMPRBLK" },
|
242
|
+
{ 10, "NOCOMPR" },
|
243
|
+
{ 11, "ENCRYPT" },
|
244
|
+
{ 12, "INDEX" },
|
245
|
+
{ 13, "IMAGIC" },
|
246
|
+
{ 14, "JOURNAL_DATA" },
|
247
|
+
{ 15, "NOTAIL" },
|
248
|
+
{ 16, "DIRSYNC" },
|
249
|
+
{ 17, "TOPDIR" },
|
250
|
+
{ 18, "HUGE_FILE" },
|
251
|
+
{ 19, "EXTENTS" },
|
252
|
+
|
253
|
+
{ 21, "EA_INODE" },
|
254
|
+
{ 22, "EOFBLOCKS" },
|
255
|
+
|
256
|
+
{ 28, "INLINE_DATA" }
|
257
|
+
};
|
258
|
+
|
259
|
+
|
260
|
+
static inline char GetHex(unsigned t) { return (char)(((t < 10) ? ('0' + t) : ('A' + (t - 10)))); }
|
261
|
+
|
262
|
+
static inline void PrintHex(unsigned v, char *s)
|
263
|
+
{
|
264
|
+
s[0] = GetHex((v >> 4) & 0xF);
|
265
|
+
s[1] = GetHex(v & 0xF);
|
266
|
+
}
|
267
|
+
|
268
|
+
|
269
|
+
enum
|
270
|
+
{
|
271
|
+
k_Type_UNKNOWN,
|
272
|
+
k_Type_REG_FILE,
|
273
|
+
k_Type_DIR,
|
274
|
+
k_Type_CHRDEV,
|
275
|
+
k_Type_BLKDEV,
|
276
|
+
k_Type_FIFO,
|
277
|
+
k_Type_SOCK,
|
278
|
+
k_Type_SYMLINK
|
279
|
+
};
|
280
|
+
|
281
|
+
static const UInt16 k_TypeToMode[] =
|
282
|
+
{
|
283
|
+
0,
|
284
|
+
MY_LIN_S_IFREG,
|
285
|
+
MY_LIN_S_IFDIR,
|
286
|
+
MY_LIN_S_IFCHR,
|
287
|
+
MY_LIN_S_IFBLK,
|
288
|
+
MY_LIN_S_IFIFO,
|
289
|
+
MY_LIN_S_IFSOCK,
|
290
|
+
MY_LIN_S_IFLNK
|
291
|
+
};
|
292
|
+
|
293
|
+
|
294
|
+
#define EXT4_GOOD_OLD_REV 0 // old (original) format
|
295
|
+
// #define EXT4_DYNAMIC_REV 1 // V2 format with dynamic inode sizes
|
296
|
+
|
297
|
+
struct CHeader
|
298
|
+
{
|
299
|
+
unsigned BlockBits;
|
300
|
+
unsigned ClusterBits;
|
301
|
+
|
302
|
+
UInt32 NumInodes;
|
303
|
+
UInt64 NumBlocks;
|
304
|
+
// UInt64 NumBlocksSuper;
|
305
|
+
UInt64 NumFreeBlocks;
|
306
|
+
UInt32 NumFreeInodes;
|
307
|
+
// UInt32 FirstDataBlock;
|
308
|
+
|
309
|
+
UInt32 BlocksPerGroup;
|
310
|
+
UInt32 ClustersPerGroup;
|
311
|
+
UInt32 InodesPerGroup;
|
312
|
+
|
313
|
+
UInt32 MountTime;
|
314
|
+
UInt32 WriteTime;
|
315
|
+
|
316
|
+
// UInt16 NumMounts;
|
317
|
+
// UInt16 NumMountsMax;
|
318
|
+
|
319
|
+
// UInt16 State;
|
320
|
+
// UInt16 Errors;
|
321
|
+
// UInt16 MinorRevLevel;
|
322
|
+
|
323
|
+
UInt32 LastCheckTime;
|
324
|
+
// UInt32 CheckInterval;
|
325
|
+
UInt32 CreatorOs;
|
326
|
+
UInt32 RevLevel;
|
327
|
+
|
328
|
+
// UInt16 DefResUid;
|
329
|
+
// UInt16 DefResGid;
|
330
|
+
|
331
|
+
UInt32 FirstInode;
|
332
|
+
UInt16 InodeSize;
|
333
|
+
UInt16 BlockGroupNr;
|
334
|
+
UInt32 FeatureCompat;
|
335
|
+
UInt32 FeatureIncompat;
|
336
|
+
UInt32 FeatureRoCompat;
|
337
|
+
Byte Uuid[16];
|
338
|
+
char VolName[16];
|
339
|
+
char LastMount[64];
|
340
|
+
// UInt32 BitmapAlgo;
|
341
|
+
|
342
|
+
UInt32 JournalInode;
|
343
|
+
UInt16 GdSize; // = 64 if 64-bit();
|
344
|
+
UInt32 CTime;
|
345
|
+
UInt16 MinExtraISize;
|
346
|
+
// UInt16 WantExtraISize;
|
347
|
+
// UInt32 Flags;
|
348
|
+
// Byte LogGroupsPerFlex;
|
349
|
+
// Byte ChecksumType;
|
350
|
+
|
351
|
+
UInt64 WrittenKB;
|
352
|
+
|
353
|
+
bool IsOldRev() const { return RevLevel == EXT4_GOOD_OLD_REV; }
|
354
|
+
|
355
|
+
UInt64 GetNumGroups() const { return (NumBlocks + BlocksPerGroup - 1) / BlocksPerGroup; }
|
356
|
+
UInt64 GetNumGroups2() const { return ((UInt64)NumInodes + InodesPerGroup - 1) / InodesPerGroup; }
|
357
|
+
|
358
|
+
bool IsThereFileType() const { return (FeatureIncompat & EXT4_FEATURE_INCOMPAT_FILETYPE) != 0; }
|
359
|
+
bool Is64Bit() const { return (FeatureIncompat & EXT4_FEATURE_INCOMPAT_64BIT) != 0; }
|
360
|
+
bool UseGdtChecksum() const { return (FeatureRoCompat & RO_COMPAT_GDT_CSUM) != 0; }
|
361
|
+
bool UseMetadataChecksum() const { return (FeatureRoCompat & RO_COMPAT_METADATA_CSUM) != 0; }
|
362
|
+
|
363
|
+
bool Parse(const Byte *p);
|
364
|
+
};
|
365
|
+
|
366
|
+
|
367
|
+
static int inline GetLog(UInt32 num)
|
368
|
+
{
|
369
|
+
for (unsigned i = 0; i < 32; i++)
|
370
|
+
if (((UInt32)1 << i) == num)
|
371
|
+
return i;
|
372
|
+
return -1;
|
373
|
+
}
|
374
|
+
|
375
|
+
static bool inline IsEmptyData(const Byte *data, unsigned size)
|
376
|
+
{
|
377
|
+
for (unsigned i = 0; i < size; i++)
|
378
|
+
if (data[i] != 0)
|
379
|
+
return false;
|
380
|
+
return true;
|
381
|
+
}
|
382
|
+
|
383
|
+
|
384
|
+
bool CHeader::Parse(const Byte *p)
|
385
|
+
{
|
386
|
+
if (GetUi16(p + 0x38) != 0xEF53)
|
387
|
+
return false;
|
388
|
+
|
389
|
+
LE_32 (0x18, BlockBits);
|
390
|
+
LE_32 (0x1C, ClusterBits);
|
391
|
+
|
392
|
+
if (ClusterBits != 0 && BlockBits != ClusterBits)
|
393
|
+
return false;
|
394
|
+
|
395
|
+
if (BlockBits > 16 - 10)
|
396
|
+
return false;
|
397
|
+
BlockBits += 10;
|
398
|
+
|
399
|
+
LE_32 (0x00, NumInodes);
|
400
|
+
LE_32 (0x04, NumBlocks);
|
401
|
+
// LE_32 (0x08, NumBlocksSuper);
|
402
|
+
LE_32 (0x0C, NumFreeBlocks);
|
403
|
+
LE_32 (0x10, NumFreeInodes);
|
404
|
+
|
405
|
+
if (NumInodes < 2 || NumInodes <= NumFreeInodes)
|
406
|
+
return false;
|
407
|
+
|
408
|
+
UInt32 FirstDataBlock;
|
409
|
+
LE_32 (0x14, FirstDataBlock);
|
410
|
+
if (FirstDataBlock != (unsigned)(BlockBits == 10 ? 1 : 0))
|
411
|
+
return false;
|
412
|
+
|
413
|
+
LE_32 (0x20, BlocksPerGroup);
|
414
|
+
LE_32 (0x24, ClustersPerGroup);
|
415
|
+
|
416
|
+
if (BlocksPerGroup != ClustersPerGroup)
|
417
|
+
return false;
|
418
|
+
if (BlocksPerGroup == 0)
|
419
|
+
return false;
|
420
|
+
if (BlocksPerGroup != ((UInt32)1 << (BlockBits + 3)))
|
421
|
+
{
|
422
|
+
// it's allowed in ext2
|
423
|
+
// return false;
|
424
|
+
}
|
425
|
+
|
426
|
+
LE_32 (0x28, InodesPerGroup);
|
427
|
+
|
428
|
+
if (InodesPerGroup < 1 || InodesPerGroup > NumInodes)
|
429
|
+
return false;
|
430
|
+
|
431
|
+
LE_32 (0x2C, MountTime);
|
432
|
+
LE_32 (0x30, WriteTime);
|
433
|
+
|
434
|
+
// LE_16 (0x34, NumMounts);
|
435
|
+
// LE_16 (0x36, NumMountsMax);
|
436
|
+
|
437
|
+
// LE_16 (0x3A, State);
|
438
|
+
// LE_16 (0x3C, Errors);
|
439
|
+
// LE_16 (0x3E, MinorRevLevel);
|
440
|
+
|
441
|
+
LE_32 (0x40, LastCheckTime);
|
442
|
+
// LE_32 (0x44, CheckInterval);
|
443
|
+
LE_32 (0x48, CreatorOs);
|
444
|
+
LE_32 (0x4C, RevLevel);
|
445
|
+
|
446
|
+
// LE_16 (0x50, DefResUid);
|
447
|
+
// LE_16 (0x52, DefResGid);
|
448
|
+
|
449
|
+
FirstInode = k_INODE_GOOD_OLD_FIRST;
|
450
|
+
InodeSize = EXT4_GOOD_OLD_INODE_SIZE;
|
451
|
+
|
452
|
+
if (!IsOldRev())
|
453
|
+
{
|
454
|
+
LE_32 (0x54, FirstInode);
|
455
|
+
LE_16 (0x58, InodeSize);
|
456
|
+
if (FirstInode < k_INODE_GOOD_OLD_FIRST)
|
457
|
+
return false;
|
458
|
+
if (InodeSize > (UInt32)1 << BlockBits)
|
459
|
+
return false;
|
460
|
+
if (GetLog(InodeSize) < 0)
|
461
|
+
return false;
|
462
|
+
}
|
463
|
+
|
464
|
+
LE_16 (0x5A, BlockGroupNr);
|
465
|
+
LE_32 (0x5C, FeatureCompat);
|
466
|
+
LE_32 (0x60, FeatureIncompat);
|
467
|
+
LE_32 (0x64, FeatureRoCompat);
|
468
|
+
|
469
|
+
memcpy(Uuid, p + 0x68, sizeof(Uuid));
|
470
|
+
memcpy(VolName, p + 0x78, sizeof(VolName));
|
471
|
+
memcpy(LastMount, p + 0x88, sizeof(LastMount));
|
472
|
+
|
473
|
+
// LE_32 (0xC8, BitmapAlgo);
|
474
|
+
|
475
|
+
LE_32 (0xE0, JournalInode);
|
476
|
+
|
477
|
+
LE_16 (0xFE, GdSize);
|
478
|
+
|
479
|
+
LE_32 (0x108, CTime);
|
480
|
+
|
481
|
+
if (Is64Bit())
|
482
|
+
{
|
483
|
+
HI_32(150, NumBlocks);
|
484
|
+
// HI_32(154, NumBlocksSuper);
|
485
|
+
HI_32(0x158, NumFreeBlocks);
|
486
|
+
}
|
487
|
+
|
488
|
+
if (NumBlocks >= (UInt64)1 << (63 - BlockBits))
|
489
|
+
return false;
|
490
|
+
|
491
|
+
|
492
|
+
LE_16(0x15C, MinExtraISize);
|
493
|
+
// LE_16(0x15E, WantExtraISize);
|
494
|
+
// LE_32(0x160, Flags);
|
495
|
+
// LE_16(0x164, RaidStride);
|
496
|
+
// LE_16(0x166, MmpInterval);
|
497
|
+
// LE_64(0x168, MmpBlock);
|
498
|
+
|
499
|
+
// LogGroupsPerFlex = p[0x174];
|
500
|
+
// ChecksumType = p[0x175];
|
501
|
+
|
502
|
+
LE_64 (0x178, WrittenKB);
|
503
|
+
|
504
|
+
// LE_32(0x194, ErrorCount);
|
505
|
+
// LE_32(0x198, ErrorTime);
|
506
|
+
// LE_32(0x19C, ErrorINode);
|
507
|
+
// LE_32(0x1A0, ErrorBlock);
|
508
|
+
|
509
|
+
if (NumBlocks < 1)
|
510
|
+
return false;
|
511
|
+
if (NumFreeBlocks > NumBlocks)
|
512
|
+
return false;
|
513
|
+
|
514
|
+
if (GetNumGroups() != GetNumGroups2())
|
515
|
+
return false;
|
516
|
+
|
517
|
+
return true;
|
518
|
+
}
|
519
|
+
|
520
|
+
|
521
|
+
struct CGroupDescriptor
|
522
|
+
{
|
523
|
+
UInt64 BlockBitmap;
|
524
|
+
UInt64 InodeBitmap;
|
525
|
+
UInt64 InodeTable;
|
526
|
+
UInt32 NumFreeBlocks;
|
527
|
+
UInt32 NumFreeInodes;
|
528
|
+
UInt32 DirCount;
|
529
|
+
|
530
|
+
UInt16 Flags;
|
531
|
+
|
532
|
+
UInt64 ExcludeBitmap;
|
533
|
+
UInt32 BlockBitmap_Checksum;
|
534
|
+
UInt32 InodeBitmap_Checksum;
|
535
|
+
UInt32 UnusedCount;
|
536
|
+
UInt16 Checksum;
|
537
|
+
|
538
|
+
void Parse(const Byte *p, unsigned size);
|
539
|
+
};
|
540
|
+
|
541
|
+
void CGroupDescriptor::Parse(const Byte *p, unsigned size)
|
542
|
+
{
|
543
|
+
LE_32 (0x00, BlockBitmap);
|
544
|
+
LE_32 (0x04, InodeBitmap);
|
545
|
+
LE_32 (0x08, InodeTable);
|
546
|
+
LE_16 (0x0C, NumFreeBlocks);
|
547
|
+
LE_16 (0x0E, NumFreeInodes);
|
548
|
+
LE_16 (0x10, DirCount);
|
549
|
+
LE_16 (0x12, Flags);
|
550
|
+
LE_32 (0x14, ExcludeBitmap);
|
551
|
+
LE_16 (0x18, BlockBitmap_Checksum);
|
552
|
+
LE_16 (0x1A, InodeBitmap_Checksum);
|
553
|
+
LE_16 (0x1C, UnusedCount);
|
554
|
+
LE_16 (0x1E, Checksum);
|
555
|
+
|
556
|
+
if (size >= 64)
|
557
|
+
{
|
558
|
+
p += 0x20;
|
559
|
+
HI_32 (0x00, BlockBitmap);
|
560
|
+
HI_32 (0x04, InodeBitmap);
|
561
|
+
HI_32 (0x08, InodeTable);
|
562
|
+
HI_16 (0x0C, NumFreeBlocks);
|
563
|
+
HI_16 (0x0E, NumFreeInodes);
|
564
|
+
HI_16 (0x10, DirCount);
|
565
|
+
HI_16 (0x12, UnusedCount); // instead of Flags
|
566
|
+
HI_32 (0x14, ExcludeBitmap);
|
567
|
+
HI_16 (0x18, BlockBitmap_Checksum);
|
568
|
+
HI_16 (0x1A, InodeBitmap_Checksum);
|
569
|
+
// HI_16 (0x1C, Reserved);
|
570
|
+
}
|
571
|
+
}
|
572
|
+
|
573
|
+
|
574
|
+
static const unsigned kNodeBlockFieldSize = 60;
|
575
|
+
|
576
|
+
struct CExtentTreeHeader
|
577
|
+
{
|
578
|
+
UInt16 NumEntries;
|
579
|
+
UInt16 MaxEntries;
|
580
|
+
UInt16 Depth;
|
581
|
+
// UInt32 Generation;
|
582
|
+
|
583
|
+
bool Parse(const Byte *p)
|
584
|
+
{
|
585
|
+
LE_16 (0x02, NumEntries);
|
586
|
+
LE_16 (0x04, MaxEntries);
|
587
|
+
LE_16 (0x06, Depth);
|
588
|
+
// LE_32 (0x08, Generation);
|
589
|
+
return Get16(p) == 0xF30A; // magic
|
590
|
+
}
|
591
|
+
};
|
592
|
+
|
593
|
+
struct CExtentIndexNode
|
594
|
+
{
|
595
|
+
UInt32 VirtBlock;
|
596
|
+
UInt64 PhyLeaf;
|
597
|
+
|
598
|
+
void Parse(const Byte *p)
|
599
|
+
{
|
600
|
+
LE_32 (0x00, VirtBlock);
|
601
|
+
LE_32 (0x04, PhyLeaf);
|
602
|
+
PhyLeaf |= (((UInt64)Get16(p + 8)) << 32);
|
603
|
+
// unused 16-bit field (at offset 0x0A) can be not zero in some cases. Why?
|
604
|
+
}
|
605
|
+
};
|
606
|
+
|
607
|
+
struct CExtent
|
608
|
+
{
|
609
|
+
UInt32 VirtBlock;
|
610
|
+
UInt16 Len;
|
611
|
+
bool IsInited;
|
612
|
+
UInt64 PhyStart;
|
613
|
+
|
614
|
+
UInt32 GetVirtEnd() const { return VirtBlock + Len; }
|
615
|
+
bool IsLenOK() const { return VirtBlock + Len >= VirtBlock; }
|
616
|
+
|
617
|
+
void Parse(const Byte *p)
|
618
|
+
{
|
619
|
+
LE_32 (0x00, VirtBlock);
|
620
|
+
LE_16 (0x04, Len);
|
621
|
+
IsInited = true;
|
622
|
+
if (Len > (UInt32)0x8000)
|
623
|
+
{
|
624
|
+
IsInited = false;
|
625
|
+
Len -= (UInt32)0x8000;
|
626
|
+
}
|
627
|
+
LE_32 (0x08, PhyStart);
|
628
|
+
UInt16 hi;
|
629
|
+
LE_16 (0x06, hi);
|
630
|
+
PhyStart |= ((UInt64)hi << 32);
|
631
|
+
}
|
632
|
+
};
|
633
|
+
|
634
|
+
|
635
|
+
|
636
|
+
struct CExtTime
|
637
|
+
{
|
638
|
+
UInt32 Val;
|
639
|
+
UInt32 Extra;
|
640
|
+
};
|
641
|
+
|
642
|
+
struct CNode
|
643
|
+
{
|
644
|
+
Int32 ParentNode; // in _refs[], -1 if not dir
|
645
|
+
int ItemIndex; // in _items[]
|
646
|
+
int SymLinkIndex; // in _symLinks[]
|
647
|
+
int DirIndex; // in _dirs[]
|
648
|
+
|
649
|
+
UInt16 Mode;
|
650
|
+
UInt16 Uid;
|
651
|
+
UInt16 Gid;
|
652
|
+
// UInt16 Checksum;
|
653
|
+
|
654
|
+
UInt64 FileSize;
|
655
|
+
CExtTime MTime;
|
656
|
+
CExtTime ATime;
|
657
|
+
CExtTime CTime;
|
658
|
+
// CExtTime InodeChangeTime;
|
659
|
+
// CExtTime DTime;
|
660
|
+
|
661
|
+
UInt64 NumBlocks;
|
662
|
+
UInt32 NumLinks;
|
663
|
+
UInt32 Flags;
|
664
|
+
|
665
|
+
UInt32 NumLinksCalced;
|
666
|
+
|
667
|
+
Byte Block[kNodeBlockFieldSize];
|
668
|
+
|
669
|
+
CNode():
|
670
|
+
ParentNode(-1),
|
671
|
+
ItemIndex(-1),
|
672
|
+
SymLinkIndex(-1),
|
673
|
+
DirIndex(0),
|
674
|
+
NumLinksCalced(0)
|
675
|
+
{}
|
676
|
+
|
677
|
+
bool IsFlags_HUGE() const { return (Flags & k_NodeFlags_HUGE) != 0; }
|
678
|
+
bool IsFlags_EXTENTS() const { return (Flags & k_NodeFlags_EXTENTS) != 0; }
|
679
|
+
|
680
|
+
bool IsDir() const { return MY_LIN_S_ISDIR(Mode); }
|
681
|
+
bool IsRegular() const { return MY_LIN_S_ISREG(Mode); }
|
682
|
+
bool IsLink() const { return MY_LIN_S_ISLNK(Mode); }
|
683
|
+
|
684
|
+
bool Parse(const Byte *p, const CHeader &_h);
|
685
|
+
};
|
686
|
+
|
687
|
+
|
688
|
+
bool CNode::Parse(const Byte *p, const CHeader &_h)
|
689
|
+
{
|
690
|
+
MTime.Extra = 0;
|
691
|
+
ATime.Extra = 0;
|
692
|
+
CTime.Extra = 0;
|
693
|
+
CTime.Val = 0;
|
694
|
+
// InodeChangeTime.Extra = 0;
|
695
|
+
// DTime.Extra = 0;
|
696
|
+
|
697
|
+
LE_16 (0x00, Mode);
|
698
|
+
LE_16 (0x02, Uid);
|
699
|
+
LE_32 (0x04, FileSize);
|
700
|
+
LE_32 (0x08, ATime.Val);
|
701
|
+
// LE_32 (0x0C, InodeChangeTime.Val);
|
702
|
+
LE_32 (0x10, MTime.Val);
|
703
|
+
// LE_32 (0x14, DTime.Val);
|
704
|
+
LE_16 (0x18, Gid);
|
705
|
+
LE_16 (0x1A, NumLinks);
|
706
|
+
|
707
|
+
LE_32 (0x1C, NumBlocks);
|
708
|
+
LE_32 (0x20, Flags);
|
709
|
+
// LE_32 (0x24, Union osd1);
|
710
|
+
|
711
|
+
memcpy(Block, p + 0x28, kNodeBlockFieldSize);
|
712
|
+
|
713
|
+
// LE_32 (0x64, Generation); // File version (for NFS)
|
714
|
+
// LE_32 (0x68, ACL);
|
715
|
+
|
716
|
+
{
|
717
|
+
UInt32 highSize;
|
718
|
+
LE_32 (0x6C, highSize); // In ext2/3 this field was named i_dir_acl
|
719
|
+
|
720
|
+
if (IsRegular()) // do we need that check ?
|
721
|
+
FileSize |= ((UInt64)highSize << 32);
|
722
|
+
}
|
723
|
+
|
724
|
+
// UInt32 fragmentAddress;
|
725
|
+
// LE_32 (0x70, fragmentAddress);
|
726
|
+
|
727
|
+
// osd2
|
728
|
+
{
|
729
|
+
// Linux;
|
730
|
+
// ext2:
|
731
|
+
// Byte FragmentNumber = p[0x74];
|
732
|
+
// Byte FragmentSize = p[0x74 + 1];
|
733
|
+
|
734
|
+
// ext4:
|
735
|
+
UInt32 numBlocksHigh;
|
736
|
+
LE_16 (0x74, numBlocksHigh);
|
737
|
+
NumBlocks |= (UInt64)numBlocksHigh << 32;
|
738
|
+
|
739
|
+
HI_16 (0x74 + 4, Uid);
|
740
|
+
HI_16 (0x74 + 6, Gid);
|
741
|
+
/*
|
742
|
+
UInt32 checksum;
|
743
|
+
LE_16 (0x74 + 8, checksum);
|
744
|
+
checksum = checksum;
|
745
|
+
*/
|
746
|
+
}
|
747
|
+
|
748
|
+
// 0x74: Byte Union osd2[12];
|
749
|
+
|
750
|
+
if (_h.InodeSize > 128)
|
751
|
+
{
|
752
|
+
UInt16 extra_isize;
|
753
|
+
LE_16 (0x80, extra_isize);
|
754
|
+
if (128 + extra_isize > _h.InodeSize)
|
755
|
+
return false;
|
756
|
+
if (extra_isize >= 0x1C)
|
757
|
+
{
|
758
|
+
// UInt16 checksumUpper;
|
759
|
+
// LE_16 (0x82, checksumUpper);
|
760
|
+
// LE_32 (0x84, InodeChangeTime.Extra);
|
761
|
+
LE_32 (0x88, MTime.Extra);
|
762
|
+
LE_32 (0x8C, ATime.Extra);
|
763
|
+
LE_32 (0x90, CTime.Val);
|
764
|
+
LE_32 (0x94, CTime.Extra);
|
765
|
+
// LE_32 (0x98, VersionHi);
|
766
|
+
}
|
767
|
+
}
|
768
|
+
|
769
|
+
PRF(printf("size = %5d", (unsigned)FileSize));
|
770
|
+
|
771
|
+
return true;
|
772
|
+
}
|
773
|
+
|
774
|
+
|
775
|
+
struct CItem
|
776
|
+
{
|
777
|
+
unsigned Node; // in _refs[]
|
778
|
+
int ParentNode; // in _refs[]
|
779
|
+
int SymLinkItemIndex; // in _items[], if the Node contains SymLink to existing dir
|
780
|
+
Byte Type;
|
781
|
+
|
782
|
+
AString Name;
|
783
|
+
|
784
|
+
CItem():
|
785
|
+
Node(0),
|
786
|
+
ParentNode(-1),
|
787
|
+
SymLinkItemIndex(-1),
|
788
|
+
Type(k_Type_UNKNOWN)
|
789
|
+
{}
|
790
|
+
|
791
|
+
void Clear()
|
792
|
+
{
|
793
|
+
Node = 0;
|
794
|
+
ParentNode = -1;
|
795
|
+
SymLinkItemIndex = -1;
|
796
|
+
Type = k_Type_UNKNOWN;
|
797
|
+
Name.Empty();
|
798
|
+
}
|
799
|
+
|
800
|
+
bool IsDir() const { return Type == k_Type_DIR; }
|
801
|
+
// bool IsNotDir() const { return Type != k_Type_DIR && Type != k_Type_UNKNOWN; }
|
802
|
+
|
803
|
+
};
|
804
|
+
|
805
|
+
|
806
|
+
|
807
|
+
static const unsigned kNumTreeLevelsMax = 6; // must be >= 3
|
808
|
+
|
809
|
+
|
810
|
+
class CHandler:
|
811
|
+
public IInArchive,
|
812
|
+
public IArchiveGetRawProps,
|
813
|
+
public IInArchiveGetStream,
|
814
|
+
public CMyUnknownImp
|
815
|
+
{
|
816
|
+
CObjectVector<CItem> _items;
|
817
|
+
CIntVector _refs;
|
818
|
+
CRecordVector<CNode> _nodes;
|
819
|
+
CObjectVector<CUIntVector> _dirs; // each CUIntVector contains indexes in _items[] only for dir items;
|
820
|
+
AStringVector _symLinks;
|
821
|
+
AStringVector _auxItems;
|
822
|
+
int _auxSysIndex;
|
823
|
+
int _auxUnknownIndex;
|
824
|
+
|
825
|
+
CMyComPtr<IInStream> _stream;
|
826
|
+
UInt64 _phySize;
|
827
|
+
bool _isArc;
|
828
|
+
bool _headersError;
|
829
|
+
bool _headersWarning;
|
830
|
+
bool _linksError;
|
831
|
+
|
832
|
+
bool _isUTF;
|
833
|
+
|
834
|
+
CHeader _h;
|
835
|
+
|
836
|
+
IArchiveOpenCallback *_openCallback;
|
837
|
+
UInt64 _totalRead;
|
838
|
+
UInt64 _totalReadPrev;
|
839
|
+
|
840
|
+
CByteBuffer _tempBufs[kNumTreeLevelsMax];
|
841
|
+
|
842
|
+
|
843
|
+
HRESULT CheckProgress2()
|
844
|
+
{
|
845
|
+
const UInt64 numFiles = _items.Size();
|
846
|
+
return _openCallback->SetCompleted(&numFiles, &_totalRead);
|
847
|
+
}
|
848
|
+
|
849
|
+
HRESULT CheckProgress()
|
850
|
+
{
|
851
|
+
HRESULT res = S_OK;
|
852
|
+
if (_openCallback)
|
853
|
+
{
|
854
|
+
if (_totalRead - _totalReadPrev >= ((UInt32)1 << 20))
|
855
|
+
{
|
856
|
+
_totalReadPrev = _totalRead;
|
857
|
+
res = CheckProgress2();
|
858
|
+
}
|
859
|
+
}
|
860
|
+
return res;
|
861
|
+
}
|
862
|
+
|
863
|
+
|
864
|
+
const int GetParentAux(const CItem &item) const
|
865
|
+
{
|
866
|
+
if (item.Node < _h.FirstInode && _auxSysIndex >= 0)
|
867
|
+
return _auxSysIndex;
|
868
|
+
return _auxUnknownIndex;
|
869
|
+
}
|
870
|
+
|
871
|
+
HRESULT SeekAndRead(IInStream *inStream, UInt64 block, Byte *data, size_t size);
|
872
|
+
HRESULT ParseDir(const Byte *data, size_t size, unsigned iNodeDir);
|
873
|
+
int FindTargetItem_for_SymLink(unsigned dirNode, const AString &path) const;
|
874
|
+
|
875
|
+
HRESULT FillFileBlocks2(UInt32 block, unsigned level, unsigned numBlocks, CRecordVector<UInt32> &blocks);
|
876
|
+
HRESULT FillFileBlocks(const Byte *p, unsigned numBlocks, CRecordVector<UInt32> &blocks);
|
877
|
+
HRESULT FillExtents(const Byte *p, size_t size, CRecordVector<CExtent> &extents, int parentDepth);
|
878
|
+
|
879
|
+
HRESULT GetStream_Node(unsigned nodeIndex, ISequentialInStream **stream);
|
880
|
+
HRESULT ExtractNode(unsigned nodeIndex, CByteBuffer &data);
|
881
|
+
|
882
|
+
void ClearRefs();
|
883
|
+
HRESULT Open2(IInStream *inStream);
|
884
|
+
|
885
|
+
void GetPath(unsigned index, AString &s) const;
|
886
|
+
bool GetPackSize(unsigned index, UInt64 &res) const;
|
887
|
+
|
888
|
+
public:
|
889
|
+
CHandler() {}
|
890
|
+
~CHandler() {}
|
891
|
+
|
892
|
+
MY_UNKNOWN_IMP3(IInArchive, IArchiveGetRawProps, IInArchiveGetStream)
|
893
|
+
|
894
|
+
INTERFACE_IInArchive(;)
|
895
|
+
INTERFACE_IArchiveGetRawProps(;)
|
896
|
+
STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **stream);
|
897
|
+
};
|
898
|
+
|
899
|
+
|
900
|
+
|
901
|
+
HRESULT CHandler::ParseDir(const Byte *p, size_t size, unsigned iNodeDir)
|
902
|
+
{
|
903
|
+
bool isThereSelfLink = false;
|
904
|
+
|
905
|
+
PRF(printf("\n\n========= node = %5d size = %5d", (unsigned)iNodeDir, (unsigned)size));
|
906
|
+
|
907
|
+
CNode &nodeDir = _nodes[_refs[iNodeDir]];
|
908
|
+
nodeDir.DirIndex = _dirs.Size();
|
909
|
+
CUIntVector &dir = _dirs.AddNew();
|
910
|
+
int parentNode = -1;
|
911
|
+
|
912
|
+
CItem item;
|
913
|
+
|
914
|
+
for (;;)
|
915
|
+
{
|
916
|
+
if (size == 0)
|
917
|
+
break;
|
918
|
+
if (size < 8)
|
919
|
+
return S_FALSE;
|
920
|
+
UInt32 iNode;
|
921
|
+
LE_32 (0x00, iNode);
|
922
|
+
unsigned recLen;
|
923
|
+
LE_16 (0x04, recLen);
|
924
|
+
unsigned nameLen = p[6];
|
925
|
+
Byte type = p[7];
|
926
|
+
|
927
|
+
if (recLen > size)
|
928
|
+
return S_FALSE;
|
929
|
+
if (nameLen + 8 > recLen)
|
930
|
+
return S_FALSE;
|
931
|
+
|
932
|
+
if (iNode >= _refs.Size())
|
933
|
+
return S_FALSE;
|
934
|
+
|
935
|
+
item.Clear();
|
936
|
+
|
937
|
+
if (_h.IsThereFileType())
|
938
|
+
item.Type = type;
|
939
|
+
else if (type != 0)
|
940
|
+
return S_FALSE;
|
941
|
+
|
942
|
+
item.ParentNode = iNodeDir;
|
943
|
+
item.Node = iNode;
|
944
|
+
item.Name.SetFrom_CalcLen((const char *)(p + 8), nameLen);
|
945
|
+
|
946
|
+
p += recLen;
|
947
|
+
size -= recLen;
|
948
|
+
|
949
|
+
if (item.Name.Len() != nameLen)
|
950
|
+
return S_FALSE;
|
951
|
+
|
952
|
+
if (_isUTF)
|
953
|
+
_isUTF = CheckUTF8(item.Name);
|
954
|
+
|
955
|
+
if (iNode == 0)
|
956
|
+
{
|
957
|
+
/*
|
958
|
+
ext3 deleted??
|
959
|
+
if (item.Name.Len() != 0)
|
960
|
+
return S_FALSE;
|
961
|
+
*/
|
962
|
+
|
963
|
+
PRF(printf("\n EMPTY %6d %d %s", (unsigned)recLen, (unsigned)type, (const char *)item.Name));
|
964
|
+
if (type == 0xDE)
|
965
|
+
{
|
966
|
+
// checksum
|
967
|
+
}
|
968
|
+
continue;
|
969
|
+
}
|
970
|
+
|
971
|
+
int nodeIndex = _refs[iNode];
|
972
|
+
if (nodeIndex < 0)
|
973
|
+
return S_FALSE;
|
974
|
+
CNode &node = _nodes[nodeIndex];
|
975
|
+
|
976
|
+
if (_h.IsThereFileType() && type != 0)
|
977
|
+
{
|
978
|
+
if (type >= ARRAY_SIZE(k_TypeToMode))
|
979
|
+
return S_FALSE;
|
980
|
+
if (k_TypeToMode[type] != (node.Mode & MY_LIN_S_IFMT))
|
981
|
+
return S_FALSE;
|
982
|
+
}
|
983
|
+
|
984
|
+
node.NumLinksCalced++;
|
985
|
+
|
986
|
+
PRF(printf("\n%s %6d %s", item.IsDir() ? "DIR " : " ", (unsigned)item.Node, (const char *)item.Name));
|
987
|
+
|
988
|
+
if (item.Name[0] == '.')
|
989
|
+
{
|
990
|
+
if (item.Name[1] == 0)
|
991
|
+
{
|
992
|
+
if (isThereSelfLink)
|
993
|
+
return S_FALSE;
|
994
|
+
isThereSelfLink = true;
|
995
|
+
if (iNode != iNodeDir)
|
996
|
+
return S_FALSE;
|
997
|
+
continue;
|
998
|
+
}
|
999
|
+
|
1000
|
+
if (item.Name[1] == '.' && item.Name[2] == 0)
|
1001
|
+
{
|
1002
|
+
if (parentNode >= 0)
|
1003
|
+
return S_FALSE;
|
1004
|
+
if (!node.IsDir())
|
1005
|
+
return S_FALSE;
|
1006
|
+
if (iNode == iNodeDir && iNode != k_INODE_ROOT)
|
1007
|
+
return S_FALSE;
|
1008
|
+
|
1009
|
+
parentNode = iNode;
|
1010
|
+
|
1011
|
+
if (nodeDir.ParentNode < 0)
|
1012
|
+
nodeDir.ParentNode = iNode;
|
1013
|
+
else if ((unsigned)nodeDir.ParentNode != iNode)
|
1014
|
+
return S_FALSE;
|
1015
|
+
|
1016
|
+
continue;
|
1017
|
+
}
|
1018
|
+
}
|
1019
|
+
|
1020
|
+
if (iNode == iNodeDir)
|
1021
|
+
return S_FALSE;
|
1022
|
+
|
1023
|
+
if (parentNode < 0)
|
1024
|
+
return S_FALSE;
|
1025
|
+
|
1026
|
+
if (node.IsDir())
|
1027
|
+
{
|
1028
|
+
if (node.ParentNode < 0)
|
1029
|
+
node.ParentNode = iNodeDir;
|
1030
|
+
else if ((unsigned)node.ParentNode != iNodeDir)
|
1031
|
+
return S_FALSE;
|
1032
|
+
const unsigned itemIndex = _items.Size();
|
1033
|
+
dir.Add(itemIndex);
|
1034
|
+
node.ItemIndex = itemIndex;
|
1035
|
+
}
|
1036
|
+
|
1037
|
+
_items.Add(item);
|
1038
|
+
}
|
1039
|
+
|
1040
|
+
if (parentNode < 0 || !isThereSelfLink)
|
1041
|
+
return S_FALSE;
|
1042
|
+
|
1043
|
+
return S_OK;
|
1044
|
+
}
|
1045
|
+
|
1046
|
+
|
1047
|
+
int CHandler::FindTargetItem_for_SymLink(unsigned iNode, const AString &path) const
|
1048
|
+
{
|
1049
|
+
unsigned pos = 0;
|
1050
|
+
|
1051
|
+
if (path.IsEmpty())
|
1052
|
+
return -1;
|
1053
|
+
|
1054
|
+
if (path[0] == '/')
|
1055
|
+
{
|
1056
|
+
iNode = k_INODE_ROOT;
|
1057
|
+
if (iNode >= _refs.Size())
|
1058
|
+
return -1;
|
1059
|
+
pos = 1;
|
1060
|
+
}
|
1061
|
+
|
1062
|
+
AString s;
|
1063
|
+
|
1064
|
+
while (pos != path.Len())
|
1065
|
+
{
|
1066
|
+
const CNode &node = _nodes[_refs[iNode]];
|
1067
|
+
int slash = path.Find('/', pos);
|
1068
|
+
|
1069
|
+
if (slash < 0)
|
1070
|
+
{
|
1071
|
+
s = path.Ptr(pos);
|
1072
|
+
pos = path.Len();
|
1073
|
+
}
|
1074
|
+
else
|
1075
|
+
{
|
1076
|
+
s.SetFrom(path.Ptr(pos), slash - pos);
|
1077
|
+
pos = slash + 1;
|
1078
|
+
}
|
1079
|
+
|
1080
|
+
if (s[0] == '.')
|
1081
|
+
{
|
1082
|
+
if (s[1] == 0)
|
1083
|
+
continue;
|
1084
|
+
else if (s[1] == '.' && s[2] == 0)
|
1085
|
+
{
|
1086
|
+
if (node.ParentNode < 0)
|
1087
|
+
return -1;
|
1088
|
+
if (iNode == k_INODE_ROOT)
|
1089
|
+
return -1;
|
1090
|
+
iNode = node.ParentNode;
|
1091
|
+
continue;
|
1092
|
+
}
|
1093
|
+
}
|
1094
|
+
|
1095
|
+
if (node.DirIndex < 0)
|
1096
|
+
return -1;
|
1097
|
+
|
1098
|
+
const CUIntVector &dir = _dirs[node.DirIndex];
|
1099
|
+
|
1100
|
+
for (unsigned i = 0;; i++)
|
1101
|
+
{
|
1102
|
+
if (i >= dir.Size())
|
1103
|
+
return -1;
|
1104
|
+
const CItem &item = _items[dir[i]];
|
1105
|
+
if (item.Name == s)
|
1106
|
+
{
|
1107
|
+
iNode = item.Node;
|
1108
|
+
break;
|
1109
|
+
}
|
1110
|
+
}
|
1111
|
+
}
|
1112
|
+
|
1113
|
+
return _nodes[_refs[iNode]].ItemIndex;
|
1114
|
+
}
|
1115
|
+
|
1116
|
+
|
1117
|
+
HRESULT CHandler::SeekAndRead(IInStream *inStream, UInt64 block, Byte *data, size_t size)
|
1118
|
+
{
|
1119
|
+
if (block == 0 || block >= _h.NumBlocks)
|
1120
|
+
return S_FALSE;
|
1121
|
+
if (((size + ((size_t)1 << _h.BlockBits) - 1) >> _h.BlockBits) > _h.NumBlocks - block)
|
1122
|
+
return S_FALSE;
|
1123
|
+
RINOK(inStream->Seek((UInt64)block << _h.BlockBits, STREAM_SEEK_SET, NULL));
|
1124
|
+
_totalRead += size;
|
1125
|
+
return ReadStream_FALSE(inStream, data, size);
|
1126
|
+
}
|
1127
|
+
|
1128
|
+
|
1129
|
+
static const unsigned kHeaderSize = 2 * 1024;
|
1130
|
+
static const unsigned kHeaderDataOffset = 1024;
|
1131
|
+
|
1132
|
+
HRESULT CHandler::Open2(IInStream *inStream)
|
1133
|
+
{
|
1134
|
+
{
|
1135
|
+
Byte buf[kHeaderSize];
|
1136
|
+
RINOK(ReadStream_FALSE(inStream, buf, kHeaderSize));
|
1137
|
+
if (!_h.Parse(buf + kHeaderDataOffset))
|
1138
|
+
return S_FALSE;
|
1139
|
+
if (_h.BlockGroupNr != 0)
|
1140
|
+
return S_FALSE; // it's just copy of super block
|
1141
|
+
}
|
1142
|
+
|
1143
|
+
{
|
1144
|
+
// ---------- Read groups and nodes ----------
|
1145
|
+
|
1146
|
+
unsigned numGroups;
|
1147
|
+
{
|
1148
|
+
UInt64 numGroups64 = _h.GetNumGroups();
|
1149
|
+
if (numGroups64 > (UInt32)1 << 31)
|
1150
|
+
return S_FALSE;
|
1151
|
+
numGroups = (unsigned)numGroups64;
|
1152
|
+
}
|
1153
|
+
|
1154
|
+
unsigned gdBits = 5;
|
1155
|
+
if (_h.Is64Bit())
|
1156
|
+
{
|
1157
|
+
if (_h.GdSize != 64)
|
1158
|
+
return S_FALSE;
|
1159
|
+
gdBits = 6;
|
1160
|
+
}
|
1161
|
+
|
1162
|
+
_isArc = true;
|
1163
|
+
_phySize = _h.NumBlocks << _h.BlockBits;
|
1164
|
+
|
1165
|
+
if (_openCallback)
|
1166
|
+
{
|
1167
|
+
RINOK(_openCallback->SetTotal(NULL, &_phySize));
|
1168
|
+
}
|
1169
|
+
|
1170
|
+
UInt64 fileSize = 0;
|
1171
|
+
RINOK(inStream->Seek(0, STREAM_SEEK_END, &fileSize));
|
1172
|
+
|
1173
|
+
CRecordVector<CGroupDescriptor> groups;
|
1174
|
+
|
1175
|
+
{
|
1176
|
+
// ---------- Read groups ----------
|
1177
|
+
|
1178
|
+
CByteBuffer gdBuf;
|
1179
|
+
size_t gdBufSize = (size_t)numGroups << gdBits;
|
1180
|
+
if ((gdBufSize >> gdBits) != numGroups)
|
1181
|
+
return S_FALSE;
|
1182
|
+
gdBuf.Alloc(gdBufSize);
|
1183
|
+
RINOK(SeekAndRead(inStream, (_h.BlockBits <= 10 ? 2 : 1), gdBuf, gdBufSize));
|
1184
|
+
|
1185
|
+
for (unsigned i = 0; i < numGroups; i++)
|
1186
|
+
{
|
1187
|
+
CGroupDescriptor gd;
|
1188
|
+
|
1189
|
+
const Byte *p = gdBuf + ((size_t)i << gdBits);
|
1190
|
+
unsigned gd_Size = (unsigned)1 << gdBits;
|
1191
|
+
gd.Parse(p, gd_Size);
|
1192
|
+
|
1193
|
+
if (_h.UseMetadataChecksum())
|
1194
|
+
{
|
1195
|
+
// use CRC32c
|
1196
|
+
}
|
1197
|
+
else if (_h.UseGdtChecksum())
|
1198
|
+
{
|
1199
|
+
UInt32 crc = Crc16Calc(_h.Uuid, sizeof(_h.Uuid));
|
1200
|
+
Byte i_le[4];
|
1201
|
+
SetUi32(i_le, i);
|
1202
|
+
crc = Crc16Update(crc, i_le, 4);
|
1203
|
+
crc = Crc16Update(crc, p, 32 - 2);
|
1204
|
+
if (gd_Size != 32)
|
1205
|
+
crc = Crc16Update(crc, p + 32, gd_Size - 32);
|
1206
|
+
if (crc != gd.Checksum)
|
1207
|
+
return S_FALSE;
|
1208
|
+
}
|
1209
|
+
|
1210
|
+
groups.Add(gd);
|
1211
|
+
}
|
1212
|
+
}
|
1213
|
+
|
1214
|
+
{
|
1215
|
+
// ---------- Read nodes ----------
|
1216
|
+
|
1217
|
+
if (_h.NumInodes < _h.NumFreeInodes)
|
1218
|
+
return S_FALSE;
|
1219
|
+
|
1220
|
+
UInt32 numNodes = _h.InodesPerGroup;
|
1221
|
+
if (numNodes > _h.NumInodes)
|
1222
|
+
numNodes = _h.NumInodes;
|
1223
|
+
size_t nodesDataSize = (size_t)numNodes * _h.InodeSize;
|
1224
|
+
|
1225
|
+
if (nodesDataSize / _h.InodeSize != numNodes)
|
1226
|
+
return S_FALSE;
|
1227
|
+
|
1228
|
+
// that code to reduce false detecting cases
|
1229
|
+
if (nodesDataSize > fileSize)
|
1230
|
+
{
|
1231
|
+
if (numNodes > (1 << 24))
|
1232
|
+
return S_FALSE;
|
1233
|
+
}
|
1234
|
+
|
1235
|
+
UInt32 numReserveInodes = _h.NumInodes - _h.NumFreeInodes + 1;
|
1236
|
+
// numReserveInodes = _h.NumInodes + 1;
|
1237
|
+
if (numReserveInodes != 0)
|
1238
|
+
{
|
1239
|
+
_nodes.Reserve(numReserveInodes);
|
1240
|
+
_refs.Reserve(numReserveInodes);
|
1241
|
+
}
|
1242
|
+
|
1243
|
+
CByteBuffer nodesData;
|
1244
|
+
nodesData.Alloc(nodesDataSize);
|
1245
|
+
|
1246
|
+
CByteBuffer nodesMap;
|
1247
|
+
const size_t blockSize = (size_t)1 << _h.BlockBits;
|
1248
|
+
nodesMap.Alloc(blockSize);
|
1249
|
+
|
1250
|
+
unsigned globalNodeIndex = 0;
|
1251
|
+
// unsigned numEmpty = 0;
|
1252
|
+
unsigned numEmpty_in_Maps = 0;
|
1253
|
+
|
1254
|
+
FOR_VECTOR (gi, groups)
|
1255
|
+
{
|
1256
|
+
if (globalNodeIndex >= _h.NumInodes)
|
1257
|
+
break;
|
1258
|
+
|
1259
|
+
const CGroupDescriptor &gd = groups[gi];
|
1260
|
+
|
1261
|
+
PRF(printf("\n\ng%6d block = %6x\n", gi, (unsigned)gd.InodeTable));
|
1262
|
+
|
1263
|
+
RINOK(SeekAndRead(inStream, gd.InodeBitmap, nodesMap, blockSize));
|
1264
|
+
RINOK(SeekAndRead(inStream, gd.InodeTable, nodesData, nodesDataSize));
|
1265
|
+
|
1266
|
+
unsigned numEmpty_in_Map = 0;
|
1267
|
+
|
1268
|
+
for (size_t n = 0; n < numNodes && globalNodeIndex < _h.NumInodes; n++, globalNodeIndex++)
|
1269
|
+
{
|
1270
|
+
if ((nodesMap[n >> 3] & ((unsigned)1 << (n & 7))) == 0)
|
1271
|
+
{
|
1272
|
+
numEmpty_in_Map++;
|
1273
|
+
continue;
|
1274
|
+
}
|
1275
|
+
|
1276
|
+
const Byte *p = nodesData + (size_t)n * _h.InodeSize;
|
1277
|
+
if (IsEmptyData(p, _h.InodeSize))
|
1278
|
+
{
|
1279
|
+
if (globalNodeIndex + 1 >= _h.FirstInode)
|
1280
|
+
{
|
1281
|
+
_headersError = true;
|
1282
|
+
// return S_FALSE;
|
1283
|
+
}
|
1284
|
+
continue;
|
1285
|
+
}
|
1286
|
+
|
1287
|
+
CNode node;
|
1288
|
+
|
1289
|
+
PRF(printf("\nnode = %5d ", (unsigned)n));
|
1290
|
+
|
1291
|
+
if (!node.Parse(p, _h))
|
1292
|
+
return S_FALSE;
|
1293
|
+
|
1294
|
+
// PRF(printf("\n %6d", (unsigned)n));
|
1295
|
+
/*
|
1296
|
+
SetUi32(p + 0x7C, 0)
|
1297
|
+
SetUi32(p + 0x82, 0)
|
1298
|
+
|
1299
|
+
UInt32 crc = Crc32C_Calc(_h.Uuid, sizeof(_h.Uuid));
|
1300
|
+
Byte i_le[4];
|
1301
|
+
SetUi32(i_le, n);
|
1302
|
+
crc = Crc32C_Update(crc, i_le, 4);
|
1303
|
+
crc = Crc32C_Update(crc, p, _h.InodeSize);
|
1304
|
+
if (crc != node.Checksum) return S_FALSE;
|
1305
|
+
*/
|
1306
|
+
|
1307
|
+
while (_refs.Size() < globalNodeIndex + 1)
|
1308
|
+
{
|
1309
|
+
// numEmpty++;
|
1310
|
+
_refs.Add(-1);
|
1311
|
+
}
|
1312
|
+
|
1313
|
+
_refs.Add(_nodes.Add(node));
|
1314
|
+
}
|
1315
|
+
|
1316
|
+
|
1317
|
+
numEmpty_in_Maps += numEmpty_in_Map;
|
1318
|
+
|
1319
|
+
if (numEmpty_in_Map != gd.NumFreeInodes)
|
1320
|
+
{
|
1321
|
+
_headersWarning = true;
|
1322
|
+
// return S_FALSE;
|
1323
|
+
}
|
1324
|
+
}
|
1325
|
+
|
1326
|
+
if (numEmpty_in_Maps != _h.NumFreeInodes)
|
1327
|
+
{
|
1328
|
+
// some ext2 examples has incorrect value in _h.NumFreeInodes.
|
1329
|
+
// so we disable check;
|
1330
|
+
_headersWarning = true;
|
1331
|
+
}
|
1332
|
+
|
1333
|
+
if (_refs.Size() <= k_INODE_ROOT)
|
1334
|
+
return S_FALSE;
|
1335
|
+
|
1336
|
+
// printf("\n numReserveInodes = %6d, _refs.Size() = %d, numEmpty = %7d\n", numReserveInodes, _refs.Size(), (unsigned)numEmpty);
|
1337
|
+
}
|
1338
|
+
}
|
1339
|
+
|
1340
|
+
_stream = inStream; // we need stream for dir nodes
|
1341
|
+
|
1342
|
+
{
|
1343
|
+
// ---------- Read Dirs ----------
|
1344
|
+
|
1345
|
+
CByteBuffer dataBuf;
|
1346
|
+
|
1347
|
+
FOR_VECTOR (i, _refs)
|
1348
|
+
{
|
1349
|
+
int nodeIndex = _refs[i];
|
1350
|
+
{
|
1351
|
+
if (nodeIndex < 0)
|
1352
|
+
continue;
|
1353
|
+
const CNode &node = _nodes[nodeIndex];
|
1354
|
+
if (!node.IsDir())
|
1355
|
+
continue;
|
1356
|
+
}
|
1357
|
+
RINOK(ExtractNode(nodeIndex, dataBuf));
|
1358
|
+
if (dataBuf.Size() == 0)
|
1359
|
+
{
|
1360
|
+
// _headersError = true;
|
1361
|
+
return S_FALSE;
|
1362
|
+
}
|
1363
|
+
else
|
1364
|
+
{
|
1365
|
+
RINOK(ParseDir(dataBuf, dataBuf.Size(), i));
|
1366
|
+
}
|
1367
|
+
RINOK(CheckProgress());
|
1368
|
+
}
|
1369
|
+
|
1370
|
+
if (_nodes[_refs[k_INODE_ROOT]].ParentNode != k_INODE_ROOT)
|
1371
|
+
return S_FALSE;
|
1372
|
+
}
|
1373
|
+
|
1374
|
+
{
|
1375
|
+
// ---------- Check NumLinks and unreferenced dir nodes ----------
|
1376
|
+
|
1377
|
+
FOR_VECTOR (i, _refs)
|
1378
|
+
{
|
1379
|
+
int nodeIndex = _refs[i];
|
1380
|
+
if (nodeIndex < 0)
|
1381
|
+
continue;
|
1382
|
+
const CNode &node = _nodes[nodeIndex];
|
1383
|
+
|
1384
|
+
if (node.NumLinks != node.NumLinksCalced)
|
1385
|
+
{
|
1386
|
+
if (node.NumLinks != 1 || node.NumLinksCalced != 0
|
1387
|
+
// ) && i >= _h.FirstInode
|
1388
|
+
)
|
1389
|
+
{
|
1390
|
+
_linksError = true;
|
1391
|
+
// return S_FALSE;
|
1392
|
+
}
|
1393
|
+
}
|
1394
|
+
|
1395
|
+
if (!node.IsDir())
|
1396
|
+
continue;
|
1397
|
+
|
1398
|
+
if (node.ParentNode < 0)
|
1399
|
+
{
|
1400
|
+
if (i >= _h.FirstInode)
|
1401
|
+
return S_FALSE;
|
1402
|
+
continue;
|
1403
|
+
}
|
1404
|
+
}
|
1405
|
+
}
|
1406
|
+
|
1407
|
+
{
|
1408
|
+
// ---------- Check that there is no loops in parents list ----------
|
1409
|
+
|
1410
|
+
unsigned numNodes = _refs.Size();
|
1411
|
+
CIntArr UsedByNode(numNodes);
|
1412
|
+
{
|
1413
|
+
{
|
1414
|
+
for (unsigned i = 0; i < numNodes; i++)
|
1415
|
+
UsedByNode[i] = -1;
|
1416
|
+
}
|
1417
|
+
}
|
1418
|
+
|
1419
|
+
FOR_VECTOR (i, _refs)
|
1420
|
+
{
|
1421
|
+
{
|
1422
|
+
int nodeIndex = _refs[i];
|
1423
|
+
if (nodeIndex < 0)
|
1424
|
+
continue;
|
1425
|
+
const CNode &node = _nodes[nodeIndex];
|
1426
|
+
if (node.ParentNode < 0 // not dir
|
1427
|
+
|| i == k_INODE_ROOT)
|
1428
|
+
continue;
|
1429
|
+
}
|
1430
|
+
|
1431
|
+
unsigned c = i;
|
1432
|
+
|
1433
|
+
for (;;)
|
1434
|
+
{
|
1435
|
+
int nodeIndex = _refs[c];
|
1436
|
+
if (nodeIndex < 0)
|
1437
|
+
return S_FALSE;
|
1438
|
+
CNode &node = _nodes[nodeIndex];
|
1439
|
+
|
1440
|
+
if (UsedByNode[c] != -1)
|
1441
|
+
{
|
1442
|
+
if ((unsigned)UsedByNode[c] == i)
|
1443
|
+
return S_FALSE;
|
1444
|
+
break;
|
1445
|
+
}
|
1446
|
+
|
1447
|
+
UsedByNode[c] = i;
|
1448
|
+
if (node.ParentNode < 0 || node.ParentNode == k_INODE_ROOT)
|
1449
|
+
break;
|
1450
|
+
if ((unsigned)node.ParentNode == i)
|
1451
|
+
return S_FALSE;
|
1452
|
+
c = node.ParentNode;
|
1453
|
+
}
|
1454
|
+
}
|
1455
|
+
}
|
1456
|
+
|
1457
|
+
{
|
1458
|
+
// ---------- Fill SymLinks data ----------
|
1459
|
+
|
1460
|
+
AString s;
|
1461
|
+
CByteBuffer data;
|
1462
|
+
|
1463
|
+
unsigned i;
|
1464
|
+
for (i = 0; i < _refs.Size(); i++)
|
1465
|
+
{
|
1466
|
+
int nodeIndex = _refs[i];
|
1467
|
+
if (nodeIndex < 0)
|
1468
|
+
continue;
|
1469
|
+
CNode &node = _nodes[nodeIndex];
|
1470
|
+
if (!node.IsLink())
|
1471
|
+
continue;
|
1472
|
+
if (node.FileSize > ((UInt32)1 << 14))
|
1473
|
+
continue;
|
1474
|
+
if (ExtractNode(nodeIndex, data) == S_OK && data.Size() != 0)
|
1475
|
+
{
|
1476
|
+
s.SetFrom_CalcLen((const char *)(const Byte *)data, (unsigned)data.Size());
|
1477
|
+
if (s.Len() == data.Size())
|
1478
|
+
node.SymLinkIndex = _symLinks.Add(s);
|
1479
|
+
RINOK(CheckProgress());
|
1480
|
+
}
|
1481
|
+
}
|
1482
|
+
|
1483
|
+
unsigned prev = 0;
|
1484
|
+
unsigned complex = 0;
|
1485
|
+
|
1486
|
+
for (i = 0; i < _items.Size(); i++)
|
1487
|
+
{
|
1488
|
+
CItem &item = _items[i];
|
1489
|
+
int sym = _nodes[_refs[item.Node]].SymLinkIndex;
|
1490
|
+
if (sym >= 0 && item.ParentNode >= 0)
|
1491
|
+
{
|
1492
|
+
item.SymLinkItemIndex = FindTargetItem_for_SymLink(item.ParentNode, _symLinks[sym]);
|
1493
|
+
if (_openCallback)
|
1494
|
+
{
|
1495
|
+
complex++;
|
1496
|
+
if (complex - prev >= (1 << 10))
|
1497
|
+
{
|
1498
|
+
RINOK(CheckProgress2());
|
1499
|
+
prev = complex;
|
1500
|
+
}
|
1501
|
+
}
|
1502
|
+
}
|
1503
|
+
}
|
1504
|
+
}
|
1505
|
+
|
1506
|
+
{
|
1507
|
+
// ---------- Add items and aux folders for unreferenced files ----------
|
1508
|
+
|
1509
|
+
bool useSys = false;
|
1510
|
+
bool useUnknown = false;
|
1511
|
+
|
1512
|
+
FOR_VECTOR (i, _refs)
|
1513
|
+
{
|
1514
|
+
int nodeIndex = _refs[i];
|
1515
|
+
if (nodeIndex < 0)
|
1516
|
+
continue;
|
1517
|
+
const CNode &node = _nodes[nodeIndex];
|
1518
|
+
|
1519
|
+
if (node.NumLinksCalced == 0 /* || i > 100 && i < 150 */) // for debug
|
1520
|
+
{
|
1521
|
+
CItem item;
|
1522
|
+
item.Node = i;
|
1523
|
+
|
1524
|
+
// we don't know how to work with k_INODE_RESIZE node (strange FileSize and Block values).
|
1525
|
+
// so we ignore it;
|
1526
|
+
|
1527
|
+
if (i == k_INODE_RESIZE)
|
1528
|
+
continue;
|
1529
|
+
|
1530
|
+
if (node.FileSize == 0)
|
1531
|
+
continue;
|
1532
|
+
|
1533
|
+
if (i < _h.FirstInode)
|
1534
|
+
{
|
1535
|
+
if (item.Node < ARRAY_SIZE(k_SysInode_Names))
|
1536
|
+
item.Name = k_SysInode_Names[item.Node];
|
1537
|
+
useSys = true;
|
1538
|
+
}
|
1539
|
+
else
|
1540
|
+
useUnknown = true;
|
1541
|
+
|
1542
|
+
if (item.Name.IsEmpty())
|
1543
|
+
{
|
1544
|
+
char temp[16];
|
1545
|
+
ConvertUInt32ToString(item.Node, temp);
|
1546
|
+
item.Name = temp;
|
1547
|
+
}
|
1548
|
+
|
1549
|
+
_items.Add(item);
|
1550
|
+
}
|
1551
|
+
}
|
1552
|
+
|
1553
|
+
if (useSys)
|
1554
|
+
_auxSysIndex = _auxItems.Add("[SYS]");
|
1555
|
+
if (useUnknown)
|
1556
|
+
_auxUnknownIndex = _auxItems.Add("[UNKNOWN]");
|
1557
|
+
}
|
1558
|
+
|
1559
|
+
return S_OK;
|
1560
|
+
}
|
1561
|
+
|
1562
|
+
|
1563
|
+
STDMETHODIMP CHandler::Open(IInStream *stream, const UInt64 *, IArchiveOpenCallback *callback)
|
1564
|
+
{
|
1565
|
+
COM_TRY_BEGIN
|
1566
|
+
{
|
1567
|
+
Close();
|
1568
|
+
HRESULT res;
|
1569
|
+
try
|
1570
|
+
{
|
1571
|
+
_openCallback = callback;
|
1572
|
+
res = Open2(stream);
|
1573
|
+
}
|
1574
|
+
catch(...)
|
1575
|
+
{
|
1576
|
+
ClearRefs();
|
1577
|
+
throw;
|
1578
|
+
}
|
1579
|
+
|
1580
|
+
if (res != S_OK)
|
1581
|
+
{
|
1582
|
+
ClearRefs();
|
1583
|
+
return res;
|
1584
|
+
}
|
1585
|
+
_stream = stream;
|
1586
|
+
}
|
1587
|
+
return S_OK;
|
1588
|
+
COM_TRY_END
|
1589
|
+
}
|
1590
|
+
|
1591
|
+
|
1592
|
+
void CHandler::ClearRefs()
|
1593
|
+
{
|
1594
|
+
_stream.Release();
|
1595
|
+
_items.Clear();
|
1596
|
+
_nodes.Clear();
|
1597
|
+
_refs.Clear();
|
1598
|
+
_auxItems.Clear();
|
1599
|
+
_symLinks.Clear();
|
1600
|
+
_dirs.Clear();
|
1601
|
+
_auxSysIndex = -1;
|
1602
|
+
_auxUnknownIndex = -1;
|
1603
|
+
}
|
1604
|
+
|
1605
|
+
|
1606
|
+
STDMETHODIMP CHandler::Close()
|
1607
|
+
{
|
1608
|
+
_totalRead = 0;
|
1609
|
+
_totalReadPrev = 0;
|
1610
|
+
_phySize = 0;
|
1611
|
+
_isArc = false;
|
1612
|
+
_headersError = false;
|
1613
|
+
_headersWarning = false;
|
1614
|
+
_linksError = false;
|
1615
|
+
_isUTF = true;
|
1616
|
+
|
1617
|
+
ClearRefs();
|
1618
|
+
return S_OK;
|
1619
|
+
}
|
1620
|
+
|
1621
|
+
|
1622
|
+
void CHandler::GetPath(unsigned index, AString &s) const
|
1623
|
+
{
|
1624
|
+
s.Empty();
|
1625
|
+
|
1626
|
+
if (index >= _items.Size())
|
1627
|
+
{
|
1628
|
+
s = _auxItems[index - _items.Size()];
|
1629
|
+
return;
|
1630
|
+
}
|
1631
|
+
|
1632
|
+
for (;;)
|
1633
|
+
{
|
1634
|
+
const CItem &item = _items[index];
|
1635
|
+
if (!s.IsEmpty())
|
1636
|
+
s.InsertAtFront(CHAR_PATH_SEPARATOR);
|
1637
|
+
s.Insert(0, item.Name);
|
1638
|
+
|
1639
|
+
if (item.ParentNode == k_INODE_ROOT)
|
1640
|
+
return;
|
1641
|
+
|
1642
|
+
if (item.ParentNode < 0)
|
1643
|
+
{
|
1644
|
+
int aux = GetParentAux(item);
|
1645
|
+
if (aux < 0)
|
1646
|
+
break;
|
1647
|
+
s.InsertAtFront(CHAR_PATH_SEPARATOR);
|
1648
|
+
s.Insert(0, _auxItems[aux]);
|
1649
|
+
return;
|
1650
|
+
}
|
1651
|
+
|
1652
|
+
const CNode &node = _nodes[_refs[item.ParentNode]];
|
1653
|
+
if (node.ItemIndex < 0)
|
1654
|
+
return;
|
1655
|
+
index = node.ItemIndex;
|
1656
|
+
|
1657
|
+
if (s.Len() > ((UInt32)1 << 16))
|
1658
|
+
{
|
1659
|
+
s.Insert(0, "[LONG]" STRING_PATH_SEPARATOR);
|
1660
|
+
return;
|
1661
|
+
}
|
1662
|
+
}
|
1663
|
+
}
|
1664
|
+
|
1665
|
+
|
1666
|
+
bool CHandler::GetPackSize(unsigned index, UInt64 &totalPack) const
|
1667
|
+
{
|
1668
|
+
if (index >= _items.Size())
|
1669
|
+
{
|
1670
|
+
totalPack = 0;
|
1671
|
+
return false;
|
1672
|
+
}
|
1673
|
+
|
1674
|
+
const CItem &item = _items[index];
|
1675
|
+
const CNode &node = _nodes[_refs[item.Node]];
|
1676
|
+
|
1677
|
+
// if (!node.IsFlags_EXTENTS())
|
1678
|
+
{
|
1679
|
+
totalPack = (UInt64)node.NumBlocks << (node.IsFlags_HUGE() ? _h.BlockBits : 9);
|
1680
|
+
return true;
|
1681
|
+
}
|
1682
|
+
|
1683
|
+
/*
|
1684
|
+
CExtentTreeHeader eth;
|
1685
|
+
if (!eth.Parse(node.Block))
|
1686
|
+
return false;
|
1687
|
+
if (eth.NumEntries > 3)
|
1688
|
+
return false;
|
1689
|
+
if (!eth.Depth == 0)
|
1690
|
+
return false;
|
1691
|
+
|
1692
|
+
UInt64 numBlocks = 0;
|
1693
|
+
{
|
1694
|
+
for (unsigned i = 0; i < eth.NumEntries; i++)
|
1695
|
+
{
|
1696
|
+
CExtent e;
|
1697
|
+
e.Parse(node.Block + 12 + i * 12);
|
1698
|
+
// const CExtent &e = node.leafs[i];
|
1699
|
+
if (e.IsInited)
|
1700
|
+
numBlocks += e.Len;
|
1701
|
+
}
|
1702
|
+
}
|
1703
|
+
|
1704
|
+
totalPack = numBlocks << _h.BlockBits;
|
1705
|
+
return true;
|
1706
|
+
*/
|
1707
|
+
}
|
1708
|
+
|
1709
|
+
|
1710
|
+
STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
|
1711
|
+
{
|
1712
|
+
*numItems = _items.Size() + _auxItems.Size();
|
1713
|
+
return S_OK;
|
1714
|
+
}
|
1715
|
+
|
1716
|
+
enum
|
1717
|
+
{
|
1718
|
+
kpidMountTime = kpidUserDefined,
|
1719
|
+
kpidLastCheckTime,
|
1720
|
+
kpidRevision,
|
1721
|
+
kpidINodeSize,
|
1722
|
+
kpidLastMount,
|
1723
|
+
kpidFeatureIncompat,
|
1724
|
+
kpidFeatureRoCompat,
|
1725
|
+
kpidWrittenKB
|
1726
|
+
|
1727
|
+
// kpidGroupSize,
|
1728
|
+
|
1729
|
+
// kpidChangeTime = kpidUserDefined + 256,
|
1730
|
+
// kpidDTime
|
1731
|
+
};
|
1732
|
+
|
1733
|
+
static const UInt32 kProps[] =
|
1734
|
+
{
|
1735
|
+
kpidPath,
|
1736
|
+
kpidIsDir,
|
1737
|
+
kpidSize,
|
1738
|
+
kpidPackSize,
|
1739
|
+
kpidPosixAttrib,
|
1740
|
+
kpidMTime,
|
1741
|
+
kpidCTime,
|
1742
|
+
kpidATime,
|
1743
|
+
// kpidChangeTime,
|
1744
|
+
// kpidDTime,
|
1745
|
+
kpidINode,
|
1746
|
+
kpidLinks,
|
1747
|
+
kpidSymLink,
|
1748
|
+
kpidCharacts,
|
1749
|
+
kpidUser,
|
1750
|
+
kpidGroup
|
1751
|
+
};
|
1752
|
+
|
1753
|
+
|
1754
|
+
static const CStatProp kArcProps[] =
|
1755
|
+
{
|
1756
|
+
{ NULL, kpidHeadersSize, VT_BSTR },
|
1757
|
+
// { NULL, kpidFileSystem, VT_BSTR },
|
1758
|
+
// kpidMethod,
|
1759
|
+
{ NULL, kpidClusterSize, VT_UI4 },
|
1760
|
+
// { "Group Size", kpidGroupSize, VT_UI8 },
|
1761
|
+
{ NULL, kpidFreeSpace, VT_UI8 },
|
1762
|
+
|
1763
|
+
{ NULL, kpidMTime, VT_FILETIME },
|
1764
|
+
{ NULL, kpidCTime, VT_FILETIME },
|
1765
|
+
{ "Mount Time", kpidMountTime, VT_FILETIME },
|
1766
|
+
{ "Last Check Time", kpidLastCheckTime, VT_FILETIME },
|
1767
|
+
|
1768
|
+
{ NULL, kpidHostOS, VT_BSTR},
|
1769
|
+
{ "Revision", kpidRevision, VT_UI4},
|
1770
|
+
{ "inode Size", kpidINodeSize, VT_UI4},
|
1771
|
+
{ NULL, kpidCodePage, VT_BSTR},
|
1772
|
+
{ NULL, kpidVolumeName, VT_BSTR},
|
1773
|
+
{ "Last Mounted", kpidLastMount, VT_BSTR},
|
1774
|
+
{ NULL, kpidId, VT_BSTR},
|
1775
|
+
{ NULL, kpidCharacts, VT_BSTR },
|
1776
|
+
{ "Incompatible Features", kpidFeatureIncompat, VT_BSTR },
|
1777
|
+
{ "Readonly-compatible Features", kpidFeatureRoCompat, VT_BSTR },
|
1778
|
+
{ "Written KiB", kpidWrittenKB, VT_UI8 }
|
1779
|
+
};
|
1780
|
+
|
1781
|
+
IMP_IInArchive_Props
|
1782
|
+
IMP_IInArchive_ArcProps_WITH_NAME
|
1783
|
+
|
1784
|
+
static void StringToProp(bool isUTF, const char *s, unsigned size, NCOM::CPropVariant &prop)
|
1785
|
+
{
|
1786
|
+
UString u;
|
1787
|
+
AString a;
|
1788
|
+
a.SetFrom_CalcLen(s, size);
|
1789
|
+
if (!isUTF || !ConvertUTF8ToUnicode(a, u))
|
1790
|
+
MultiByteToUnicodeString2(u, a);
|
1791
|
+
prop = u;
|
1792
|
+
}
|
1793
|
+
|
1794
|
+
static void UnixTimeToProp(UInt32 val, NCOM::CPropVariant &prop)
|
1795
|
+
{
|
1796
|
+
if (val != 0)
|
1797
|
+
{
|
1798
|
+
FILETIME ft;
|
1799
|
+
NTime::UnixTimeToFileTime(val, ft);
|
1800
|
+
prop = ft;
|
1801
|
+
}
|
1802
|
+
}
|
1803
|
+
|
1804
|
+
STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
|
1805
|
+
{
|
1806
|
+
COM_TRY_BEGIN
|
1807
|
+
|
1808
|
+
NCOM::CPropVariant prop;
|
1809
|
+
|
1810
|
+
switch (propID)
|
1811
|
+
{
|
1812
|
+
/*
|
1813
|
+
case kpidFileSystem:
|
1814
|
+
{
|
1815
|
+
AString res = "Ext4";
|
1816
|
+
prop = res;
|
1817
|
+
break;
|
1818
|
+
}
|
1819
|
+
*/
|
1820
|
+
|
1821
|
+
case kpidIsTree: prop = true; break;
|
1822
|
+
case kpidIsAux: prop = true; break;
|
1823
|
+
case kpidINode: prop = true; break;
|
1824
|
+
|
1825
|
+
case kpidClusterSize: prop = (UInt32)1 << _h.BlockBits; break;
|
1826
|
+
// case kpidGroupSize: prop = (UInt64)_h.BlocksPerGroup << _h.BlockBits; break;
|
1827
|
+
|
1828
|
+
case kpidFreeSpace: prop = (UInt64)_h.NumFreeBlocks << _h.BlockBits; break;
|
1829
|
+
|
1830
|
+
case kpidCTime: UnixTimeToProp(_h.CTime, prop); break;
|
1831
|
+
case kpidMTime: UnixTimeToProp(_h.WriteTime, prop); break;
|
1832
|
+
case kpidMountTime: UnixTimeToProp(_h.MountTime, prop); break;
|
1833
|
+
case kpidLastCheckTime: UnixTimeToProp(_h.LastCheckTime, prop); break;
|
1834
|
+
|
1835
|
+
case kpidHostOS:
|
1836
|
+
{
|
1837
|
+
char temp[16];
|
1838
|
+
const char *s = NULL;
|
1839
|
+
if (_h.CreatorOs < ARRAY_SIZE(kHostOS))
|
1840
|
+
s = kHostOS[_h.CreatorOs];
|
1841
|
+
else
|
1842
|
+
{
|
1843
|
+
ConvertUInt32ToString(_h.CreatorOs, temp);
|
1844
|
+
s = temp;
|
1845
|
+
}
|
1846
|
+
prop = s;
|
1847
|
+
break;
|
1848
|
+
}
|
1849
|
+
|
1850
|
+
case kpidRevision: prop = _h.RevLevel; break;
|
1851
|
+
|
1852
|
+
case kpidINodeSize: prop = _h.InodeSize; break;
|
1853
|
+
|
1854
|
+
case kpidId:
|
1855
|
+
{
|
1856
|
+
if (!IsEmptyData(_h.Uuid, 16))
|
1857
|
+
{
|
1858
|
+
char s[16 * 2 + 2];
|
1859
|
+
for (unsigned i = 0; i < 16; i++)
|
1860
|
+
PrintHex(_h.Uuid[i], s + i * 2);
|
1861
|
+
s[16 * 2] = 0;
|
1862
|
+
prop = s;
|
1863
|
+
}
|
1864
|
+
break;
|
1865
|
+
}
|
1866
|
+
|
1867
|
+
case kpidCodePage: if (_isUTF) prop = "UTF-8"; break;
|
1868
|
+
|
1869
|
+
case kpidShortComment:
|
1870
|
+
case kpidVolumeName:
|
1871
|
+
StringToProp(_isUTF, _h.VolName, sizeof(_h.VolName), prop); break;
|
1872
|
+
|
1873
|
+
case kpidLastMount: StringToProp(_isUTF, _h.LastMount, sizeof(_h.LastMount), prop); break;
|
1874
|
+
|
1875
|
+
case kpidCharacts: FLAGS_TO_PROP(g_FeatureCompat_Flags, _h.FeatureCompat, prop); break;
|
1876
|
+
case kpidFeatureIncompat: FLAGS_TO_PROP(g_FeatureIncompat_Flags, _h.FeatureIncompat, prop); break;
|
1877
|
+
case kpidFeatureRoCompat: FLAGS_TO_PROP(g_FeatureRoCompat_Flags, _h.FeatureRoCompat, prop); break;
|
1878
|
+
case kpidWrittenKB: if (_h.WrittenKB != 0) prop = _h.WrittenKB; break;
|
1879
|
+
|
1880
|
+
case kpidPhySize: prop = _phySize; break;
|
1881
|
+
|
1882
|
+
case kpidErrorFlags:
|
1883
|
+
{
|
1884
|
+
UInt32 v = 0;
|
1885
|
+
if (!_isArc) v |= kpv_ErrorFlags_IsNotArc;;
|
1886
|
+
if (_linksError) v |= kpv_ErrorFlags_HeadersError;
|
1887
|
+
if (_headersError) v |= kpv_ErrorFlags_HeadersError;
|
1888
|
+
if (!_stream && v == 0 && _isArc)
|
1889
|
+
v = kpv_ErrorFlags_HeadersError;
|
1890
|
+
if (v != 0)
|
1891
|
+
prop = v;
|
1892
|
+
break;
|
1893
|
+
}
|
1894
|
+
|
1895
|
+
case kpidWarningFlags:
|
1896
|
+
{
|
1897
|
+
UInt32 v = 0;
|
1898
|
+
if (_headersWarning) v |= kpv_ErrorFlags_HeadersError;
|
1899
|
+
if (v != 0)
|
1900
|
+
prop = v;
|
1901
|
+
break;
|
1902
|
+
}
|
1903
|
+
}
|
1904
|
+
|
1905
|
+
prop.Detach(value);
|
1906
|
+
return S_OK;
|
1907
|
+
|
1908
|
+
COM_TRY_END
|
1909
|
+
}
|
1910
|
+
|
1911
|
+
|
1912
|
+
/*
|
1913
|
+
static const Byte kRawProps[] =
|
1914
|
+
{
|
1915
|
+
// kpidSha1,
|
1916
|
+
};
|
1917
|
+
*/
|
1918
|
+
|
1919
|
+
STDMETHODIMP CHandler::GetNumRawProps(UInt32 *numProps)
|
1920
|
+
{
|
1921
|
+
// *numProps = ARRAY_SIZE(kRawProps);
|
1922
|
+
*numProps = 0;
|
1923
|
+
return S_OK;
|
1924
|
+
}
|
1925
|
+
|
1926
|
+
STDMETHODIMP CHandler::GetRawPropInfo(UInt32 /* index */, BSTR *name, PROPID *propID)
|
1927
|
+
{
|
1928
|
+
// *propID = kRawProps[index];
|
1929
|
+
*propID = 0;
|
1930
|
+
*name = 0;
|
1931
|
+
return S_OK;
|
1932
|
+
}
|
1933
|
+
|
1934
|
+
STDMETHODIMP CHandler::GetParent(UInt32 index, UInt32 *parent, UInt32 *parentType)
|
1935
|
+
{
|
1936
|
+
*parentType = NParentType::kDir;
|
1937
|
+
*parent = (UInt32)(Int32)-1;
|
1938
|
+
|
1939
|
+
if (index >= _items.Size())
|
1940
|
+
return S_OK;
|
1941
|
+
|
1942
|
+
const CItem &item = _items[index];
|
1943
|
+
|
1944
|
+
if (item.ParentNode < 0)
|
1945
|
+
{
|
1946
|
+
int aux = GetParentAux(item);
|
1947
|
+
if (aux >= 0)
|
1948
|
+
*parent = _items.Size() + aux;
|
1949
|
+
}
|
1950
|
+
else
|
1951
|
+
{
|
1952
|
+
int itemIndex = _nodes[_refs[item.ParentNode]].ItemIndex;
|
1953
|
+
if (itemIndex >= 0)
|
1954
|
+
*parent = itemIndex;
|
1955
|
+
}
|
1956
|
+
|
1957
|
+
return S_OK;
|
1958
|
+
}
|
1959
|
+
|
1960
|
+
|
1961
|
+
STDMETHODIMP CHandler::GetRawProp(UInt32 index, PROPID propID, const void **data, UInt32 *dataSize, UInt32 *propType)
|
1962
|
+
{
|
1963
|
+
*data = NULL;
|
1964
|
+
*dataSize = 0;
|
1965
|
+
*propType = 0;
|
1966
|
+
|
1967
|
+
if (propID == kpidName && _isUTF)
|
1968
|
+
{
|
1969
|
+
if (index < _items.Size())
|
1970
|
+
{
|
1971
|
+
const AString &s = _items[index].Name;
|
1972
|
+
if (!s.IsEmpty())
|
1973
|
+
{
|
1974
|
+
*data = (void *)(const char *)s;
|
1975
|
+
*dataSize = (UInt32)s.Len() + 1;
|
1976
|
+
*propType = NPropDataType::kUtf8z;
|
1977
|
+
}
|
1978
|
+
return S_OK;
|
1979
|
+
}
|
1980
|
+
else
|
1981
|
+
{
|
1982
|
+
const AString &s = _auxItems[index - _items.Size()];
|
1983
|
+
{
|
1984
|
+
*data = (void *)(const char *)s;
|
1985
|
+
*dataSize = (UInt32)s.Len() + 1;
|
1986
|
+
*propType = NPropDataType::kUtf8z;
|
1987
|
+
}
|
1988
|
+
return S_OK;
|
1989
|
+
}
|
1990
|
+
}
|
1991
|
+
|
1992
|
+
return S_OK;
|
1993
|
+
}
|
1994
|
+
|
1995
|
+
|
1996
|
+
static void ExtTimeToProp(const CExtTime &t, NCOM::CPropVariant &prop)
|
1997
|
+
{
|
1998
|
+
/*
|
1999
|
+
UInt32 nano = 0;
|
2000
|
+
if (t.Extra != 0)
|
2001
|
+
{
|
2002
|
+
UInt32 mask = t.Extra & 3;
|
2003
|
+
if (mask != 0)
|
2004
|
+
return;
|
2005
|
+
nano = t.Extra >> 2;
|
2006
|
+
}
|
2007
|
+
UInt64 v;
|
2008
|
+
if (t.Val == 0 && nano == 0)
|
2009
|
+
return;
|
2010
|
+
if (!NTime::UnixTime_to_FileTime64(t.Val, v))
|
2011
|
+
return;
|
2012
|
+
if (nano != 0)
|
2013
|
+
v += nano / 100;
|
2014
|
+
|
2015
|
+
FILETIME ft;
|
2016
|
+
ft.dwLowDateTime = (DWORD)v;
|
2017
|
+
ft.dwHighDateTime = (DWORD)(v >> 32);
|
2018
|
+
prop = ft;
|
2019
|
+
*/
|
2020
|
+
if (t.Val == 0)
|
2021
|
+
return;
|
2022
|
+
if (t.Extra != 0)
|
2023
|
+
{
|
2024
|
+
UInt32 mask = t.Extra & 3;
|
2025
|
+
if (mask != 0)
|
2026
|
+
return;
|
2027
|
+
}
|
2028
|
+
FILETIME ft;
|
2029
|
+
if (NTime::UnixTime64ToFileTime(t.Val, ft))
|
2030
|
+
prop = ft;
|
2031
|
+
}
|
2032
|
+
|
2033
|
+
|
2034
|
+
STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
|
2035
|
+
{
|
2036
|
+
COM_TRY_BEGIN
|
2037
|
+
NCOM::CPropVariant prop;
|
2038
|
+
|
2039
|
+
if (index >= _items.Size())
|
2040
|
+
{
|
2041
|
+
switch (propID)
|
2042
|
+
{
|
2043
|
+
case kpidPath:
|
2044
|
+
case kpidName:
|
2045
|
+
{
|
2046
|
+
AString s = _auxItems[index - _items.Size()];
|
2047
|
+
prop = s;
|
2048
|
+
break;
|
2049
|
+
}
|
2050
|
+
case kpidIsDir: prop = true; break;
|
2051
|
+
case kpidIsAux: prop = true; break;
|
2052
|
+
}
|
2053
|
+
}
|
2054
|
+
else
|
2055
|
+
{
|
2056
|
+
|
2057
|
+
const CItem &item = _items[index];
|
2058
|
+
const CNode &node = _nodes[_refs[item.Node]];
|
2059
|
+
bool isDir = node.IsDir();
|
2060
|
+
|
2061
|
+
switch (propID)
|
2062
|
+
{
|
2063
|
+
case kpidPath:
|
2064
|
+
{
|
2065
|
+
UString u;
|
2066
|
+
{
|
2067
|
+
AString s;
|
2068
|
+
GetPath(index, s);
|
2069
|
+
if (!_isUTF || !ConvertUTF8ToUnicode(s, u))
|
2070
|
+
MultiByteToUnicodeString2(u, s);
|
2071
|
+
}
|
2072
|
+
prop = u;
|
2073
|
+
break;
|
2074
|
+
}
|
2075
|
+
|
2076
|
+
case kpidName:
|
2077
|
+
{
|
2078
|
+
{
|
2079
|
+
UString u;
|
2080
|
+
{
|
2081
|
+
if (!_isUTF || !ConvertUTF8ToUnicode(item.Name, u))
|
2082
|
+
MultiByteToUnicodeString2(u, item.Name);
|
2083
|
+
}
|
2084
|
+
prop = u;
|
2085
|
+
}
|
2086
|
+
break;
|
2087
|
+
}
|
2088
|
+
|
2089
|
+
case kpidIsDir:
|
2090
|
+
{
|
2091
|
+
bool isDir2 = isDir;
|
2092
|
+
if (item.SymLinkItemIndex >= 0)
|
2093
|
+
isDir2 = _nodes[_refs[_items[item.SymLinkItemIndex].Node]].IsDir();
|
2094
|
+
prop = isDir2;
|
2095
|
+
break;
|
2096
|
+
}
|
2097
|
+
|
2098
|
+
case kpidSize: if (!isDir) prop = node.FileSize; break;
|
2099
|
+
|
2100
|
+
case kpidPackSize:
|
2101
|
+
if (!isDir)
|
2102
|
+
{
|
2103
|
+
UInt64 size;
|
2104
|
+
if (GetPackSize(index, size))
|
2105
|
+
prop = size;
|
2106
|
+
}
|
2107
|
+
break;
|
2108
|
+
|
2109
|
+
case kpidPosixAttrib:
|
2110
|
+
{
|
2111
|
+
/*
|
2112
|
+
if (node.Type != 0 && node.Type < ARRAY_SIZE(k_TypeToMode))
|
2113
|
+
prop = (UInt32)(node.Mode & 0xFFF) | k_TypeToMode[node.Type];
|
2114
|
+
*/
|
2115
|
+
prop = (UInt32)(node.Mode);
|
2116
|
+
break;
|
2117
|
+
}
|
2118
|
+
|
2119
|
+
case kpidMTime: ExtTimeToProp(node.MTime, prop); break;
|
2120
|
+
case kpidCTime: ExtTimeToProp(node.CTime, prop); break;
|
2121
|
+
case kpidATime: ExtTimeToProp(node.ATime, prop); break;
|
2122
|
+
// case kpidDTime: ExtTimeToProp(node.DTime, prop); break;
|
2123
|
+
// case kpidChangeTime: ExtTimeToProp(node.InodeChangeTime, prop); break;
|
2124
|
+
|
2125
|
+
case kpidUser: prop = (UInt32)node.Uid; break;
|
2126
|
+
case kpidGroup: prop = (UInt32)node.Gid; break;
|
2127
|
+
case kpidLinks: prop = node.NumLinks; break;
|
2128
|
+
case kpidINode: prop = (UInt32)item.Node; break;
|
2129
|
+
case kpidStreamId: if (!isDir) prop = (UInt32)item.Node; break;
|
2130
|
+
case kpidCharacts: FLAGS_TO_PROP(g_NodeFlags, (UInt32)node.Flags, prop); break;
|
2131
|
+
|
2132
|
+
case kpidSymLink:
|
2133
|
+
{
|
2134
|
+
if (node.SymLinkIndex >= 0)
|
2135
|
+
{
|
2136
|
+
UString u;
|
2137
|
+
{
|
2138
|
+
const AString &s = _symLinks[node.SymLinkIndex];
|
2139
|
+
if (!_isUTF || !ConvertUTF8ToUnicode(s, u))
|
2140
|
+
MultiByteToUnicodeString2(u, s);
|
2141
|
+
}
|
2142
|
+
prop = u;
|
2143
|
+
}
|
2144
|
+
break;
|
2145
|
+
}
|
2146
|
+
}
|
2147
|
+
|
2148
|
+
}
|
2149
|
+
|
2150
|
+
prop.Detach(value);
|
2151
|
+
return S_OK;
|
2152
|
+
COM_TRY_END
|
2153
|
+
}
|
2154
|
+
|
2155
|
+
|
2156
|
+
class CClusterInStream2:
|
2157
|
+
public IInStream,
|
2158
|
+
public CMyUnknownImp
|
2159
|
+
{
|
2160
|
+
UInt64 _virtPos;
|
2161
|
+
UInt64 _physPos;
|
2162
|
+
UInt32 _curRem;
|
2163
|
+
public:
|
2164
|
+
unsigned BlockBits;
|
2165
|
+
UInt64 Size;
|
2166
|
+
CMyComPtr<IInStream> Stream;
|
2167
|
+
CRecordVector<UInt32> Vector;
|
2168
|
+
|
2169
|
+
HRESULT SeekToPhys() { return Stream->Seek(_physPos, STREAM_SEEK_SET, NULL); }
|
2170
|
+
|
2171
|
+
HRESULT InitAndSeek()
|
2172
|
+
{
|
2173
|
+
_curRem = 0;
|
2174
|
+
_virtPos = 0;
|
2175
|
+
_physPos = 0;
|
2176
|
+
if (Vector.Size() > 0)
|
2177
|
+
{
|
2178
|
+
_physPos = (Vector[0] << BlockBits);
|
2179
|
+
return SeekToPhys();
|
2180
|
+
}
|
2181
|
+
return S_OK;
|
2182
|
+
}
|
2183
|
+
|
2184
|
+
MY_UNKNOWN_IMP2(ISequentialInStream, IInStream)
|
2185
|
+
|
2186
|
+
STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
|
2187
|
+
STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
|
2188
|
+
};
|
2189
|
+
|
2190
|
+
|
2191
|
+
STDMETHODIMP CClusterInStream2::Read(void *data, UInt32 size, UInt32 *processedSize)
|
2192
|
+
{
|
2193
|
+
if (processedSize)
|
2194
|
+
*processedSize = 0;
|
2195
|
+
if (_virtPos >= Size)
|
2196
|
+
return S_OK;
|
2197
|
+
{
|
2198
|
+
UInt64 rem = Size - _virtPos;
|
2199
|
+
if (size > rem)
|
2200
|
+
size = (UInt32)rem;
|
2201
|
+
}
|
2202
|
+
if (size == 0)
|
2203
|
+
return S_OK;
|
2204
|
+
|
2205
|
+
if (_curRem == 0)
|
2206
|
+
{
|
2207
|
+
const UInt32 blockSize = (UInt32)1 << BlockBits;
|
2208
|
+
const UInt32 virtBlock = (UInt32)(_virtPos >> BlockBits);
|
2209
|
+
const UInt32 offsetInBlock = (UInt32)_virtPos & (blockSize - 1);
|
2210
|
+
const UInt32 phyBlock = Vector[virtBlock];
|
2211
|
+
|
2212
|
+
if (phyBlock == 0)
|
2213
|
+
{
|
2214
|
+
UInt32 cur = blockSize - offsetInBlock;
|
2215
|
+
if (cur > size)
|
2216
|
+
cur = size;
|
2217
|
+
memset(data, 0, cur);
|
2218
|
+
_virtPos += cur;
|
2219
|
+
if (processedSize)
|
2220
|
+
*processedSize = cur;
|
2221
|
+
return S_OK;
|
2222
|
+
}
|
2223
|
+
|
2224
|
+
UInt64 newPos = ((UInt64)phyBlock << BlockBits) + offsetInBlock;
|
2225
|
+
if (newPos != _physPos)
|
2226
|
+
{
|
2227
|
+
_physPos = newPos;
|
2228
|
+
RINOK(SeekToPhys());
|
2229
|
+
}
|
2230
|
+
|
2231
|
+
_curRem = blockSize - offsetInBlock;
|
2232
|
+
|
2233
|
+
for (unsigned i = 1; i < 64 && (virtBlock + i) < (UInt32)Vector.Size() && phyBlock + i == Vector[virtBlock + i]; i++)
|
2234
|
+
_curRem += (UInt32)1 << BlockBits;
|
2235
|
+
}
|
2236
|
+
|
2237
|
+
if (size > _curRem)
|
2238
|
+
size = _curRem;
|
2239
|
+
HRESULT res = Stream->Read(data, size, &size);
|
2240
|
+
if (processedSize)
|
2241
|
+
*processedSize = size;
|
2242
|
+
_physPos += size;
|
2243
|
+
_virtPos += size;
|
2244
|
+
_curRem -= size;
|
2245
|
+
return res;
|
2246
|
+
}
|
2247
|
+
|
2248
|
+
STDMETHODIMP CClusterInStream2::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition)
|
2249
|
+
{
|
2250
|
+
switch (seekOrigin)
|
2251
|
+
{
|
2252
|
+
case STREAM_SEEK_SET: break;
|
2253
|
+
case STREAM_SEEK_CUR: offset += _virtPos; break;
|
2254
|
+
case STREAM_SEEK_END: offset += Size; break;
|
2255
|
+
default: return STG_E_INVALIDFUNCTION;
|
2256
|
+
}
|
2257
|
+
if (offset < 0)
|
2258
|
+
return HRESULT_WIN32_ERROR_NEGATIVE_SEEK;
|
2259
|
+
if (_virtPos != (UInt64)offset)
|
2260
|
+
_curRem = 0;
|
2261
|
+
_virtPos = offset;
|
2262
|
+
if (newPosition)
|
2263
|
+
*newPosition = offset;
|
2264
|
+
return S_OK;
|
2265
|
+
}
|
2266
|
+
|
2267
|
+
|
2268
|
+
class CExtInStream:
|
2269
|
+
public IInStream,
|
2270
|
+
public CMyUnknownImp
|
2271
|
+
{
|
2272
|
+
UInt64 _virtPos;
|
2273
|
+
UInt64 _phyPos;
|
2274
|
+
public:
|
2275
|
+
unsigned BlockBits;
|
2276
|
+
UInt64 Size;
|
2277
|
+
CMyComPtr<IInStream> Stream;
|
2278
|
+
CRecordVector<CExtent> Extents;
|
2279
|
+
|
2280
|
+
CExtInStream() {}
|
2281
|
+
|
2282
|
+
HRESULT StartSeek()
|
2283
|
+
{
|
2284
|
+
_virtPos = 0;
|
2285
|
+
_phyPos = 0;
|
2286
|
+
return Stream->Seek(_phyPos, STREAM_SEEK_SET, NULL);
|
2287
|
+
}
|
2288
|
+
|
2289
|
+
MY_UNKNOWN_IMP2(ISequentialInStream, IInStream)
|
2290
|
+
STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
|
2291
|
+
STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
|
2292
|
+
};
|
2293
|
+
|
2294
|
+
STDMETHODIMP CExtInStream::Read(void *data, UInt32 size, UInt32 *processedSize)
|
2295
|
+
{
|
2296
|
+
if (processedSize)
|
2297
|
+
*processedSize = 0;
|
2298
|
+
if (_virtPos >= Size)
|
2299
|
+
return S_OK;
|
2300
|
+
{
|
2301
|
+
UInt64 rem = Size - _virtPos;
|
2302
|
+
if (size > rem)
|
2303
|
+
size = (UInt32)rem;
|
2304
|
+
}
|
2305
|
+
if (size == 0)
|
2306
|
+
return S_OK;
|
2307
|
+
|
2308
|
+
UInt32 blockIndex = (UInt32)(_virtPos >> BlockBits);
|
2309
|
+
|
2310
|
+
unsigned left = 0, right = Extents.Size();
|
2311
|
+
for (;;)
|
2312
|
+
{
|
2313
|
+
unsigned mid = (left + right) / 2;
|
2314
|
+
if (mid == left)
|
2315
|
+
break;
|
2316
|
+
if (blockIndex < Extents[mid].VirtBlock)
|
2317
|
+
right = mid;
|
2318
|
+
else
|
2319
|
+
left = mid;
|
2320
|
+
}
|
2321
|
+
|
2322
|
+
{
|
2323
|
+
const CExtent &extent = Extents[left];
|
2324
|
+
if (blockIndex < extent.VirtBlock)
|
2325
|
+
return E_FAIL;
|
2326
|
+
UInt32 bo = blockIndex - extent.VirtBlock;
|
2327
|
+
if (bo >= extent.Len)
|
2328
|
+
return E_FAIL;
|
2329
|
+
|
2330
|
+
UInt32 offset = ((UInt32)_virtPos & (((UInt32)1 << BlockBits) - 1));
|
2331
|
+
UInt32 remBlocks = extent.Len - bo;
|
2332
|
+
UInt64 remBytes = ((UInt64)remBlocks << BlockBits);
|
2333
|
+
remBytes -= offset;
|
2334
|
+
|
2335
|
+
if (size > remBytes)
|
2336
|
+
size = (UInt32)remBytes;
|
2337
|
+
|
2338
|
+
if (!extent.IsInited)
|
2339
|
+
{
|
2340
|
+
memset(data, 0, size);
|
2341
|
+
_virtPos += size;
|
2342
|
+
if (processedSize)
|
2343
|
+
*processedSize = size;
|
2344
|
+
return S_OK;
|
2345
|
+
}
|
2346
|
+
|
2347
|
+
UInt64 phyBlock = extent.PhyStart + bo;
|
2348
|
+
UInt64 phy = (phyBlock << BlockBits) + offset;
|
2349
|
+
|
2350
|
+
if (phy != _phyPos)
|
2351
|
+
{
|
2352
|
+
RINOK(Stream->Seek(phy, STREAM_SEEK_SET, NULL));
|
2353
|
+
_phyPos = phy;
|
2354
|
+
}
|
2355
|
+
|
2356
|
+
UInt32 realProcessSize = 0;
|
2357
|
+
|
2358
|
+
HRESULT res = Stream->Read(data, size, &realProcessSize);
|
2359
|
+
|
2360
|
+
_phyPos += realProcessSize;
|
2361
|
+
_virtPos += realProcessSize;
|
2362
|
+
if (processedSize)
|
2363
|
+
*processedSize = realProcessSize;
|
2364
|
+
return res;
|
2365
|
+
}
|
2366
|
+
}
|
2367
|
+
|
2368
|
+
|
2369
|
+
STDMETHODIMP CExtInStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition)
|
2370
|
+
{
|
2371
|
+
switch (seekOrigin)
|
2372
|
+
{
|
2373
|
+
case STREAM_SEEK_SET: break;
|
2374
|
+
case STREAM_SEEK_CUR: offset += _virtPos; break;
|
2375
|
+
case STREAM_SEEK_END: offset += Size; break;
|
2376
|
+
default: return STG_E_INVALIDFUNCTION;
|
2377
|
+
}
|
2378
|
+
if (offset < 0)
|
2379
|
+
return HRESULT_WIN32_ERROR_NEGATIVE_SEEK;
|
2380
|
+
_virtPos = offset;
|
2381
|
+
if (newPosition)
|
2382
|
+
*newPosition = offset;
|
2383
|
+
return S_OK;
|
2384
|
+
}
|
2385
|
+
|
2386
|
+
|
2387
|
+
|
2388
|
+
HRESULT CHandler::FillFileBlocks2(UInt32 block, unsigned level, unsigned numBlocks, CRecordVector<UInt32> &blocks)
|
2389
|
+
{
|
2390
|
+
const size_t blockSize = (size_t)1 << _h.BlockBits;
|
2391
|
+
CByteBuffer &tempBuf = _tempBufs[level];
|
2392
|
+
tempBuf.Alloc(blockSize);
|
2393
|
+
|
2394
|
+
PRF2(printf("\n level = %d, block = %7d", level, (unsigned)block));
|
2395
|
+
|
2396
|
+
RINOK(SeekAndRead(_stream, block, tempBuf, blockSize));
|
2397
|
+
|
2398
|
+
const Byte *p = tempBuf;
|
2399
|
+
size_t num = (size_t)1 << (_h.BlockBits - 2);
|
2400
|
+
|
2401
|
+
for (size_t i = 0; i < num; i++)
|
2402
|
+
{
|
2403
|
+
if (blocks.Size() == numBlocks)
|
2404
|
+
break;
|
2405
|
+
UInt32 val = GetUi32(p + 4 * i);
|
2406
|
+
if (val >= _h.NumBlocks)
|
2407
|
+
return S_FALSE;
|
2408
|
+
|
2409
|
+
if (level != 0)
|
2410
|
+
{
|
2411
|
+
if (val == 0)
|
2412
|
+
{
|
2413
|
+
/*
|
2414
|
+
size_t num = (size_t)1 << ((_h.BlockBits - 2) * (level));
|
2415
|
+
PRF2(printf("\n num empty = %3d", (unsigned)num));
|
2416
|
+
for (size_t k = 0; k < num; k++)
|
2417
|
+
{
|
2418
|
+
blocks.Add(0);
|
2419
|
+
if (blocks.Size() == numBlocks)
|
2420
|
+
return S_OK;
|
2421
|
+
}
|
2422
|
+
continue;
|
2423
|
+
*/
|
2424
|
+
return S_FALSE;
|
2425
|
+
}
|
2426
|
+
|
2427
|
+
RINOK(FillFileBlocks2(val, level - 1, numBlocks, blocks));
|
2428
|
+
continue;
|
2429
|
+
}
|
2430
|
+
|
2431
|
+
PRF2(printf("\n i = %3d, blocks.Size() = %6d, block = %5d ", i, blocks.Size(), (unsigned)val));
|
2432
|
+
|
2433
|
+
PRF(printf("\n i = %3d, start = %5d ", (unsigned)i, (unsigned)val));
|
2434
|
+
|
2435
|
+
blocks.Add(val);
|
2436
|
+
}
|
2437
|
+
|
2438
|
+
return S_OK;
|
2439
|
+
}
|
2440
|
+
|
2441
|
+
|
2442
|
+
static const unsigned kNumDirectNodeBlocks = 12;
|
2443
|
+
|
2444
|
+
HRESULT CHandler::FillFileBlocks(const Byte *p, unsigned numBlocks, CRecordVector<UInt32> &blocks)
|
2445
|
+
{
|
2446
|
+
// ext2 supports zero blocks (blockIndex == 0).
|
2447
|
+
|
2448
|
+
blocks.ClearAndReserve(numBlocks);
|
2449
|
+
|
2450
|
+
for (unsigned i = 0; i < kNumDirectNodeBlocks; i++)
|
2451
|
+
{
|
2452
|
+
if (i == numBlocks)
|
2453
|
+
return S_OK;
|
2454
|
+
UInt32 val = GetUi32(p + 4 * i);
|
2455
|
+
if (val >= _h.NumBlocks)
|
2456
|
+
return S_FALSE;
|
2457
|
+
blocks.Add(val);
|
2458
|
+
}
|
2459
|
+
|
2460
|
+
for (unsigned level = 0; level < 3; level++)
|
2461
|
+
{
|
2462
|
+
if (blocks.Size() == numBlocks)
|
2463
|
+
break;
|
2464
|
+
UInt32 val = GetUi32(p + 4 * (kNumDirectNodeBlocks + level));
|
2465
|
+
if (val >= _h.NumBlocks)
|
2466
|
+
return S_FALSE;
|
2467
|
+
|
2468
|
+
if (val == 0)
|
2469
|
+
{
|
2470
|
+
/*
|
2471
|
+
size_t num = (size_t)1 << ((_h.BlockBits - 2) * (level + 1));
|
2472
|
+
for (size_t k = 0; k < num; k++)
|
2473
|
+
{
|
2474
|
+
blocks.Add(0);
|
2475
|
+
if (blocks.Size() == numBlocks)
|
2476
|
+
return S_OK;
|
2477
|
+
}
|
2478
|
+
continue;
|
2479
|
+
*/
|
2480
|
+
return S_FALSE;
|
2481
|
+
}
|
2482
|
+
|
2483
|
+
RINOK(FillFileBlocks2(val, level, numBlocks, blocks));
|
2484
|
+
}
|
2485
|
+
|
2486
|
+
return S_OK;
|
2487
|
+
}
|
2488
|
+
|
2489
|
+
|
2490
|
+
static void AddSkipExtents(CRecordVector<CExtent> &extents, UInt32 virtBlock, UInt32 numBlocks)
|
2491
|
+
{
|
2492
|
+
while (numBlocks != 0)
|
2493
|
+
{
|
2494
|
+
UInt32 len = numBlocks;
|
2495
|
+
const UInt32 kLenMax = (UInt32)1 << 15;
|
2496
|
+
if (len > kLenMax)
|
2497
|
+
len = kLenMax;
|
2498
|
+
CExtent e;
|
2499
|
+
e.VirtBlock = virtBlock;
|
2500
|
+
e.Len = (UInt16)len;
|
2501
|
+
e.IsInited = false;
|
2502
|
+
e.PhyStart = 0;
|
2503
|
+
extents.Add(e);
|
2504
|
+
virtBlock += len;
|
2505
|
+
numBlocks -= len;
|
2506
|
+
}
|
2507
|
+
}
|
2508
|
+
|
2509
|
+
static bool UpdateExtents(CRecordVector<CExtent> &extents, UInt32 block)
|
2510
|
+
{
|
2511
|
+
if (extents.IsEmpty())
|
2512
|
+
{
|
2513
|
+
if (block == 0)
|
2514
|
+
return true;
|
2515
|
+
AddSkipExtents(extents, 0, block);
|
2516
|
+
return true;
|
2517
|
+
}
|
2518
|
+
|
2519
|
+
const CExtent &prev = extents.Back();
|
2520
|
+
if (block < prev.VirtBlock)
|
2521
|
+
return false;
|
2522
|
+
UInt32 prevEnd = prev.GetVirtEnd();
|
2523
|
+
if (block == prevEnd)
|
2524
|
+
return true;
|
2525
|
+
AddSkipExtents(extents, prevEnd, block - prevEnd);
|
2526
|
+
return true;
|
2527
|
+
}
|
2528
|
+
|
2529
|
+
|
2530
|
+
HRESULT CHandler::FillExtents(const Byte *p, size_t size, CRecordVector<CExtent> &extents, int parentDepth)
|
2531
|
+
{
|
2532
|
+
CExtentTreeHeader eth;
|
2533
|
+
if (!eth.Parse(p))
|
2534
|
+
return S_FALSE;
|
2535
|
+
|
2536
|
+
if (parentDepth >= 0 && eth.Depth != parentDepth - 1) // (eth.Depth >= parentDepth)
|
2537
|
+
return S_FALSE;
|
2538
|
+
|
2539
|
+
if (12 + 12 * (size_t)eth.NumEntries > size)
|
2540
|
+
return S_FALSE;
|
2541
|
+
|
2542
|
+
if (eth.Depth >= kNumTreeLevelsMax)
|
2543
|
+
return S_FALSE;
|
2544
|
+
|
2545
|
+
if (eth.Depth == 0)
|
2546
|
+
{
|
2547
|
+
for (unsigned i = 0; i < eth.NumEntries; i++)
|
2548
|
+
{
|
2549
|
+
CExtent e;
|
2550
|
+
e.Parse(p + 12 + i * 12);
|
2551
|
+
if (e.PhyStart == 0
|
2552
|
+
|| e.PhyStart > _h.NumBlocks
|
2553
|
+
|| e.PhyStart + e.Len > _h.NumBlocks
|
2554
|
+
|| !e.IsLenOK())
|
2555
|
+
return S_FALSE;
|
2556
|
+
if (!UpdateExtents(extents, e.VirtBlock))
|
2557
|
+
return S_FALSE;
|
2558
|
+
extents.Add(e);
|
2559
|
+
}
|
2560
|
+
|
2561
|
+
return S_OK;
|
2562
|
+
}
|
2563
|
+
|
2564
|
+
const size_t blockSize = (size_t)1 << _h.BlockBits;
|
2565
|
+
CByteBuffer &tempBuf = _tempBufs[eth.Depth];
|
2566
|
+
tempBuf.Alloc(blockSize);
|
2567
|
+
|
2568
|
+
for (unsigned i = 0; i < eth.NumEntries; i++)
|
2569
|
+
{
|
2570
|
+
CExtentIndexNode e;
|
2571
|
+
e.Parse(p + 12 + i * 12);
|
2572
|
+
|
2573
|
+
if (e.PhyLeaf == 0 || e.PhyLeaf >= _h.NumBlocks)
|
2574
|
+
return S_FALSE;
|
2575
|
+
|
2576
|
+
if (!UpdateExtents(extents, e.VirtBlock))
|
2577
|
+
return S_FALSE;
|
2578
|
+
|
2579
|
+
RINOK(SeekAndRead(_stream, e.PhyLeaf, tempBuf, blockSize));
|
2580
|
+
RINOK(FillExtents(tempBuf, blockSize, extents, eth.Depth));
|
2581
|
+
}
|
2582
|
+
|
2583
|
+
return S_OK;
|
2584
|
+
}
|
2585
|
+
|
2586
|
+
|
2587
|
+
HRESULT CHandler::GetStream_Node(unsigned nodeIndex, ISequentialInStream **stream)
|
2588
|
+
{
|
2589
|
+
COM_TRY_BEGIN
|
2590
|
+
|
2591
|
+
*stream = NULL;
|
2592
|
+
|
2593
|
+
const CNode &node = _nodes[nodeIndex];
|
2594
|
+
|
2595
|
+
if (!node.IsFlags_EXTENTS())
|
2596
|
+
{
|
2597
|
+
// maybe sparse file can have (node.NumBlocks == 0) ?
|
2598
|
+
|
2599
|
+
/* The following code doesn't work correctly for some CentOS images,
|
2600
|
+
where there are nodes with inline data and (node.NumBlocks != 0).
|
2601
|
+
If you know better way to detect inline data, please notify 7-Zip developers. */
|
2602
|
+
|
2603
|
+
if (node.NumBlocks == 0 && node.FileSize < kNodeBlockFieldSize)
|
2604
|
+
{
|
2605
|
+
Create_BufInStream_WithNewBuffer(node.Block, (size_t)node.FileSize, stream);
|
2606
|
+
return S_OK;
|
2607
|
+
}
|
2608
|
+
}
|
2609
|
+
|
2610
|
+
if (node.FileSize >= ((UInt64)1 << 63))
|
2611
|
+
return S_FALSE;
|
2612
|
+
|
2613
|
+
CMyComPtr<IInStream> streamTemp;
|
2614
|
+
|
2615
|
+
UInt64 numBlocks64 = (node.FileSize + (UInt64)(((UInt32)1 << _h.BlockBits) - 1)) >> _h.BlockBits;
|
2616
|
+
|
2617
|
+
if (node.IsFlags_EXTENTS())
|
2618
|
+
{
|
2619
|
+
if ((UInt32)numBlocks64 != numBlocks64)
|
2620
|
+
return S_FALSE;
|
2621
|
+
|
2622
|
+
CExtInStream *streamSpec = new CExtInStream;
|
2623
|
+
streamTemp = streamSpec;
|
2624
|
+
|
2625
|
+
streamSpec->BlockBits = _h.BlockBits;
|
2626
|
+
streamSpec->Size = node.FileSize;
|
2627
|
+
streamSpec->Stream = _stream;
|
2628
|
+
|
2629
|
+
RINOK(FillExtents(node.Block, kNodeBlockFieldSize, streamSpec->Extents, -1));
|
2630
|
+
|
2631
|
+
UInt32 end = 0;
|
2632
|
+
if (!streamSpec->Extents.IsEmpty())
|
2633
|
+
end = streamSpec->Extents.Back().GetVirtEnd();
|
2634
|
+
if (end < numBlocks64)
|
2635
|
+
{
|
2636
|
+
AddSkipExtents(streamSpec->Extents, end, (UInt32)(numBlocks64 - end));
|
2637
|
+
// return S_FALSE;
|
2638
|
+
}
|
2639
|
+
|
2640
|
+
RINOK(streamSpec->StartSeek());
|
2641
|
+
}
|
2642
|
+
else
|
2643
|
+
{
|
2644
|
+
{
|
2645
|
+
UInt64 numBlocks2 = numBlocks64;
|
2646
|
+
|
2647
|
+
if (numBlocks64 > kNumDirectNodeBlocks)
|
2648
|
+
{
|
2649
|
+
UInt64 rem = numBlocks64 - kNumDirectNodeBlocks;
|
2650
|
+
const unsigned refBits = (_h.BlockBits - 2);
|
2651
|
+
const size_t numRefsInBlocks = (size_t)1 << refBits;
|
2652
|
+
numBlocks2++;
|
2653
|
+
if (rem > numRefsInBlocks)
|
2654
|
+
{
|
2655
|
+
numBlocks2++;
|
2656
|
+
const UInt64 numL2 = (rem - 1) >> refBits;
|
2657
|
+
numBlocks2 += numL2;
|
2658
|
+
if (numL2 > numRefsInBlocks)
|
2659
|
+
{
|
2660
|
+
numBlocks2++;
|
2661
|
+
numBlocks2 += (numL2 - 1) >> refBits;
|
2662
|
+
}
|
2663
|
+
}
|
2664
|
+
}
|
2665
|
+
|
2666
|
+
const unsigned specBits = (node.IsFlags_HUGE() ? 0 : _h.BlockBits - 9);
|
2667
|
+
const UInt32 specMask = ((UInt32)1 << specBits) - 1;;
|
2668
|
+
if ((node.NumBlocks & specMask) != 0)
|
2669
|
+
return S_FALSE;
|
2670
|
+
const UInt64 numBlocks64_from_header = node.NumBlocks >> specBits;
|
2671
|
+
if (numBlocks64_from_header < numBlocks2)
|
2672
|
+
{
|
2673
|
+
// why (numBlocks64_from_header > numBlocks2) in some cases?
|
2674
|
+
// return S_FALSE;
|
2675
|
+
}
|
2676
|
+
}
|
2677
|
+
|
2678
|
+
unsigned numBlocks = (unsigned)numBlocks64;
|
2679
|
+
if (numBlocks != numBlocks64)
|
2680
|
+
return S_FALSE;
|
2681
|
+
|
2682
|
+
CClusterInStream2 *streamSpec = new CClusterInStream2;
|
2683
|
+
streamTemp = streamSpec;
|
2684
|
+
|
2685
|
+
streamSpec->BlockBits = _h.BlockBits;
|
2686
|
+
streamSpec->Size = node.FileSize;
|
2687
|
+
streamSpec->Stream = _stream;
|
2688
|
+
|
2689
|
+
RINOK(FillFileBlocks(node.Block, numBlocks, streamSpec->Vector));
|
2690
|
+
streamSpec->InitAndSeek();
|
2691
|
+
}
|
2692
|
+
|
2693
|
+
*stream = streamTemp.Detach();
|
2694
|
+
|
2695
|
+
return S_OK;
|
2696
|
+
|
2697
|
+
COM_TRY_END
|
2698
|
+
}
|
2699
|
+
|
2700
|
+
|
2701
|
+
HRESULT CHandler::ExtractNode(unsigned nodeIndex, CByteBuffer &data)
|
2702
|
+
{
|
2703
|
+
data.Free();
|
2704
|
+
const CNode &node = _nodes[nodeIndex];
|
2705
|
+
size_t size = (size_t)node.FileSize;
|
2706
|
+
if (size != node.FileSize)
|
2707
|
+
return S_FALSE;
|
2708
|
+
CMyComPtr<ISequentialInStream> inSeqStream;
|
2709
|
+
RINOK(GetStream_Node(nodeIndex, &inSeqStream));
|
2710
|
+
if (!inSeqStream)
|
2711
|
+
return S_FALSE;
|
2712
|
+
data.Alloc(size);
|
2713
|
+
_totalRead += size;
|
2714
|
+
return ReadStream_FALSE(inSeqStream, data, size);
|
2715
|
+
}
|
2716
|
+
|
2717
|
+
|
2718
|
+
STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
|
2719
|
+
Int32 testMode, IArchiveExtractCallback *extractCallback)
|
2720
|
+
{
|
2721
|
+
COM_TRY_BEGIN
|
2722
|
+
bool allFilesMode = (numItems == (UInt32)(Int32)-1);
|
2723
|
+
if (allFilesMode)
|
2724
|
+
numItems = _items.Size() + _auxItems.Size();
|
2725
|
+
if (numItems == 0)
|
2726
|
+
return S_OK;
|
2727
|
+
|
2728
|
+
UInt64 totalSize = 0;
|
2729
|
+
UInt32 i;
|
2730
|
+
|
2731
|
+
for (i = 0; i < numItems; i++)
|
2732
|
+
{
|
2733
|
+
UInt32 index = allFilesMode ? i : indices[i];
|
2734
|
+
if (index >= _items.Size())
|
2735
|
+
continue;
|
2736
|
+
const CItem &item = _items[index];
|
2737
|
+
const CNode &node = _nodes[_refs[item.Node]];
|
2738
|
+
if (!node.IsDir())
|
2739
|
+
totalSize += node.FileSize;
|
2740
|
+
}
|
2741
|
+
|
2742
|
+
extractCallback->SetTotal(totalSize);
|
2743
|
+
|
2744
|
+
UInt64 totalPackSize;
|
2745
|
+
totalSize = totalPackSize = 0;
|
2746
|
+
|
2747
|
+
NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder();
|
2748
|
+
CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;
|
2749
|
+
|
2750
|
+
CLocalProgress *lps = new CLocalProgress;
|
2751
|
+
CMyComPtr<ICompressProgressInfo> progress = lps;
|
2752
|
+
lps->Init(extractCallback, false);
|
2753
|
+
|
2754
|
+
for (i = 0;; i++)
|
2755
|
+
{
|
2756
|
+
lps->InSize = totalPackSize;
|
2757
|
+
lps->OutSize = totalSize;
|
2758
|
+
RINOK(lps->SetCur());
|
2759
|
+
|
2760
|
+
if (i == numItems)
|
2761
|
+
break;
|
2762
|
+
|
2763
|
+
CMyComPtr<ISequentialOutStream> outStream;
|
2764
|
+
Int32 askMode = testMode ?
|
2765
|
+
NExtract::NAskMode::kTest :
|
2766
|
+
NExtract::NAskMode::kExtract;
|
2767
|
+
|
2768
|
+
UInt32 index = allFilesMode ? i : indices[i];
|
2769
|
+
|
2770
|
+
RINOK(extractCallback->GetStream(index, &outStream, askMode));
|
2771
|
+
|
2772
|
+
if (index >= _items.Size())
|
2773
|
+
{
|
2774
|
+
RINOK(extractCallback->PrepareOperation(askMode));
|
2775
|
+
RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kOK));
|
2776
|
+
continue;
|
2777
|
+
}
|
2778
|
+
|
2779
|
+
const CItem &item = _items[index];
|
2780
|
+
const CNode &node = _nodes[_refs[item.Node]];
|
2781
|
+
|
2782
|
+
if (node.IsDir())
|
2783
|
+
{
|
2784
|
+
RINOK(extractCallback->PrepareOperation(askMode));
|
2785
|
+
RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kOK));
|
2786
|
+
continue;
|
2787
|
+
}
|
2788
|
+
|
2789
|
+
UInt64 unpackSize = node.FileSize;
|
2790
|
+
totalSize += unpackSize;
|
2791
|
+
UInt64 packSize;
|
2792
|
+
if (GetPackSize(index, packSize))
|
2793
|
+
totalPackSize += packSize;
|
2794
|
+
|
2795
|
+
if (!testMode && !outStream)
|
2796
|
+
continue;
|
2797
|
+
RINOK(extractCallback->PrepareOperation(askMode));
|
2798
|
+
|
2799
|
+
int res = NExtract::NOperationResult::kDataError;
|
2800
|
+
{
|
2801
|
+
CMyComPtr<ISequentialInStream> inSeqStream;
|
2802
|
+
HRESULT hres = GetStream(index, &inSeqStream);
|
2803
|
+
if (hres == S_FALSE || !inSeqStream)
|
2804
|
+
{
|
2805
|
+
if (hres == E_OUTOFMEMORY)
|
2806
|
+
return hres;
|
2807
|
+
res = NExtract::NOperationResult::kUnsupportedMethod;
|
2808
|
+
}
|
2809
|
+
else
|
2810
|
+
{
|
2811
|
+
RINOK(hres);
|
2812
|
+
{
|
2813
|
+
hres = copyCoder->Code(inSeqStream, outStream, NULL, NULL, progress);
|
2814
|
+
if (hres == S_OK)
|
2815
|
+
{
|
2816
|
+
if (copyCoderSpec->TotalSize == unpackSize)
|
2817
|
+
res = NExtract::NOperationResult::kOK;
|
2818
|
+
}
|
2819
|
+
else if (hres == E_NOTIMPL)
|
2820
|
+
{
|
2821
|
+
res = NExtract::NOperationResult::kUnsupportedMethod;
|
2822
|
+
}
|
2823
|
+
else if (hres != S_FALSE)
|
2824
|
+
{
|
2825
|
+
RINOK(hres);
|
2826
|
+
}
|
2827
|
+
}
|
2828
|
+
}
|
2829
|
+
}
|
2830
|
+
RINOK(extractCallback->SetOperationResult(res));
|
2831
|
+
}
|
2832
|
+
|
2833
|
+
return S_OK;
|
2834
|
+
COM_TRY_END
|
2835
|
+
}
|
2836
|
+
|
2837
|
+
|
2838
|
+
STDMETHODIMP CHandler::GetStream(UInt32 index, ISequentialInStream **stream)
|
2839
|
+
{
|
2840
|
+
*stream = NULL;
|
2841
|
+
if (index >= _items.Size())
|
2842
|
+
return S_FALSE;
|
2843
|
+
return GetStream_Node(_refs[_items[index].Node], stream);
|
2844
|
+
}
|
2845
|
+
|
2846
|
+
|
2847
|
+
API_FUNC_static_IsArc IsArc_Ext(const Byte *p, size_t size)
|
2848
|
+
{
|
2849
|
+
if (size < kHeaderSize)
|
2850
|
+
return k_IsArc_Res_NEED_MORE;
|
2851
|
+
CHeader h;
|
2852
|
+
if (!h.Parse(p + kHeaderDataOffset))
|
2853
|
+
return k_IsArc_Res_NO;
|
2854
|
+
return k_IsArc_Res_YES;
|
2855
|
+
}
|
2856
|
+
}
|
2857
|
+
|
2858
|
+
static const Byte k_Signature[] = { 0x53, 0xEF };
|
2859
|
+
|
2860
|
+
REGISTER_ARC_I(
|
2861
|
+
"Ext", "ext ext2 ext3 ext4 img", 0, 0xC7,
|
2862
|
+
k_Signature,
|
2863
|
+
0x438,
|
2864
|
+
0,
|
2865
|
+
IsArc_Ext)
|
2866
|
+
|
2867
|
+
}}
|