seven-zip 1.4.2 → 1.7.0.rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (887) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +49 -0
  3. data/.github/workflows/release.yml +21 -0
  4. data/README.md +13 -2
  5. data/Rakefile +2 -0
  6. data/ext/p7zip/C/7zBuf.h +4 -8
  7. data/ext/p7zip/C/7zBuf2.c +9 -3
  8. data/ext/p7zip/C/7zCrc.c +84 -32
  9. data/ext/p7zip/C/7zCrc.h +2 -2
  10. data/ext/p7zip/C/7zCrcOpt.c +89 -8
  11. data/ext/p7zip/C/7zStream.c +4 -2
  12. data/ext/p7zip/C/{Types.h → 7zTypes.h} +8 -6
  13. data/ext/p7zip/C/7zVersion.h +21 -6
  14. data/ext/p7zip/C/Aes.c +28 -15
  15. data/ext/p7zip/C/Aes.h +2 -2
  16. data/ext/p7zip/C/Alloc.c +60 -12
  17. data/ext/p7zip/C/Alloc.h +6 -7
  18. data/ext/p7zip/C/Bcj2.c +256 -0
  19. data/ext/p7zip/C/Bcj2.h +146 -0
  20. data/ext/p7zip/C/Bcj2Enc.c +312 -0
  21. data/ext/p7zip/C/Blake2.h +48 -0
  22. data/ext/p7zip/C/Blake2s.c +244 -0
  23. data/ext/p7zip/C/Bra.c +2 -0
  24. data/ext/p7zip/C/Bra.h +4 -8
  25. data/ext/p7zip/C/Bra86.c +48 -51
  26. data/ext/p7zip/C/BraIA64.c +3 -1
  27. data/ext/p7zip/C/BwtSort.c +3 -4
  28. data/ext/p7zip/C/BwtSort.h +4 -8
  29. data/ext/p7zip/C/Compiler.h +32 -0
  30. data/ext/p7zip/C/CpuArch.c +50 -7
  31. data/ext/p7zip/C/CpuArch.h +112 -41
  32. data/ext/p7zip/C/Delta.c +2 -0
  33. data/ext/p7zip/C/Delta.h +4 -8
  34. data/ext/p7zip/C/HuffEnc.c +8 -6
  35. data/ext/p7zip/C/HuffEnc.h +4 -8
  36. data/ext/p7zip/C/LzFind.c +391 -108
  37. data/ext/p7zip/C/LzFind.h +20 -18
  38. data/ext/p7zip/C/LzFindMt.c +100 -90
  39. data/ext/p7zip/C/LzFindMt.h +4 -8
  40. data/ext/p7zip/C/LzHash.h +23 -20
  41. data/ext/p7zip/C/Lzma2Dec.c +48 -26
  42. data/ext/p7zip/C/Lzma2Dec.h +4 -8
  43. data/ext/p7zip/C/Lzma2Enc.c +58 -15
  44. data/ext/p7zip/C/Lzma2Enc.h +3 -7
  45. data/ext/p7zip/C/{LzmaUtil/Lzma86Enc.h → Lzma86.h} +47 -14
  46. data/ext/p7zip/C/{LzmaUtil/Lzma86Dec.c → Lzma86Dec.c} +6 -13
  47. data/ext/p7zip/C/{LzmaUtil/Lzma86Enc.c → Lzma86Enc.c} +8 -15
  48. data/ext/p7zip/C/LzmaDec.c +180 -79
  49. data/ext/p7zip/C/LzmaDec.h +4 -8
  50. data/ext/p7zip/C/LzmaEnc.c +230 -147
  51. data/ext/p7zip/C/LzmaEnc.h +6 -8
  52. data/ext/p7zip/C/MtCoder.c +3 -3
  53. data/ext/p7zip/C/Ppmd.h +5 -5
  54. data/ext/p7zip/C/Ppmd7.c +9 -7
  55. data/ext/p7zip/C/Ppmd7.h +3 -3
  56. data/ext/p7zip/C/Ppmd7Dec.c +2 -0
  57. data/ext/p7zip/C/Ppmd7Enc.c +4 -2
  58. data/ext/p7zip/C/Ppmd8.c +34 -31
  59. data/ext/p7zip/C/Ppmd8.h +5 -1
  60. data/ext/p7zip/C/Ppmd8Dec.c +2 -0
  61. data/ext/p7zip/C/Ppmd8Enc.c +2 -0
  62. data/ext/p7zip/C/Precomp.h +10 -0
  63. data/ext/p7zip/C/RotateDefs.h +11 -1
  64. data/ext/p7zip/C/Sha1.c +340 -0
  65. data/ext/p7zip/C/Sha1.h +38 -0
  66. data/ext/p7zip/C/Sha256.c +107 -63
  67. data/ext/p7zip/C/Sha256.h +2 -2
  68. data/ext/p7zip/C/Sort.c +59 -11
  69. data/ext/p7zip/C/Sort.h +8 -10
  70. data/ext/p7zip/C/Threads.h +1 -1
  71. data/ext/p7zip/C/Xz.c +7 -5
  72. data/ext/p7zip/C/Xz.h +40 -17
  73. data/ext/p7zip/C/XzCrc64.c +69 -16
  74. data/ext/p7zip/C/XzCrc64.h +2 -2
  75. data/ext/p7zip/C/XzCrc64Opt.c +69 -0
  76. data/ext/p7zip/C/XzDec.c +93 -55
  77. data/ext/p7zip/C/XzEnc.c +206 -165
  78. data/ext/p7zip/C/XzEnc.h +23 -9
  79. data/ext/p7zip/C/XzIn.c +50 -43
  80. data/ext/p7zip/CPP/7zip/Archive/7z/7zCompressionMode.h +37 -13
  81. data/ext/p7zip/CPP/7zip/Archive/7z/7zDecode.cpp +392 -181
  82. data/ext/p7zip/CPP/7zip/Archive/7z/7zDecode.h +29 -29
  83. data/ext/p7zip/CPP/7zip/Archive/7z/7zEncode.cpp +424 -212
  84. data/ext/p7zip/CPP/7zip/Archive/7z/7zEncode.h +53 -16
  85. data/ext/p7zip/CPP/7zip/Archive/7z/7zExtract.cpp +312 -174
  86. data/ext/p7zip/CPP/7zip/Archive/7z/7zFolderInStream.cpp +74 -61
  87. data/ext/p7zip/CPP/7zip/Archive/7z/7zFolderInStream.h +22 -19
  88. data/ext/p7zip/CPP/7zip/Archive/7z/7zHandler.cpp +505 -232
  89. data/ext/p7zip/CPP/7zip/Archive/7z/7zHandler.h +70 -16
  90. data/ext/p7zip/CPP/7zip/Archive/7z/7zHandlerOut.cpp +602 -172
  91. data/ext/p7zip/CPP/7zip/Archive/7z/7zHeader.cpp +5 -0
  92. data/ext/p7zip/CPP/7zip/Archive/7z/7zHeader.h +54 -3
  93. data/ext/p7zip/CPP/7zip/Archive/7z/7zIn.cpp +981 -616
  94. data/ext/p7zip/CPP/7zip/Archive/7z/7zIn.h +275 -89
  95. data/ext/p7zip/CPP/7zip/Archive/7z/7zItem.h +77 -162
  96. data/ext/p7zip/CPP/7zip/Archive/7z/7zOut.cpp +288 -238
  97. data/ext/p7zip/CPP/7zip/Archive/7z/7zOut.h +189 -20
  98. data/ext/p7zip/CPP/7zip/Archive/7z/7zProperties.cpp +59 -49
  99. data/ext/p7zip/CPP/7zip/Archive/7z/7zRegister.cpp +12 -9
  100. data/ext/p7zip/CPP/7zip/Archive/7z/7zSpecStream.cpp +4 -6
  101. data/ext/p7zip/CPP/7zip/Archive/7z/7zSpecStream.h +5 -5
  102. data/ext/p7zip/CPP/7zip/Archive/7z/7zUpdate.cpp +1743 -447
  103. data/ext/p7zip/CPP/7zip/Archive/7z/7zUpdate.h +61 -10
  104. data/ext/p7zip/CPP/7zip/Archive/ApmHandler.cpp +84 -120
  105. data/ext/p7zip/CPP/7zip/Archive/ArHandler.cpp +854 -0
  106. data/ext/p7zip/CPP/7zip/Archive/ArchiveExports.cpp +48 -32
  107. data/ext/p7zip/CPP/7zip/Archive/ArjHandler.cpp +519 -340
  108. data/ext/p7zip/CPP/7zip/Archive/Bz2Handler.cpp +223 -203
  109. data/ext/p7zip/CPP/7zip/Archive/Cab/CabBlockInStream.cpp +50 -139
  110. data/ext/p7zip/CPP/7zip/Archive/Cab/CabBlockInStream.h +17 -18
  111. data/ext/p7zip/CPP/7zip/Archive/Cab/CabHandler.cpp +566 -234
  112. data/ext/p7zip/CPP/7zip/Archive/Cab/CabHandler.h +10 -1
  113. data/ext/p7zip/CPP/7zip/Archive/Cab/CabHeader.cpp +2 -2
  114. data/ext/p7zip/CPP/7zip/Archive/Cab/CabHeader.h +12 -15
  115. data/ext/p7zip/CPP/7zip/Archive/Cab/CabIn.cpp +341 -122
  116. data/ext/p7zip/CPP/7zip/Archive/Cab/CabIn.h +81 -66
  117. data/ext/p7zip/CPP/7zip/Archive/Cab/CabItem.h +17 -14
  118. data/ext/p7zip/CPP/7zip/Archive/Cab/CabRegister.cpp +10 -4
  119. data/ext/p7zip/CPP/7zip/Archive/Chm/ChmHandler.cpp +190 -83
  120. data/ext/p7zip/CPP/7zip/Archive/Chm/ChmHandler.h +7 -1
  121. data/ext/p7zip/CPP/7zip/Archive/Chm/ChmIn.cpp +292 -174
  122. data/ext/p7zip/CPP/7zip/Archive/Chm/ChmIn.h +73 -47
  123. data/ext/p7zip/CPP/7zip/Archive/ComHandler.cpp +886 -0
  124. data/ext/p7zip/CPP/7zip/Archive/Common/CoderMixer2.cpp +994 -71
  125. data/ext/p7zip/CPP/7zip/Archive/Common/CoderMixer2.h +364 -101
  126. data/ext/p7zip/CPP/7zip/Archive/Common/DummyOutStream.cpp +7 -12
  127. data/ext/p7zip/CPP/7zip/Archive/Common/DummyOutStream.h +4 -3
  128. data/ext/p7zip/CPP/7zip/Archive/Common/FindSignature.cpp +6 -6
  129. data/ext/p7zip/CPP/7zip/Archive/Common/FindSignature.h +2 -2
  130. data/ext/p7zip/CPP/7zip/Archive/Common/HandlerOut.cpp +77 -543
  131. data/ext/p7zip/CPP/7zip/Archive/Common/HandlerOut.h +31 -51
  132. data/ext/p7zip/CPP/7zip/Archive/Common/InStreamWithCRC.cpp +18 -14
  133. data/ext/p7zip/CPP/7zip/Archive/Common/ItemNameUtils.cpp +34 -7
  134. data/ext/p7zip/CPP/7zip/Archive/Common/ItemNameUtils.h +5 -2
  135. data/ext/p7zip/CPP/7zip/Archive/Common/MultiStream.cpp +25 -24
  136. data/ext/p7zip/CPP/7zip/Archive/Common/MultiStream.h +8 -3
  137. data/ext/p7zip/CPP/7zip/Archive/Common/OutStreamWithCRC.h +1 -0
  138. data/ext/p7zip/CPP/7zip/Archive/Common/OutStreamWithSha1.cpp +2 -2
  139. data/ext/p7zip/CPP/7zip/Archive/Common/OutStreamWithSha1.h +5 -5
  140. data/ext/p7zip/CPP/7zip/Archive/Common/ParseProperties.cpp +0 -174
  141. data/ext/p7zip/CPP/7zip/Archive/Common/ParseProperties.h +2 -14
  142. data/ext/p7zip/CPP/7zip/Archive/CpioHandler.cpp +506 -335
  143. data/ext/p7zip/CPP/7zip/Archive/CramfsHandler.cpp +227 -84
  144. data/ext/p7zip/CPP/7zip/Archive/DeflateProps.cpp +0 -115
  145. data/ext/p7zip/CPP/7zip/Archive/DeflateProps.h +0 -29
  146. data/ext/p7zip/CPP/7zip/Archive/DllExports2.cpp +63 -17
  147. data/ext/p7zip/CPP/7zip/Archive/DmgHandler.cpp +1007 -339
  148. data/ext/p7zip/CPP/7zip/Archive/ElfHandler.cpp +618 -177
  149. data/ext/p7zip/CPP/7zip/Archive/ExtHandler.cpp +2867 -0
  150. data/ext/p7zip/CPP/7zip/Archive/FatHandler.cpp +136 -76
  151. data/ext/p7zip/CPP/7zip/Archive/FlvHandler.cpp +132 -150
  152. data/ext/p7zip/CPP/7zip/Archive/GptHandler.cpp +405 -0
  153. data/ext/p7zip/CPP/7zip/Archive/GzHandler.cpp +560 -214
  154. data/ext/p7zip/CPP/7zip/Archive/HandlerCont.cpp +288 -0
  155. data/ext/p7zip/CPP/7zip/Archive/HandlerCont.h +116 -0
  156. data/ext/p7zip/CPP/7zip/Archive/HfsHandler.cpp +1880 -0
  157. data/ext/p7zip/CPP/7zip/Archive/IArchive.h +415 -51
  158. data/ext/p7zip/CPP/7zip/Archive/IhexHandler.cpp +497 -0
  159. data/ext/p7zip/CPP/7zip/Archive/Iso/IsoHandler.cpp +158 -71
  160. data/ext/p7zip/CPP/7zip/Archive/Iso/IsoHandler.h +2 -1
  161. data/ext/p7zip/CPP/7zip/Archive/Iso/IsoHeader.cpp +0 -9
  162. data/ext/p7zip/CPP/7zip/Archive/Iso/IsoHeader.h +8 -5
  163. data/ext/p7zip/CPP/7zip/Archive/Iso/IsoIn.cpp +311 -91
  164. data/ext/p7zip/CPP/7zip/Archive/Iso/IsoIn.h +101 -83
  165. data/ext/p7zip/CPP/7zip/Archive/Iso/IsoItem.h +48 -39
  166. data/ext/p7zip/CPP/7zip/Archive/Iso/IsoRegister.cpp +12 -4
  167. data/ext/p7zip/CPP/7zip/Archive/LzhHandler.cpp +127 -114
  168. data/ext/p7zip/CPP/7zip/Archive/LzmaHandler.cpp +264 -121
  169. data/ext/p7zip/CPP/7zip/Archive/MachoHandler.cpp +402 -242
  170. data/ext/p7zip/CPP/7zip/Archive/MbrHandler.cpp +56 -114
  171. data/ext/p7zip/CPP/7zip/Archive/MslzHandler.cpp +230 -90
  172. data/ext/p7zip/CPP/7zip/Archive/MubHandler.cpp +129 -153
  173. data/ext/p7zip/CPP/7zip/Archive/Nsis/NsisDecode.cpp +179 -58
  174. data/ext/p7zip/CPP/7zip/Archive/Nsis/NsisDecode.h +36 -7
  175. data/ext/p7zip/CPP/7zip/Archive/Nsis/NsisHandler.cpp +407 -237
  176. data/ext/p7zip/CPP/7zip/Archive/Nsis/NsisHandler.h +9 -16
  177. data/ext/p7zip/CPP/7zip/Archive/Nsis/NsisIn.cpp +5535 -1098
  178. data/ext/p7zip/CPP/7zip/Archive/Nsis/NsisIn.h +345 -81
  179. data/ext/p7zip/CPP/7zip/Archive/Nsis/NsisRegister.cpp +11 -4
  180. data/ext/p7zip/CPP/7zip/Archive/NtfsHandler.cpp +1424 -434
  181. data/ext/p7zip/CPP/7zip/Archive/PeHandler.cpp +1831 -521
  182. data/ext/p7zip/CPP/7zip/Archive/PpmdHandler.cpp +50 -35
  183. data/ext/p7zip/CPP/7zip/Archive/QcowHandler.cpp +615 -0
  184. data/ext/p7zip/CPP/7zip/Archive/Rar/Rar5Handler.cpp +2746 -0
  185. data/ext/p7zip/CPP/7zip/Archive/Rar/Rar5Handler.h +411 -0
  186. data/ext/p7zip/CPP/7zip/Archive/Rar/RarHandler.cpp +1241 -355
  187. data/ext/p7zip/CPP/7zip/Archive/Rar/RarHandler.h +70 -20
  188. data/ext/p7zip/CPP/7zip/Archive/Rar/RarHeader.h +38 -34
  189. data/ext/p7zip/CPP/7zip/Archive/Rar/RarItem.h +34 -16
  190. data/ext/p7zip/CPP/7zip/Archive/Rar/RarVol.h +129 -0
  191. data/ext/p7zip/CPP/7zip/Archive/RpmHandler.cpp +641 -194
  192. data/ext/p7zip/CPP/7zip/Archive/SplitHandler.cpp +174 -181
  193. data/ext/p7zip/CPP/7zip/Archive/SquashfsHandler.cpp +237 -174
  194. data/ext/p7zip/CPP/7zip/Archive/SwfHandler.cpp +471 -192
  195. data/ext/p7zip/CPP/7zip/Archive/Tar/TarHandler.cpp +350 -59
  196. data/ext/p7zip/CPP/7zip/Archive/Tar/TarHandler.h +24 -7
  197. data/ext/p7zip/CPP/7zip/Archive/Tar/TarHandlerOut.cpp +79 -27
  198. data/ext/p7zip/CPP/7zip/Archive/Tar/TarHeader.cpp +5 -7
  199. data/ext/p7zip/CPP/7zip/Archive/Tar/TarHeader.h +20 -44
  200. data/ext/p7zip/CPP/7zip/Archive/Tar/TarIn.cpp +279 -64
  201. data/ext/p7zip/CPP/7zip/Archive/Tar/TarIn.h +10 -1
  202. data/ext/p7zip/CPP/7zip/Archive/Tar/TarItem.h +34 -8
  203. data/ext/p7zip/CPP/7zip/Archive/Tar/TarOut.cpp +145 -87
  204. data/ext/p7zip/CPP/7zip/Archive/Tar/TarOut.h +13 -5
  205. data/ext/p7zip/CPP/7zip/Archive/Tar/TarRegister.cpp +14 -9
  206. data/ext/p7zip/CPP/7zip/Archive/Tar/TarUpdate.cpp +154 -27
  207. data/ext/p7zip/CPP/7zip/Archive/Tar/TarUpdate.h +10 -6
  208. data/ext/p7zip/CPP/7zip/Archive/Udf/UdfHandler.cpp +53 -128
  209. data/ext/p7zip/CPP/7zip/Archive/Udf/UdfHandler.h +6 -5
  210. data/ext/p7zip/CPP/7zip/Archive/Udf/UdfIn.cpp +384 -119
  211. data/ext/p7zip/CPP/7zip/Archive/Udf/UdfIn.h +40 -21
  212. data/ext/p7zip/CPP/7zip/Archive/UefiHandler.cpp +1618 -0
  213. data/ext/p7zip/CPP/7zip/Archive/VdiHandler.cpp +362 -0
  214. data/ext/p7zip/CPP/7zip/Archive/VhdHandler.cpp +438 -247
  215. data/ext/p7zip/CPP/7zip/Archive/VmdkHandler.cpp +1518 -0
  216. data/ext/p7zip/CPP/7zip/Archive/Wim/WimHandler.cpp +837 -249
  217. data/ext/p7zip/CPP/7zip/Archive/Wim/WimHandler.h +73 -47
  218. data/ext/p7zip/CPP/7zip/Archive/Wim/WimHandlerOut.cpp +1614 -351
  219. data/ext/p7zip/CPP/7zip/Archive/Wim/WimIn.cpp +1519 -513
  220. data/ext/p7zip/CPP/7zip/Archive/Wim/WimIn.h +498 -139
  221. data/ext/p7zip/CPP/7zip/Archive/Wim/WimRegister.cpp +13 -9
  222. data/ext/p7zip/CPP/7zip/Archive/XarHandler.cpp +272 -128
  223. data/ext/p7zip/CPP/7zip/Archive/XzHandler.cpp +502 -253
  224. data/ext/p7zip/CPP/7zip/Archive/XzHandler.h +65 -0
  225. data/ext/p7zip/CPP/7zip/Archive/ZHandler.cpp +114 -39
  226. data/ext/p7zip/CPP/7zip/Archive/Zip/ZipAddCommon.cpp +118 -134
  227. data/ext/p7zip/CPP/7zip/Archive/Zip/ZipAddCommon.h +6 -0
  228. data/ext/p7zip/CPP/7zip/Archive/Zip/ZipCompressionMode.h +40 -20
  229. data/ext/p7zip/CPP/7zip/Archive/Zip/ZipHandler.cpp +541 -274
  230. data/ext/p7zip/CPP/7zip/Archive/Zip/ZipHandler.h +13 -40
  231. data/ext/p7zip/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp +165 -254
  232. data/ext/p7zip/CPP/7zip/Archive/Zip/ZipHeader.h +70 -178
  233. data/ext/p7zip/CPP/7zip/Archive/Zip/ZipIn.cpp +1934 -550
  234. data/ext/p7zip/CPP/7zip/Archive/Zip/ZipIn.h +294 -63
  235. data/ext/p7zip/CPP/7zip/Archive/Zip/ZipItem.cpp +160 -86
  236. data/ext/p7zip/CPP/7zip/Archive/Zip/ZipItem.h +139 -110
  237. data/ext/p7zip/CPP/7zip/Archive/Zip/ZipOut.cpp +177 -154
  238. data/ext/p7zip/CPP/7zip/Archive/Zip/ZipOut.h +50 -18
  239. data/ext/p7zip/CPP/7zip/Archive/Zip/ZipRegister.cpp +18 -9
  240. data/ext/p7zip/CPP/7zip/Archive/Zip/ZipUpdate.cpp +367 -201
  241. data/ext/p7zip/CPP/7zip/Archive/Zip/ZipUpdate.h +11 -10
  242. data/ext/p7zip/CPP/7zip/Bundles/Format7zFree/makefile +2 -319
  243. data/ext/p7zip/CPP/7zip/Bundles/Format7zFree/makefile.depend +0 -4962
  244. data/ext/p7zip/CPP/7zip/Bundles/Format7zFree/makefile.list +1004 -259
  245. data/ext/p7zip/CPP/7zip/Common/CWrappers.cpp +26 -22
  246. data/ext/p7zip/CPP/7zip/Common/CWrappers.h +19 -14
  247. data/ext/p7zip/CPP/7zip/Common/CreateCoder.cpp +298 -130
  248. data/ext/p7zip/CPP/7zip/Common/CreateCoder.h +118 -34
  249. data/ext/p7zip/CPP/7zip/Common/FilePathAutoRename.cpp +24 -28
  250. data/ext/p7zip/CPP/7zip/Common/FilePathAutoRename.h +5 -5
  251. data/ext/p7zip/CPP/7zip/Common/FileStreams.cpp +268 -65
  252. data/ext/p7zip/CPP/7zip/Common/FileStreams.h +70 -33
  253. data/ext/p7zip/CPP/7zip/Common/FilterCoder.cpp +302 -131
  254. data/ext/p7zip/CPP/7zip/Common/FilterCoder.h +141 -43
  255. data/ext/p7zip/CPP/7zip/Common/InBuffer.cpp +87 -35
  256. data/ext/p7zip/CPP/7zip/Common/InBuffer.h +54 -45
  257. data/ext/p7zip/CPP/7zip/Common/InOutTempBuffer.cpp +22 -17
  258. data/ext/p7zip/CPP/7zip/Common/InOutTempBuffer.h +5 -5
  259. data/ext/p7zip/CPP/7zip/Common/LimitedStreams.cpp +256 -43
  260. data/ext/p7zip/CPP/7zip/Common/LimitedStreams.h +135 -8
  261. data/ext/p7zip/CPP/7zip/Common/MemBlocks.cpp +5 -5
  262. data/ext/p7zip/CPP/7zip/Common/MemBlocks.h +3 -3
  263. data/ext/p7zip/CPP/7zip/Common/MethodId.cpp +0 -24
  264. data/ext/p7zip/CPP/7zip/Common/MethodId.h +1 -1
  265. data/ext/p7zip/CPP/7zip/Common/MethodProps.cpp +430 -71
  266. data/ext/p7zip/CPP/7zip/Common/MethodProps.h +170 -17
  267. data/ext/p7zip/CPP/7zip/Common/OffsetStream.cpp +8 -4
  268. data/ext/p7zip/CPP/7zip/Common/OffsetStream.h +4 -3
  269. data/ext/p7zip/CPP/7zip/Common/OutBuffer.cpp +26 -31
  270. data/ext/p7zip/CPP/7zip/Common/OutBuffer.h +17 -18
  271. data/ext/p7zip/CPP/7zip/Common/OutMemStream.cpp +5 -5
  272. data/ext/p7zip/CPP/7zip/Common/OutMemStream.h +5 -4
  273. data/ext/p7zip/CPP/7zip/Common/ProgressUtils.cpp +22 -13
  274. data/ext/p7zip/CPP/7zip/Common/ProgressUtils.h +4 -3
  275. data/ext/p7zip/CPP/7zip/Common/PropId.cpp +108 -0
  276. data/ext/p7zip/CPP/7zip/Common/RegisterArc.h +63 -17
  277. data/ext/p7zip/CPP/7zip/Common/RegisterCodec.h +79 -6
  278. data/ext/p7zip/CPP/7zip/Common/StreamBinder.cpp +95 -90
  279. data/ext/p7zip/CPP/7zip/Common/StreamBinder.h +46 -23
  280. data/ext/p7zip/CPP/7zip/Common/StreamObjects.cpp +88 -24
  281. data/ext/p7zip/CPP/7zip/Common/StreamObjects.h +36 -14
  282. data/ext/p7zip/CPP/7zip/Common/StreamUtils.cpp +4 -4
  283. data/ext/p7zip/CPP/7zip/Common/StreamUtils.h +6 -6
  284. data/ext/p7zip/CPP/7zip/Common/UniqBlocks.cpp +57 -0
  285. data/ext/p7zip/CPP/7zip/Common/UniqBlocks.h +26 -0
  286. data/ext/p7zip/CPP/7zip/Common/VirtThread.cpp +8 -6
  287. data/ext/p7zip/CPP/7zip/Common/VirtThread.h +6 -5
  288. data/ext/p7zip/CPP/7zip/Compress/BZip2Const.h +13 -12
  289. data/ext/p7zip/CPP/7zip/Compress/BZip2Crc.h +1 -1
  290. data/ext/p7zip/CPP/7zip/Compress/BZip2Decoder.cpp +198 -147
  291. data/ext/p7zip/CPP/7zip/Compress/BZip2Decoder.h +60 -27
  292. data/ext/p7zip/CPP/7zip/Compress/BZip2Encoder.cpp +111 -116
  293. data/ext/p7zip/CPP/7zip/Compress/BZip2Encoder.h +53 -59
  294. data/ext/p7zip/CPP/7zip/Compress/BZip2Register.cpp +12 -7
  295. data/ext/p7zip/CPP/7zip/Compress/Bcj2Coder.cpp +554 -282
  296. data/ext/p7zip/CPP/7zip/Compress/Bcj2Coder.h +73 -71
  297. data/ext/p7zip/CPP/7zip/Compress/Bcj2Register.cpp +10 -5
  298. data/ext/p7zip/CPP/7zip/Compress/BcjCoder.cpp +13 -4
  299. data/ext/p7zip/CPP/7zip/Compress/BcjCoder.h +17 -5
  300. data/ext/p7zip/CPP/7zip/Compress/BcjRegister.cpp +7 -9
  301. data/ext/p7zip/CPP/7zip/Compress/BitlDecoder.cpp +2 -2
  302. data/ext/p7zip/CPP/7zip/Compress/BitlDecoder.h +58 -61
  303. data/ext/p7zip/CPP/7zip/Compress/BitlEncoder.h +24 -25
  304. data/ext/p7zip/CPP/7zip/Compress/BitmDecoder.h +46 -17
  305. data/ext/p7zip/CPP/7zip/Compress/BitmEncoder.h +18 -19
  306. data/ext/p7zip/CPP/7zip/Compress/BranchMisc.cpp +14 -28
  307. data/ext/p7zip/CPP/7zip/Compress/BranchMisc.h +27 -6
  308. data/ext/p7zip/CPP/7zip/Compress/BranchRegister.cpp +26 -15
  309. data/ext/p7zip/CPP/7zip/Compress/ByteSwap.cpp +45 -26
  310. data/ext/p7zip/CPP/7zip/Compress/CodecExports.cpp +254 -70
  311. data/ext/p7zip/CPP/7zip/Compress/CopyCoder.cpp +65 -17
  312. data/ext/p7zip/CPP/7zip/Compress/CopyCoder.h +15 -3
  313. data/ext/p7zip/CPP/7zip/Compress/CopyRegister.cpp +5 -4
  314. data/ext/p7zip/CPP/7zip/Compress/Deflate64Register.cpp +12 -6
  315. data/ext/p7zip/CPP/7zip/Compress/DeflateConst.h +43 -46
  316. data/ext/p7zip/CPP/7zip/Compress/DeflateDecoder.cpp +145 -81
  317. data/ext/p7zip/CPP/7zip/Compress/DeflateDecoder.h +31 -33
  318. data/ext/p7zip/CPP/7zip/Compress/DeflateEncoder.cpp +179 -162
  319. data/ext/p7zip/CPP/7zip/Compress/DeflateEncoder.h +35 -30
  320. data/ext/p7zip/CPP/7zip/Compress/DeflateRegister.cpp +11 -7
  321. data/ext/p7zip/CPP/7zip/Compress/DeltaFilter.cpp +55 -39
  322. data/ext/p7zip/CPP/7zip/Compress/{DllExports2.cpp → DllExports2Compress.cpp} +8 -8
  323. data/ext/p7zip/CPP/7zip/Compress/DllExportsCompress.cpp +48 -0
  324. data/ext/p7zip/CPP/7zip/Compress/HuffmanDecoder.h +220 -49
  325. data/ext/p7zip/CPP/7zip/Compress/ImplodeDecoder.cpp +14 -9
  326. data/ext/p7zip/CPP/7zip/Compress/ImplodeDecoder.h +2 -3
  327. data/ext/p7zip/CPP/7zip/Compress/ImplodeHuffmanDecoder.cpp +7 -7
  328. data/ext/p7zip/CPP/7zip/Compress/ImplodeHuffmanDecoder.h +1 -1
  329. data/ext/p7zip/CPP/7zip/Compress/LzOutWindow.cpp +1 -1
  330. data/ext/p7zip/CPP/7zip/Compress/LzOutWindow.h +21 -18
  331. data/ext/p7zip/CPP/7zip/Compress/LzhDecoder.cpp +171 -141
  332. data/ext/p7zip/CPP/7zip/Compress/LzhDecoder.h +32 -64
  333. data/ext/p7zip/CPP/7zip/Compress/Lzham/LICENSE +22 -0
  334. data/ext/p7zip/CPP/7zip/Compress/Lzham/LzhamRegister.cpp +783 -0
  335. data/ext/p7zip/CPP/7zip/Compress/Lzham/README.md +211 -0
  336. data/ext/p7zip/CPP/7zip/Compress/Lzham/include/lzham.h +803 -0
  337. data/ext/p7zip/CPP/7zip/Compress/Lzham/include/lzham_dynamic_lib.h +156 -0
  338. data/ext/p7zip/CPP/7zip/Compress/Lzham/include/lzham_exports.inc +31 -0
  339. data/ext/p7zip/CPP/7zip/Compress/Lzham/include/lzham_static_lib.h +59 -0
  340. data/ext/p7zip/CPP/7zip/Compress/Lzham/include/zlib.h +2 -0
  341. data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamcomp/CMakeLists.txt +69 -0
  342. data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamcomp/lzham_comp.h +38 -0
  343. data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamcomp/lzham_lzbase.cpp +244 -0
  344. data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamcomp/lzham_lzbase.h +46 -0
  345. data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamcomp/lzham_lzcomp.cpp +750 -0
  346. data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamcomp/lzham_lzcomp_internal.cpp +2240 -0
  347. data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamcomp/lzham_lzcomp_internal.h +503 -0
  348. data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamcomp/lzham_lzcomp_state.cpp +1684 -0
  349. data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamcomp/lzham_match_accel.cpp +947 -0
  350. data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamcomp/lzham_match_accel.h +164 -0
  351. data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamcomp/lzham_null_threading.h +98 -0
  352. data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamcomp/lzham_pthreads_threading.cpp +214 -0
  353. data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamcomp/lzham_pthreads_threading.h +535 -0
  354. data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamcomp/lzham_threading.h +12 -0
  355. data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamcomp/lzham_win32_threading.cpp +232 -0
  356. data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamcomp/lzham_win32_threading.h +387 -0
  357. data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamcomp/lzhamcomp.vcxproj +208 -0
  358. data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/CMakeLists.txt +86 -0
  359. data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_assert.cpp +80 -0
  360. data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_assert.h +58 -0
  361. data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_checksum.cpp +73 -0
  362. data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_checksum.h +13 -0
  363. data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_config.h +25 -0
  364. data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_core.h +303 -0
  365. data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_decomp.h +37 -0
  366. data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_helpers.h +54 -0
  367. data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_huffman_codes.cpp +286 -0
  368. data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_huffman_codes.h +32 -0
  369. data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_lzdecomp.cpp +1586 -0
  370. data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_lzdecompbase.cpp +131 -0
  371. data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_lzdecompbase.h +89 -0
  372. data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_math.h +142 -0
  373. data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_mem.cpp +463 -0
  374. data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_mem.h +115 -0
  375. data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_platform.cpp +159 -0
  376. data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_platform.h +284 -0
  377. data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_prefix_coding.cpp +431 -0
  378. data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_prefix_coding.h +157 -0
  379. data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_symbol_codec.cpp +1527 -0
  380. data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_symbol_codec.h +494 -0
  381. data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_timer.cpp +147 -0
  382. data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_timer.h +99 -0
  383. data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_traits.h +141 -0
  384. data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_types.h +72 -0
  385. data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_utils.h +58 -0
  386. data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_vector.cpp +83 -0
  387. data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzham_vector.h +628 -0
  388. data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamdecomp/lzhamdecomp.vcxproj +224 -0
  389. data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamlib/lzham_lib.cpp +179 -0
  390. data/ext/p7zip/CPP/7zip/Compress/Lzham/lzhamlib/lzhamlib.vcxproj +187 -0
  391. data/ext/p7zip/CPP/7zip/Compress/Lzham/makefile +10 -0
  392. data/ext/p7zip/CPP/7zip/Compress/Lzham/makefile.depend +0 -0
  393. data/ext/p7zip/CPP/7zip/Compress/Lzham/makefile.list +129 -0
  394. data/ext/p7zip/CPP/7zip/Compress/Lzma2Decoder.cpp +123 -46
  395. data/ext/p7zip/CPP/7zip/Compress/Lzma2Decoder.h +29 -14
  396. data/ext/p7zip/CPP/7zip/Compress/Lzma2Encoder.cpp +14 -9
  397. data/ext/p7zip/CPP/7zip/Compress/Lzma2Encoder.h +1 -1
  398. data/ext/p7zip/CPP/7zip/Compress/Lzma2Register.cpp +9 -7
  399. data/ext/p7zip/CPP/7zip/Compress/LzmaDecoder.cpp +24 -8
  400. data/ext/p7zip/CPP/7zip/Compress/LzmaDecoder.h +8 -1
  401. data/ext/p7zip/CPP/7zip/Compress/LzmaEncoder.cpp +30 -27
  402. data/ext/p7zip/CPP/7zip/Compress/LzmaEncoder.h +3 -1
  403. data/ext/p7zip/CPP/7zip/Compress/LzmaRegister.cpp +9 -7
  404. data/ext/p7zip/CPP/7zip/Compress/LzmsDecoder.cpp +576 -0
  405. data/ext/p7zip/CPP/7zip/Compress/LzmsDecoder.h +271 -0
  406. data/ext/p7zip/CPP/7zip/Compress/Lzx.h +32 -36
  407. data/ext/p7zip/CPP/7zip/Compress/LzxDecoder.cpp +380 -238
  408. data/ext/p7zip/CPP/7zip/Compress/LzxDecoder.h +170 -83
  409. data/ext/p7zip/CPP/7zip/Compress/Mtf8.h +7 -9
  410. data/ext/p7zip/CPP/7zip/Compress/PpmdDecoder.cpp +1 -5
  411. data/ext/p7zip/CPP/7zip/Compress/PpmdEncoder.cpp +51 -18
  412. data/ext/p7zip/CPP/7zip/Compress/PpmdEncoder.h +18 -8
  413. data/ext/p7zip/CPP/7zip/Compress/PpmdRegister.cpp +9 -8
  414. data/ext/p7zip/CPP/7zip/Compress/PpmdZip.cpp +61 -25
  415. data/ext/p7zip/CPP/7zip/Compress/PpmdZip.h +21 -6
  416. data/ext/p7zip/CPP/7zip/Compress/QuantumDecoder.cpp +122 -102
  417. data/ext/p7zip/CPP/7zip/Compress/QuantumDecoder.h +68 -157
  418. data/ext/p7zip/CPP/7zip/Compress/Rar/makefile +33 -18
  419. data/ext/p7zip/CPP/7zip/Compress/Rar/makefile.depend +0 -158
  420. data/ext/p7zip/CPP/7zip/Compress/Rar/makefile.list +105 -56
  421. data/ext/p7zip/CPP/7zip/Compress/Rar1Decoder.cpp +34 -21
  422. data/ext/p7zip/CPP/7zip/Compress/Rar1Decoder.h +2 -0
  423. data/ext/p7zip/CPP/7zip/Compress/Rar2Decoder.cpp +77 -67
  424. data/ext/p7zip/CPP/7zip/Compress/Rar2Decoder.h +12 -10
  425. data/ext/p7zip/CPP/7zip/Compress/Rar3Decoder.cpp +139 -118
  426. data/ext/p7zip/CPP/7zip/Compress/Rar3Decoder.h +48 -33
  427. data/ext/p7zip/CPP/7zip/Compress/Rar3Vm.cpp +148 -113
  428. data/ext/p7zip/CPP/7zip/Compress/Rar3Vm.h +35 -19
  429. data/ext/p7zip/CPP/7zip/Compress/Rar5Decoder.cpp +961 -0
  430. data/ext/p7zip/CPP/7zip/Compress/Rar5Decoder.h +335 -0
  431. data/ext/p7zip/CPP/7zip/Compress/RarCodecsRegister.cpp +13 -6
  432. data/ext/p7zip/CPP/7zip/Compress/ShrinkDecoder.cpp +91 -71
  433. data/ext/p7zip/CPP/7zip/Compress/ShrinkDecoder.h +2 -4
  434. data/ext/p7zip/CPP/7zip/Compress/XpressDecoder.cpp +129 -0
  435. data/ext/p7zip/CPP/7zip/Compress/XpressDecoder.h +13 -0
  436. data/ext/p7zip/CPP/7zip/Compress/ZDecoder.cpp +98 -20
  437. data/ext/p7zip/CPP/7zip/Compress/ZDecoder.h +19 -7
  438. data/ext/p7zip/CPP/7zip/Compress/ZlibDecoder.cpp +14 -11
  439. data/ext/p7zip/CPP/7zip/Compress/ZlibDecoder.h +32 -1
  440. data/ext/p7zip/CPP/7zip/Crypto/7zAes.cpp +137 -101
  441. data/ext/p7zip/CPP/7zip/Crypto/7zAes.h +31 -30
  442. data/ext/p7zip/CPP/7zip/Crypto/7zAesRegister.cpp +8 -9
  443. data/ext/p7zip/CPP/7zip/Crypto/HmacSha1.cpp +39 -28
  444. data/ext/p7zip/CPP/7zip/Crypto/HmacSha1.h +3 -3
  445. data/ext/p7zip/CPP/7zip/Crypto/HmacSha256.cpp +62 -0
  446. data/ext/p7zip/CPP/7zip/Crypto/HmacSha256.h +27 -0
  447. data/ext/p7zip/CPP/7zip/Crypto/MyAes.cpp +73 -7
  448. data/ext/p7zip/CPP/7zip/Crypto/MyAes.h +25 -8
  449. data/ext/p7zip/CPP/7zip/Crypto/MyAesReg.cpp +16 -0
  450. data/ext/p7zip/CPP/7zip/Crypto/Pbkdf2HmacSha1.cpp +29 -15
  451. data/ext/p7zip/CPP/7zip/Crypto/Pbkdf2HmacSha1.h +2 -1
  452. data/ext/p7zip/CPP/7zip/Crypto/RandGen.cpp +49 -34
  453. data/ext/p7zip/CPP/7zip/Crypto/RandGen.h +2 -2
  454. data/ext/p7zip/CPP/7zip/Crypto/Rar20Crypto.cpp +36 -39
  455. data/ext/p7zip/CPP/7zip/Crypto/Rar20Crypto.h +15 -17
  456. data/ext/p7zip/CPP/7zip/Crypto/Rar5Aes.cpp +257 -0
  457. data/ext/p7zip/CPP/7zip/Crypto/Rar5Aes.h +84 -0
  458. data/ext/p7zip/CPP/7zip/Crypto/RarAes.cpp +70 -71
  459. data/ext/p7zip/CPP/7zip/Crypto/RarAes.h +24 -19
  460. data/ext/p7zip/CPP/7zip/Crypto/Sha1Cls.h +51 -0
  461. data/ext/p7zip/CPP/7zip/Crypto/WzAes.cpp +68 -54
  462. data/ext/p7zip/CPP/7zip/Crypto/WzAes.h +37 -27
  463. data/ext/p7zip/CPP/7zip/Crypto/ZipCrypto.cpp +60 -34
  464. data/ext/p7zip/CPP/7zip/Crypto/ZipCrypto.h +28 -11
  465. data/ext/p7zip/CPP/7zip/Crypto/ZipStrong.cpp +90 -28
  466. data/ext/p7zip/CPP/7zip/Crypto/ZipStrong.h +13 -2
  467. data/ext/p7zip/CPP/7zip/Guid.txt +57 -11
  468. data/ext/p7zip/CPP/7zip/ICoder.h +202 -17
  469. data/ext/p7zip/CPP/7zip/IDecl.h +16 -3
  470. data/ext/p7zip/CPP/7zip/IPassword.h +1 -2
  471. data/ext/p7zip/CPP/7zip/IProgress.h +2 -16
  472. data/ext/p7zip/CPP/7zip/IStream.h +82 -13
  473. data/ext/p7zip/CPP/7zip/MyVersion.h +2 -11
  474. data/ext/p7zip/CPP/7zip/PropID.h +60 -9
  475. data/ext/p7zip/CPP/Common/C_FileIO.cpp +5 -1
  476. data/ext/p7zip/CPP/Common/C_FileIO.h +7 -1
  477. data/ext/p7zip/CPP/Common/CommandLineParser.cpp +122 -148
  478. data/ext/p7zip/CPP/Common/CommandLineParser.h +20 -29
  479. data/ext/p7zip/CPP/Common/Common.h +13 -0
  480. data/ext/p7zip/CPP/Common/CrcReg.cpp +98 -0
  481. data/ext/p7zip/CPP/Common/Defs.h +5 -10
  482. data/ext/p7zip/CPP/Common/DynLimBuf.cpp +93 -0
  483. data/ext/p7zip/CPP/Common/DynLimBuf.h +40 -0
  484. data/ext/p7zip/CPP/Common/DynamicBuffer.h +45 -31
  485. data/ext/p7zip/CPP/Common/IntToString.cpp +109 -40
  486. data/ext/p7zip/CPP/Common/IntToString.h +14 -9
  487. data/ext/p7zip/CPP/Common/Lang.cpp +120 -87
  488. data/ext/p7zip/CPP/Common/Lang.h +10 -15
  489. data/ext/p7zip/CPP/Common/ListFileUtils.cpp +82 -40
  490. data/ext/p7zip/CPP/Common/ListFileUtils.h +7 -4
  491. data/ext/p7zip/CPP/Common/MyBuffer.h +244 -0
  492. data/ext/p7zip/CPP/Common/MyCom.h +65 -28
  493. data/ext/p7zip/CPP/Common/MyGuidDef.h +1 -1
  494. data/ext/p7zip/CPP/Common/MyInitGuid.h +23 -0
  495. data/ext/p7zip/CPP/Common/MyLinux.h +42 -0
  496. data/ext/p7zip/CPP/Common/MyMap.cpp +8 -8
  497. data/ext/p7zip/CPP/Common/MyMap.h +2 -2
  498. data/ext/p7zip/CPP/Common/MyString.cpp +1643 -117
  499. data/ext/p7zip/CPP/Common/MyString.h +677 -486
  500. data/ext/p7zip/CPP/Common/MyTypes.h +38 -0
  501. data/ext/p7zip/CPP/Common/MyUnknown.h +4 -0
  502. data/ext/p7zip/CPP/Common/MyVector.cpp +0 -84
  503. data/ext/p7zip/CPP/Common/MyVector.h +472 -112
  504. data/ext/p7zip/CPP/Common/MyWindows.cpp +18 -1
  505. data/ext/p7zip/CPP/Common/MyWindows.h +8 -0
  506. data/ext/p7zip/CPP/Common/MyXml.cpp +169 -118
  507. data/ext/p7zip/CPP/Common/MyXml.h +14 -11
  508. data/ext/p7zip/CPP/Common/NewHandler.cpp +39 -0
  509. data/ext/p7zip/CPP/Common/NewHandler.h +55 -2
  510. data/ext/p7zip/CPP/Common/Random.h +14 -0
  511. data/ext/p7zip/CPP/Common/Sha1Reg.cpp +40 -0
  512. data/ext/p7zip/CPP/Common/Sha256Reg.cpp +40 -0
  513. data/ext/p7zip/CPP/Common/StdInStream.cpp +46 -27
  514. data/ext/p7zip/CPP/Common/StdInStream.h +11 -10
  515. data/ext/p7zip/CPP/Common/StdOutStream.cpp +48 -35
  516. data/ext/p7zip/CPP/Common/StdOutStream.h +44 -17
  517. data/ext/p7zip/CPP/Common/StringConvert.cpp +56 -17
  518. data/ext/p7zip/CPP/Common/StringConvert.h +7 -3
  519. data/ext/p7zip/CPP/Common/StringToInt.cpp +102 -48
  520. data/ext/p7zip/CPP/Common/StringToInt.h +13 -10
  521. data/ext/p7zip/CPP/Common/TextConfig.cpp +33 -47
  522. data/ext/p7zip/CPP/Common/TextConfig.h +3 -6
  523. data/ext/p7zip/CPP/Common/UTFConvert.cpp +218 -75
  524. data/ext/p7zip/CPP/Common/UTFConvert.h +4 -3
  525. data/ext/p7zip/CPP/Common/Wildcard.cpp +345 -125
  526. data/ext/p7zip/CPP/Common/Wildcard.h +82 -13
  527. data/ext/p7zip/CPP/Common/XzCrc64Reg.cpp +42 -0
  528. data/ext/p7zip/CPP/Windows/FileDir.cpp +427 -475
  529. data/ext/p7zip/CPP/Windows/FileDir.h +94 -72
  530. data/ext/p7zip/CPP/Windows/FileFind.cpp +235 -244
  531. data/ext/p7zip/CPP/Windows/FileFind.h +63 -59
  532. data/ext/p7zip/CPP/Windows/FileIO.cpp +29 -46
  533. data/ext/p7zip/CPP/Windows/FileIO.h +40 -42
  534. data/ext/p7zip/CPP/Windows/FileName.cpp +696 -17
  535. data/ext/p7zip/CPP/Windows/FileName.h +11 -3
  536. data/ext/p7zip/CPP/Windows/NtCheck.h +2 -0
  537. data/ext/p7zip/CPP/Windows/PropVariant.cpp +134 -30
  538. data/ext/p7zip/CPP/Windows/PropVariant.h +80 -24
  539. data/ext/p7zip/CPP/Windows/PropVariantUtils.cpp +89 -18
  540. data/ext/p7zip/CPP/Windows/PropVariantUtils.h +12 -7
  541. data/ext/p7zip/CPP/Windows/System.cpp +20 -15
  542. data/ext/p7zip/CPP/Windows/System.h +3 -2
  543. data/ext/p7zip/CPP/Windows/TimeUtils.cpp +203 -0
  544. data/ext/p7zip/CPP/Windows/TimeUtils.h +24 -0
  545. data/ext/p7zip/CPP/include_windows/basetyps.h +4 -4
  546. data/ext/p7zip/CPP/include_windows/windows.h +17 -11
  547. data/ext/p7zip/CPP/myWindows/StdAfx.h +97 -5
  548. data/ext/p7zip/CPP/myWindows/config.h +20 -5
  549. data/ext/p7zip/CPP/myWindows/myPrivate.h +8 -0
  550. data/ext/p7zip/CPP/myWindows/wine_date_and_time.cpp +34 -0
  551. data/ext/p7zip/ChangeLog +283 -35
  552. data/ext/p7zip/{DOCS → DOC}/7zC.txt +6 -13
  553. data/ext/p7zip/{DOCS → DOC}/License.txt +3 -2
  554. data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/commands/add.htm +93 -87
  555. data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/commands/bench.htm +88 -79
  556. data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/commands/delete.htm +62 -59
  557. data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/commands/extract.htm +96 -91
  558. data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/commands/extract_full.htm +73 -68
  559. data/ext/p7zip/DOC/MANUAL/cmdline/commands/hash.htm +65 -0
  560. data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/commands/index.htm +36 -33
  561. data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/commands/list.htm +78 -77
  562. data/ext/p7zip/DOC/MANUAL/cmdline/commands/rename.htm +51 -0
  563. data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/commands/style.css +232 -232
  564. data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/commands/test.htm +47 -46
  565. data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/commands/update.htm +71 -66
  566. data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/exit_codes.htm +27 -27
  567. data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/index.htm +29 -29
  568. data/ext/p7zip/{DOCS/MANUAL/switches → DOC/MANUAL/cmdline}/style.css +232 -232
  569. data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/ar_exclude.htm +56 -56
  570. data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/ar_include.htm +80 -83
  571. data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/ar_no.htm +52 -52
  572. data/ext/p7zip/DOC/MANUAL/cmdline/switches/bb.htm +61 -0
  573. data/ext/p7zip/DOC/MANUAL/cmdline/switches/bs.htm +67 -0
  574. data/ext/p7zip/DOC/MANUAL/cmdline/switches/charset.htm +61 -0
  575. data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/exclude.htm +71 -60
  576. data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/include.htm +89 -87
  577. data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/index.htm +95 -64
  578. data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/large_pages.htm +59 -50
  579. data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/list_tech.htm +36 -36
  580. data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/method.htm +738 -625
  581. data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/output_dir.htm +53 -53
  582. data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/overwrite.htm +56 -56
  583. data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/password.htm +55 -54
  584. data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/recurse.htm +85 -83
  585. data/ext/p7zip/DOC/MANUAL/cmdline/switches/sa.htm +58 -0
  586. data/ext/p7zip/DOC/MANUAL/cmdline/switches/scc.htm +42 -0
  587. data/ext/p7zip/DOC/MANUAL/cmdline/switches/scrc.htm +53 -0
  588. data/ext/p7zip/DOC/MANUAL/cmdline/switches/sdel.htm +39 -0
  589. data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/sfx.htm +153 -156
  590. data/ext/p7zip/DOC/MANUAL/cmdline/switches/shared.htm +40 -0
  591. data/ext/p7zip/DOC/MANUAL/cmdline/switches/sni.htm +56 -0
  592. data/ext/p7zip/DOC/MANUAL/cmdline/switches/sns.htm +77 -0
  593. data/ext/p7zip/DOC/MANUAL/cmdline/switches/spf.htm +80 -0
  594. data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/ssc.htm +50 -50
  595. data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/stdin.htm +56 -55
  596. data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/stdout.htm +54 -50
  597. data/ext/p7zip/DOC/MANUAL/cmdline/switches/stl.htm +39 -0
  598. data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/stop_switch.htm +31 -31
  599. data/ext/p7zip/DOC/MANUAL/cmdline/switches/stx.htm +50 -0
  600. data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline/switches}/style.css +232 -232
  601. data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/type.htm +121 -83
  602. data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/update.htm +177 -176
  603. data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/volume.htm +49 -49
  604. data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/working_dir.htm +56 -55
  605. data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/switches/yes.htm +48 -48
  606. data/ext/p7zip/{DOCS/MANUAL → DOC/MANUAL/cmdline}/syntax.htm +120 -120
  607. data/ext/p7zip/DOC/MANUAL/fm/about.htm +21 -0
  608. data/ext/p7zip/DOC/MANUAL/fm/benchmark.htm +56 -0
  609. data/ext/p7zip/DOC/MANUAL/fm/index.htm +54 -0
  610. data/ext/p7zip/DOC/MANUAL/fm/menu.htm +154 -0
  611. data/ext/p7zip/DOC/MANUAL/fm/options.htm +152 -0
  612. data/ext/p7zip/DOC/MANUAL/fm/plugins/7-zip/add.htm +311 -0
  613. data/ext/p7zip/DOC/MANUAL/fm/plugins/7-zip/extract.htm +78 -0
  614. data/ext/p7zip/DOC/MANUAL/fm/plugins/7-zip/index.htm +63 -0
  615. data/ext/p7zip/DOC/MANUAL/fm/plugins/7-zip/style.css +232 -0
  616. data/ext/p7zip/DOC/MANUAL/fm/plugins/index.htm +22 -0
  617. data/ext/p7zip/DOC/MANUAL/fm/plugins/style.css +232 -0
  618. data/ext/p7zip/DOC/MANUAL/fm/style.css +232 -0
  619. data/ext/p7zip/DOC/MANUAL/general/7z.htm +117 -0
  620. data/ext/p7zip/DOC/MANUAL/general/faq.htm +125 -0
  621. data/ext/p7zip/DOC/MANUAL/general/formats.htm +100 -0
  622. data/ext/p7zip/DOC/MANUAL/general/index.htm +27 -0
  623. data/ext/p7zip/DOC/MANUAL/general/license.htm +30 -0
  624. data/ext/p7zip/DOC/MANUAL/general/performance.htm +98 -0
  625. data/ext/p7zip/DOC/MANUAL/general/style.css +232 -0
  626. data/ext/p7zip/DOC/MANUAL/general/thanks.htm +43 -0
  627. data/ext/p7zip/DOC/MANUAL/start.htm +37 -0
  628. data/ext/p7zip/DOC/MANUAL/style.css +232 -0
  629. data/ext/p7zip/DOC/Methods.txt +158 -0
  630. data/ext/p7zip/{DOCS → DOC}/copying.txt +9 -11
  631. data/ext/p7zip/DOC/lzma.txt +328 -0
  632. data/ext/p7zip/{DOCS → DOC}/readme.txt +42 -65
  633. data/ext/p7zip/{DOCS/history.txt → DOC/src-history.txt} +88 -2
  634. data/ext/p7zip/README +117 -91
  635. data/ext/p7zip/TODO +0 -2
  636. data/ext/p7zip/install.sh +31 -29
  637. data/ext/p7zip/last_error +1 -0
  638. data/ext/p7zip/makefile +29 -125
  639. data/ext/p7zip/makefile.afl +23 -0
  640. data/ext/p7zip/makefile.aix_gcc +5 -4
  641. data/ext/p7zip/makefile.android_arm +49 -0
  642. data/ext/p7zip/makefile.beos +5 -4
  643. data/ext/p7zip/makefile.common +150 -0
  644. data/ext/p7zip/makefile.crc32 +3 -3
  645. data/ext/p7zip/makefile.cygwin +5 -4
  646. data/ext/p7zip/makefile.cygwin64 +21 -0
  647. data/ext/p7zip/makefile.cygwin64_asm +22 -0
  648. data/ext/p7zip/makefile.cygwin_asm +6 -4
  649. data/ext/p7zip/makefile.cygwin_clang +21 -0
  650. data/ext/p7zip/makefile.cygwin_clang_asm +23 -0
  651. data/ext/p7zip/{makefile.djgpp_old → makefile.djgpp} +5 -4
  652. data/ext/p7zip/makefile.djgpp_watt +7 -5
  653. data/ext/p7zip/makefile.freebsd5 +5 -4
  654. data/ext/p7zip/{makefile.freebsd6 → makefile.freebsd6+} +6 -5
  655. data/ext/p7zip/makefile.glb +27 -18
  656. data/ext/p7zip/makefile.gprof +3 -2
  657. data/ext/p7zip/makefile.haiku +19 -0
  658. data/ext/p7zip/makefile.hpux-acc +3 -2
  659. data/ext/p7zip/makefile.hpux-acc_64 +3 -2
  660. data/ext/p7zip/makefile.hpux-gcc +5 -4
  661. data/ext/p7zip/makefile.linux_amd64 +5 -4
  662. data/ext/p7zip/makefile.linux_amd64_asm +12 -5
  663. data/ext/p7zip/makefile.linux_amd64_asm_icc +5 -3
  664. data/ext/p7zip/makefile.linux_amd64_sanitizer +26 -0
  665. data/ext/p7zip/makefile.linux_any_cpu +5 -4
  666. data/ext/p7zip/makefile.linux_any_cpu_gcc_4.X +7 -4
  667. data/ext/p7zip/makefile.linux_clang_amd64_asm +25 -0
  668. data/ext/p7zip/makefile.linux_clang_amd64_asm_sanitize +27 -0
  669. data/ext/p7zip/makefile.linux_cross_aarch64 +25 -0
  670. data/ext/p7zip/makefile.linux_cross_arm +7 -4
  671. data/ext/p7zip/makefile.linux_cross_djgpp +27 -0
  672. data/ext/p7zip/makefile.linux_cross_m68k +26 -0
  673. data/ext/p7zip/makefile.linux_cross_mipsel +27 -0
  674. data/ext/p7zip/makefile.linux_cross_ppc +25 -0
  675. data/ext/p7zip/makefile.linux_cross_ppc64 +25 -0
  676. data/ext/p7zip/makefile.linux_cross_ppc64le +25 -0
  677. data/ext/p7zip/makefile.linux_cross_s390x +25 -0
  678. data/ext/p7zip/makefile.linux_cross_sparc64 +25 -0
  679. data/ext/p7zip/makefile.linux_gcc6_sanitize +23 -0
  680. data/ext/p7zip/makefile.linux_gcc_2.95_no_need_for_libstdc +6 -4
  681. data/ext/p7zip/makefile.linux_other +6 -5
  682. data/ext/p7zip/makefile.linux_s390x +5 -4
  683. data/ext/p7zip/{makefile.machine_base → makefile.linux_scan-build} +5 -4
  684. data/ext/p7zip/makefile.linux_valgrind +25 -0
  685. data/ext/p7zip/{makefile.linux_clang_amd64 → makefile.linux_x32} +6 -5
  686. data/ext/p7zip/makefile.linux_x86_asm_gcc_4.X +10 -5
  687. data/ext/p7zip/makefile.linux_x86_asm_gcc_4.X_fltk +8 -4
  688. data/ext/p7zip/makefile.linux_x86_asm_gcc_mudflap_4.X +4 -2
  689. data/ext/p7zip/makefile.linux_x86_asm_icc +4 -2
  690. data/ext/p7zip/makefile.linux_x86_icc +3 -2
  691. data/ext/p7zip/makefile.macosx_arm64 +17 -0
  692. data/ext/p7zip/{makefile.macosx_32bits → makefile.macosx_gcc_32bits} +3 -2
  693. data/ext/p7zip/{makefile.macosx_32bits_asm → makefile.macosx_gcc_32bits_asm} +5 -3
  694. data/ext/p7zip/{makefile.macosx_32bits_ppc → makefile.macosx_gcc_32bits_ppc} +3 -2
  695. data/ext/p7zip/{makefile.macosx_64bits → makefile.macosx_gcc_64bits} +3 -2
  696. data/ext/p7zip/makefile.macosx_llvm_64bits +9 -3
  697. data/ext/p7zip/makefile.netbsd +5 -4
  698. data/ext/p7zip/makefile.netware_asm_gcc_3.X +6 -4
  699. data/ext/p7zip/makefile.oldmake +41 -130
  700. data/ext/p7zip/makefile.openbsd +7 -3
  701. data/ext/p7zip/makefile.openbsd_no_port +9 -5
  702. data/ext/p7zip/makefile.qnx_shared.bin +5 -4
  703. data/ext/p7zip/makefile.qnx_static +5 -4
  704. data/ext/p7zip/makefile.solaris_sparc_CC_32 +5 -4
  705. data/ext/p7zip/makefile.solaris_sparc_CC_64 +6 -4
  706. data/ext/p7zip/makefile.solaris_sparc_gcc +7 -6
  707. data/ext/p7zip/makefile.solaris_x86 +5 -4
  708. data/ext/p7zip/makefile.tru64 +5 -4
  709. data/ext/seven_zip_ruby/extconf.rb +92 -6
  710. data/ext/seven_zip_ruby/seven_zip_archive.cpp +40 -17
  711. data/ext/seven_zip_ruby/seven_zip_archive.h +1 -1
  712. data/ext/seven_zip_ruby/utils.cpp +267 -124
  713. data/ext/seven_zip_ruby/utils.h +2 -0
  714. data/lib/seven_zip_ruby/7z.dll +0 -0
  715. data/lib/seven_zip_ruby/7z.sfx +0 -0
  716. data/lib/seven_zip_ruby/7z64.dll +0 -0
  717. data/lib/seven_zip_ruby/7zCon.sfx +0 -0
  718. data/lib/seven_zip_ruby/seven_zip_reader.rb +16 -1
  719. data/lib/seven_zip_ruby/version.rb +1 -1
  720. data/p7zip/.gitignore +7 -0
  721. data/p7zip/README.txt +29 -0
  722. data/p7zip/extract.sh +134 -0
  723. data/spec/seven_zip_ruby_spec.rb +22 -13
  724. data/test/res/The Flying Spaghetti Monster.txt +3 -0
  725. data/test/res/The Three Little Pigs.txt +5 -0
  726. data/test/res/UTF_content.txt +3 -0
  727. data/test/res/test_reader_data.7z +0 -0
  728. data/test/res/test_reader_filename_cp932.7z +0 -0
  729. data/test/res/test_reader_files.7z +0 -0
  730. data/test/test_seven_zip_reader.rb +187 -0
  731. data/test/test_seven_zip_writer.rb +184 -0
  732. metadata +267 -219
  733. data/.github/workflows/test-and-release.yml +0 -43
  734. data/ext/C/Types.h +0 -254
  735. data/ext/CPP/7zip/Archive/IArchive.h +0 -234
  736. data/ext/CPP/7zip/IDecl.h +0 -15
  737. data/ext/CPP/7zip/IPassword.h +0 -24
  738. data/ext/CPP/7zip/IProgress.h +0 -33
  739. data/ext/CPP/7zip/IStream.h +0 -58
  740. data/ext/CPP/7zip/PropID.h +0 -76
  741. data/ext/CPP/Common/MyCom.h +0 -225
  742. data/ext/CPP/Common/MyGuidDef.h +0 -54
  743. data/ext/CPP/Common/MyInitGuid.h +0 -22
  744. data/ext/CPP/Common/MyUnknown.h +0 -13
  745. data/ext/CPP/Common/MyWindows.h +0 -204
  746. data/ext/CPP/Common/Types.h +0 -11
  747. data/ext/CPP/Windows/PropVariant.h +0 -56
  748. data/ext/CPP/include_windows/basetyps.h +0 -19
  749. data/ext/CPP/include_windows/tchar.h +0 -89
  750. data/ext/CPP/include_windows/windows.h +0 -194
  751. data/ext/p7zip/Asm/x64/7zCrcT8U.asm +0 -103
  752. data/ext/p7zip/Asm/x86/7zCrcT8U.asm +0 -101
  753. data/ext/p7zip/C/7zCrcT8.c +0 -43
  754. data/ext/p7zip/C/Alloc.back3 +0 -238
  755. data/ext/p7zip/C/Alloc.c.back +0 -243
  756. data/ext/p7zip/C/Alloc.c.back2 +0 -222
  757. data/ext/p7zip/C/LzmaUtil/Lzma86Dec.h +0 -51
  758. data/ext/p7zip/CPP/7zip/Archive/7z/7zFolderOutStream.cpp +0 -149
  759. data/ext/p7zip/CPP/7zip/Archive/7z/7zFolderOutStream.h +0 -58
  760. data/ext/p7zip/CPP/7zip/Archive/Chm/ChmHeader.cpp +0 -24
  761. data/ext/p7zip/CPP/7zip/Archive/Chm/ChmHeader.h +0 -28
  762. data/ext/p7zip/CPP/7zip/Archive/Chm/ChmRegister.cpp +0 -13
  763. data/ext/p7zip/CPP/7zip/Archive/Com/ComHandler.cpp +0 -239
  764. data/ext/p7zip/CPP/7zip/Archive/Com/ComHandler.h +0 -28
  765. data/ext/p7zip/CPP/7zip/Archive/Com/ComIn.cpp +0 -389
  766. data/ext/p7zip/CPP/7zip/Archive/Com/ComIn.h +0 -119
  767. data/ext/p7zip/CPP/7zip/Archive/Com/ComRegister.cpp +0 -13
  768. data/ext/p7zip/CPP/7zip/Archive/Common/CoderMixer2MT.cpp +0 -240
  769. data/ext/p7zip/CPP/7zip/Archive/Common/CoderMixer2MT.h +0 -80
  770. data/ext/p7zip/CPP/7zip/Archive/Common/CoderMixer2ST.cpp +0 -239
  771. data/ext/p7zip/CPP/7zip/Archive/Common/CoderMixer2ST.h +0 -88
  772. data/ext/p7zip/CPP/7zip/Archive/Common/CrossThreadProgress.cpp +0 -15
  773. data/ext/p7zip/CPP/7zip/Archive/Common/CrossThreadProgress.h +0 -37
  774. data/ext/p7zip/CPP/7zip/Archive/DebHandler.cpp +0 -413
  775. data/ext/p7zip/CPP/7zip/Archive/Hfs/HfsHandler.cpp +0 -243
  776. data/ext/p7zip/CPP/7zip/Archive/Hfs/HfsHandler.h +0 -26
  777. data/ext/p7zip/CPP/7zip/Archive/Hfs/HfsIn.cpp +0 -480
  778. data/ext/p7zip/CPP/7zip/Archive/Hfs/HfsIn.h +0 -154
  779. data/ext/p7zip/CPP/7zip/Archive/Hfs/HfsRegister.cpp +0 -13
  780. data/ext/p7zip/CPP/7zip/Archive/Rar/RarHeader.cpp +0 -21
  781. data/ext/p7zip/CPP/7zip/Archive/Rar/RarIn.cpp +0 -478
  782. data/ext/p7zip/CPP/7zip/Archive/Rar/RarIn.h +0 -123
  783. data/ext/p7zip/CPP/7zip/Archive/Rar/RarItem.cpp +0 -55
  784. data/ext/p7zip/CPP/7zip/Archive/Rar/RarRegister.cpp +0 -13
  785. data/ext/p7zip/CPP/7zip/Archive/Rar/RarVolumeInStream.cpp +0 -78
  786. data/ext/p7zip/CPP/7zip/Archive/Rar/RarVolumeInStream.h +0 -49
  787. data/ext/p7zip/CPP/7zip/Archive/Udf/UdfRegister.cpp +0 -13
  788. data/ext/p7zip/CPP/7zip/Archive/Zip/ZipHeader.cpp +0 -36
  789. data/ext/p7zip/CPP/7zip/Archive/Zip/ZipItemEx.h +0 -34
  790. data/ext/p7zip/CPP/7zip/CMAKE/CMakeLists_7zFM.txt +0 -163
  791. data/ext/p7zip/CPP/7zip/CMAKE/CMakeLists_7zG.txt +0 -131
  792. data/ext/p7zip/CPP/7zip/CMAKE/CMakeLists_7za.txt +0 -253
  793. data/ext/p7zip/CPP/7zip/CMAKE/CMakeLists_ALL.txt +0 -32
  794. data/ext/p7zip/CPP/7zip/CMAKE/CMakeLists_Format7zFree.txt +0 -290
  795. data/ext/p7zip/CPP/7zip/CMAKE/generate.sh +0 -37
  796. data/ext/p7zip/CPP/7zip/CMAKE/generate_xcode.sh +0 -32
  797. data/ext/p7zip/CPP/7zip/Common/LockedStream.cpp +0 -23
  798. data/ext/p7zip/CPP/7zip/Common/LockedStream.h +0 -38
  799. data/ext/p7zip/CPP/7zip/Compress/ArjDecoder1.cpp +0 -309
  800. data/ext/p7zip/CPP/7zip/Compress/ArjDecoder1.h +0 -98
  801. data/ext/p7zip/CPP/7zip/Compress/ArjDecoder2.cpp +0 -90
  802. data/ext/p7zip/CPP/7zip/Compress/ArjDecoder2.h +0 -59
  803. data/ext/p7zip/CPP/7zip/Compress/BranchCoder.cpp +0 -19
  804. data/ext/p7zip/CPP/7zip/Compress/BranchCoder.h +0 -44
  805. data/ext/p7zip/CPP/7zip/Compress/DllExports.cpp +0 -39
  806. data/ext/p7zip/CPP/7zip/Compress/LZMA_Alone/LzmaAlone.cpp +0 -531
  807. data/ext/p7zip/CPP/7zip/Compress/LZMA_Alone/LzmaBench.cpp +0 -1018
  808. data/ext/p7zip/CPP/7zip/Compress/LZMA_Alone/LzmaBench.h +0 -48
  809. data/ext/p7zip/CPP/7zip/Compress/LZMA_Alone/LzmaBenchCon.cpp +0 -311
  810. data/ext/p7zip/CPP/7zip/Compress/LZMA_Alone/LzmaBenchCon.h +0 -20
  811. data/ext/p7zip/CPP/7zip/Compress/LZMA_Alone/makefile +0 -173
  812. data/ext/p7zip/CPP/7zip/Compress/Lzx86Converter.cpp +0 -90
  813. data/ext/p7zip/CPP/7zip/Compress/Lzx86Converter.h +0 -46
  814. data/ext/p7zip/CPP/7zip/Compress/RangeCoder.h +0 -205
  815. data/ext/p7zip/CPP/7zip/Compress/RangeCoderBit.h +0 -114
  816. data/ext/p7zip/CPP/7zip/Crypto/Sha1.cpp +0 -229
  817. data/ext/p7zip/CPP/7zip/Crypto/Sha1.h +0 -68
  818. data/ext/p7zip/CPP/7zip/PREMAKE/generate.sh +0 -18
  819. data/ext/p7zip/CPP/7zip/PREMAKE/premake4.lua +0 -263
  820. data/ext/p7zip/CPP/7zip/QMAKE/7ZA/7ZA.pro +0 -228
  821. data/ext/p7zip/CPP/7zip/QMAKE/7ZA/7ZA_osx.pro +0 -228
  822. data/ext/p7zip/CPP/7zip/QMAKE/test_emul/test_emul.pro +0 -26
  823. data/ext/p7zip/CPP/7zip/TEST/TestUI/TestUI.cpp +0 -560
  824. data/ext/p7zip/CPP/7zip/TEST/TestUI/makefile +0 -33
  825. data/ext/p7zip/CPP/7zip/TEST/TestUI/makefile.depend +0 -577
  826. data/ext/p7zip/CPP/7zip/TEST/TestUI/makefile.list +0 -16
  827. data/ext/p7zip/CPP/Common/Buffer.h +0 -77
  828. data/ext/p7zip/CPP/Common/Types.h +0 -11
  829. data/ext/p7zip/CPP/Windows/COM.cpp +0 -37
  830. data/ext/p7zip/CPP/Windows/COM.h +0 -69
  831. data/ext/p7zip/CPP/Windows/Clipboard.cpp +0 -160
  832. data/ext/p7zip/CPP/Windows/Clipboard.h +0 -28
  833. data/ext/p7zip/CPP/Windows/CommonDialog.h +0 -19
  834. data/ext/p7zip/CPP/Windows/Control/ComboBox.h +0 -82
  835. data/ext/p7zip/CPP/Windows/Control/Controls.cpp +0 -515
  836. data/ext/p7zip/CPP/Windows/Control/Dialog.cpp +0 -560
  837. data/ext/p7zip/CPP/Windows/Control/Dialog.h +0 -179
  838. data/ext/p7zip/CPP/Windows/Control/DialogImpl.h +0 -73
  839. data/ext/p7zip/CPP/Windows/Control/Edit.h +0 -24
  840. data/ext/p7zip/CPP/Windows/Control/ListView.h +0 -164
  841. data/ext/p7zip/CPP/Windows/Control/ProgressBar.h +0 -34
  842. data/ext/p7zip/CPP/Windows/Control/Static.h +0 -23
  843. data/ext/p7zip/CPP/Windows/Control/StatusBar.h +0 -56
  844. data/ext/p7zip/CPP/Windows/Control/Window2.cpp +0 -211
  845. data/ext/p7zip/CPP/Windows/Control/Window2.h +0 -111
  846. data/ext/p7zip/CPP/Windows/DLL.cpp +0 -193
  847. data/ext/p7zip/CPP/Windows/DLL.h +0 -48
  848. data/ext/p7zip/CPP/Windows/Error.cpp +0 -58
  849. data/ext/p7zip/CPP/Windows/Error.h +0 -33
  850. data/ext/p7zip/CPP/Windows/Menu.h +0 -4
  851. data/ext/p7zip/CPP/Windows/PropVariantConversions.cpp +0 -142
  852. data/ext/p7zip/CPP/Windows/PropVariantConversions.h +0 -14
  853. data/ext/p7zip/CPP/Windows/Registry.cpp +0 -313
  854. data/ext/p7zip/CPP/Windows/Registry.h +0 -113
  855. data/ext/p7zip/CPP/Windows/ResourceString.h +0 -22
  856. data/ext/p7zip/CPP/Windows/Shell.h +0 -21
  857. data/ext/p7zip/CPP/Windows/Time.cpp +0 -88
  858. data/ext/p7zip/CPP/Windows/Time.h +0 -21
  859. data/ext/p7zip/CPP/Windows/Window.cpp +0 -101
  860. data/ext/p7zip/CPP/Windows/Window.h +0 -43
  861. data/ext/p7zip/CPP/myWindows/initguid.h +0 -4
  862. data/ext/p7zip/CPP/myWindows/makefile +0 -21
  863. data/ext/p7zip/CPP/myWindows/makefile.depend +0 -32
  864. data/ext/p7zip/CPP/myWindows/makefile.list +0 -28
  865. data/ext/p7zip/CPP/myWindows/myAddExeFlag.cpp +0 -20
  866. data/ext/p7zip/CPP/myWindows/myGetTickCount.cpp +0 -8
  867. data/ext/p7zip/CPP/myWindows/mySplitCommandLine.cpp +0 -82
  868. data/ext/p7zip/CPP/myWindows/test_emul.cpp +0 -745
  869. data/ext/p7zip/CPP/myWindows/wine_GetXXXDefaultLangID.cpp +0 -741
  870. data/ext/p7zip/DOCS/MANUAL/switches/charset.htm +0 -49
  871. data/ext/p7zip/DOCS/Methods.txt +0 -152
  872. data/ext/p7zip/DOCS/lzma.txt +0 -598
  873. data/ext/p7zip/contrib/VirtualFileSystemForMidnightCommander/ChangeLog +0 -41
  874. data/ext/p7zip/contrib/VirtualFileSystemForMidnightCommander/readme +0 -21
  875. data/ext/p7zip/contrib/VirtualFileSystemForMidnightCommander/readme.u7z +0 -30
  876. data/ext/p7zip/contrib/VirtualFileSystemForMidnightCommander/u7z +0 -133
  877. data/ext/p7zip/contrib/gzip-like_CLI_wrapper_for_7z/README +0 -21
  878. data/ext/p7zip/contrib/gzip-like_CLI_wrapper_for_7z/check/check.sh +0 -117
  879. data/ext/p7zip/contrib/gzip-like_CLI_wrapper_for_7z/check/files.tar +0 -0
  880. data/ext/p7zip/contrib/gzip-like_CLI_wrapper_for_7z/man1/p7zip.1 +0 -33
  881. data/ext/p7zip/contrib/gzip-like_CLI_wrapper_for_7z/p7zip +0 -144
  882. data/ext/p7zip/contrib/qnx630sp3/qnx630sp3-shared +0 -14
  883. data/ext/p7zip/contrib/qnx630sp3/qnx630sp3-static +0 -10
  884. data/ext/p7zip/integration_context_menu.txt +0 -51
  885. data/ext/p7zip/makefile.rules +0 -661
  886. /data/ext/p7zip/{DOCS → DOC}/7zFormat.txt +0 -0
  887. /data/ext/p7zip/{DOCS → DOC}/unRarLicense.txt +0 -0
@@ -4,15 +4,15 @@
4
4
 
5
5
  #include "../../../../C/CpuArch.h"
6
6
 
7
- #include "../../Common/LimitedStreams.h"
8
- #include "../../Common/ProgressUtils.h"
7
+ #include "../../../Common/Wildcard.h"
9
8
 
10
9
  #include "../../Common/CreateCoder.h"
10
+ #include "../../Common/LimitedStreams.h"
11
+ #include "../../Common/ProgressUtils.h"
11
12
 
12
13
  #include "../../Compress/CopyCoder.h"
13
14
 
14
15
  #include "../Common/ItemNameUtils.h"
15
- #include "../Common/OutStreamWithCRC.h"
16
16
 
17
17
  #include "7zDecode.h"
18
18
  #include "7zEncode.h"
@@ -28,18 +28,396 @@
28
28
  namespace NArchive {
29
29
  namespace N7z {
30
30
 
31
- static const UInt64 k_LZMA = 0x030101;
32
- static const UInt64 k_BCJ = 0x03030103;
33
- static const UInt64 k_BCJ2 = 0x0303011B;
34
31
 
35
- static const wchar_t *kMatchFinderForBCJ2_LZMA = L"BT2";
36
- static const UInt32 kDictionaryForBCJ2_LZMA = 1 << 20;
37
- static const UInt32 kAlgorithmForBCJ2_LZMA = 1;
38
- static const UInt32 kNumFastBytesForBCJ2_LZMA = 64;
32
+ #define k_X86 k_BCJ
33
+
34
+ struct CFilterMode
35
+ {
36
+ UInt32 Id;
37
+ UInt32 Delta;
38
+
39
+ CFilterMode(): Id(0), Delta(0) {}
40
+
41
+ void SetDelta()
42
+ {
43
+ if (Id == k_IA64)
44
+ Delta = 16;
45
+ else if (Id == k_ARM || Id == k_PPC || Id == k_PPC)
46
+ Delta = 4;
47
+ else if (Id == k_ARMT)
48
+ Delta = 2;
49
+ else
50
+ Delta = 0;
51
+ }
52
+ };
53
+
54
+
55
+ /* ---------- PE ---------- */
56
+
57
+ #define MZ_SIG 0x5A4D
58
+
59
+ #define PE_SIG 0x00004550
60
+ #define PE_OptHeader_Magic_32 0x10B
61
+ #define PE_OptHeader_Magic_64 0x20B
62
+ #define PE_SectHeaderSize 40
63
+ #define PE_SECT_EXECUTE 0x20000000
64
+
65
+ static int Parse_EXE(const Byte *buf, size_t size, CFilterMode *filterMode)
66
+ {
67
+ if (size < 512 || GetUi16(buf) != MZ_SIG)
68
+ return 0;
69
+
70
+ const Byte *p;
71
+ UInt32 peOffset, optHeaderSize, filterId;
72
+
73
+ peOffset = GetUi32(buf + 0x3C);
74
+ if (peOffset >= 0x1000 || peOffset + 512 > size || (peOffset & 7) != 0)
75
+ return 0;
76
+ p = buf + peOffset;
77
+ if (GetUi32(p) != PE_SIG)
78
+ return 0;
79
+ p += 4;
80
+
81
+ switch (GetUi16(p))
82
+ {
83
+ case 0x014C:
84
+ case 0x8664: filterId = k_X86; break;
85
+
86
+ /*
87
+ IMAGE_FILE_MACHINE_ARM 0x01C0 // ARM LE
88
+ IMAGE_FILE_MACHINE_THUMB 0x01C2 // ARM Thumb / Thumb-2 LE
89
+ IMAGE_FILE_MACHINE_ARMNT 0x01C4 // ARM Thumb-2, LE
90
+ Note: We use ARM filter for 0x01C2. (WinCE 5 - 0x01C2) files mostly contain ARM code (not Thumb/Thumb-2).
91
+ */
92
+
93
+ case 0x01C0: // WinCE old
94
+ case 0x01C2: filterId = k_ARM; break; // WinCE new
95
+ case 0x01C4: filterId = k_ARMT; break; // WinRT
96
+
97
+ case 0x0200: filterId = k_IA64; break;
98
+ default: return 0;
99
+ }
100
+
101
+ optHeaderSize = GetUi16(p + 16);
102
+ if (optHeaderSize > (1 << 10))
103
+ return 0;
104
+
105
+ p += 20; /* headerSize */
106
+
107
+ switch (GetUi16(p))
108
+ {
109
+ case PE_OptHeader_Magic_32:
110
+ case PE_OptHeader_Magic_64:
111
+ break;
112
+ default:
113
+ return 0;
114
+ }
115
+
116
+ filterMode->Id = filterId;
117
+ return 1;
118
+ }
119
+
120
+
121
+ /* ---------- ELF ---------- */
122
+
123
+ #define ELF_SIG 0x464C457F
124
+
125
+ #define ELF_CLASS_32 1
126
+ #define ELF_CLASS_64 2
127
+
128
+ #define ELF_DATA_2LSB 1
129
+ #define ELF_DATA_2MSB 2
130
+
131
+ static UInt16 Get16(const Byte *p, Bool be) { if (be) return (UInt16)GetBe16(p); return (UInt16)GetUi16(p); }
132
+ static UInt32 Get32(const Byte *p, Bool be) { if (be) return GetBe32(p); return GetUi32(p); }
133
+ // static UInt64 Get64(const Byte *p, Bool be) { if (be) return GetBe64(p); return GetUi64(p); }
134
+
135
+ static int Parse_ELF(const Byte *buf, size_t size, CFilterMode *filterMode)
136
+ {
137
+ Bool /* is32, */ be;
138
+ UInt32 filterId;
139
+
140
+ if (size < 512 || buf[6] != 1) /* ver */
141
+ return 0;
142
+
143
+ if (GetUi32(buf) != ELF_SIG)
144
+ return 0;
145
+
146
+ switch (buf[4])
147
+ {
148
+ case ELF_CLASS_32: /* is32 = True; */ break;
149
+ case ELF_CLASS_64: /* is32 = False; */ break;
150
+ default: return 0;
151
+ }
152
+
153
+ switch (buf[5])
154
+ {
155
+ case ELF_DATA_2LSB: be = False; break;
156
+ case ELF_DATA_2MSB: be = True; break;
157
+ default: return 0;
158
+ }
159
+
160
+ switch (Get16(buf + 0x12, be))
161
+ {
162
+ case 3:
163
+ case 6:
164
+ case 62: filterId = k_X86; break;
165
+ case 2:
166
+ case 18:
167
+ case 43: filterId = k_SPARC; break;
168
+ case 20:
169
+ case 21: if (!be) return 0; filterId = k_PPC; break;
170
+ case 40: if ( be) return 0; filterId = k_ARM; break;
171
+
172
+ /* Some IA-64 ELF exacutable have size that is not aligned for 16 bytes.
173
+ So we don't use IA-64 filter for IA-64 ELF */
174
+ // case 50: if ( be) return 0; filterId = k_IA64; break;
175
+
176
+ default: return 0;
177
+ }
178
+
179
+ filterMode->Id = filterId;
180
+ return 1;
181
+ }
182
+
183
+
184
+
185
+ /* ---------- Mach-O ---------- */
186
+
187
+ #define MACH_SIG_BE_32 0xCEFAEDFE
188
+ #define MACH_SIG_BE_64 0xCFFAEDFE
189
+ #define MACH_SIG_LE_32 0xFEEDFACE
190
+ #define MACH_SIG_LE_64 0xFEEDFACF
191
+
192
+ #define MACH_ARCH_ABI64 (1 << 24)
193
+ #define MACH_MACHINE_386 7
194
+ #define MACH_MACHINE_ARM 12
195
+ #define MACH_MACHINE_SPARC 14
196
+ #define MACH_MACHINE_PPC 18
197
+ #define MACH_MACHINE_PPC64 (MACH_ARCH_ABI64 | MACH_MACHINE_PPC)
198
+ #define MACH_MACHINE_AMD64 (MACH_ARCH_ABI64 | MACH_MACHINE_386)
199
+
200
+ static unsigned Parse_MACH(const Byte *buf, size_t size, CFilterMode *filterMode)
201
+ {
202
+ UInt32 filterId, numCommands, commandsSize;
203
+
204
+ if (size < 512)
205
+ return 0;
206
+
207
+ Bool /* mode64, */ be;
208
+ switch (GetUi32(buf))
209
+ {
210
+ case MACH_SIG_BE_32: /* mode64 = False; */ be = True; break;
211
+ case MACH_SIG_BE_64: /* mode64 = True; */ be = True; break;
212
+ case MACH_SIG_LE_32: /* mode64 = False; */ be = False; break;
213
+ case MACH_SIG_LE_64: /* mode64 = True; */ be = False; break;
214
+ default: return 0;
215
+ }
216
+
217
+ switch (Get32(buf + 4, be))
218
+ {
219
+ case MACH_MACHINE_386:
220
+ case MACH_MACHINE_AMD64: filterId = k_X86; break;
221
+ case MACH_MACHINE_ARM: if ( be) return 0; filterId = k_ARM; break;
222
+ case MACH_MACHINE_SPARC: if (!be) return 0; filterId = k_SPARC; break;
223
+ case MACH_MACHINE_PPC:
224
+ case MACH_MACHINE_PPC64: if (!be) return 0; filterId = k_PPC; break;
225
+ default: return 0;
226
+ }
227
+
228
+ numCommands = Get32(buf + 0x10, be);
229
+ commandsSize = Get32(buf + 0x14, be);
230
+
231
+ if (commandsSize > (1 << 24) || numCommands > (1 << 18))
232
+ return 0;
233
+
234
+ filterMode->Id = filterId;
235
+ return 1;
236
+ }
237
+
238
+
239
+ /* ---------- WAV ---------- */
240
+
241
+ #define WAV_SUBCHUNK_fmt 0x20746D66
242
+ #define WAV_SUBCHUNK_data 0x61746164
243
+
244
+ #define RIFF_SIG 0x46464952
245
+
246
+ static Bool Parse_WAV(const Byte *buf, size_t size, CFilterMode *filterMode)
247
+ {
248
+ UInt32 subChunkSize, pos;
249
+ if (size < 0x2C)
250
+ return False;
251
+
252
+ if (GetUi32(buf + 0) != RIFF_SIG ||
253
+ GetUi32(buf + 8) != 0x45564157 || // WAVE
254
+ GetUi32(buf + 0xC) != WAV_SUBCHUNK_fmt)
255
+ return False;
256
+ subChunkSize = GetUi32(buf + 0x10);
257
+ /* [0x14 = format] = 1 (PCM) */
258
+ if (subChunkSize < 0x10 || subChunkSize > 0x12 || GetUi16(buf + 0x14) != 1)
259
+ return False;
260
+
261
+ unsigned numChannels = GetUi16(buf + 0x16);
262
+ unsigned bitsPerSample = GetUi16(buf + 0x22);
263
+
264
+ if ((bitsPerSample & 0x7) != 0 || bitsPerSample >= 256 || numChannels >= 256)
265
+ return False;
266
+
267
+ pos = 0x14 + subChunkSize;
268
+
269
+ const int kNumSubChunksTests = 10;
270
+ // Do we need to scan more than 3 sub-chunks?
271
+ for (int i = 0; i < kNumSubChunksTests; i++)
272
+ {
273
+ if (pos + 8 > size)
274
+ return False;
275
+ subChunkSize = GetUi32(buf + pos + 4);
276
+ if (GetUi32(buf + pos) == WAV_SUBCHUNK_data)
277
+ {
278
+ unsigned delta = numChannels * (bitsPerSample >> 3);
279
+ if (delta >= 256)
280
+ return False;
281
+ filterMode->Id = k_Delta;
282
+ filterMode->Delta = delta;
283
+ return True;
284
+ }
285
+ if (subChunkSize > (1 << 16))
286
+ return False;
287
+ pos += subChunkSize + 8;
288
+ }
289
+ return False;
290
+ }
291
+
292
+ static Bool ParseFile(const Byte *buf, size_t size, CFilterMode *filterMode)
293
+ {
294
+ filterMode->Id = 0;
295
+ filterMode->Delta = 0;
296
+
297
+ if (Parse_EXE(buf, size, filterMode)) return True;
298
+ if (Parse_ELF(buf, size, filterMode)) return True;
299
+ if (Parse_MACH(buf, size, filterMode)) return True;
300
+ return Parse_WAV(buf, size, filterMode);
301
+ }
302
+
303
+
304
+
305
+
306
+ struct CFilterMode2: public CFilterMode
307
+ {
308
+ bool Encrypted;
309
+ unsigned GroupIndex;
310
+
311
+ CFilterMode2(): Encrypted(false) {}
312
+
313
+ int Compare(const CFilterMode2 &m) const
314
+ {
315
+ if (!Encrypted)
316
+ {
317
+ if (m.Encrypted)
318
+ return -1;
319
+ }
320
+ else if (!m.Encrypted)
321
+ return 1;
322
+
323
+ if (Id < m.Id) return -1;
324
+ if (Id > m.Id) return 1;
325
+
326
+ if (Delta < m.Delta) return -1;
327
+ if (Delta > m.Delta) return 1;
328
+
329
+ return 0;
330
+ }
331
+
332
+ bool operator ==(const CFilterMode2 &m) const
333
+ {
334
+ return Id == m.Id && Delta == m.Delta && Encrypted == m.Encrypted;
335
+ }
336
+ };
337
+
338
+ static unsigned GetGroup(CRecordVector<CFilterMode2> &filters, const CFilterMode2 &m)
339
+ {
340
+ unsigned i;
341
+ for (i = 0; i < filters.Size(); i++)
342
+ {
343
+ const CFilterMode2 &m2 = filters[i];
344
+ if (m == m2)
345
+ return i;
346
+ /*
347
+ if (m.Encrypted != m2.Encrypted)
348
+ {
349
+ if (!m.Encrypted)
350
+ break;
351
+ continue;
352
+ }
353
+
354
+ if (m.Id < m2.Id) break;
355
+ if (m.Id != m2.Id) continue;
356
+
357
+ if (m.Delta < m2.Delta) break;
358
+ if (m.Delta != m2.Delta) continue;
359
+ */
360
+ }
361
+ // filters.Insert(i, m);
362
+ // return i;
363
+ return filters.Add(m);
364
+ }
365
+
366
+ static inline bool Is86Filter(CMethodId m)
367
+ {
368
+ return (m == k_BCJ || m == k_BCJ2);
369
+ }
370
+
371
+ static inline bool IsExeFilter(CMethodId m)
372
+ {
373
+ switch (m)
374
+ {
375
+ case k_BCJ:
376
+ case k_BCJ2:
377
+ case k_ARM:
378
+ case k_ARMT:
379
+ case k_PPC:
380
+ case k_SPARC:
381
+ case k_IA64:
382
+ return true;
383
+ }
384
+ return false;
385
+ }
386
+
387
+ static unsigned Get_FilterGroup_for_Folder(
388
+ CRecordVector<CFilterMode2> &filters, const CFolderEx &f, bool extractFilter)
389
+ {
390
+ CFilterMode2 m;
391
+ m.Id = 0;
392
+ m.Delta = 0;
393
+ m.Encrypted = f.IsEncrypted();
394
+
395
+ if (extractFilter)
396
+ {
397
+ const CCoderInfo &coder = f.Coders[f.UnpackCoder];
398
+
399
+ if (coder.MethodID == k_Delta)
400
+ {
401
+ if (coder.Props.Size() == 1)
402
+ {
403
+ m.Delta = (unsigned)coder.Props[0] + 1;
404
+ m.Id = k_Delta;
405
+ }
406
+ }
407
+ else if (IsExeFilter(coder.MethodID))
408
+ {
409
+ m.Id = (UInt32)coder.MethodID;
410
+ if (m.Id == k_BCJ2)
411
+ m.Id = k_BCJ;
412
+ m.SetDelta();
413
+ }
414
+ }
415
+
416
+ return GetGroup(filters, m);
417
+ }
418
+
419
+
39
420
 
40
- #ifdef MY_CPU_X86_OR_AMD64
41
- #define USE_86_FILTER
42
- #endif
43
421
 
44
422
  static HRESULT WriteRange(IInStream *inStream, ISequentialOutStream *outStream,
45
423
  UInt64 position, UInt64 size, ICompressProgressInfo *progress)
@@ -56,34 +434,27 @@ static HRESULT WriteRange(IInStream *inStream, ISequentialOutStream *outStream,
56
434
  return (copyCoderSpec->TotalSize == size ? S_OK : E_FAIL);
57
435
  }
58
436
 
59
- static int GetReverseSlashPos(const UString &name)
60
- {
61
- int slashPos = name.ReverseFind(L'/');
62
- #ifdef _WIN32
63
- int slash1Pos = name.ReverseFind(L'\\');
64
- slashPos = MyMax(slashPos, slash1Pos);
65
- #endif
66
- return slashPos;
67
- }
68
-
69
- int CUpdateItem::GetExtensionPos() const
437
+ /*
438
+ unsigned CUpdateItem::GetExtensionPos() const
70
439
  {
71
- int slashPos = GetReverseSlashPos(Name);
72
- int dotPos = Name.ReverseFind(L'.');
73
- if (dotPos < 0 || (dotPos < slashPos && slashPos >= 0))
74
- return Name.Length();
440
+ int slashPos = Name.ReverseFind_PathSepar();
441
+ int dotPos = Name.ReverseFind_Dot();
442
+ if (dotPos <= slashPos)
443
+ return Name.Len();
75
444
  return dotPos + 1;
76
445
  }
77
446
 
78
447
  UString CUpdateItem::GetExtension() const
79
448
  {
80
- return Name.Mid(GetExtensionPos());
449
+ return Name.Ptr(GetExtensionPos());
81
450
  }
451
+ */
82
452
 
83
453
  #define RINOZ(x) { int __tt = (x); if (__tt != 0) return __tt; }
84
454
 
85
455
  #define RINOZ_COMP(a, b) RINOZ(MyCompare(a, b))
86
456
 
457
+ /*
87
458
  static int CompareBuffers(const CByteBuffer &a1, const CByteBuffer &a2)
88
459
  {
89
460
  size_t c1 = a1.GetCapacity();
@@ -102,7 +473,7 @@ static int CompareCoders(const CCoderInfo &c1, const CCoderInfo &c2)
102
473
  return CompareBuffers(c1.Props, c2.Props);
103
474
  }
104
475
 
105
- static int CompareBindPairs(const CBindPair &b1, const CBindPair &b2)
476
+ static int CompareBonds(const CBond &b1, const CBond &b2)
106
477
  {
107
478
  RINOZ_COMP(b1.InIndex, b2.InIndex);
108
479
  return MyCompare(b1.OutIndex, b2.OutIndex);
@@ -116,77 +487,86 @@ static int CompareFolders(const CFolder &f1, const CFolder &f2)
116
487
  int i;
117
488
  for (i = 0; i < s1; i++)
118
489
  RINOZ(CompareCoders(f1.Coders[i], f2.Coders[i]));
119
- s1 = f1.BindPairs.Size();
120
- s2 = f2.BindPairs.Size();
490
+ s1 = f1.Bonds.Size();
491
+ s2 = f2.Bonds.Size();
121
492
  RINOZ_COMP(s1, s2);
122
493
  for (i = 0; i < s1; i++)
123
- RINOZ(CompareBindPairs(f1.BindPairs[i], f2.BindPairs[i]));
494
+ RINOZ(CompareBonds(f1.Bonds[i], f2.Bonds[i]));
124
495
  return 0;
125
496
  }
497
+ */
126
498
 
127
499
  /*
128
500
  static int CompareFiles(const CFileItem &f1, const CFileItem &f2)
129
501
  {
130
- return MyStringCompareNoCase(f1.Name, f2.Name);
502
+ return CompareFileNames(f1.Name, f2.Name);
131
503
  }
132
504
  */
133
505
 
134
506
  struct CFolderRepack
135
507
  {
136
- int FolderIndex;
137
- int Group;
508
+ unsigned FolderIndex;
138
509
  CNum NumCopyFiles;
139
510
  };
140
511
 
141
- static int CompareFolderRepacks(const CFolderRepack *p1, const CFolderRepack *p2, void *param)
512
+ /*
513
+ static int CompareFolderRepacks(const CFolderRepack *p1, const CFolderRepack *p2, void *)
142
514
  {
143
- RINOZ_COMP(p1->Group, p2->Group);
144
515
  int i1 = p1->FolderIndex;
145
516
  int i2 = p2->FolderIndex;
146
- const CArchiveDatabaseEx &db = *(const CArchiveDatabaseEx *)param;
147
- RINOZ(CompareFolders(
148
- db.Folders[i1],
149
- db.Folders[i2]));
517
+ // In that version we don't want to parse folders here, so we don't compare folders
518
+ // probably it must be improved in future
519
+ // const CDbEx &db = *(const CDbEx *)param;
520
+ // RINOZ(CompareFolders(
521
+ // db.Folders[i1],
522
+ // db.Folders[i2]));
523
+
150
524
  return MyCompare(i1, i2);
151
- /*
152
- RINOZ_COMP(
153
- db.NumUnpackStreamsVector[i1],
154
- db.NumUnpackStreamsVector[i2]);
155
- if (db.NumUnpackStreamsVector[i1] == 0)
156
- return 0;
157
- return CompareFiles(
158
- db.Files[db.FolderStartFileIndex[i1]],
159
- db.Files[db.FolderStartFileIndex[i2]]);
160
- */
525
+
526
+ // RINOZ_COMP(
527
+ // db.NumUnpackStreamsVector[i1],
528
+ // db.NumUnpackStreamsVector[i2]);
529
+ // if (db.NumUnpackStreamsVector[i1] == 0)
530
+ // return 0;
531
+ // return CompareFiles(
532
+ // db.Files[db.FolderStartFileIndex[i1]],
533
+ // db.Files[db.FolderStartFileIndex[i2]]);
161
534
  }
535
+ */
162
536
 
163
- ////////////////////////////////////////////////////////////
537
+ /*
538
+ we sort empty files and dirs in such order:
539
+ - Dir.NonAnti (name sorted)
540
+ - File.NonAnti (name sorted)
541
+ - File.Anti (name sorted)
542
+ - Dir.Anti (reverse name sorted)
543
+ */
164
544
 
165
- static int CompareEmptyItems(const int *p1, const int *p2, void *param)
545
+ static int CompareEmptyItems(const unsigned *p1, const unsigned *p2, void *param)
166
546
  {
167
547
  const CObjectVector<CUpdateItem> &updateItems = *(const CObjectVector<CUpdateItem> *)param;
168
548
  const CUpdateItem &u1 = updateItems[*p1];
169
549
  const CUpdateItem &u2 = updateItems[*p2];
550
+ // NonAnti < Anti
551
+ if (u1.IsAnti != u2.IsAnti)
552
+ return (u1.IsAnti ? 1 : -1);
170
553
  if (u1.IsDir != u2.IsDir)
171
- return (u1.IsDir) ? 1 : -1;
172
- if (u1.IsDir)
173
554
  {
174
- if (u1.IsAnti != u2.IsAnti)
555
+ // Dir.NonAnti < File < Dir.Anti
556
+ if (u1.IsDir)
175
557
  return (u1.IsAnti ? 1 : -1);
176
- int n = MyStringCompareNoCase(u1.Name, u2.Name);
177
- return -n;
558
+ return (u2.IsAnti ? -1 : 1);
178
559
  }
179
- if (u1.IsAnti != u2.IsAnti)
180
- return (u1.IsAnti ? 1 : -1);
181
- return MyStringCompareNoCase(u1.Name, u2.Name);
560
+ int n = CompareFileNames(u1.Name, u2.Name);
561
+ return (u1.IsDir && u1.IsAnti) ? -n : n;
182
562
  }
183
563
 
184
564
  static const char *g_Exts =
185
- " lzma 7z ace arc arj bz bz2 deb lzo lzx gz pak rpm sit tgz tbz tbz2 tgz cab ha lha lzh rar zoo"
565
+ " 7z xz lzma ace arc arj bz tbz bz2 tbz2 cab deb gz tgz ha lha lzh lzo lzx pak rar rpm sit zoo"
186
566
  " zip jar ear war msi"
187
567
  " 3gp avi mov mpeg mpg mpe wmv"
188
568
  " aac ape fla flac la mp3 m4a mp4 ofr ogg pac ra rm rka shn swa tta wv wma wav"
189
- " swf "
569
+ " swf"
190
570
  " chm hxi hxs"
191
571
  " gif jpeg jpg jp2 png tiff bmp ico psd psp"
192
572
  " awg ps eps cgm dxf svg vrml wmf emf ai md"
@@ -195,25 +575,28 @@ static const char *g_Exts =
195
575
  " iso bin nrg mdf img pdi tar cpio xpi"
196
576
  " vfd vhd vud vmc vsv"
197
577
  " vmdk dsk nvram vmem vmsd vmsn vmss vmtm"
198
- " inl inc idl acf asa h hpp hxx c cpp cxx rc java cs pas bas vb cls ctl frm dlg def"
578
+ " inl inc idl acf asa"
579
+ " h hpp hxx c cpp cxx m mm go swift"
580
+ " rc java cs rs pas bas vb cls ctl frm dlg def"
199
581
  " f77 f f90 f95"
200
- " asm sql manifest dep "
201
- " mak clw csproj vcproj sln dsp dsw "
202
- " class "
203
- " bat cmd"
582
+ " asm s"
583
+ " sql manifest dep"
584
+ " mak clw csproj vcproj sln dsp dsw"
585
+ " class"
586
+ " bat cmd bash sh"
204
587
  " xml xsd xsl xslt hxk hxc htm html xhtml xht mht mhtml htw asp aspx css cgi jsp shtml"
205
- " awk sed hta js php php3 php4 php5 phptml pl pm py pyo rb sh tcl vbs"
588
+ " awk sed hta js json php php3 php4 php5 phptml pl pm py pyo rb tcl ts vbs"
206
589
  " text txt tex ans asc srt reg ini doc docx mcw dot rtf hlp xls xlr xlt xlw ppt pdf"
207
590
  " sxc sxd sxi sxg sxw stc sti stw stm odt ott odg otg odp otp ods ots odf"
208
591
  " abw afp cwk lwp wpd wps wpt wrf wri"
209
592
  " abf afm bdf fon mgf otf pcf pfa snf ttf"
210
593
  " dbf mdb nsf ntf wdb db fdb gdb"
211
- " exe dll ocx vbx sfx sys tlb awx com obj lib out o so "
594
+ " exe dll ocx vbx sfx sys tlb awx com obj lib out o so"
212
595
  " pdb pch idb ncb opt";
213
596
 
214
- int GetExtIndex(const char *ext)
597
+ static unsigned GetExtIndex(const char *ext)
215
598
  {
216
- int extIndex = 1;
599
+ unsigned extIndex = 1;
217
600
  const char *p = g_Exts;
218
601
  for (;;)
219
602
  {
@@ -222,7 +605,7 @@ int GetExtIndex(const char *ext)
222
605
  return extIndex;
223
606
  if (c == ' ')
224
607
  continue;
225
- int pos = 0;
608
+ unsigned pos = 0;
226
609
  for (;;)
227
610
  {
228
611
  char c2 = ext[pos++];
@@ -248,9 +631,11 @@ struct CRefItem
248
631
  {
249
632
  const CUpdateItem *UpdateItem;
250
633
  UInt32 Index;
251
- UInt32 ExtensionPos;
252
- UInt32 NamePos;
253
- int ExtensionIndex;
634
+ unsigned ExtensionPos;
635
+ unsigned NamePos;
636
+ unsigned ExtensionIndex;
637
+
638
+ CRefItem() {};
254
639
  CRefItem(UInt32 index, const CUpdateItem &ui, bool sortByType):
255
640
  UpdateItem(&ui),
256
641
  Index(index),
@@ -260,92 +645,168 @@ struct CRefItem
260
645
  {
261
646
  if (sortByType)
262
647
  {
263
- int slashPos = GetReverseSlashPos(ui.Name);
264
- NamePos = ((slashPos >= 0) ? (slashPos + 1) : 0);
265
- int dotPos = ui.Name.ReverseFind(L'.');
266
- if (dotPos < 0 || (dotPos < slashPos && slashPos >= 0))
267
- ExtensionPos = ui.Name.Length();
648
+ int slashPos = ui.Name.ReverseFind_PathSepar();
649
+ NamePos = slashPos + 1;
650
+ int dotPos = ui.Name.ReverseFind_Dot();
651
+ if (dotPos <= slashPos)
652
+ ExtensionPos = ui.Name.Len();
268
653
  else
269
654
  {
270
655
  ExtensionPos = dotPos + 1;
271
- UString us = ui.Name.Mid(ExtensionPos);
272
- if (!us.IsEmpty())
656
+ if (ExtensionPos != ui.Name.Len())
273
657
  {
274
- us.MakeLower();
275
- int i;
276
658
  AString s;
277
- for (i = 0; i < us.Length(); i++)
659
+ for (unsigned pos = ExtensionPos;; pos++)
278
660
  {
279
- wchar_t c = us[i];
661
+ wchar_t c = ui.Name[pos];
280
662
  if (c >= 0x80)
281
663
  break;
282
- s += (char)c;
664
+ if (c == 0)
665
+ {
666
+ ExtensionIndex = GetExtIndex(s);
667
+ break;
668
+ }
669
+ s += (char)MyCharLower_Ascii((char)c);
283
670
  }
284
- if (i == us.Length())
285
- ExtensionIndex = GetExtIndex(s);
286
- else
287
- ExtensionIndex = 0;
288
671
  }
289
672
  }
290
673
  }
291
674
  }
292
675
  };
293
676
 
677
+ struct CSortParam
678
+ {
679
+ // const CObjectVector<CTreeFolder> *TreeFolders;
680
+ bool SortByType;
681
+ };
682
+
683
+ /*
684
+ we sort files in such order:
685
+ - Dir.NonAnti (name sorted)
686
+ - alt streams
687
+ - Dirs
688
+ - Dir.Anti (reverse name sorted)
689
+ */
690
+
691
+
294
692
  static int CompareUpdateItems(const CRefItem *p1, const CRefItem *p2, void *param)
295
693
  {
296
694
  const CRefItem &a1 = *p1;
297
695
  const CRefItem &a2 = *p2;
298
696
  const CUpdateItem &u1 = *a1.UpdateItem;
299
697
  const CUpdateItem &u2 = *a2.UpdateItem;
300
- int n;
698
+
699
+ /*
700
+ if (u1.IsAltStream != u2.IsAltStream)
701
+ return u1.IsAltStream ? 1 : -1;
702
+ */
703
+
704
+ // Actually there are no dirs that time. They were stored in other steps
705
+ // So that code is unused?
301
706
  if (u1.IsDir != u2.IsDir)
302
- return (u1.IsDir) ? 1 : -1;
707
+ return u1.IsDir ? 1 : -1;
303
708
  if (u1.IsDir)
304
709
  {
305
710
  if (u1.IsAnti != u2.IsAnti)
306
711
  return (u1.IsAnti ? 1 : -1);
307
- n = MyStringCompareNoCase(u1.Name, u2.Name);
712
+ int n = CompareFileNames(u1.Name, u2.Name);
308
713
  return -n;
309
714
  }
310
- bool sortByType = *(bool *)param;
715
+
716
+ // bool sortByType = *(bool *)param;
717
+ const CSortParam *sortParam = (const CSortParam *)param;
718
+ bool sortByType = sortParam->SortByType;
311
719
  if (sortByType)
312
720
  {
313
721
  RINOZ_COMP(a1.ExtensionIndex, a2.ExtensionIndex);
314
- RINOZ(MyStringCompareNoCase(u1.Name + a1.ExtensionPos, u2.Name + a2.ExtensionPos));
315
- RINOZ(MyStringCompareNoCase(u1.Name + a1.NamePos, u2.Name + a2.NamePos));
722
+ RINOZ(CompareFileNames(u1.Name.Ptr(a1.ExtensionPos), u2.Name.Ptr(a2.ExtensionPos)));
723
+ RINOZ(CompareFileNames(u1.Name.Ptr(a1.NamePos), u2.Name.Ptr(a2.NamePos)));
316
724
  if (!u1.MTimeDefined && u2.MTimeDefined) return 1;
317
725
  if (u1.MTimeDefined && !u2.MTimeDefined) return -1;
318
726
  if (u1.MTimeDefined && u2.MTimeDefined) RINOZ_COMP(u1.MTime, u2.MTime);
319
727
  RINOZ_COMP(u1.Size, u2.Size);
320
728
  }
321
- return MyStringCompareNoCase(u1.Name, u2.Name);
729
+ /*
730
+ int par1 = a1.UpdateItem->ParentFolderIndex;
731
+ int par2 = a2.UpdateItem->ParentFolderIndex;
732
+ const CTreeFolder &tf1 = (*sortParam->TreeFolders)[par1];
733
+ const CTreeFolder &tf2 = (*sortParam->TreeFolders)[par2];
734
+
735
+ int b1 = tf1.SortIndex, e1 = tf1.SortIndexEnd;
736
+ int b2 = tf2.SortIndex, e2 = tf2.SortIndexEnd;
737
+ if (b1 < b2)
738
+ {
739
+ if (e1 <= b2)
740
+ return -1;
741
+ // p2 in p1
742
+ int par = par2;
743
+ for (;;)
744
+ {
745
+ const CTreeFolder &tf = (*sortParam->TreeFolders)[par];
746
+ par = tf.Parent;
747
+ if (par == par1)
748
+ {
749
+ RINOZ(CompareFileNames(u1.Name, tf.Name));
750
+ break;
751
+ }
752
+ }
753
+ }
754
+ else if (b2 < b1)
755
+ {
756
+ if (e2 <= b1)
757
+ return 1;
758
+ // p1 in p2
759
+ int par = par1;
760
+ for (;;)
761
+ {
762
+ const CTreeFolder &tf = (*sortParam->TreeFolders)[par];
763
+ par = tf.Parent;
764
+ if (par == par2)
765
+ {
766
+ RINOZ(CompareFileNames(tf.Name, u2.Name));
767
+ break;
768
+ }
769
+ }
770
+ }
771
+ */
772
+ // RINOZ_COMP(a1.UpdateItem->ParentSortIndex, a2.UpdateItem->ParentSortIndex);
773
+ RINOK(CompareFileNames(u1.Name, u2.Name));
774
+ RINOZ_COMP(a1.UpdateItem->IndexInClient, a2.UpdateItem->IndexInClient);
775
+ RINOZ_COMP(a1.UpdateItem->IndexInArchive, a2.UpdateItem->IndexInArchive);
776
+ return 0;
322
777
  }
323
778
 
324
779
  struct CSolidGroup
325
780
  {
326
781
  CRecordVector<UInt32> Indices;
782
+
783
+ CRecordVector<CFolderRepack> folderRefs;
327
784
  };
328
785
 
329
- #ifdef _WIN32
330
- static wchar_t *g_ExeExts[] =
786
+ static const char *g_ExeExts[] =
331
787
  {
332
- L"dll",
333
- L"exe",
334
- L"ocx",
335
- L"sfx",
336
- L"sys"
788
+ "dll"
789
+ , "exe"
790
+ , "ocx"
791
+ , "sfx"
792
+ , "sys"
337
793
  };
338
794
 
339
- static bool IsExeExt(const UString &ext)
795
+ static bool IsExeExt(const wchar_t *ext)
340
796
  {
341
- for (int i = 0; i < sizeof(g_ExeExts) / sizeof(g_ExeExts[0]); i++)
342
- if (ext.CompareNoCase(g_ExeExts[i]) == 0)
797
+ for (unsigned i = 0; i < ARRAY_SIZE(g_ExeExts); i++)
798
+ if (StringsAreEqualNoCase_Ascii(ext, g_ExeExts[i]))
343
799
  return true;
344
800
  return false;
345
801
  }
346
- #else
802
+
803
+ #ifndef _WIN32
347
804
  static bool IsExeFile(const CUpdateItem &ui)
348
805
  {
806
+ int dotPos = ui.Name.ReverseFind(L'.');
807
+ if (dotPos >= 0)
808
+ if (IsExeExt(ui.Name.Ptr(dotPos + 1)) ) return true;
809
+
349
810
  if (ui.Attrib & FILE_ATTRIBUTE_UNIX_EXTENSION) {
350
811
  unsigned short st_mode = ui.Attrib >> 16;
351
812
  if ((st_mode & 00111) && (ui.Size >= 2048))
@@ -355,7 +816,7 @@ static bool IsExeFile(const CUpdateItem &ui)
355
816
  NWindows::NFile::NIO::CInFile file;
356
817
  if (file.Open(ui.Name))
357
818
  {
358
- char buffer[512];
819
+ char buffer[2048];
359
820
  UINT32 processedSize;
360
821
  if (file.Read(buffer,sizeof(buffer),processedSize))
361
822
  {
@@ -374,95 +835,305 @@ static bool IsExeFile(const CUpdateItem &ui)
374
835
  }
375
836
  #endif
376
837
 
377
- #ifdef USE_86_FILTER
378
-
379
- static inline void GetMethodFull(UInt64 methodID, UInt32 numInStreams, CMethodFull &methodResult)
838
+ struct CAnalysis
380
839
  {
381
- methodResult.Id = methodID;
382
- methodResult.NumInStreams = numInStreams;
383
- methodResult.NumOutStreams = 1;
384
- }
840
+ CMyComPtr<IArchiveUpdateCallbackFile> Callback;
841
+ CByteBuffer Buffer;
842
+
843
+ bool ParseWav;
844
+ bool ParseExe;
845
+ bool ParseAll;
846
+
847
+ CAnalysis():
848
+ ParseWav(true),
849
+ ParseExe(false),
850
+ ParseAll(false)
851
+ {}
852
+
853
+ HRESULT GetFilterGroup(UInt32 index, const CUpdateItem &ui, CFilterMode &filterMode);
854
+ };
855
+
856
+ static const size_t kAnalysisBufSize = 1 << 14;
385
857
 
386
- static void MakeExeMethod(const CCompressionMethodMode &method,
387
- bool bcj2Filter, CCompressionMethodMode &exeMethod)
858
+ HRESULT CAnalysis::GetFilterGroup(UInt32 index, const CUpdateItem &ui, CFilterMode &filterMode)
388
859
  {
389
- exeMethod = method;
390
- if (bcj2Filter)
860
+ filterMode.Id = 0;
861
+ filterMode.Delta = 0;
862
+
863
+ CFilterMode filterModeTemp = filterMode;
864
+
865
+ int slashPos = ui.Name.ReverseFind_PathSepar();
866
+ int dotPos = ui.Name.ReverseFind_Dot();
867
+
868
+ // if (dotPos > slashPos)
391
869
  {
392
- CMethodFull methodFull;
393
- GetMethodFull(k_BCJ2, 4, methodFull);
394
- exeMethod.Methods.Insert(0, methodFull);
395
- GetMethodFull(k_LZMA, 1, methodFull);
870
+ bool needReadFile = ParseAll;
871
+
872
+ bool probablyIsSameIsa = false;
873
+
874
+ if (!needReadFile || !Callback)
396
875
  {
397
- CProp prop;
398
- prop.Id = NCoderPropID::kAlgorithm;
399
- prop.Value = kAlgorithmForBCJ2_LZMA;
400
- methodFull.Props.Add(prop);
876
+ const wchar_t *ext;
877
+ if (dotPos > slashPos)
878
+ ext = ui.Name.Ptr(dotPos + 1);
879
+ else
880
+ ext = ui.Name.RightPtr(0);
881
+
882
+ // p7zip uses the trick to store posix attributes in high 16 bits
883
+ if (ui.Attrib & 0x8000)
884
+ {
885
+ unsigned st_mode = ui.Attrib >> 16;
886
+ // st_mode = 00111;
887
+ if ((st_mode & 00111) && (ui.Size >= 2048))
888
+ {
889
+ #ifndef _WIN32
890
+ probablyIsSameIsa = true;
891
+ #endif
892
+ needReadFile = true;
893
+ }
894
+ }
895
+
896
+ #ifdef _WIN32
897
+ if (IsExeExt(ext))
898
+ #else
899
+ if (IsExeFile(ui))
900
+ #endif
901
+ {
902
+ needReadFile = true;
903
+ #ifdef _WIN32
904
+ probablyIsSameIsa = true;
905
+ needReadFile = ParseExe;
906
+ #endif
907
+ }
908
+ else if (StringsAreEqualNoCase_Ascii(ext, "wav"))
909
+ {
910
+ needReadFile = ParseWav;
911
+ }
912
+ /*
913
+ else if (!needReadFile && ParseUnixExt)
914
+ {
915
+ if (StringsAreEqualNoCase_Ascii(ext, "so")
916
+ || StringsAreEqualNoCase_Ascii(ext, ""))
917
+
918
+ needReadFile = true;
919
+ }
920
+ */
401
921
  }
922
+
923
+ if (needReadFile && Callback)
402
924
  {
403
- CProp prop;
404
- prop.Id = NCoderPropID::kMatchFinder;
405
- prop.Value = kMatchFinderForBCJ2_LZMA;
406
- methodFull.Props.Add(prop);
925
+ if (Buffer.Size() != kAnalysisBufSize)
926
+ {
927
+ Buffer.Alloc(kAnalysisBufSize);
928
+ }
929
+ {
930
+ CMyComPtr<ISequentialInStream> stream;
931
+ HRESULT result = Callback->GetStream2(index, &stream, NUpdateNotifyOp::kAnalyze);
932
+ if (result == S_OK && stream)
933
+ {
934
+ size_t size = kAnalysisBufSize;
935
+ result = ReadStream(stream, Buffer, &size);
936
+ stream.Release();
937
+ // RINOK(Callback->SetOperationResult2(index, NUpdate::NOperationResult::kOK));
938
+ if (result == S_OK)
939
+ {
940
+ Bool parseRes = ParseFile(Buffer, size, &filterModeTemp);
941
+ if (parseRes && filterModeTemp.Delta == 0)
942
+ {
943
+ filterModeTemp.SetDelta();
944
+ if (filterModeTemp.Delta != 0 && filterModeTemp.Id != k_Delta)
945
+ {
946
+ if (ui.Size % filterModeTemp.Delta != 0)
947
+ {
948
+ parseRes = false;
949
+ }
950
+ }
951
+ }
952
+ if (!parseRes)
953
+ {
954
+ filterModeTemp.Id = 0;
955
+ filterModeTemp.Delta = 0;
956
+ }
957
+ }
958
+ }
959
+ }
407
960
  }
961
+ else if ((needReadFile && !Callback) || probablyIsSameIsa)
408
962
  {
409
- CProp prop;
410
- prop.Id = NCoderPropID::kDictionarySize;
411
- prop.Value = kDictionaryForBCJ2_LZMA;
412
- methodFull.Props.Add(prop);
963
+ #ifdef MY_CPU_X86_OR_AMD64
964
+ if (probablyIsSameIsa)
965
+ filterModeTemp.Id = k_X86;
966
+ #endif
413
967
  }
968
+ }
969
+
970
+ filterMode = filterModeTemp;
971
+ return S_OK;
972
+ }
973
+
974
+ static inline void GetMethodFull(UInt64 methodID, UInt32 numStreams, CMethodFull &m)
975
+ {
976
+ m.Id = methodID;
977
+ m.NumStreams = numStreams;
978
+ }
979
+
980
+ static HRESULT AddBondForFilter(CCompressionMethodMode &mode)
981
+ {
982
+ for (unsigned c = 1; c < mode.Methods.Size(); c++)
983
+ {
984
+ if (!mode.IsThereBond_to_Coder(c))
414
985
  {
415
- CProp prop;
416
- prop.Id = NCoderPropID::kNumFastBytes;
417
- prop.Value = kNumFastBytesForBCJ2_LZMA;
418
- methodFull.Props.Add(prop);
986
+ CBond2 bond;
987
+ bond.OutCoder = 0;
988
+ bond.OutStream = 0;
989
+ bond.InCoder = c;
990
+ mode.Bonds.Add(bond);
991
+ return S_OK;
419
992
  }
993
+ }
994
+ return E_INVALIDARG;
995
+ }
996
+
997
+ static HRESULT AddFilterBond(CCompressionMethodMode &mode)
998
+ {
999
+ if (!mode.Bonds.IsEmpty())
1000
+ return AddBondForFilter(mode);
1001
+ return S_OK;
1002
+ }
1003
+
1004
+ static HRESULT AddBcj2Methods(CCompressionMethodMode &mode)
1005
+ {
1006
+ // mode.Methods[0] must be k_BCJ2 method !
1007
+
1008
+ CMethodFull m;
1009
+ GetMethodFull(k_LZMA, 1, m);
1010
+
1011
+ m.AddProp32(NCoderPropID::kDictionarySize, 1 << 20);
1012
+ m.AddProp32(NCoderPropID::kNumFastBytes, 128);
1013
+ m.AddProp32(NCoderPropID::kNumThreads, 1);
1014
+ m.AddProp32(NCoderPropID::kLitPosBits, 2);
1015
+ m.AddProp32(NCoderPropID::kLitContextBits, 0);
1016
+ // m.AddProp_Ascii(NCoderPropID::kMatchFinder, "BT2");
1017
+
1018
+ unsigned methodIndex = mode.Methods.Size();
1019
+
1020
+ if (mode.Bonds.IsEmpty())
1021
+ {
1022
+ for (unsigned i = 1; i + 1 < mode.Methods.Size(); i++)
420
1023
  {
421
- CProp prop;
422
- prop.Id = NCoderPropID::kNumThreads;
423
- prop.Value = (UInt32)1;
424
- methodFull.Props.Add(prop);
1024
+ CBond2 bond;
1025
+ bond.OutCoder = i;
1026
+ bond.OutStream = 0;
1027
+ bond.InCoder = i + 1;
1028
+ mode.Bonds.Add(bond);
425
1029
  }
1030
+ }
426
1031
 
427
- exeMethod.Methods.Add(methodFull);
428
- exeMethod.Methods.Add(methodFull);
429
- CBind bind;
1032
+ mode.Methods.Add(m);
1033
+ mode.Methods.Add(m);
1034
+
1035
+ RINOK(AddBondForFilter(mode));
1036
+ CBond2 bond;
1037
+ bond.OutCoder = 0;
1038
+ bond.InCoder = methodIndex; bond.OutStream = 1; mode.Bonds.Add(bond);
1039
+ bond.InCoder = methodIndex + 1; bond.OutStream = 2; mode.Bonds.Add(bond);
1040
+ return S_OK;
1041
+ }
430
1042
 
431
- bind.OutCoder = 0;
432
- bind.InStream = 0;
1043
+ static HRESULT MakeExeMethod(CCompressionMethodMode &mode,
1044
+ const CFilterMode &filterMode, /* bool addFilter, */ bool bcj2Filter)
1045
+ {
1046
+ if (mode.Filter_was_Inserted)
1047
+ {
1048
+ const CMethodFull &m = mode.Methods[0];
1049
+ CMethodId id = m.Id;
1050
+ if (id == k_BCJ2)
1051
+ return AddBcj2Methods(mode);
1052
+ if (!m.IsSimpleCoder())
1053
+ return E_NOTIMPL;
1054
+ // if (Bonds.IsEmpty()) we can create bonds later
1055
+ return AddFilterBond(mode);
1056
+ }
433
1057
 
434
- bind.InCoder = 1;
435
- bind.OutStream = 0;
436
- exeMethod.Binds.Add(bind);
1058
+ if (filterMode.Id == 0)
1059
+ return S_OK;
437
1060
 
438
- bind.InCoder = 2;
439
- bind.OutStream = 1;
440
- exeMethod.Binds.Add(bind);
1061
+ CMethodFull &m = mode.Methods.InsertNew(0);
441
1062
 
442
- bind.InCoder = 3;
443
- bind.OutStream = 2;
444
- exeMethod.Binds.Add(bind);
1063
+ {
1064
+ FOR_VECTOR(k, mode.Bonds)
1065
+ {
1066
+ CBond2 &bond = mode.Bonds[k];
1067
+ bond.InCoder++;
1068
+ bond.OutCoder++;
1069
+ }
1070
+ }
1071
+
1072
+ HRESULT res;
1073
+
1074
+ if (bcj2Filter && Is86Filter(filterMode.Id))
1075
+ {
1076
+ GetMethodFull(k_BCJ2, 4, m);
1077
+ res = AddBcj2Methods(mode);
445
1078
  }
446
1079
  else
447
1080
  {
448
- CMethodFull methodFull;
449
- GetMethodFull(k_BCJ, 1, methodFull);
450
- exeMethod.Methods.Insert(0, methodFull);
451
- CBind bind;
452
- bind.OutCoder = 0;
453
- bind.InStream = 0;
454
- bind.InCoder = 1;
455
- bind.OutStream = 0;
456
- exeMethod.Binds.Add(bind);
1081
+ GetMethodFull(filterMode.Id, 1, m);
1082
+ if (filterMode.Id == k_Delta)
1083
+ m.AddProp32(NCoderPropID::kDefaultProp, filterMode.Delta);
1084
+ res = AddFilterBond(mode);
1085
+
1086
+ int alignBits = -1;
1087
+ if (filterMode.Id == k_Delta || filterMode.Delta != 0)
1088
+ {
1089
+ if (filterMode.Delta == 1) alignBits = 0;
1090
+ else if (filterMode.Delta == 2) alignBits = 1;
1091
+ else if (filterMode.Delta == 4) alignBits = 2;
1092
+ else if (filterMode.Delta == 8) alignBits = 3;
1093
+ else if (filterMode.Delta == 16) alignBits = 4;
1094
+ }
1095
+ else
1096
+ {
1097
+ // alignBits = GetAlignForFilterMethod(filterMode.Id);
1098
+ }
1099
+
1100
+ if (res == S_OK && alignBits >= 0)
1101
+ {
1102
+ unsigned nextCoder = 1;
1103
+ if (!mode.Bonds.IsEmpty())
1104
+ {
1105
+ nextCoder = mode.Bonds.Back().InCoder;
1106
+ }
1107
+ if (nextCoder < mode.Methods.Size())
1108
+ {
1109
+ CMethodFull &nextMethod = mode.Methods[nextCoder];
1110
+ if (nextMethod.Id == k_LZMA || nextMethod.Id == k_LZMA2)
1111
+ {
1112
+ if (!nextMethod.Are_Lzma_Model_Props_Defined())
1113
+ {
1114
+ if (alignBits != 0)
1115
+ {
1116
+ if (alignBits > 2 || filterMode.Id == k_Delta)
1117
+ nextMethod.AddProp32(NCoderPropID::kPosStateBits, alignBits);
1118
+ unsigned lc = 0;
1119
+ if (alignBits < 3)
1120
+ lc = 3 - alignBits;
1121
+ nextMethod.AddProp32(NCoderPropID::kLitContextBits, lc);
1122
+ nextMethod.AddProp32(NCoderPropID::kLitPosBits, alignBits);
1123
+ }
1124
+ }
1125
+ }
1126
+ }
1127
+ }
457
1128
  }
1129
+
1130
+ return res;
458
1131
  }
459
1132
 
460
- #endif
461
1133
 
462
1134
  static void FromUpdateItemToFileItem(const CUpdateItem &ui,
463
1135
  CFileItem &file, CFileItem2 &file2)
464
1136
  {
465
- file.Name = NItemName::MakeLegalName(ui.Name);
466
1137
  if (ui.AttribDefined)
467
1138
  file.SetAttrib(ui.Attrib);
468
1139
 
@@ -470,140 +1141,345 @@ static void FromUpdateItemToFileItem(const CUpdateItem &ui,
470
1141
  file2.ATime = ui.ATime; file2.ATimeDefined = ui.ATimeDefined;
471
1142
  file2.MTime = ui.MTime; file2.MTimeDefined = ui.MTimeDefined;
472
1143
  file2.IsAnti = ui.IsAnti;
1144
+ // file2.IsAux = false;
473
1145
  file2.StartPosDefined = false;
474
1146
 
475
1147
  file.Size = ui.Size;
476
1148
  file.IsDir = ui.IsDir;
477
1149
  file.HasStream = ui.HasStream();
1150
+ // file.IsAltStream = ui.IsAltStream;
478
1151
  }
479
1152
 
480
- class CFolderOutStream2:
481
- public ISequentialOutStream,
1153
+ class CRepackInStreamWithSizes:
1154
+ public ISequentialInStream,
1155
+ public ICompressGetSubStreamSize,
482
1156
  public CMyUnknownImp
483
1157
  {
484
- COutStreamWithCRC *_crcStreamSpec;
485
- CMyComPtr<ISequentialOutStream> _crcStream;
486
- const CArchiveDatabaseEx *_db;
1158
+ CMyComPtr<ISequentialInStream> _stream;
1159
+ // UInt64 _size;
487
1160
  const CBoolVector *_extractStatuses;
488
- CMyComPtr<ISequentialOutStream> _outStream;
489
1161
  UInt32 _startIndex;
490
- int _currentIndex;
1162
+ public:
1163
+ const CDbEx *_db;
1164
+
1165
+ void Init(ISequentialInStream *stream, UInt32 startIndex, const CBoolVector *extractStatuses)
1166
+ {
1167
+ _startIndex = startIndex;
1168
+ _extractStatuses = extractStatuses;
1169
+ // _size = 0;
1170
+ _stream = stream;
1171
+ }
1172
+ // UInt64 GetSize() const { return _size; }
1173
+
1174
+ MY_UNKNOWN_IMP2(ISequentialInStream, ICompressGetSubStreamSize)
1175
+
1176
+ STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
1177
+
1178
+ STDMETHOD(GetSubStreamSize)(UInt64 subStream, UInt64 *value);
1179
+ };
1180
+
1181
+ STDMETHODIMP CRepackInStreamWithSizes::Read(void *data, UInt32 size, UInt32 *processedSize)
1182
+ {
1183
+ return _stream->Read(data, size, processedSize);
1184
+ /*
1185
+ UInt32 realProcessedSize;
1186
+ HRESULT result = _stream->Read(data, size, &realProcessedSize);
1187
+ _size += realProcessedSize;
1188
+ if (processedSize)
1189
+ *processedSize = realProcessedSize;
1190
+ return result;
1191
+ */
1192
+ }
1193
+
1194
+ STDMETHODIMP CRepackInStreamWithSizes::GetSubStreamSize(UInt64 subStream, UInt64 *value)
1195
+ {
1196
+ *value = 0;
1197
+ if (subStream >= _extractStatuses->Size())
1198
+ return S_FALSE; // E_FAIL;
1199
+ unsigned index = (unsigned)subStream;
1200
+ if ((*_extractStatuses)[index])
1201
+ {
1202
+ const CFileItem &fi = _db->Files[_startIndex + index];
1203
+ if (fi.HasStream)
1204
+ *value = fi.Size;
1205
+ }
1206
+ return S_OK;
1207
+ }
1208
+
1209
+
1210
+ class CRepackStreamBase
1211
+ {
1212
+ protected:
1213
+ bool _needWrite;
491
1214
  bool _fileIsOpen;
1215
+ bool _calcCrc;
1216
+ UInt32 _crc;
492
1217
  UInt64 _rem;
493
1218
 
494
- void OpenFile();
495
- void CloseFile();
496
- HRESULT CloseFileAndSetResult();
1219
+ const CBoolVector *_extractStatuses;
1220
+ UInt32 _startIndex;
1221
+ unsigned _currentIndex;
1222
+
1223
+ HRESULT OpenFile();
1224
+ HRESULT CloseFile();
497
1225
  HRESULT ProcessEmptyFiles();
1226
+
498
1227
  public:
499
- MY_UNKNOWN_IMP
500
-
501
- CFolderOutStream2()
502
- {
503
- _crcStreamSpec = new COutStreamWithCRC;
504
- _crcStream = _crcStreamSpec;
505
- }
1228
+ const CDbEx *_db;
1229
+ CMyComPtr<IArchiveUpdateCallbackFile> _opCallback;
1230
+ CMyComPtr<IArchiveExtractCallbackMessage> _extractCallback;
506
1231
 
507
- HRESULT Init(const CArchiveDatabaseEx *db, UInt32 startIndex,
508
- const CBoolVector *extractStatuses, ISequentialOutStream *outStream);
509
- void ReleaseOutStream();
1232
+ HRESULT Init(UInt32 startIndex, const CBoolVector *extractStatuses);
510
1233
  HRESULT CheckFinishedState() const { return (_currentIndex == _extractStatuses->Size()) ? S_OK: E_FAIL; }
511
-
512
- STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
513
1234
  };
514
1235
 
515
- HRESULT CFolderOutStream2::Init(const CArchiveDatabaseEx *db, UInt32 startIndex,
516
- const CBoolVector *extractStatuses, ISequentialOutStream *outStream)
1236
+ HRESULT CRepackStreamBase::Init(UInt32 startIndex, const CBoolVector *extractStatuses)
517
1237
  {
518
- _db = db;
519
1238
  _startIndex = startIndex;
520
1239
  _extractStatuses = extractStatuses;
521
- _outStream = outStream;
522
1240
 
523
1241
  _currentIndex = 0;
524
1242
  _fileIsOpen = false;
1243
+
525
1244
  return ProcessEmptyFiles();
526
1245
  }
527
1246
 
528
- void CFolderOutStream2::ReleaseOutStream()
1247
+ HRESULT CRepackStreamBase::OpenFile()
529
1248
  {
530
- _outStream.Release();
531
- _crcStreamSpec->ReleaseStream();
532
- }
1249
+ UInt32 arcIndex = _startIndex + _currentIndex;
1250
+ const CFileItem &fi = _db->Files[arcIndex];
1251
+
1252
+ _needWrite = (*_extractStatuses)[_currentIndex];
1253
+ if (_opCallback)
1254
+ {
1255
+ RINOK(_opCallback->ReportOperation(
1256
+ NEventIndexType::kInArcIndex, arcIndex,
1257
+ _needWrite ?
1258
+ NUpdateNotifyOp::kRepack :
1259
+ NUpdateNotifyOp::kSkip));
1260
+ }
1261
+
1262
+ _crc = CRC_INIT_VAL;
1263
+ _calcCrc = (fi.CrcDefined && !fi.IsDir);
533
1264
 
534
- void CFolderOutStream2::OpenFile()
535
- {
536
- _crcStreamSpec->SetStream((*_extractStatuses)[_currentIndex] ? (ISequentialOutStream *)_outStream : NULL); // FIXED for gcc 2.95
537
- _crcStreamSpec->Init(true);
538
1265
  _fileIsOpen = true;
539
- _rem = _db->Files[_startIndex + _currentIndex].Size;
1266
+ _rem = fi.Size;
1267
+ return S_OK;
540
1268
  }
541
1269
 
542
- void CFolderOutStream2::CloseFile()
1270
+ const HRESULT k_My_HRESULT_CRC_ERROR = 0x20000002;
1271
+
1272
+ HRESULT CRepackStreamBase::CloseFile()
543
1273
  {
544
- _crcStreamSpec->ReleaseStream();
1274
+ UInt32 arcIndex = _startIndex + _currentIndex;
1275
+ const CFileItem &fi = _db->Files[arcIndex];
545
1276
  _fileIsOpen = false;
546
1277
  _currentIndex++;
547
- }
1278
+ if (!_calcCrc || fi.Crc == CRC_GET_DIGEST(_crc))
1279
+ return S_OK;
548
1280
 
549
- HRESULT CFolderOutStream2::CloseFileAndSetResult()
550
- {
551
- const CFileItem &file = _db->Files[_startIndex + _currentIndex];
552
- CloseFile();
553
- return (file.IsDir || !file.CrcDefined || file.Crc == _crcStreamSpec->GetCRC()) ? S_OK: S_FALSE;
1281
+ if (_extractCallback)
1282
+ {
1283
+ RINOK(_extractCallback->ReportExtractResult(
1284
+ NEventIndexType::kInArcIndex, arcIndex,
1285
+ NExtract::NOperationResult::kCRCError));
1286
+ }
1287
+ // return S_FALSE;
1288
+ return k_My_HRESULT_CRC_ERROR;
554
1289
  }
555
1290
 
556
- HRESULT CFolderOutStream2::ProcessEmptyFiles()
1291
+ HRESULT CRepackStreamBase::ProcessEmptyFiles()
557
1292
  {
558
1293
  while (_currentIndex < _extractStatuses->Size() && _db->Files[_startIndex + _currentIndex].Size == 0)
559
1294
  {
560
- OpenFile();
561
- RINOK(CloseFileAndSetResult());
1295
+ RINOK(OpenFile());
1296
+ RINOK(CloseFile());
562
1297
  }
563
1298
  return S_OK;
564
1299
  }
1300
+
1301
+
1302
+
1303
+ #ifndef _7ZIP_ST
1304
+
1305
+ class CFolderOutStream2:
1306
+ public CRepackStreamBase,
1307
+ public ISequentialOutStream,
1308
+ public CMyUnknownImp
1309
+ {
1310
+ public:
1311
+ CMyComPtr<ISequentialOutStream> _stream;
1312
+
1313
+ MY_UNKNOWN_IMP
1314
+
1315
+ STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
1316
+ };
565
1317
 
566
1318
  STDMETHODIMP CFolderOutStream2::Write(const void *data, UInt32 size, UInt32 *processedSize)
567
1319
  {
568
- if (processedSize != NULL)
1320
+ if (processedSize)
569
1321
  *processedSize = 0;
1322
+
570
1323
  while (size != 0)
571
1324
  {
572
1325
  if (_fileIsOpen)
573
1326
  {
574
- UInt32 cur = size < _rem ? size : (UInt32)_rem;
575
- RINOK(_crcStream->Write(data, cur, &cur));
576
- if (cur == 0)
577
- break;
1327
+ UInt32 cur = (size < _rem ? size : (UInt32)_rem);
1328
+ HRESULT result = S_OK;
1329
+ if (_needWrite)
1330
+ result = _stream->Write(data, cur, &cur);
1331
+ if (_calcCrc)
1332
+ _crc = CrcUpdate(_crc, data, cur);
1333
+ if (processedSize)
1334
+ *processedSize += cur;
578
1335
  data = (const Byte *)data + cur;
579
1336
  size -= cur;
580
1337
  _rem -= cur;
581
- if (processedSize != NULL)
582
- *processedSize += cur;
583
1338
  if (_rem == 0)
584
1339
  {
585
- RINOK(CloseFileAndSetResult());
1340
+ RINOK(CloseFile());
586
1341
  RINOK(ProcessEmptyFiles());
587
- continue;
588
1342
  }
1343
+ RINOK(result);
1344
+ if (cur == 0)
1345
+ break;
1346
+ continue;
589
1347
  }
590
- else
1348
+
1349
+ RINOK(ProcessEmptyFiles());
1350
+ if (_currentIndex == _extractStatuses->Size())
591
1351
  {
592
- RINOK(ProcessEmptyFiles());
593
- if (_currentIndex == _extractStatuses->Size())
1352
+ // we don't support write cut here
1353
+ return E_FAIL;
1354
+ }
1355
+ RINOK(OpenFile());
1356
+ }
1357
+
1358
+ return S_OK;
1359
+ }
1360
+
1361
+ #endif
1362
+
1363
+
1364
+
1365
+ static const UInt32 kTempBufSize = 1 << 16;
1366
+
1367
+ class CFolderInStream2:
1368
+ public CRepackStreamBase,
1369
+ public ISequentialInStream,
1370
+ public CMyUnknownImp
1371
+ {
1372
+ Byte *_buf;
1373
+ public:
1374
+ CMyComPtr<ISequentialInStream> _inStream;
1375
+ HRESULT Result;
1376
+
1377
+ MY_UNKNOWN_IMP
1378
+
1379
+ CFolderInStream2():
1380
+ Result(S_OK)
1381
+ {
1382
+ _buf = new Byte[kTempBufSize];
1383
+ }
1384
+
1385
+ ~CFolderInStream2()
1386
+ {
1387
+ delete []_buf;
1388
+ }
1389
+
1390
+ void Init() { Result = S_OK; }
1391
+ STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
1392
+ };
1393
+
1394
+ STDMETHODIMP CFolderInStream2::Read(void *data, UInt32 size, UInt32 *processedSize)
1395
+ {
1396
+ if (processedSize)
1397
+ *processedSize = 0;
1398
+
1399
+ while (size != 0)
1400
+ {
1401
+ if (_fileIsOpen)
1402
+ {
1403
+ UInt32 cur = (size < _rem ? size : (UInt32)_rem);
1404
+
1405
+ void *buf;
1406
+ if (_needWrite)
1407
+ buf = data;
1408
+ else
594
1409
  {
595
- // we don't support partial extracting
596
- return E_FAIL;
1410
+ buf = _buf;
1411
+ if (cur > kTempBufSize)
1412
+ cur = kTempBufSize;
1413
+ }
1414
+
1415
+ HRESULT result = _inStream->Read(buf, cur, &cur);
1416
+ _crc = CrcUpdate(_crc, buf, cur);
1417
+ _rem -= cur;
1418
+
1419
+ if (_needWrite)
1420
+ {
1421
+ data = (Byte *)data + cur;
1422
+ size -= cur;
1423
+ if (processedSize)
1424
+ *processedSize += cur;
597
1425
  }
598
- OpenFile();
1426
+
1427
+ if (result != S_OK)
1428
+ Result = result;
1429
+
1430
+ if (_rem == 0)
1431
+ {
1432
+ RINOK(CloseFile());
1433
+ RINOK(ProcessEmptyFiles());
1434
+ }
1435
+
1436
+ RINOK(result);
1437
+
1438
+ if (cur == 0)
1439
+ return E_FAIL;
1440
+
1441
+ continue;
599
1442
  }
1443
+
1444
+ RINOK(ProcessEmptyFiles());
1445
+ if (_currentIndex == _extractStatuses->Size())
1446
+ {
1447
+ return S_OK;
1448
+ }
1449
+ RINOK(OpenFile());
600
1450
  }
1451
+
601
1452
  return S_OK;
602
1453
  }
603
1454
 
604
- class CThreadDecoder: public CVirtThread
1455
+
1456
+ class CThreadDecoder
1457
+ #ifndef _7ZIP_ST
1458
+ : public CVirtThread
1459
+ #endif
605
1460
  {
606
1461
  public:
1462
+ CDecoder Decoder;
1463
+
1464
+ CThreadDecoder(bool multiThreadMixer):
1465
+ Decoder(multiThreadMixer)
1466
+ {
1467
+ #ifndef _7ZIP_ST
1468
+ if (multiThreadMixer)
1469
+ {
1470
+ MtMode = false;
1471
+ NumThreads = 1;
1472
+ FosSpec = new CFolderOutStream2;
1473
+ Fos = FosSpec;
1474
+ Result = E_FAIL;
1475
+ }
1476
+ #endif
1477
+ // UnpackSize = 0;
1478
+ // send_UnpackSize = false;
1479
+ }
1480
+
1481
+ #ifndef _7ZIP_ST
1482
+
607
1483
  HRESULT Result;
608
1484
  CMyComPtr<IInStream> InStream;
609
1485
 
@@ -611,54 +1487,58 @@ public:
611
1487
  CMyComPtr<ISequentialOutStream> Fos;
612
1488
 
613
1489
  UInt64 StartPos;
614
- const UInt64 *PackSizes;
615
- const CFolder *Folder;
1490
+ const CFolders *Folders;
1491
+ int FolderIndex;
1492
+
1493
+ // bool send_UnpackSize;
1494
+ // UInt64 UnpackSize;
1495
+
616
1496
  #ifndef _NO_CRYPTO
617
- CMyComPtr<ICryptoGetTextPassword> GetTextPassword;
1497
+ CMyComPtr<ICryptoGetTextPassword> getTextPassword;
618
1498
  #endif
619
1499
 
620
- DECL_EXTERNAL_CODECS_VARS
621
- CDecoder Decoder;
1500
+ DECL_EXTERNAL_CODECS_LOC_VARS2;
622
1501
 
623
1502
  #ifndef _7ZIP_ST
624
1503
  bool MtMode;
625
1504
  UInt32 NumThreads;
626
1505
  #endif
627
1506
 
628
- CThreadDecoder():
629
- Decoder(true)
630
- {
631
- #ifndef _7ZIP_ST
632
- MtMode = false;
633
- NumThreads = 1;
634
- #endif
635
- FosSpec = new CFolderOutStream2;
636
- Fos = FosSpec;
637
- Result = E_FAIL;
638
- }
1507
+
1508
+ ~CThreadDecoder() { CVirtThread::WaitThreadFinish(); }
639
1509
  virtual void Execute();
1510
+
1511
+ #endif
640
1512
  };
641
1513
 
1514
+ #ifndef _7ZIP_ST
1515
+
642
1516
  void CThreadDecoder::Execute()
643
1517
  {
644
1518
  try
645
1519
  {
646
1520
  #ifndef _NO_CRYPTO
647
- bool passwordIsDefined;
1521
+ bool isEncrypted = false;
1522
+ bool passwordIsDefined = false;
1523
+ UString password;
648
1524
  #endif
1525
+
649
1526
  Result = Decoder.Decode(
650
- EXTERNAL_CODECS_VARS
1527
+ EXTERNAL_CODECS_LOC_VARS
651
1528
  InStream,
652
1529
  StartPos,
653
- PackSizes,
654
- *Folder,
1530
+ *Folders, FolderIndex,
1531
+
1532
+ // send_UnpackSize ? &UnpackSize : NULL,
1533
+ NULL, // unpackSize : FULL unpack
1534
+
655
1535
  Fos,
656
- NULL
657
- #ifndef _NO_CRYPTO
658
- , GetTextPassword, passwordIsDefined
659
- #endif
1536
+ NULL, // compressProgress
1537
+ NULL // *inStreamMainRes
1538
+
1539
+ _7Z_DECODER_CRYPRO_VARS
660
1540
  #ifndef _7ZIP_ST
661
- , MtMode, NumThreads
1541
+ , MtMode, NumThreads
662
1542
  #endif
663
1543
  );
664
1544
  }
@@ -666,21 +1546,15 @@ void CThreadDecoder::Execute()
666
1546
  {
667
1547
  Result = E_FAIL;
668
1548
  }
1549
+
1550
+ /*
669
1551
  if (Result == S_OK)
670
1552
  Result = FosSpec->CheckFinishedState();
671
- FosSpec->ReleaseOutStream();
1553
+ */
1554
+ FosSpec->_stream.Release();
672
1555
  }
673
1556
 
674
- bool static Is86FilteredFolder(const CFolder &f)
675
- {
676
- for (int i = 0; i < f.Coders.Size(); i++)
677
- {
678
- CMethodId m = f.Coders[i].MethodID;
679
- if (m == k_BCJ || m == k_BCJ2)
680
- return true;
681
- }
682
- return false;
683
- }
1557
+ #endif
684
1558
 
685
1559
  #ifndef _NO_CRYPTO
686
1560
 
@@ -702,22 +1576,27 @@ STDMETHODIMP CCryptoGetTextPassword::CryptoGetTextPassword(BSTR *password)
702
1576
 
703
1577
  #endif
704
1578
 
705
- static const int kNumGroupsMax = 4;
706
1579
 
707
- #ifdef USE_86_FILTER
708
- static bool Is86Group(int group) { return (group & 1) != 0; }
709
- #endif
710
- static bool IsEncryptedGroup(int group) { return (group & 2) != 0; }
711
- static int GetGroupIndex(bool encrypted, int bcjFiltered)
712
- { return (encrypted ? 2 : 0) + (bcjFiltered ? 1 : 0); }
1580
+ static void GetFile(const CDatabase &inDb, unsigned index, CFileItem &file, CFileItem2 &file2)
1581
+ {
1582
+ file = inDb.Files[index];
1583
+ file2.CTimeDefined = inDb.CTime.GetItem(index, file2.CTime);
1584
+ file2.ATimeDefined = inDb.ATime.GetItem(index, file2.ATime);
1585
+ file2.MTimeDefined = inDb.MTime.GetItem(index, file2.MTime);
1586
+ file2.StartPosDefined = inDb.StartPos.GetItem(index, file2.StartPos);
1587
+ file2.IsAnti = inDb.IsItemAnti(index);
1588
+ // file2.IsAux = inDb.IsItemAux(index);
1589
+ }
713
1590
 
714
1591
  HRESULT Update(
715
1592
  DECL_EXTERNAL_CODECS_LOC_VARS
716
1593
  IInStream *inStream,
717
- const CArchiveDatabaseEx *db,
1594
+ const CDbEx *db,
718
1595
  const CObjectVector<CUpdateItem> &updateItems,
1596
+ // const CObjectVector<CTreeFolder> &treeFolders,
1597
+ // const CUniqBlocks &secureBlocks,
719
1598
  COutArchive &archive,
720
- CArchiveDatabase &newDatabase,
1599
+ CArchiveDatabaseOut &newDatabase,
721
1600
  ISequentialOutStream *seqOutStream,
722
1601
  IArchiveUpdateCallback *updateCallback,
723
1602
  const CUpdateOptions &options
@@ -729,6 +1608,15 @@ HRESULT Update(
729
1608
  UInt64 numSolidFiles = options.NumSolidFiles;
730
1609
  if (numSolidFiles == 0)
731
1610
  numSolidFiles = 1;
1611
+
1612
+ CMyComPtr<IArchiveUpdateCallbackFile> opCallback;
1613
+ updateCallback->QueryInterface(IID_IArchiveUpdateCallbackFile, (void **)&opCallback);
1614
+
1615
+ CMyComPtr<IArchiveExtractCallbackMessage> extractCallback;
1616
+ updateCallback->QueryInterface(IID_IArchiveExtractCallbackMessage, (void **)&extractCallback);
1617
+
1618
+ // size_t totalSecureDataSize = (size_t)secureBlocks.GetTotalSizeInBytes();
1619
+
732
1620
  /*
733
1621
  CMyComPtr<IOutStream> outStream;
734
1622
  RINOK(seqOutStream->QueryInterface(IID_IOutStream, (void **)&outStream));
@@ -736,37 +1624,56 @@ HRESULT Update(
736
1624
  return E_NOTIMPL;
737
1625
  */
738
1626
 
739
- UInt64 startBlockSize = db != 0 ? db->ArchiveInfo.StartPosition: 0;
1627
+ UInt64 startBlockSize = db ? db->ArcInfo.StartPosition: 0;
740
1628
  if (startBlockSize > 0 && !options.RemoveSfxBlock)
741
1629
  {
742
1630
  RINOK(WriteRange(inStream, seqOutStream, 0, startBlockSize, NULL));
743
1631
  }
744
1632
 
745
- CRecordVector<int> fileIndexToUpdateIndexMap;
746
- CRecordVector<CFolderRepack> folderRefs;
1633
+ CIntArr fileIndexToUpdateIndexMap;
747
1634
  UInt64 complexity = 0;
748
1635
  UInt64 inSizeForReduce2 = 0;
749
1636
  bool needEncryptedRepack = false;
750
- if (db != 0)
1637
+
1638
+ CRecordVector<CFilterMode2> filters;
1639
+ CObjectVector<CSolidGroup> groups;
1640
+ bool thereAreRepacks = false;
1641
+
1642
+ bool useFilters = options.UseFilters;
1643
+ if (useFilters)
1644
+ {
1645
+ const CCompressionMethodMode &method = *options.Method;
1646
+
1647
+ FOR_VECTOR (i, method.Methods)
1648
+ if (IsFilterMethod(method.Methods[i].Id))
1649
+ {
1650
+ useFilters = false;
1651
+ break;
1652
+ }
1653
+ }
1654
+
1655
+ if (db)
751
1656
  {
752
- fileIndexToUpdateIndexMap.Reserve(db->Files.Size());
753
- int i;
1657
+ fileIndexToUpdateIndexMap.Alloc(db->Files.Size());
1658
+ unsigned i;
1659
+
754
1660
  for (i = 0; i < db->Files.Size(); i++)
755
- fileIndexToUpdateIndexMap.Add(-1);
1661
+ fileIndexToUpdateIndexMap[i] = -1;
756
1662
 
757
1663
  for (i = 0; i < updateItems.Size(); i++)
758
1664
  {
759
1665
  int index = updateItems[i].IndexInArchive;
760
1666
  if (index != -1)
761
- fileIndexToUpdateIndexMap[index] = i;
1667
+ fileIndexToUpdateIndexMap[(unsigned)index] = i;
762
1668
  }
763
1669
 
764
- for (i = 0; i < db->Folders.Size(); i++)
1670
+ for (i = 0; i < db->NumFolders; i++)
765
1671
  {
766
1672
  CNum indexInFolder = 0;
767
1673
  CNum numCopyItems = 0;
768
1674
  CNum numUnpackStreams = db->NumUnpackStreamsVector[i];
769
1675
  UInt64 repackSize = 0;
1676
+
770
1677
  for (CNum fi = db->FolderStartFileIndex[i]; indexInFolder < numUnpackStreams; fi++)
771
1678
  {
772
1679
  const CFileItem &file = db->Files[fi];
@@ -788,100 +1695,141 @@ HRESULT Update(
788
1695
  CFolderRepack rep;
789
1696
  rep.FolderIndex = i;
790
1697
  rep.NumCopyFiles = numCopyItems;
791
- const CFolder &f = db->Folders[i];
792
- bool isEncrypted = f.IsEncrypted();
793
- rep.Group = GetGroupIndex(isEncrypted, Is86FilteredFolder(f));
794
- folderRefs.Add(rep);
795
- if (numCopyItems == numUnpackStreams)
1698
+ CFolderEx f;
1699
+ db->ParseFolderEx(i, f);
1700
+
1701
+ const bool isEncrypted = f.IsEncrypted();
1702
+ const bool needCopy = (numCopyItems == numUnpackStreams);
1703
+ const bool extractFilter = (useFilters || needCopy);
1704
+
1705
+ unsigned groupIndex = Get_FilterGroup_for_Folder(filters, f, extractFilter);
1706
+
1707
+ while (groupIndex >= groups.Size())
1708
+ groups.AddNew();
1709
+
1710
+ groups[groupIndex].folderRefs.Add(rep);
1711
+
1712
+ if (needCopy)
796
1713
  complexity += db->GetFolderFullPackSize(i);
797
1714
  else
798
1715
  {
1716
+ thereAreRepacks = true;
799
1717
  complexity += repackSize;
800
- if (repackSize > inSizeForReduce2)
1718
+ if (inSizeForReduce2 < repackSize)
801
1719
  inSizeForReduce2 = repackSize;
802
1720
  if (isEncrypted)
803
1721
  needEncryptedRepack = true;
804
1722
  }
805
1723
  }
806
- folderRefs.Sort(CompareFolderRepacks, (void *)db);
807
1724
  }
808
1725
 
809
1726
  UInt64 inSizeForReduce = 0;
810
- int i;
811
- for (i = 0; i < updateItems.Size(); i++)
812
1727
  {
813
- const CUpdateItem &ui = updateItems[i];
814
- if (ui.NewData)
1728
+ FOR_VECTOR (i, updateItems)
815
1729
  {
816
- complexity += ui.Size;
817
- if (numSolidFiles != 1)
818
- inSizeForReduce += ui.Size;
819
- else if (ui.Size > inSizeForReduce)
820
- inSizeForReduce = ui.Size;
1730
+ const CUpdateItem &ui = updateItems[i];
1731
+ if (ui.NewData)
1732
+ {
1733
+ complexity += ui.Size;
1734
+ if (numSolidFiles != 1)
1735
+ inSizeForReduce += ui.Size;
1736
+ else if (inSizeForReduce < ui.Size)
1737
+ inSizeForReduce = ui.Size;
1738
+ }
821
1739
  }
822
1740
  }
823
1741
 
824
- if (inSizeForReduce2 > inSizeForReduce)
1742
+ if (inSizeForReduce < inSizeForReduce2)
825
1743
  inSizeForReduce = inSizeForReduce2;
826
1744
 
827
- const UInt32 kMinReduceSize = (1 << 16);
828
- if (inSizeForReduce < kMinReduceSize)
829
- inSizeForReduce = kMinReduceSize;
830
-
831
1745
  RINOK(updateCallback->SetTotal(complexity));
832
1746
 
833
1747
  CLocalProgress *lps = new CLocalProgress;
834
1748
  CMyComPtr<ICompressProgressInfo> progress = lps;
835
1749
  lps->Init(updateCallback, true);
836
1750
 
837
- CThreadDecoder threadDecoder;
838
- if (!folderRefs.IsEmpty())
1751
+ #ifndef _7ZIP_ST
1752
+
1753
+ CStreamBinder sb;
1754
+ if (options.MultiThreadMixer)
1755
+ {
1756
+ RINOK(sb.CreateEvents());
1757
+ }
1758
+
1759
+ #endif
1760
+
1761
+ CThreadDecoder threadDecoder(options.MultiThreadMixer);
1762
+
1763
+ #ifndef _7ZIP_ST
1764
+ if (options.MultiThreadMixer && thereAreRepacks)
839
1765
  {
840
1766
  #ifdef EXTERNAL_CODECS
841
- threadDecoder._codecsInfo = codecsInfo;
842
- threadDecoder._externalCodecs = *externalCodecs;
1767
+ threadDecoder.__externalCodecs = __externalCodecs;
843
1768
  #endif
844
1769
  RINOK(threadDecoder.Create());
845
1770
  }
846
-
847
- CObjectVector<CSolidGroup> groups;
848
- for (i = 0; i < kNumGroupsMax; i++)
849
- groups.Add(CSolidGroup());
1771
+ #endif
850
1772
 
851
1773
  {
852
- // ---------- Split files to 2 groups ----------
1774
+ CAnalysis analysis;
1775
+ if (options.AnalysisLevel == 0)
1776
+ {
1777
+ analysis.ParseWav = false;
1778
+ analysis.ParseExe = false;
1779
+ analysis.ParseAll = false;
1780
+ }
1781
+ else
1782
+ {
1783
+ analysis.Callback = opCallback;
1784
+ if (options.AnalysisLevel > 0)
1785
+ {
1786
+ analysis.ParseWav = true;
1787
+ if (options.AnalysisLevel >= 7)
1788
+ {
1789
+ analysis.ParseExe = true;
1790
+ if (options.AnalysisLevel >= 9)
1791
+ analysis.ParseAll = true;
1792
+ }
1793
+ }
1794
+ }
1795
+
1796
+ // ---------- Split files to groups ----------
853
1797
 
854
- bool useFilters = options.UseFilters;
855
1798
  const CCompressionMethodMode &method = *options.Method;
856
- if (method.Methods.Size() != 1 || method.Binds.Size() != 0)
857
- useFilters = false;
858
- for (i = 0; i < updateItems.Size(); i++)
1799
+
1800
+ FOR_VECTOR (i, updateItems)
859
1801
  {
860
1802
  const CUpdateItem &ui = updateItems[i];
861
1803
  if (!ui.NewData || !ui.HasStream())
862
1804
  continue;
863
- bool filteredGroup = false;
1805
+
1806
+ CFilterMode2 fm;
864
1807
  if (useFilters)
865
1808
  {
866
- #ifdef _WIN32
867
- int dotPos = ui.Name.ReverseFind(L'.');
868
- if (dotPos >= 0)
869
- filteredGroup = IsExeExt(ui.Name.Mid(dotPos + 1));
870
- #else
871
- filteredGroup = IsExeFile(ui);
872
- #endif
1809
+ RINOK(analysis.GetFilterGroup(i, ui, fm));
873
1810
  }
874
- groups[GetGroupIndex(method.PasswordIsDefined, filteredGroup)].Indices.Add(i);
1811
+ fm.Encrypted = method.PasswordIsDefined;
1812
+
1813
+ unsigned groupIndex = GetGroup(filters, fm);
1814
+ while (groupIndex >= groups.Size())
1815
+ groups.AddNew();
1816
+ groups[groupIndex].Indices.Add(i);
875
1817
  }
876
1818
  }
877
1819
 
1820
+
878
1821
  #ifndef _NO_CRYPTO
879
1822
 
880
1823
  CCryptoGetTextPassword *getPasswordSpec = NULL;
1824
+ CMyComPtr<ICryptoGetTextPassword> getTextPassword;
881
1825
  if (needEncryptedRepack)
882
1826
  {
883
1827
  getPasswordSpec = new CCryptoGetTextPassword;
884
- threadDecoder.GetTextPassword = getPasswordSpec;
1828
+ getTextPassword = getPasswordSpec;
1829
+
1830
+ #ifndef _7ZIP_ST
1831
+ threadDecoder.getTextPassword = getPasswordSpec;
1832
+ #endif
885
1833
 
886
1834
  if (options.Method->PasswordIsDefined)
887
1835
  getPasswordSpec->Password = options.Method->Password;
@@ -891,33 +1839,145 @@ HRESULT Update(
891
1839
  return E_NOTIMPL;
892
1840
  CMyComBSTR password;
893
1841
  RINOK(getDecoderPassword->CryptoGetTextPassword(&password));
894
- getPasswordSpec->Password = password;
1842
+ if (password)
1843
+ getPasswordSpec->Password = password;
895
1844
  }
896
1845
  }
897
1846
 
898
1847
  #endif
899
1848
 
1849
+
900
1850
  // ---------- Compress ----------
901
1851
 
902
1852
  RINOK(archive.Create(seqOutStream, false));
903
1853
  RINOK(archive.SkipPrefixArchiveHeader());
904
1854
 
905
- int folderRefIndex = 0;
1855
+ /*
1856
+ CIntVector treeFolderToArcIndex;
1857
+ treeFolderToArcIndex.Reserve(treeFolders.Size());
1858
+ for (i = 0; i < treeFolders.Size(); i++)
1859
+ treeFolderToArcIndex.Add(-1);
1860
+ // ---------- Write Tree (only AUX dirs) ----------
1861
+ for (i = 1; i < treeFolders.Size(); i++)
1862
+ {
1863
+ const CTreeFolder &treeFolder = treeFolders[i];
1864
+ CFileItem file;
1865
+ CFileItem2 file2;
1866
+ file2.Init();
1867
+ int secureID = 0;
1868
+ if (treeFolder.UpdateItemIndex < 0)
1869
+ {
1870
+ // we can store virtual dir item wuthout attrib, but we want all items have attrib.
1871
+ file.SetAttrib(FILE_ATTRIBUTE_DIRECTORY);
1872
+ file2.IsAux = true;
1873
+ }
1874
+ else
1875
+ {
1876
+ const CUpdateItem &ui = updateItems[treeFolder.UpdateItemIndex];
1877
+ // if item is not dir, then it's parent for alt streams.
1878
+ // we will write such items later
1879
+ if (!ui.IsDir)
1880
+ continue;
1881
+ secureID = ui.SecureIndex;
1882
+ if (ui.NewProps)
1883
+ FromUpdateItemToFileItem(ui, file, file2);
1884
+ else
1885
+ GetFile(*db, ui.IndexInArchive, file, file2);
1886
+ }
1887
+ file.Size = 0;
1888
+ file.HasStream = false;
1889
+ file.IsDir = true;
1890
+ file.Parent = treeFolder.Parent;
1891
+
1892
+ treeFolderToArcIndex[i] = newDatabase.Files.Size();
1893
+ newDatabase.AddFile(file, file2, treeFolder.Name);
1894
+
1895
+ if (totalSecureDataSize != 0)
1896
+ newDatabase.SecureIDs.Add(secureID);
1897
+ }
1898
+ */
1899
+
1900
+ {
1901
+ /* ---------- Write non-AUX dirs and Empty files ---------- */
1902
+ CUIntVector emptyRefs;
1903
+
1904
+ unsigned i;
1905
+
1906
+ for (i = 0; i < updateItems.Size(); i++)
1907
+ {
1908
+ const CUpdateItem &ui = updateItems[i];
1909
+ if (ui.NewData)
1910
+ {
1911
+ if (ui.HasStream())
1912
+ continue;
1913
+ }
1914
+ else if (ui.IndexInArchive != -1 && db->Files[ui.IndexInArchive].HasStream)
1915
+ continue;
1916
+ /*
1917
+ if (ui.TreeFolderIndex >= 0)
1918
+ continue;
1919
+ */
1920
+ emptyRefs.Add(i);
1921
+ }
1922
+
1923
+ emptyRefs.Sort(CompareEmptyItems, (void *)&updateItems);
1924
+
1925
+ for (i = 0; i < emptyRefs.Size(); i++)
1926
+ {
1927
+ const CUpdateItem &ui = updateItems[emptyRefs[i]];
1928
+ CFileItem file;
1929
+ CFileItem2 file2;
1930
+ UString name;
1931
+ if (ui.NewProps)
1932
+ {
1933
+ FromUpdateItemToFileItem(ui, file, file2);
1934
+ name = ui.Name;
1935
+ }
1936
+ else
1937
+ {
1938
+ GetFile(*db, ui.IndexInArchive, file, file2);
1939
+ db->GetPath(ui.IndexInArchive, name);
1940
+ }
1941
+
1942
+ /*
1943
+ if (totalSecureDataSize != 0)
1944
+ newDatabase.SecureIDs.Add(ui.SecureIndex);
1945
+ file.Parent = ui.ParentFolderIndex;
1946
+ */
1947
+ newDatabase.AddFile(file, file2, name);
1948
+ }
1949
+ }
1950
+
906
1951
  lps->ProgressOffset = 0;
907
1952
 
908
- for (int groupIndex = 0; groupIndex < kNumGroupsMax; groupIndex++)
909
1953
  {
910
- const CSolidGroup &group = groups[groupIndex];
1954
+ // ---------- Sort Filters ----------
1955
+
1956
+ FOR_VECTOR (i, filters)
1957
+ {
1958
+ filters[i].GroupIndex = i;
1959
+ }
1960
+ filters.Sort2();
1961
+ }
1962
+
1963
+ for (unsigned groupIndex = 0; groupIndex < filters.Size(); groupIndex++)
1964
+ {
1965
+ const CFilterMode2 &filterMode = filters[groupIndex];
911
1966
 
912
- CCompressionMethodMode method;
913
- #ifdef USE_86_FILTER
914
- if (Is86Group(groupIndex))
915
- MakeExeMethod(*options.Method, options.MaxFilter, method);
916
- else
917
- #endif
918
- method = *options.Method;
1967
+ CCompressionMethodMode method = *options.Method;
1968
+ {
1969
+ HRESULT res = MakeExeMethod(method, filterMode,
1970
+ #ifdef _7ZIP_ST
1971
+ false
1972
+ #else
1973
+ options.MaxFilter && options.MultiThreadMixer
1974
+ #endif
1975
+ );
1976
+
1977
+ RINOK(res);
1978
+ }
919
1979
 
920
- if (IsEncryptedGroup(groupIndex))
1980
+ if (filterMode.Encrypted)
921
1981
  {
922
1982
  if (!method.PasswordIsDefined)
923
1983
  {
@@ -936,93 +1996,282 @@ HRESULT Update(
936
1996
 
937
1997
  CEncoder encoder(method);
938
1998
 
939
- for (; folderRefIndex < folderRefs.Size(); folderRefIndex++)
1999
+ // ---------- Repack and copy old solid blocks ----------
2000
+
2001
+ const CSolidGroup &group = groups[filterMode.GroupIndex];
2002
+
2003
+ FOR_VECTOR(folderRefIndex, group.folderRefs)
940
2004
  {
941
- const CFolderRepack &rep = folderRefs[folderRefIndex];
942
- if (rep.Group != groupIndex)
943
- break;
944
- int folderIndex = rep.FolderIndex;
2005
+ const CFolderRepack &rep = group.folderRefs[folderRefIndex];
2006
+
2007
+ unsigned folderIndex = rep.FolderIndex;
945
2008
 
946
- if (rep.NumCopyFiles == db->NumUnpackStreamsVector[folderIndex])
2009
+ CNum numUnpackStreams = db->NumUnpackStreamsVector[folderIndex];
2010
+
2011
+ if (rep.NumCopyFiles == numUnpackStreams)
947
2012
  {
2013
+ if (opCallback)
2014
+ {
2015
+ RINOK(opCallback->ReportOperation(
2016
+ NEventIndexType::kBlockIndex, (UInt32)folderIndex,
2017
+ NUpdateNotifyOp::kReplicate));
2018
+
2019
+ // ---------- Copy old solid block ----------
2020
+ {
2021
+ CNum indexInFolder = 0;
2022
+ for (CNum fi = db->FolderStartFileIndex[folderIndex]; indexInFolder < numUnpackStreams; fi++)
2023
+ {
2024
+ if (db->Files[fi].HasStream)
2025
+ {
2026
+ indexInFolder++;
2027
+ RINOK(opCallback->ReportOperation(
2028
+ NEventIndexType::kInArcIndex, (UInt32)fi,
2029
+ NUpdateNotifyOp::kReplicate));
2030
+ }
2031
+ }
2032
+ }
2033
+ }
2034
+
948
2035
  UInt64 packSize = db->GetFolderFullPackSize(folderIndex);
949
2036
  RINOK(WriteRange(inStream, archive.SeqStream,
950
- db->GetFolderStreamPos(folderIndex, 0), packSize, progress));
2037
+ db->GetFolderStreamPos(folderIndex, 0), packSize, progress));
951
2038
  lps->ProgressOffset += packSize;
952
2039
 
953
- const CFolder &folder = db->Folders[folderIndex];
954
- CNum startIndex = db->FolderStartPackStreamIndex[folderIndex];
955
- for (int j = 0; j < folder.PackStreams.Size(); j++)
2040
+ CFolder &folder = newDatabase.Folders.AddNew();
2041
+ db->ParseFolderInfo(folderIndex, folder);
2042
+ CNum startIndex = db->FoStartPackStreamIndex[folderIndex];
2043
+ FOR_VECTOR(j, folder.PackStreams)
956
2044
  {
957
- newDatabase.PackSizes.Add(db->PackSizes[startIndex + j]);
2045
+ newDatabase.PackSizes.Add(db->GetStreamPackSize(startIndex + j));
958
2046
  // newDatabase.PackCRCsDefined.Add(db.PackCRCsDefined[startIndex + j]);
959
2047
  // newDatabase.PackCRCs.Add(db.PackCRCs[startIndex + j]);
960
2048
  }
961
- newDatabase.Folders.Add(folder);
2049
+
2050
+ size_t indexStart = db->FoToCoderUnpackSizes[folderIndex];
2051
+ size_t indexEnd = db->FoToCoderUnpackSizes[folderIndex + 1];
2052
+ for (; indexStart < indexEnd; indexStart++)
2053
+ newDatabase.CoderUnpackSizes.Add(db->CoderUnpackSizes[indexStart]);
962
2054
  }
963
2055
  else
964
2056
  {
965
- CStreamBinder sb;
966
- RINOK(sb.CreateEvents());
967
- CMyComPtr<ISequentialOutStream> sbOutStream;
968
- CMyComPtr<ISequentialInStream> sbInStream;
969
- sb.CreateStreams(&sbInStream, &sbOutStream);
2057
+ // ---------- Repack old solid block ----------
2058
+
970
2059
  CBoolVector extractStatuses;
971
2060
 
972
- CNum numUnpackStreams = db->NumUnpackStreamsVector[folderIndex];
973
2061
  CNum indexInFolder = 0;
974
-
2062
+
2063
+ if (opCallback)
2064
+ {
2065
+ RINOK(opCallback->ReportOperation(
2066
+ NEventIndexType::kBlockIndex, (UInt32)folderIndex,
2067
+ NUpdateNotifyOp::kRepack))
2068
+ }
2069
+
2070
+ /* We could reduce data size of decoded folder, if we don't need to repack
2071
+ last files in folder. But the gain in speed is small in most cases.
2072
+ So we unpack full folder. */
2073
+
2074
+ UInt64 sizeToEncode = 0;
2075
+
2076
+ /*
2077
+ UInt64 importantUnpackSize = 0;
2078
+ unsigned numImportantFiles = 0;
2079
+ UInt64 decodeSize = 0;
2080
+ */
2081
+
975
2082
  for (CNum fi = db->FolderStartFileIndex[folderIndex]; indexInFolder < numUnpackStreams; fi++)
976
2083
  {
977
2084
  bool needExtract = false;
978
- if (db->Files[fi].HasStream)
2085
+ const CFileItem &file = db->Files[fi];
2086
+
2087
+ if (file.HasStream)
979
2088
  {
980
2089
  indexInFolder++;
981
2090
  int updateIndex = fileIndexToUpdateIndexMap[fi];
982
2091
  if (updateIndex >= 0 && !updateItems[updateIndex].NewData)
983
2092
  needExtract = true;
2093
+ // decodeSize += file.Size;
984
2094
  }
2095
+
985
2096
  extractStatuses.Add(needExtract);
2097
+ if (needExtract)
2098
+ {
2099
+ sizeToEncode += file.Size;
2100
+ /*
2101
+ numImportantFiles = extractStatuses.Size();
2102
+ importantUnpackSize = decodeSize;
2103
+ */
2104
+ }
986
2105
  }
987
2106
 
988
- RINOK(threadDecoder.FosSpec->Init(db, db->FolderStartFileIndex[folderIndex], &extractStatuses, sbOutStream));
989
- sbOutStream.Release();
990
-
991
- threadDecoder.InStream = inStream;
992
- threadDecoder.Folder = &db->Folders[folderIndex];
993
- threadDecoder.StartPos = db->GetFolderStreamPos(folderIndex, 0);
994
- threadDecoder.PackSizes = &db->PackSizes[db->FolderStartPackStreamIndex[folderIndex]];
995
-
996
- threadDecoder.Start();
997
-
998
- int startPackIndex = newDatabase.PackSizes.Size();
999
- CFolder newFolder;
1000
- RINOK(encoder.Encode(
1001
- EXTERNAL_CODECS_LOC_VARS
1002
- sbInStream, NULL, &inSizeForReduce, newFolder,
1003
- archive.SeqStream, newDatabase.PackSizes, progress));
1004
-
1005
- threadDecoder.WaitFinish();
2107
+ // extractStatuses.DeleteFrom(numImportantFiles);
2108
+
2109
+ unsigned startPackIndex = newDatabase.PackSizes.Size();
2110
+ UInt64 curUnpackSize;
2111
+ {
2112
+
2113
+ CMyComPtr<ISequentialInStream> sbInStream;
2114
+ CRepackStreamBase *repackBase;
2115
+ CFolderInStream2 *FosSpec2 = NULL;
2116
+
2117
+ CRepackInStreamWithSizes *inStreamSizeCountSpec = new CRepackInStreamWithSizes;
2118
+ CMyComPtr<ISequentialInStream> inStreamSizeCount = inStreamSizeCountSpec;
2119
+ {
2120
+ #ifndef _7ZIP_ST
2121
+ if (options.MultiThreadMixer)
2122
+ {
2123
+ repackBase = threadDecoder.FosSpec;
2124
+ CMyComPtr<ISequentialOutStream> sbOutStream;
2125
+ sb.CreateStreams(&sbInStream, &sbOutStream);
2126
+ sb.ReInit();
2127
+
2128
+ threadDecoder.FosSpec->_stream = sbOutStream;
2129
+
2130
+ threadDecoder.InStream = inStream;
2131
+ threadDecoder.StartPos = db->ArcInfo.DataStartPosition; // db->GetFolderStreamPos(folderIndex, 0);
2132
+ threadDecoder.Folders = (const CFolders *)db;
2133
+ threadDecoder.FolderIndex = folderIndex;
2134
+
2135
+ // threadDecoder.UnpackSize = importantUnpackSize;
2136
+ // threadDecoder.send_UnpackSize = true;
2137
+ }
2138
+ else
2139
+ #endif
2140
+ {
2141
+ FosSpec2 = new CFolderInStream2;
2142
+ FosSpec2->Init();
2143
+ sbInStream = FosSpec2;
2144
+ repackBase = FosSpec2;
2145
+
2146
+ #ifndef _NO_CRYPTO
2147
+ bool isEncrypted = false;
2148
+ bool passwordIsDefined = false;
2149
+ UString password;
2150
+ #endif
2151
+
2152
+ CMyComPtr<ISequentialInStream> decodedStream;
2153
+ HRESULT res = threadDecoder.Decoder.Decode(
2154
+ EXTERNAL_CODECS_LOC_VARS
2155
+ inStream,
2156
+ db->ArcInfo.DataStartPosition, // db->GetFolderStreamPos(folderIndex, 0);,
2157
+ *db, folderIndex,
2158
+ // &importantUnpackSize, // *unpackSize
2159
+ NULL, // *unpackSize : FULL unpack
2160
+
2161
+ NULL, // *outStream
2162
+ NULL, // *compressProgress
2163
+ &decodedStream
2164
+
2165
+ _7Z_DECODER_CRYPRO_VARS
2166
+ #ifndef _7ZIP_ST
2167
+ , false // mtMode
2168
+ , 1 // numThreads
2169
+ #endif
2170
+ );
2171
+
2172
+ RINOK(res);
2173
+ if (!decodedStream)
2174
+ return E_FAIL;
2175
+
2176
+ FosSpec2->_inStream = decodedStream;
2177
+ }
2178
+
2179
+ repackBase->_db = db;
2180
+ repackBase->_opCallback = opCallback;
2181
+ repackBase->_extractCallback = extractCallback;
2182
+
2183
+ UInt32 startIndex = db->FolderStartFileIndex[folderIndex];
2184
+ RINOK(repackBase->Init(startIndex, &extractStatuses));
2185
+
2186
+ inStreamSizeCountSpec->_db = db;
2187
+ inStreamSizeCountSpec->Init(sbInStream, startIndex, &extractStatuses);
2188
+
2189
+ #ifndef _7ZIP_ST
2190
+ if (options.MultiThreadMixer)
2191
+ {
2192
+ threadDecoder.Start();
2193
+ }
2194
+ #endif
2195
+ }
2196
+
2197
+
2198
+ HRESULT encodeRes = encoder.Encode(
2199
+ EXTERNAL_CODECS_LOC_VARS
2200
+ inStreamSizeCount,
2201
+ // NULL,
2202
+ &inSizeForReduce,
2203
+ newDatabase.Folders.AddNew(), newDatabase.CoderUnpackSizes, curUnpackSize,
2204
+ archive.SeqStream, newDatabase.PackSizes, progress);
2205
+
2206
+ if (encodeRes == k_My_HRESULT_CRC_ERROR)
2207
+ return E_FAIL;
2208
+
2209
+ #ifndef _7ZIP_ST
2210
+ if (options.MultiThreadMixer)
2211
+ {
2212
+ // 16.00: hang was fixed : for case if decoding was not finished.
2213
+ // We close CBinderInStream and it calls CStreamBinder::CloseRead()
2214
+ inStreamSizeCount.Release();
2215
+ sbInStream.Release();
2216
+
2217
+ threadDecoder.WaitExecuteFinish();
2218
+
2219
+ HRESULT decodeRes = threadDecoder.Result;
2220
+ // if (res == k_My_HRESULT_CRC_ERROR)
2221
+ if (decodeRes == S_FALSE)
2222
+ {
2223
+ if (extractCallback)
2224
+ {
2225
+ RINOK(extractCallback->ReportExtractResult(
2226
+ NEventIndexType::kInArcIndex, db->FolderStartFileIndex[folderIndex],
2227
+ // NEventIndexType::kBlockIndex, (UInt32)folderIndex,
2228
+ NExtract::NOperationResult::kDataError));
2229
+ }
2230
+ return E_FAIL;
2231
+ }
2232
+ RINOK(decodeRes);
2233
+ if (encodeRes == S_OK)
2234
+ if (sb.ProcessedSize != sizeToEncode)
2235
+ encodeRes = E_FAIL;
2236
+ }
2237
+ else
2238
+ #endif
2239
+ {
2240
+ if (FosSpec2->Result == S_FALSE)
2241
+ {
2242
+ if (extractCallback)
2243
+ {
2244
+ RINOK(extractCallback->ReportExtractResult(
2245
+ NEventIndexType::kBlockIndex, (UInt32)folderIndex,
2246
+ NExtract::NOperationResult::kDataError));
2247
+ }
2248
+ return E_FAIL;
2249
+ }
2250
+ RINOK(FosSpec2->Result);
2251
+ }
1006
2252
 
1007
- RINOK(threadDecoder.Result);
2253
+ RINOK(encodeRes);
2254
+ RINOK(repackBase->CheckFinishedState());
2255
+
2256
+ if (curUnpackSize != sizeToEncode)
2257
+ return E_FAIL;
2258
+ }
1008
2259
 
1009
2260
  for (; startPackIndex < newDatabase.PackSizes.Size(); startPackIndex++)
1010
2261
  lps->OutSize += newDatabase.PackSizes[startPackIndex];
1011
- lps->InSize += newFolder.GetUnpackSize();
1012
-
1013
- newDatabase.Folders.Add(newFolder);
2262
+ lps->InSize += curUnpackSize;
1014
2263
  }
1015
2264
 
1016
2265
  newDatabase.NumUnpackStreamsVector.Add(rep.NumCopyFiles);
1017
2266
 
1018
- CNum numUnpackStreams = db->NumUnpackStreamsVector[folderIndex];
1019
-
1020
2267
  CNum indexInFolder = 0;
1021
2268
  for (CNum fi = db->FolderStartFileIndex[folderIndex]; indexInFolder < numUnpackStreams; fi++)
1022
2269
  {
1023
2270
  CFileItem file;
1024
2271
  CFileItem2 file2;
1025
- db->GetFile(fi, file, file2);
2272
+ GetFile(*db, fi, file, file2);
2273
+ UString name;
2274
+ db->GetPath(fi, name);
1026
2275
  if (file.HasStream)
1027
2276
  {
1028
2277
  indexInFolder++;
@@ -1041,30 +2290,47 @@ HRESULT Update(
1041
2290
  uf.CrcDefined = file.CrcDefined;
1042
2291
  uf.HasStream = file.HasStream;
1043
2292
  file = uf;
2293
+ name = ui.Name;
1044
2294
  }
1045
- newDatabase.AddFile(file, file2);
2295
+ /*
2296
+ file.Parent = ui.ParentFolderIndex;
2297
+ if (ui.TreeFolderIndex >= 0)
2298
+ treeFolderToArcIndex[ui.TreeFolderIndex] = newDatabase.Files.Size();
2299
+ if (totalSecureDataSize != 0)
2300
+ newDatabase.SecureIDs.Add(ui.SecureIndex);
2301
+ */
2302
+ newDatabase.AddFile(file, file2, name);
1046
2303
  }
1047
2304
  }
1048
2305
  }
1049
2306
  }
1050
2307
 
1051
- int numFiles = group.Indices.Size();
2308
+
2309
+ // ---------- Compress files to new solid blocks ----------
2310
+
2311
+ unsigned numFiles = group.Indices.Size();
1052
2312
  if (numFiles == 0)
1053
2313
  continue;
1054
2314
  CRecordVector<CRefItem> refItems;
1055
- refItems.Reserve(numFiles);
1056
- bool sortByType = (numSolidFiles > 1);
2315
+ refItems.ClearAndSetSize(numFiles);
2316
+ bool sortByType = (options.UseTypeSorting && numSolidFiles > 1);
2317
+
2318
+ unsigned i;
2319
+
1057
2320
  for (i = 0; i < numFiles; i++)
1058
- refItems.Add(CRefItem(group.Indices[i], updateItems[group.Indices[i]], sortByType));
1059
- refItems.Sort(CompareUpdateItems, (void *)&sortByType);
2321
+ refItems[i] = CRefItem(group.Indices[i], updateItems[group.Indices[i]], sortByType);
2322
+
2323
+ CSortParam sortParam;
2324
+ // sortParam.TreeFolders = &treeFolders;
2325
+ sortParam.SortByType = sortByType;
2326
+ refItems.Sort(CompareUpdateItems, (void *)&sortParam);
1060
2327
 
1061
- CRecordVector<UInt32> indices;
1062
- indices.Reserve(numFiles);
2328
+ CObjArray<UInt32> indices(numFiles);
1063
2329
 
1064
2330
  for (i = 0; i < numFiles; i++)
1065
2331
  {
1066
2332
  UInt32 index = refItems[i].Index;
1067
- indices.Add(index);
2333
+ indices[i] = index;
1068
2334
  /*
1069
2335
  const CUpdateItem &ui = updateItems[index];
1070
2336
  CFileItem file;
@@ -1081,10 +2347,11 @@ HRESULT Update(
1081
2347
  for (i = 0; i < numFiles;)
1082
2348
  {
1083
2349
  UInt64 totalSize = 0;
1084
- int numSubFiles;
1085
- UString prevExtension;
1086
- for (numSubFiles = 0; i + numSubFiles < numFiles &&
1087
- numSubFiles < numSolidFiles; numSubFiles++)
2350
+ unsigned numSubFiles;
2351
+
2352
+ const wchar_t *prevExtension = NULL;
2353
+
2354
+ for (numSubFiles = 0; i + numSubFiles < numFiles && numSubFiles < numSolidFiles; numSubFiles++)
1088
2355
  {
1089
2356
  const CUpdateItem &ui = updateItems[indices[i + numSubFiles]];
1090
2357
  totalSize += ui.Size;
@@ -1092,49 +2359,65 @@ HRESULT Update(
1092
2359
  break;
1093
2360
  if (options.SolidExtension)
1094
2361
  {
1095
- UString ext = ui.GetExtension();
2362
+ int slashPos = ui.Name.ReverseFind_PathSepar();
2363
+ int dotPos = ui.Name.ReverseFind_Dot();
2364
+ const wchar_t *ext = ui.Name.Ptr(dotPos <= slashPos ? ui.Name.Len() : dotPos + 1);
1096
2365
  if (numSubFiles == 0)
1097
2366
  prevExtension = ext;
1098
- else
1099
- if (ext.CompareNoCase(prevExtension) != 0)
1100
- break;
2367
+ else if (!StringsAreEqualNoCase(ext, prevExtension))
2368
+ break;
1101
2369
  }
1102
2370
  }
2371
+
1103
2372
  if (numSubFiles < 1)
1104
2373
  numSubFiles = 1;
1105
2374
 
2375
+ RINOK(lps->SetCur());
2376
+
1106
2377
  CFolderInStream *inStreamSpec = new CFolderInStream;
1107
2378
  CMyComPtr<ISequentialInStream> solidInStream(inStreamSpec);
1108
2379
  inStreamSpec->Init(updateCallback, &indices[i], numSubFiles);
1109
2380
 
1110
- CFolder folderItem;
1111
-
1112
- int startPackIndex = newDatabase.PackSizes.Size();
2381
+ unsigned startPackIndex = newDatabase.PackSizes.Size();
2382
+ UInt64 curFolderUnpackSize;
1113
2383
  RINOK(encoder.Encode(
1114
2384
  EXTERNAL_CODECS_LOC_VARS
1115
- solidInStream, NULL, &inSizeForReduce, folderItem,
2385
+ solidInStream,
2386
+ // NULL,
2387
+ &inSizeForReduce,
2388
+ newDatabase.Folders.AddNew(), newDatabase.CoderUnpackSizes, curFolderUnpackSize,
1116
2389
  archive.SeqStream, newDatabase.PackSizes, progress));
1117
2390
 
2391
+ if (!inStreamSpec->WasFinished())
2392
+ return E_FAIL;
2393
+
1118
2394
  for (; startPackIndex < newDatabase.PackSizes.Size(); startPackIndex++)
1119
2395
  lps->OutSize += newDatabase.PackSizes[startPackIndex];
1120
2396
 
1121
- lps->InSize += folderItem.GetUnpackSize();
2397
+ lps->InSize += curFolderUnpackSize;
1122
2398
  // for ()
1123
2399
  // newDatabase.PackCRCsDefined.Add(false);
1124
2400
  // newDatabase.PackCRCs.Add(0);
1125
-
1126
- newDatabase.Folders.Add(folderItem);
1127
-
2401
+
1128
2402
  CNum numUnpackStreams = 0;
1129
- for (int subIndex = 0; subIndex < numSubFiles; subIndex++)
2403
+ UInt64 skippedSize = 0;
2404
+
2405
+ for (unsigned subIndex = 0; subIndex < numSubFiles; subIndex++)
1130
2406
  {
1131
2407
  const CUpdateItem &ui = updateItems[indices[i + subIndex]];
1132
2408
  CFileItem file;
1133
2409
  CFileItem2 file2;
2410
+ UString name;
1134
2411
  if (ui.NewProps)
2412
+ {
1135
2413
  FromUpdateItemToFileItem(ui, file, file2);
2414
+ name = ui.Name;
2415
+ }
1136
2416
  else
1137
- db->GetFile(ui.IndexInArchive, file, file2);
2417
+ {
2418
+ GetFile(*db, ui.IndexInArchive, file, file2);
2419
+ db->GetPath(ui.IndexInArchive, name);
2420
+ }
1138
2421
  if (file2.IsAnti || file.IsDir)
1139
2422
  return E_FAIL;
1140
2423
 
@@ -1144,12 +2427,15 @@ HRESULT Update(
1144
2427
  */
1145
2428
  if (!inStreamSpec->Processed[subIndex])
1146
2429
  {
2430
+ skippedSize += ui.Size;
1147
2431
  continue;
1148
- // file.Name += L".locked";
2432
+ // file.Name.AddAscii(".locked");
1149
2433
  }
1150
2434
 
1151
2435
  file.Crc = inStreamSpec->CRCs[subIndex];
1152
2436
  file.Size = inStreamSpec->Sizes[subIndex];
2437
+
2438
+ // if (file.Size >= 0) // test purposes
1153
2439
  if (file.Size != 0)
1154
2440
  {
1155
2441
  file.CrcDefined = true;
@@ -1161,55 +2447,65 @@ HRESULT Update(
1161
2447
  file.CrcDefined = false;
1162
2448
  file.HasStream = false;
1163
2449
  }
1164
- newDatabase.AddFile(file, file2);
2450
+
2451
+ /*
2452
+ file.Parent = ui.ParentFolderIndex;
2453
+ if (ui.TreeFolderIndex >= 0)
2454
+ treeFolderToArcIndex[ui.TreeFolderIndex] = newDatabase.Files.Size();
2455
+ if (totalSecureDataSize != 0)
2456
+ newDatabase.SecureIDs.Add(ui.SecureIndex);
2457
+ */
2458
+ newDatabase.AddFile(file, file2, name);
1165
2459
  }
2460
+
1166
2461
  // numUnpackStreams = 0 is very bad case for locked files
1167
2462
  // v3.13 doesn't understand it.
1168
2463
  newDatabase.NumUnpackStreamsVector.Add(numUnpackStreams);
1169
2464
  i += numSubFiles;
2465
+
2466
+ if (skippedSize != 0 && complexity >= skippedSize)
2467
+ {
2468
+ complexity -= skippedSize;
2469
+ RINOK(updateCallback->SetTotal(complexity));
2470
+ }
1170
2471
  }
1171
2472
  }
1172
2473
 
1173
- if (folderRefIndex != folderRefs.Size())
1174
- return E_FAIL;
2474
+ RINOK(lps->SetCur());
1175
2475
 
1176
2476
  /*
1177
- folderRefs.ClearAndFree();
1178
2477
  fileIndexToUpdateIndexMap.ClearAndFree();
1179
2478
  groups.ClearAndFree();
1180
2479
  */
1181
2480
 
2481
+ /*
2482
+ for (i = 0; i < newDatabase.Files.Size(); i++)
1182
2483
  {
1183
- // ---------- Write Folders & Empty Files ----------
1184
-
1185
- CRecordVector<int> emptyRefs;
1186
- for (i = 0; i < updateItems.Size(); i++)
1187
- {
1188
- const CUpdateItem &ui = updateItems[i];
1189
- if (ui.NewData)
1190
- {
1191
- if (ui.HasStream())
1192
- continue;
1193
- }
1194
- else if (ui.IndexInArchive != -1 && db->Files[ui.IndexInArchive].HasStream)
1195
- continue;
1196
- emptyRefs.Add(i);
1197
- }
1198
- emptyRefs.Sort(CompareEmptyItems, (void *)&updateItems);
1199
- for (i = 0; i < emptyRefs.Size(); i++)
2484
+ CFileItem &file = newDatabase.Files[i];
2485
+ file.Parent = treeFolderToArcIndex[file.Parent];
2486
+ }
2487
+
2488
+ if (totalSecureDataSize != 0)
2489
+ {
2490
+ newDatabase.SecureBuf.SetCapacity(totalSecureDataSize);
2491
+ size_t pos = 0;
2492
+ newDatabase.SecureSizes.Reserve(secureBlocks.Sorted.Size());
2493
+ for (i = 0; i < secureBlocks.Sorted.Size(); i++)
1200
2494
  {
1201
- const CUpdateItem &ui = updateItems[emptyRefs[i]];
1202
- CFileItem file;
1203
- CFileItem2 file2;
1204
- if (ui.NewProps)
1205
- FromUpdateItemToFileItem(ui, file, file2);
1206
- else
1207
- db->GetFile(ui.IndexInArchive, file, file2);
1208
- newDatabase.AddFile(file, file2);
2495
+ const CByteBuffer &buf = secureBlocks.Bufs[secureBlocks.Sorted[i]];
2496
+ size_t size = buf.GetCapacity();
2497
+ if (size != 0)
2498
+ memcpy(newDatabase.SecureBuf + pos, buf, size);
2499
+ newDatabase.SecureSizes.Add((UInt32)size);
2500
+ pos += size;
1209
2501
  }
1210
2502
  }
1211
-
2503
+ */
1212
2504
  newDatabase.ReserveDown();
2505
+
2506
+ if (opCallback)
2507
+ RINOK(opCallback->ReportOperation(NEventIndexType::kNoIndex, (UInt32)(Int32)-1, NUpdateNotifyOp::kHeader));
2508
+
1213
2509
  return S_OK;
1214
2510
  }
1215
2511