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
@@ -0,0 +1,1880 @@
1
+ // HfsHandler.cpp
2
+
3
+ #include "StdAfx.h"
4
+
5
+ #include "../../../C/CpuArch.h"
6
+
7
+ #include "../../Common/ComTry.h"
8
+ #include "../../Common/MyString.h"
9
+
10
+ #include "../../Windows/PropVariant.h"
11
+
12
+ #include "../Common/LimitedStreams.h"
13
+ #include "../Common/RegisterArc.h"
14
+ #include "../Common/StreamObjects.h"
15
+ #include "../Common/StreamUtils.h"
16
+
17
+ #include "../Compress/ZlibDecoder.h"
18
+
19
+ /* if HFS_SHOW_ALT_STREAMS is defined, the handler will show attribute files
20
+ and resource forks. In most cases it looks useless. So we disable it. */
21
+
22
+ // #define HFS_SHOW_ALT_STREAMS
23
+
24
+ #define Get16(p) GetBe16(p)
25
+ #define Get32(p) GetBe32(p)
26
+ #define Get64(p) GetBe64(p)
27
+
28
+ namespace NArchive {
29
+ namespace NHfs {
30
+
31
+ static const char *kResFileName = "rsrc"; // "com.apple.ResourceFork";
32
+
33
+ struct CExtent
34
+ {
35
+ UInt32 Pos;
36
+ UInt32 NumBlocks;
37
+ };
38
+
39
+ struct CIdExtents
40
+ {
41
+ UInt32 ID;
42
+ UInt32 StartBlock;
43
+ CRecordVector<CExtent> Extents;
44
+ };
45
+
46
+ struct CFork
47
+ {
48
+ UInt64 Size;
49
+ UInt32 NumBlocks;
50
+ // UInt32 ClumpSize;
51
+ CRecordVector<CExtent> Extents;
52
+
53
+ CFork(): Size(0), NumBlocks(0) {}
54
+
55
+ void Parse(const Byte *p);
56
+
57
+ bool IsEmpty() const { return Size == 0 && NumBlocks == 0 && Extents.Size() == 0; }
58
+
59
+ UInt32 Calc_NumBlocks_from_Extents() const;
60
+ bool Check_NumBlocks() const;
61
+
62
+ bool Check_Size_with_NumBlocks(unsigned blockSizeLog) const
63
+ {
64
+ return Size <= ((UInt64)NumBlocks << blockSizeLog);
65
+ }
66
+
67
+ bool IsOk(unsigned blockSizeLog) const
68
+ {
69
+ // we don't check cases with extra (empty) blocks in last extent
70
+ return Check_NumBlocks() && Check_Size_with_NumBlocks(blockSizeLog);
71
+ }
72
+
73
+ bool Upgrade(const CObjectVector<CIdExtents> &items, UInt32 id);
74
+ bool UpgradeAndTest(const CObjectVector<CIdExtents> &items, UInt32 id, unsigned blockSizeLog)
75
+ {
76
+ if (!Upgrade(items, id))
77
+ return false;
78
+ return IsOk(blockSizeLog);
79
+ }
80
+ };
81
+
82
+ static const unsigned kNumFixedExtents = 8;
83
+
84
+ void CFork::Parse(const Byte *p)
85
+ {
86
+ Extents.Clear();
87
+ Size = Get64(p);
88
+ // ClumpSize = Get32(p + 8);
89
+ NumBlocks = Get32(p + 12);
90
+ p += 16;
91
+ for (unsigned i = 0; i < kNumFixedExtents; i++, p += 8)
92
+ {
93
+ CExtent e;
94
+ e.Pos = Get32(p);
95
+ e.NumBlocks = Get32(p + 4);
96
+ if (e.NumBlocks != 0)
97
+ Extents.Add(e);
98
+ }
99
+ }
100
+
101
+ UInt32 CFork::Calc_NumBlocks_from_Extents() const
102
+ {
103
+ UInt32 num = 0;
104
+ FOR_VECTOR (i, Extents)
105
+ {
106
+ num += Extents[i].NumBlocks;
107
+ }
108
+ return num;
109
+ }
110
+
111
+ bool CFork::Check_NumBlocks() const
112
+ {
113
+ UInt32 num = 0;
114
+ FOR_VECTOR (i, Extents)
115
+ {
116
+ UInt32 next = num + Extents[i].NumBlocks;
117
+ if (next < num)
118
+ return false;
119
+ num = next;
120
+ }
121
+ return num == NumBlocks;
122
+ }
123
+
124
+ struct CIdIndexPair
125
+ {
126
+ UInt32 ID;
127
+ int Index;
128
+
129
+ int Compare(const CIdIndexPair &a) const;
130
+ };
131
+
132
+ #define RINOZ(x) { int __tt = (x); if (__tt != 0) return __tt; }
133
+
134
+ int CIdIndexPair::Compare(const CIdIndexPair &a) const
135
+ {
136
+ RINOZ(MyCompare(ID, a.ID));
137
+ return MyCompare(Index, a.Index);
138
+ }
139
+
140
+ static int FindItemIndex(const CRecordVector<CIdIndexPair> &items, UInt32 id)
141
+ {
142
+ unsigned left = 0, right = items.Size();
143
+ while (left != right)
144
+ {
145
+ unsigned mid = (left + right) / 2;
146
+ UInt32 midVal = items[mid].ID;
147
+ if (id == midVal)
148
+ return items[mid].Index;
149
+ if (id < midVal)
150
+ right = mid;
151
+ else
152
+ left = mid + 1;
153
+ }
154
+ return -1;
155
+ }
156
+
157
+ static int Find_in_IdExtents(const CObjectVector<CIdExtents> &items, UInt32 id)
158
+ {
159
+ unsigned left = 0, right = items.Size();
160
+ while (left != right)
161
+ {
162
+ unsigned mid = (left + right) / 2;
163
+ UInt32 midVal = items[mid].ID;
164
+ if (id == midVal)
165
+ return mid;
166
+ if (id < midVal)
167
+ right = mid;
168
+ else
169
+ left = mid + 1;
170
+ }
171
+ return -1;
172
+ }
173
+
174
+ bool CFork::Upgrade(const CObjectVector<CIdExtents> &items, UInt32 id)
175
+ {
176
+ int index = Find_in_IdExtents(items, id);
177
+ if (index < 0)
178
+ return true;
179
+ const CIdExtents &item = items[index];
180
+ if (Calc_NumBlocks_from_Extents() != item.StartBlock)
181
+ return false;
182
+ Extents += item.Extents;
183
+ return true;
184
+ }
185
+
186
+
187
+ struct CVolHeader
188
+ {
189
+ Byte Header[2];
190
+ UInt16 Version;
191
+ // UInt32 Attr;
192
+ // UInt32 LastMountedVersion;
193
+ // UInt32 JournalInfoBlock;
194
+
195
+ UInt32 CTime;
196
+ UInt32 MTime;
197
+ // UInt32 BackupTime;
198
+ // UInt32 CheckedTime;
199
+
200
+ UInt32 NumFiles;
201
+ UInt32 NumFolders;
202
+ unsigned BlockSizeLog;
203
+ UInt32 NumBlocks;
204
+ UInt32 NumFreeBlocks;
205
+
206
+ // UInt32 WriteCount;
207
+ // UInt32 FinderInfo[8];
208
+ // UInt64 VolID;
209
+
210
+ UInt64 GetPhySize() const { return (UInt64)NumBlocks << BlockSizeLog; }
211
+ UInt64 GetFreeSize() const { return (UInt64)NumFreeBlocks << BlockSizeLog; }
212
+ bool IsHfsX() const { return Version > 4; }
213
+ };
214
+
215
+ inline void HfsTimeToFileTime(UInt32 hfsTime, FILETIME &ft)
216
+ {
217
+ UInt64 v = ((UInt64)3600 * 24 * (365 * 303 + 24 * 3) + hfsTime) * 10000000;
218
+ ft.dwLowDateTime = (DWORD)v;
219
+ ft.dwHighDateTime = (DWORD)(v >> 32);
220
+ }
221
+
222
+ enum ERecordType
223
+ {
224
+ RECORD_TYPE_FOLDER = 1,
225
+ RECORD_TYPE_FILE,
226
+ RECORD_TYPE_FOLDER_THREAD,
227
+ RECORD_TYPE_FILE_THREAD
228
+ };
229
+
230
+ struct CItem
231
+ {
232
+ UString Name;
233
+
234
+ UInt32 ParentID;
235
+
236
+ UInt16 Type;
237
+ UInt16 FileMode;
238
+ // UInt16 Flags;
239
+ // UInt32 Valence;
240
+ UInt32 ID;
241
+ UInt32 CTime;
242
+ UInt32 MTime;
243
+ // UInt32 AttrMTime;
244
+ UInt32 ATime;
245
+ // UInt32 BackupDate;
246
+
247
+ /*
248
+ UInt32 OwnerID;
249
+ UInt32 GroupID;
250
+ Byte AdminFlags;
251
+ Byte OwnerFlags;
252
+ union
253
+ {
254
+ UInt32 iNodeNum;
255
+ UInt32 LinkCount;
256
+ UInt32 RawDevice;
257
+ } special;
258
+
259
+ UInt32 FileType;
260
+ UInt32 FileCreator;
261
+ UInt16 FinderFlags;
262
+ UInt16 Point[2];
263
+ */
264
+
265
+ CFork DataFork;
266
+ CFork ResourceFork;
267
+
268
+ // for compressed attribute
269
+ UInt64 UnpackSize;
270
+ size_t DataPos;
271
+ UInt32 PackSize;
272
+ unsigned Method;
273
+ bool UseAttr;
274
+ bool UseInlineData;
275
+
276
+ CItem(): UseAttr(false), UseInlineData(false) {}
277
+ bool IsDir() const { return Type == RECORD_TYPE_FOLDER; }
278
+ const CFork &GetFork(bool isResource) const { return (CFork & )*(isResource ? &ResourceFork: &DataFork ); }
279
+ };
280
+
281
+ struct CAttr
282
+ {
283
+ UInt32 ID;
284
+ UInt32 Size;
285
+ size_t Pos;
286
+ UString Name;
287
+ };
288
+
289
+ struct CRef
290
+ {
291
+ unsigned ItemIndex;
292
+ int AttrIndex;
293
+ int Parent;
294
+ bool IsResource;
295
+
296
+ bool IsAltStream() const { return IsResource || AttrIndex >= 0; }
297
+ CRef(): AttrIndex(-1), Parent(-1), IsResource(false) {}
298
+ };
299
+
300
+ class CDatabase
301
+ {
302
+ HRESULT ReadFile(const CFork &fork, CByteBuffer &buf, IInStream *inStream);
303
+ HRESULT LoadExtentFile(const CFork &fork, IInStream *inStream, CObjectVector<CIdExtents> *overflowExtentsArray);
304
+ HRESULT LoadAttrs(const CFork &fork, IInStream *inStream, IArchiveOpenCallback *progress);
305
+ HRESULT LoadCatalog(const CFork &fork, const CObjectVector<CIdExtents> *overflowExtentsArray, IInStream *inStream, IArchiveOpenCallback *progress);
306
+ bool Parse_decmpgfs(const CAttr &attr, CItem &item, bool &skip);
307
+ public:
308
+ CRecordVector<CRef> Refs;
309
+ CObjectVector<CItem> Items;
310
+ CObjectVector<CAttr> Attrs;
311
+
312
+ CByteBuffer AttrBuf;
313
+
314
+ CVolHeader Header;
315
+ bool HeadersError;
316
+ bool ThereAreAltStreams;
317
+ // bool CaseSensetive;
318
+ UString ResFileName;
319
+
320
+ UInt64 PhySize;
321
+
322
+ void Clear()
323
+ {
324
+ PhySize = 0;
325
+ HeadersError = false;
326
+ ThereAreAltStreams = false;
327
+ // CaseSensetive = false;
328
+ Refs.Clear();
329
+ Items.Clear();
330
+ Attrs.Clear();
331
+ AttrBuf.Free();
332
+ }
333
+
334
+ UInt64 Get_UnpackSize_of_Ref(const CRef &ref) const
335
+ {
336
+ if (ref.AttrIndex >= 0)
337
+ return Attrs[ref.AttrIndex].Size;
338
+ const CItem &item = Items[ref.ItemIndex];
339
+ if (item.IsDir())
340
+ return 0;
341
+ if (item.UseAttr)
342
+ return item.UnpackSize;
343
+ return item.GetFork(ref.IsResource).Size;
344
+ }
345
+
346
+ void GetItemPath(unsigned index, NWindows::NCOM::CPropVariant &path) const;
347
+ HRESULT Open2(IInStream *inStream, IArchiveOpenCallback *progress);
348
+ };
349
+
350
+ enum
351
+ {
352
+ kHfsID_Root = 1,
353
+ kHfsID_RootFolder = 2,
354
+ kHfsID_ExtentsFile = 3,
355
+ kHfsID_CatalogFile = 4,
356
+ kHfsID_BadBlockFile = 5,
357
+ kHfsID_AllocationFile = 6,
358
+ kHfsID_StartupFile = 7,
359
+ kHfsID_AttributesFile = 8,
360
+ kHfsID_RepairCatalogFile = 14,
361
+ kHfsID_BogusExtentFile = 15,
362
+ kHfsID_FirstUserCatalogNode = 16
363
+ };
364
+
365
+ void CDatabase::GetItemPath(unsigned index, NWindows::NCOM::CPropVariant &path) const
366
+ {
367
+ unsigned len = 0;
368
+ const unsigned kNumLevelsMax = (1 << 10);
369
+ int cur = index;
370
+ unsigned i;
371
+
372
+ for (i = 0; i < kNumLevelsMax; i++)
373
+ {
374
+ const CRef &ref = Refs[cur];
375
+ const UString *s;
376
+
377
+ if (ref.IsResource)
378
+ s = &ResFileName;
379
+ else if (ref.AttrIndex >= 0)
380
+ s = &Attrs[ref.AttrIndex].Name;
381
+ else
382
+ s = &Items[ref.ItemIndex].Name;
383
+
384
+ len += s->Len();
385
+ len++;
386
+ cur = ref.Parent;
387
+ if (cur < 0)
388
+ break;
389
+ }
390
+
391
+ len--;
392
+ wchar_t *p = path.AllocBstr(len);
393
+ p[len] = 0;
394
+ cur = index;
395
+
396
+ for (;;)
397
+ {
398
+ const CRef &ref = Refs[cur];
399
+ const UString *s;
400
+ wchar_t delimChar = L':';
401
+
402
+ if (ref.IsResource)
403
+ s = &ResFileName;
404
+ else if (ref.AttrIndex >= 0)
405
+ s = &Attrs[ref.AttrIndex].Name;
406
+ else
407
+ {
408
+ delimChar = WCHAR_PATH_SEPARATOR;
409
+ s = &Items[ref.ItemIndex].Name;
410
+ }
411
+
412
+ unsigned curLen = s->Len();
413
+ len -= curLen;
414
+
415
+ const wchar_t *src = (const wchar_t *)*s;
416
+ wchar_t *dest = p + len;
417
+ for (unsigned j = 0; j < curLen; j++)
418
+ dest[j] = src[j];
419
+
420
+ if (len == 0)
421
+ break;
422
+ p[--len] = delimChar;
423
+ cur = ref.Parent;
424
+ }
425
+ }
426
+
427
+ // Actually we read all blocks. It can be larger than fork.Size
428
+
429
+ HRESULT CDatabase::ReadFile(const CFork &fork, CByteBuffer &buf, IInStream *inStream)
430
+ {
431
+ if (fork.NumBlocks >= Header.NumBlocks)
432
+ return S_FALSE;
433
+ size_t totalSize = (size_t)fork.NumBlocks << Header.BlockSizeLog;
434
+ if ((totalSize >> Header.BlockSizeLog) != fork.NumBlocks)
435
+ return S_FALSE;
436
+ buf.Alloc(totalSize);
437
+ UInt32 curBlock = 0;
438
+ FOR_VECTOR (i, fork.Extents)
439
+ {
440
+ if (curBlock >= fork.NumBlocks)
441
+ return S_FALSE;
442
+ const CExtent &e = fork.Extents[i];
443
+ if (e.Pos > Header.NumBlocks ||
444
+ e.NumBlocks > fork.NumBlocks - curBlock ||
445
+ e.NumBlocks > Header.NumBlocks - e.Pos)
446
+ return S_FALSE;
447
+ RINOK(inStream->Seek((UInt64)e.Pos << Header.BlockSizeLog, STREAM_SEEK_SET, NULL));
448
+ RINOK(ReadStream_FALSE(inStream,
449
+ (Byte *)buf + ((size_t)curBlock << Header.BlockSizeLog),
450
+ (size_t)e.NumBlocks << Header.BlockSizeLog));
451
+ curBlock += e.NumBlocks;
452
+ }
453
+ return S_OK;
454
+ }
455
+
456
+ static const unsigned kNodeDescriptor_Size = 14;
457
+
458
+ struct CNodeDescriptor
459
+ {
460
+ UInt32 fLink;
461
+ // UInt32 bLink;
462
+ Byte Kind;
463
+ // Byte Height;
464
+ unsigned NumRecords;
465
+
466
+ bool CheckNumRecords(unsigned nodeSizeLog)
467
+ {
468
+ return (kNodeDescriptor_Size + ((UInt32)NumRecords + 1) * 2 <= ((UInt32)1 << nodeSizeLog));
469
+ }
470
+ void Parse(const Byte *p);
471
+ };
472
+
473
+ void CNodeDescriptor::Parse(const Byte *p)
474
+ {
475
+ fLink = Get32(p);
476
+ // bLink = Get32(p + 4);
477
+ Kind = p[8];
478
+ // Height = p[9];
479
+ NumRecords = Get16(p + 10);
480
+ }
481
+
482
+ struct CHeaderRec
483
+ {
484
+ // UInt16 TreeDepth;
485
+ // UInt32 RootNode;
486
+ // UInt32 LeafRecords;
487
+ UInt32 FirstLeafNode;
488
+ // UInt32 LastLeafNode;
489
+ unsigned NodeSizeLog;
490
+ // UInt16 MaxKeyLength;
491
+ UInt32 TotalNodes;
492
+ // UInt32 FreeNodes;
493
+ // UInt16 Reserved1;
494
+ // UInt32 ClumpSize;
495
+ // Byte BtreeType;
496
+ // Byte KeyCompareType;
497
+ // UInt32 Attributes;
498
+ // UInt32 Reserved3[16];
499
+
500
+ HRESULT Parse(const Byte *p);
501
+ };
502
+
503
+ HRESULT CHeaderRec::Parse(const Byte *p)
504
+ {
505
+ // TreeDepth = Get16(p);
506
+ // RootNode = Get32(p + 2);
507
+ // LeafRecords = Get32(p + 6);
508
+ FirstLeafNode = Get32(p + 0xA);
509
+ // LastLeafNode = Get32(p + 0xE);
510
+ UInt32 nodeSize = Get16(p + 0x12);
511
+
512
+ unsigned i;
513
+ for (i = 9; ((UInt32)1 << i) != nodeSize; i++)
514
+ if (i == 16)
515
+ return S_FALSE;
516
+ NodeSizeLog = i;
517
+
518
+ // MaxKeyLength = Get16(p + 0x14);
519
+ TotalNodes = Get32(p + 0x16);
520
+ // FreeNodes = Get32(p + 0x1A);
521
+ // Reserved1 = Get16(p + 0x1E);
522
+ // ClumpSize = Get32(p + 0x20);
523
+ // BtreeType = p[0x24];
524
+ // KeyCompareType = p[0x25];
525
+ // Attributes = Get32(p + 0x26);
526
+ /*
527
+ for (int i = 0; i < 16; i++)
528
+ Reserved3[i] = Get32(p + 0x2A + i * 4);
529
+ */
530
+ return S_OK;
531
+ }
532
+
533
+
534
+ static const Byte kNodeType_Leaf = 0xFF;
535
+ // static const Byte kNodeType_Index = 0;
536
+ // static const Byte kNodeType_Header = 1;
537
+ // static const Byte kNodeType_Mode = 2;
538
+
539
+ static const Byte kExtentForkType_Data = 0;
540
+ static const Byte kExtentForkType_Resource = 0xFF;
541
+
542
+ /* It loads data extents from Extents Overflow File
543
+ Most dmg installers are not fragmented. So there are no extents in Overflow File. */
544
+
545
+ HRESULT CDatabase::LoadExtentFile(const CFork &fork, IInStream *inStream, CObjectVector<CIdExtents> *overflowExtentsArray)
546
+ {
547
+ if (fork.NumBlocks == 0)
548
+ return S_OK;
549
+ CByteBuffer buf;
550
+ RINOK(ReadFile(fork, buf, inStream));
551
+ const Byte *p = (const Byte *)buf;
552
+
553
+ // CNodeDescriptor nodeDesc;
554
+ // nodeDesc.Parse(p);
555
+ CHeaderRec hr;
556
+ RINOK(hr.Parse(p + kNodeDescriptor_Size));
557
+
558
+ if ((buf.Size() >> hr.NodeSizeLog) < hr.TotalNodes)
559
+ return S_FALSE;
560
+
561
+ UInt32 node = hr.FirstLeafNode;
562
+ if (node == 0)
563
+ return S_OK;
564
+
565
+ CByteBuffer usedBuf(hr.TotalNodes);
566
+ memset(usedBuf, 0, hr.TotalNodes);
567
+
568
+ while (node != 0)
569
+ {
570
+ if (node >= hr.TotalNodes || usedBuf[node] != 0)
571
+ return S_FALSE;
572
+ usedBuf[node] = 1;
573
+
574
+ size_t nodeOffset = (size_t)node << hr.NodeSizeLog;
575
+ CNodeDescriptor desc;
576
+ desc.Parse(p + nodeOffset);
577
+ if (!desc.CheckNumRecords(hr.NodeSizeLog))
578
+ return S_FALSE;
579
+ if (desc.Kind != kNodeType_Leaf)
580
+ return S_FALSE;
581
+
582
+ UInt32 endBlock = 0;
583
+
584
+ for (unsigned i = 0; i < desc.NumRecords; i++)
585
+ {
586
+ UInt32 nodeSize = (UInt32)1 << hr.NodeSizeLog;
587
+ UInt32 offs = Get16(p + nodeOffset + nodeSize - (i + 1) * 2);
588
+ UInt32 offsNext = Get16(p + nodeOffset + nodeSize - (i + 2) * 2);
589
+ if (offs > nodeSize || offsNext > nodeSize)
590
+ return S_FALSE;
591
+ UInt32 recSize = offsNext - offs;
592
+ const unsigned kKeyLen = 10;
593
+
594
+ if (recSize != 2 + kKeyLen + kNumFixedExtents * 8)
595
+ return S_FALSE;
596
+
597
+ const Byte *r = p + nodeOffset + offs;
598
+ if (Get16(r) != kKeyLen)
599
+ return S_FALSE;
600
+
601
+ Byte forkType = r[2];
602
+ unsigned forkTypeIndex;
603
+ if (forkType == kExtentForkType_Data)
604
+ forkTypeIndex = 0;
605
+ else if (forkType == kExtentForkType_Resource)
606
+ forkTypeIndex = 1;
607
+ else
608
+ continue;
609
+ CObjectVector<CIdExtents> &overflowExtents = overflowExtentsArray[forkTypeIndex];
610
+
611
+ UInt32 id = Get32(r + 4);
612
+ UInt32 startBlock = Get32(r + 8);
613
+ r += 2 + kKeyLen;
614
+
615
+ bool needNew = true;
616
+
617
+ if (overflowExtents.Size() != 0)
618
+ {
619
+ CIdExtents &e = overflowExtents.Back();
620
+ if (e.ID == id)
621
+ {
622
+ if (endBlock != startBlock)
623
+ return S_FALSE;
624
+ needNew = false;
625
+ }
626
+ }
627
+
628
+ if (needNew)
629
+ {
630
+ CIdExtents &e = overflowExtents.AddNew();
631
+ e.ID = id;
632
+ e.StartBlock = startBlock;
633
+ endBlock = startBlock;
634
+ }
635
+
636
+ CIdExtents &e = overflowExtents.Back();
637
+
638
+ for (unsigned k = 0; k < kNumFixedExtents; k++, r += 8)
639
+ {
640
+ CExtent ee;
641
+ ee.Pos = Get32(r);
642
+ ee.NumBlocks = Get32(r + 4);
643
+ if (ee.NumBlocks != 0)
644
+ {
645
+ e.Extents.Add(ee);
646
+ endBlock += ee.NumBlocks;
647
+ }
648
+ }
649
+ }
650
+
651
+ node = desc.fLink;
652
+ }
653
+ return S_OK;
654
+ }
655
+
656
+ static void LoadName(const Byte *data, unsigned len, UString &dest)
657
+ {
658
+ wchar_t *p = dest.GetBuf(len);
659
+ unsigned i;
660
+ for (i = 0; i < len; i++)
661
+ {
662
+ wchar_t c = Get16(data + i * 2);
663
+ if (c == 0)
664
+ break;
665
+ p[i] = c;
666
+ }
667
+ p[i] = 0;
668
+ dest.ReleaseBuf_SetLen(i);
669
+ }
670
+
671
+ static bool IsNameEqualTo(const Byte *data, const char *name)
672
+ {
673
+ for (unsigned i = 0;; i++)
674
+ {
675
+ char c = name[i];
676
+ if (c == 0)
677
+ return true;
678
+ if (Get16(data + i * 2) != (Byte)c)
679
+ return false;
680
+ }
681
+ }
682
+
683
+ static const UInt32 kAttrRecordType_Inline = 0x10;
684
+ // static const UInt32 kAttrRecordType_Fork = 0x20;
685
+ // static const UInt32 kAttrRecordType_Extents = 0x30;
686
+
687
+ HRESULT CDatabase::LoadAttrs(const CFork &fork, IInStream *inStream, IArchiveOpenCallback *progress)
688
+ {
689
+ if (fork.NumBlocks == 0)
690
+ return S_OK;
691
+
692
+ RINOK(ReadFile(fork, AttrBuf, inStream));
693
+ const Byte *p = (const Byte *)AttrBuf;
694
+
695
+ // CNodeDescriptor nodeDesc;
696
+ // nodeDesc.Parse(p);
697
+ CHeaderRec hr;
698
+ RINOK(hr.Parse(p + kNodeDescriptor_Size));
699
+
700
+ // CaseSensetive = (Header.IsHfsX() && hr.KeyCompareType == 0xBC);
701
+
702
+ if ((AttrBuf.Size() >> hr.NodeSizeLog) < hr.TotalNodes)
703
+ return S_FALSE;
704
+
705
+ UInt32 node = hr.FirstLeafNode;
706
+ if (node == 0)
707
+ return S_OK;
708
+
709
+ CByteBuffer usedBuf(hr.TotalNodes);
710
+ memset(usedBuf, 0, hr.TotalNodes);
711
+
712
+ CFork resFork;
713
+
714
+ while (node != 0)
715
+ {
716
+ if (node >= hr.TotalNodes || usedBuf[node] != 0)
717
+ return S_FALSE;
718
+ usedBuf[node] = 1;
719
+
720
+ size_t nodeOffset = (size_t)node << hr.NodeSizeLog;
721
+ CNodeDescriptor desc;
722
+ desc.Parse(p + nodeOffset);
723
+ if (!desc.CheckNumRecords(hr.NodeSizeLog))
724
+ return S_FALSE;
725
+ if (desc.Kind != kNodeType_Leaf)
726
+ return S_FALSE;
727
+
728
+ for (unsigned i = 0; i < desc.NumRecords; i++)
729
+ {
730
+ UInt32 nodeSize = (1 << hr.NodeSizeLog);
731
+ UInt32 offs = Get16(p + nodeOffset + nodeSize - (i + 1) * 2);
732
+ UInt32 offsNext = Get16(p + nodeOffset + nodeSize - (i + 2) * 2);
733
+ UInt32 recSize = offsNext - offs;
734
+ if (offs >= nodeSize
735
+ || offsNext >= nodeSize
736
+ || offsNext < offs)
737
+ return S_FALSE;
738
+
739
+ const unsigned kHeadSize = 14;
740
+ if (recSize < kHeadSize)
741
+ return S_FALSE;
742
+
743
+ const Byte *r = p + nodeOffset + offs;
744
+ UInt32 keyLen = Get16(r);
745
+
746
+ // UInt16 pad = Get16(r + 2);
747
+ UInt32 fileID = Get32(r + 4);
748
+ unsigned startBlock = Get32(r + 8);
749
+ if (startBlock != 0)
750
+ {
751
+ // that case is still unsupported
752
+ HeadersError = true;
753
+ continue;
754
+ }
755
+ unsigned nameLen = Get16(r + 12);
756
+
757
+ if (keyLen + 2 > recSize ||
758
+ keyLen != kHeadSize - 2 + nameLen * 2)
759
+ return S_FALSE;
760
+ r += kHeadSize;
761
+ recSize -= kHeadSize;
762
+
763
+ const Byte *name = r;
764
+ r += nameLen * 2;
765
+ recSize -= nameLen * 2;
766
+
767
+ if (recSize < 4)
768
+ return S_FALSE;
769
+
770
+ UInt32 recordType = Get32(r);
771
+ if (recordType != kAttrRecordType_Inline)
772
+ {
773
+ // Probably only kAttrRecordType_Inline now is used in real HFS files
774
+ HeadersError = true;
775
+ continue;
776
+ }
777
+
778
+ const UInt32 kRecordHeaderSize = 16;
779
+ if (recSize < kRecordHeaderSize)
780
+ return S_FALSE;
781
+ UInt32 dataSize = Get32(r + 12);
782
+
783
+ r += kRecordHeaderSize;
784
+ recSize -= kRecordHeaderSize;
785
+
786
+ if (recSize < dataSize)
787
+ return S_FALSE;
788
+
789
+ CAttr &attr = Attrs.AddNew();
790
+ attr.ID = fileID;
791
+ attr.Pos = nodeOffset + offs + 2 + keyLen + kRecordHeaderSize;
792
+ attr.Size = dataSize;
793
+ LoadName(name, nameLen, attr.Name);
794
+
795
+ if (progress && (i & 0xFFF) == 0)
796
+ {
797
+ UInt64 numFiles = 0;
798
+ RINOK(progress->SetCompleted(&numFiles, NULL));
799
+ }
800
+ }
801
+
802
+ node = desc.fLink;
803
+ }
804
+ return S_OK;
805
+ }
806
+
807
+ static const UInt32 kMethod_Attr = 3; // data stored in attribute file
808
+ static const UInt32 kMethod_Resource = 4; // data stored in resource fork
809
+
810
+ bool CDatabase::Parse_decmpgfs(const CAttr &attr, CItem &item, bool &skip)
811
+ {
812
+ skip = false;
813
+ if (!attr.Name.IsEqualTo("com.apple.decmpfs"))
814
+ return true;
815
+ if (item.UseAttr || !item.DataFork.IsEmpty())
816
+ return false;
817
+
818
+ const UInt32 k_decmpfs_headerSize = 16;
819
+ UInt32 dataSize = attr.Size;
820
+ if (dataSize < k_decmpfs_headerSize)
821
+ return false;
822
+ const Byte *r = AttrBuf + attr.Pos;
823
+ if (GetUi32(r) != 0x636D7066) // magic == "fpmc"
824
+ return false;
825
+ item.Method = GetUi32(r + 4);
826
+ item.UnpackSize = GetUi64(r + 8);
827
+ dataSize -= k_decmpfs_headerSize;
828
+ r += k_decmpfs_headerSize;
829
+ if (item.Method == kMethod_Resource)
830
+ {
831
+ if (dataSize != 0)
832
+ return false;
833
+ item.UseAttr = true;
834
+ }
835
+ else if (item.Method == kMethod_Attr)
836
+ {
837
+ if (dataSize == 0)
838
+ return false;
839
+ Byte b = r[0];
840
+ if ((b & 0xF) == 0xF)
841
+ {
842
+ dataSize--;
843
+ if (item.UnpackSize > dataSize)
844
+ return false;
845
+ item.DataPos = attr.Pos + k_decmpfs_headerSize + 1;
846
+ item.PackSize = dataSize;
847
+ item.UseAttr = true;
848
+ item.UseInlineData = true;
849
+ }
850
+ else
851
+ {
852
+ item.DataPos = attr.Pos + k_decmpfs_headerSize;
853
+ item.PackSize = dataSize;
854
+ item.UseAttr = true;
855
+ }
856
+ }
857
+ else
858
+ return false;
859
+ skip = true;
860
+ return true;
861
+ }
862
+
863
+ HRESULT CDatabase::LoadCatalog(const CFork &fork, const CObjectVector<CIdExtents> *overflowExtentsArray, IInStream *inStream, IArchiveOpenCallback *progress)
864
+ {
865
+ unsigned reserveSize = (unsigned)(Header.NumFolders + 1 + Header.NumFiles);
866
+ Items.ClearAndReserve(reserveSize);
867
+ Refs.ClearAndReserve(reserveSize);
868
+
869
+ CRecordVector<CIdIndexPair> IdToIndexMap;
870
+ IdToIndexMap.ClearAndReserve(reserveSize);
871
+
872
+ CByteBuffer buf;
873
+ RINOK(ReadFile(fork, buf, inStream));
874
+ const Byte *p = (const Byte *)buf;
875
+
876
+ // CNodeDescriptor nodeDesc;
877
+ // nodeDesc.Parse(p);
878
+ CHeaderRec hr;
879
+ RINOK(hr.Parse(p + kNodeDescriptor_Size));
880
+
881
+ // CaseSensetive = (Header.IsHfsX() && hr.KeyCompareType == 0xBC);
882
+
883
+ if ((buf.Size() >> hr.NodeSizeLog) < hr.TotalNodes)
884
+ return S_FALSE;
885
+
886
+ CByteBuffer usedBuf(hr.TotalNodes);
887
+ memset(usedBuf, 0, hr.TotalNodes);
888
+
889
+ CFork resFork;
890
+
891
+ UInt32 node = hr.FirstLeafNode;
892
+ UInt32 numFiles = 0;
893
+ UInt32 numFolders = 0;
894
+
895
+ while (node != 0)
896
+ {
897
+ if (node >= hr.TotalNodes || usedBuf[node] != 0)
898
+ return S_FALSE;
899
+ usedBuf[node] = 1;
900
+
901
+ size_t nodeOffset = (size_t)node << hr.NodeSizeLog;
902
+ CNodeDescriptor desc;
903
+ desc.Parse(p + nodeOffset);
904
+ if (!desc.CheckNumRecords(hr.NodeSizeLog))
905
+ return S_FALSE;
906
+ if (desc.Kind != kNodeType_Leaf)
907
+ return S_FALSE;
908
+
909
+ for (unsigned i = 0; i < desc.NumRecords; i++)
910
+ {
911
+ UInt32 nodeSize = (1 << hr.NodeSizeLog);
912
+ UInt32 offs = Get16(p + nodeOffset + nodeSize - (i + 1) * 2);
913
+ UInt32 offsNext = Get16(p + nodeOffset + nodeSize - (i + 2) * 2);
914
+ UInt32 recSize = offsNext - offs;
915
+ if (offs >= nodeSize
916
+ || offs >= nodeSize
917
+ || offsNext < offs
918
+ || recSize < 6)
919
+ return S_FALSE;
920
+
921
+ const Byte *r = p + nodeOffset + offs;
922
+ UInt32 keyLen = Get16(r);
923
+ UInt32 parentID = Get32(r + 2);
924
+ if (keyLen < 6 || (keyLen & 1) != 0 || keyLen + 2 > recSize)
925
+ return S_FALSE;
926
+ r += 6;
927
+ recSize -= 6;
928
+ keyLen -= 6;
929
+
930
+ unsigned nameLen = Get16(r);
931
+ if (nameLen * 2 != (unsigned)keyLen)
932
+ return S_FALSE;
933
+ r += 2;
934
+ recSize -= 2;
935
+
936
+ r += nameLen * 2;
937
+ recSize -= nameLen * 2;
938
+
939
+ if (recSize < 2)
940
+ return S_FALSE;
941
+ UInt16 type = Get16(r);
942
+
943
+ if (type != RECORD_TYPE_FOLDER &&
944
+ type != RECORD_TYPE_FILE)
945
+ continue;
946
+
947
+ const unsigned kBasicRecSize = 0x58;
948
+ if (recSize < kBasicRecSize)
949
+ return S_FALSE;
950
+
951
+ CItem &item = Items.AddNew();
952
+ item.ParentID = parentID;
953
+ item.Type = type;
954
+ // item.Flags = Get16(r + 2);
955
+ // item.Valence = Get32(r + 4);
956
+ item.ID = Get32(r + 8);
957
+ {
958
+ const Byte *name = r - (nameLen * 2);
959
+ LoadName(name, nameLen, item.Name);
960
+ if (item.Name.Len() <= 1)
961
+ {
962
+ if (item.Name.IsEmpty() && nameLen == 21)
963
+ {
964
+ if (GetUi32(name) == 0 &&
965
+ GetUi32(name + 4) == 0 &&
966
+ IsNameEqualTo(name + 8, "HFS+ Private Data"))
967
+ {
968
+ // it's folder for "Hard Links" files
969
+ item.Name.SetFromAscii("[HFS+ Private Data]");
970
+ }
971
+ }
972
+
973
+ // Some dmg files have ' ' folder item.
974
+ if (item.Name.IsEmpty() || item.Name[0] == L' ')
975
+ item.Name.SetFromAscii("[]");
976
+ }
977
+ }
978
+
979
+ item.CTime = Get32(r + 0xC);
980
+ item.MTime = Get32(r + 0x10);
981
+ // item.AttrMTime = Get32(r + 0x14);
982
+ item.ATime = Get32(r + 0x18);
983
+ // item.BackupDate = Get32(r + 0x1C);
984
+
985
+ /*
986
+ item.OwnerID = Get32(r + 0x20);
987
+ item.GroupID = Get32(r + 0x24);
988
+ item.AdminFlags = r[0x28];
989
+ item.OwnerFlags = r[0x29];
990
+ */
991
+ item.FileMode = Get16(r + 0x2A);
992
+ /*
993
+ item.special.iNodeNum = Get16(r + 0x2C); // or .linkCount
994
+ item.FileType = Get32(r + 0x30);
995
+ item.FileCreator = Get32(r + 0x34);
996
+ item.FinderFlags = Get16(r + 0x38);
997
+ item.Point[0] = Get16(r + 0x3A); // v
998
+ item.Point[1] = Get16(r + 0x3C); // h
999
+ */
1000
+
1001
+ // const refIndex = Refs.Size();
1002
+ CIdIndexPair pair;
1003
+ pair.ID = item.ID;
1004
+ pair.Index = Items.Size() - 1;
1005
+ IdToIndexMap.Add(pair);
1006
+
1007
+ recSize -= kBasicRecSize;
1008
+ r += kBasicRecSize;
1009
+ if (item.IsDir())
1010
+ {
1011
+ numFolders++;
1012
+ if (recSize != 0)
1013
+ return S_FALSE;
1014
+ }
1015
+ else
1016
+ {
1017
+ numFiles++;
1018
+ const unsigned kForkRecSize = 16 + kNumFixedExtents * 8;
1019
+ if (recSize != kForkRecSize * 2)
1020
+ return S_FALSE;
1021
+
1022
+ item.DataFork.Parse(r);
1023
+
1024
+ if (!item.DataFork.UpgradeAndTest(overflowExtentsArray[0], item.ID, Header.BlockSizeLog))
1025
+ HeadersError = true;
1026
+
1027
+ item.ResourceFork.Parse(r + kForkRecSize);
1028
+ if (!item.ResourceFork.IsEmpty())
1029
+ {
1030
+ if (!item.ResourceFork.UpgradeAndTest(overflowExtentsArray[1], item.ID, Header.BlockSizeLog))
1031
+ HeadersError = true;
1032
+ ThereAreAltStreams = true;
1033
+ }
1034
+ }
1035
+ if (progress && (Items.Size() & 0xFFF) == 0)
1036
+ {
1037
+ UInt64 numItems = Items.Size();
1038
+ RINOK(progress->SetCompleted(&numItems, NULL));
1039
+ }
1040
+ }
1041
+ node = desc.fLink;
1042
+ }
1043
+
1044
+ if (Header.NumFiles != numFiles ||
1045
+ Header.NumFolders + 1 != numFolders)
1046
+ HeadersError = true;
1047
+
1048
+ IdToIndexMap.Sort2();
1049
+ {
1050
+ for (unsigned i = 1; i < IdToIndexMap.Size(); i++)
1051
+ if (IdToIndexMap[i - 1].ID == IdToIndexMap[i].ID)
1052
+ return S_FALSE;
1053
+ }
1054
+
1055
+
1056
+ CBoolArr skipAttr(Attrs.Size());
1057
+ {
1058
+ for (unsigned i = 0; i < Attrs.Size(); i++)
1059
+ skipAttr[i] = false;
1060
+ }
1061
+
1062
+ {
1063
+ FOR_VECTOR (i, Attrs)
1064
+ {
1065
+ const CAttr &attr = Attrs[i];
1066
+
1067
+ int itemIndex = FindItemIndex(IdToIndexMap, attr.ID);
1068
+ if (itemIndex < 0)
1069
+ {
1070
+ HeadersError = true;
1071
+ continue;
1072
+ }
1073
+ if (!Parse_decmpgfs(attr, Items[itemIndex], skipAttr[i]))
1074
+ HeadersError = true;
1075
+ }
1076
+ }
1077
+
1078
+ IdToIndexMap.ClearAndReserve(Items.Size());
1079
+
1080
+ {
1081
+ FOR_VECTOR (i, Items)
1082
+ {
1083
+ const CItem &item = Items[i];
1084
+
1085
+ CIdIndexPair pair;
1086
+ pair.ID = item.ID;
1087
+ pair.Index = Refs.Size();
1088
+ IdToIndexMap.Add(pair);
1089
+
1090
+ CRef ref;
1091
+ ref.ItemIndex = i;
1092
+ Refs.Add(ref);
1093
+
1094
+ #ifdef HFS_SHOW_ALT_STREAMS
1095
+
1096
+ if (item.ResourceFork.IsEmpty())
1097
+ continue;
1098
+ if (item.UseAttr && item.Method == kMethod_Resource)
1099
+ continue;
1100
+ CRef resRef;
1101
+ resRef.ItemIndex = i;
1102
+ resRef.IsResource = true;
1103
+ resRef.Parent = Refs.Size() - 1;
1104
+ Refs.Add(resRef);
1105
+
1106
+ #endif
1107
+ }
1108
+ }
1109
+
1110
+ IdToIndexMap.Sort2();
1111
+
1112
+ {
1113
+ FOR_VECTOR (i, Refs)
1114
+ {
1115
+ CRef &ref = Refs[i];
1116
+ if (ref.IsResource)
1117
+ continue;
1118
+ CItem &item = Items[ref.ItemIndex];
1119
+ ref.Parent = FindItemIndex(IdToIndexMap, item.ParentID);
1120
+ if (ref.Parent >= 0)
1121
+ {
1122
+ if (!Items[Refs[ref.Parent].ItemIndex].IsDir())
1123
+ {
1124
+ ref.Parent = -1;
1125
+ HeadersError = true;
1126
+ }
1127
+ }
1128
+ }
1129
+ }
1130
+
1131
+ #ifdef HFS_SHOW_ALT_STREAMS
1132
+ {
1133
+ FOR_VECTOR (i, Attrs)
1134
+ {
1135
+ if (skipAttr[i])
1136
+ continue;
1137
+ const CAttr &attr = Attrs[i];
1138
+
1139
+ int refIndex = FindItemIndex(IdToIndexMap, attr.ID);
1140
+ if (refIndex < 0)
1141
+ {
1142
+ HeadersError = true;
1143
+ continue;
1144
+ }
1145
+
1146
+ CRef ref;
1147
+ ref.AttrIndex = i;
1148
+ ref.Parent = refIndex;
1149
+ ref.ItemIndex = Refs[refIndex].ItemIndex;
1150
+ Refs.Add(ref);
1151
+ }
1152
+ }
1153
+ #endif
1154
+
1155
+ return S_OK;
1156
+ }
1157
+
1158
+ static const unsigned kHeaderPadSize = (1 << 10);
1159
+
1160
+ HRESULT CDatabase::Open2(IInStream *inStream, IArchiveOpenCallback *progress)
1161
+ {
1162
+ Clear();
1163
+ static const unsigned kHeaderSize = kHeaderPadSize + 512;
1164
+ Byte buf[kHeaderSize];
1165
+ RINOK(ReadStream_FALSE(inStream, buf, kHeaderSize));
1166
+ {
1167
+ for (unsigned i = 0; i < kHeaderPadSize; i++)
1168
+ if (buf[i] != 0)
1169
+ return S_FALSE;
1170
+ }
1171
+ const Byte *p = buf + kHeaderPadSize;
1172
+ CVolHeader &h = Header;
1173
+
1174
+ h.Header[0] = p[0];
1175
+ h.Header[1] = p[1];
1176
+ if (p[0] != 'H' || (p[1] != '+' && p[1] != 'X'))
1177
+ return S_FALSE;
1178
+ h.Version = Get16(p + 2);
1179
+ if (h.Version < 4 || h.Version > 5)
1180
+ return S_FALSE;
1181
+
1182
+ // h.Attr = Get32(p + 4);
1183
+ // h.LastMountedVersion = Get32(p + 8);
1184
+ // h.JournalInfoBlock = Get32(p + 0xC);
1185
+
1186
+ h.CTime = Get32(p + 0x10);
1187
+ h.MTime = Get32(p + 0x14);
1188
+ // h.BackupTime = Get32(p + 0x18);
1189
+ // h.CheckedTime = Get32(p + 0x1C);
1190
+
1191
+ h.NumFiles = Get32(p + 0x20);
1192
+ h.NumFolders = Get32(p + 0x24);
1193
+
1194
+ if (h.NumFolders > ((UInt32)1 << 29) ||
1195
+ h.NumFiles > ((UInt32)1 << 30))
1196
+ return S_FALSE;
1197
+ if (progress)
1198
+ {
1199
+ UInt64 numFiles = (UInt64)h.NumFiles + h.NumFolders + 1;
1200
+ RINOK(progress->SetTotal(&numFiles, NULL));
1201
+ }
1202
+
1203
+ UInt32 blockSize = Get32(p + 0x28);
1204
+
1205
+ {
1206
+ unsigned i;
1207
+ for (i = 9; ((UInt32)1 << i) != blockSize; i++)
1208
+ if (i == 31)
1209
+ return S_FALSE;
1210
+ h.BlockSizeLog = i;
1211
+ }
1212
+
1213
+ h.NumBlocks = Get32(p + 0x2C);
1214
+ h.NumFreeBlocks = Get32(p + 0x30);
1215
+
1216
+ /*
1217
+ h.NextCalatlogNodeID = Get32(p + 0x40);
1218
+ h.WriteCount = Get32(p + 0x44);
1219
+ for (i = 0; i < 6; i++)
1220
+ h.FinderInfo[i] = Get32(p + 0x50 + i * 4);
1221
+ h.VolID = Get64(p + 0x68);
1222
+ */
1223
+
1224
+ /*
1225
+ UInt64 endPos;
1226
+ RINOK(inStream->Seek(0, STREAM_SEEK_END, &endPos));
1227
+ if ((endPos >> h.BlockSizeLog) < h.NumBlocks)
1228
+ return S_FALSE;
1229
+ */
1230
+
1231
+ ResFileName.SetFromAscii(kResFileName);
1232
+
1233
+ CFork extentsFork, catalogFork, attrFork;
1234
+ // allocationFork.Parse(p + 0x70 + 0x50 * 0);
1235
+ extentsFork.Parse(p + 0x70 + 0x50 * 1);
1236
+ catalogFork.Parse(p + 0x70 + 0x50 * 2);
1237
+ attrFork.Parse (p + 0x70 + 0x50 * 3);
1238
+ // startupFork.Parse(p + 0x70 + 0x50 * 4);
1239
+
1240
+ CObjectVector<CIdExtents> overflowExtents[2];
1241
+ if (!extentsFork.IsOk(Header.BlockSizeLog))
1242
+ HeadersError = true;
1243
+ else
1244
+ {
1245
+ HRESULT res = LoadExtentFile(extentsFork, inStream, overflowExtents);
1246
+ if (res == S_FALSE)
1247
+ HeadersError = true;
1248
+ else if (res != S_OK)
1249
+ return res;
1250
+ }
1251
+
1252
+ if (!catalogFork.UpgradeAndTest(overflowExtents[0], kHfsID_CatalogFile, Header.BlockSizeLog))
1253
+ return S_FALSE;
1254
+
1255
+ if (!attrFork.UpgradeAndTest(overflowExtents[0], kHfsID_AttributesFile, Header.BlockSizeLog))
1256
+ HeadersError = true;
1257
+ else
1258
+ {
1259
+ if (attrFork.Size != 0)
1260
+ RINOK(LoadAttrs(attrFork, inStream, progress));
1261
+ }
1262
+
1263
+ RINOK(LoadCatalog(catalogFork, overflowExtents, inStream, progress));
1264
+
1265
+ PhySize = Header.GetPhySize();
1266
+ return S_OK;
1267
+ }
1268
+
1269
+
1270
+
1271
+ class CHandler:
1272
+ public IInArchive,
1273
+ public IArchiveGetRawProps,
1274
+ public IInArchiveGetStream,
1275
+ public CMyUnknownImp,
1276
+ public CDatabase
1277
+ {
1278
+ CMyComPtr<IInStream> _stream;
1279
+
1280
+ HRESULT GetForkStream(const CFork &fork, ISequentialInStream **stream);
1281
+
1282
+ HRESULT ExtractZlibFile(
1283
+ ISequentialOutStream *realOutStream,
1284
+ const CItem &item,
1285
+ NCompress::NZlib::CDecoder *_zlibDecoderSpec,
1286
+ CByteBuffer &buf,
1287
+ UInt64 progressStart,
1288
+ IArchiveExtractCallback *extractCallback);
1289
+ public:
1290
+ MY_UNKNOWN_IMP3(IInArchive, IArchiveGetRawProps, IInArchiveGetStream)
1291
+ INTERFACE_IInArchive(;)
1292
+ INTERFACE_IArchiveGetRawProps(;)
1293
+ STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **stream);
1294
+ };
1295
+
1296
+ static const Byte kProps[] =
1297
+ {
1298
+ kpidPath,
1299
+ kpidIsDir,
1300
+ kpidSize,
1301
+ kpidPackSize,
1302
+ kpidCTime,
1303
+ kpidMTime,
1304
+ kpidATime,
1305
+ kpidPosixAttrib
1306
+ };
1307
+
1308
+ static const Byte kArcProps[] =
1309
+ {
1310
+ kpidMethod,
1311
+ kpidClusterSize,
1312
+ kpidFreeSpace,
1313
+ kpidCTime,
1314
+ kpidMTime
1315
+ };
1316
+
1317
+ IMP_IInArchive_Props
1318
+ IMP_IInArchive_ArcProps
1319
+
1320
+ static void HfsTimeToProp(UInt32 hfsTime, NWindows::NCOM::CPropVariant &prop)
1321
+ {
1322
+ FILETIME ft;
1323
+ HfsTimeToFileTime(hfsTime, ft);
1324
+ prop = ft;
1325
+ }
1326
+
1327
+ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
1328
+ {
1329
+ COM_TRY_BEGIN
1330
+ NWindows::NCOM::CPropVariant prop;
1331
+ switch (propID)
1332
+ {
1333
+ case kpidExtension: prop = Header.IsHfsX() ? "hfsx" : "hfs"; break;
1334
+ case kpidMethod: prop = Header.IsHfsX() ? "HFSX" : "HFS+"; break;
1335
+ case kpidPhySize: prop = PhySize; break;
1336
+ case kpidClusterSize: prop = (UInt32)1 << Header.BlockSizeLog; break;
1337
+ case kpidFreeSpace: prop = (UInt64)Header.GetFreeSize(); break;
1338
+ case kpidMTime: HfsTimeToProp(Header.MTime, prop); break;
1339
+ case kpidCTime:
1340
+ {
1341
+ FILETIME localFt, ft;
1342
+ HfsTimeToFileTime(Header.CTime, localFt);
1343
+ if (LocalFileTimeToFileTime(&localFt, &ft))
1344
+ prop = ft;
1345
+ break;
1346
+ }
1347
+ case kpidIsTree: prop = true; break;
1348
+ case kpidErrorFlags:
1349
+ {
1350
+ UInt32 flags = 0;
1351
+ if (HeadersError) flags |= kpv_ErrorFlags_HeadersError;
1352
+ if (flags != 0)
1353
+ prop = flags;
1354
+ break;
1355
+ }
1356
+ case kpidIsAltStream: prop = ThereAreAltStreams; break;
1357
+ }
1358
+ prop.Detach(value);
1359
+ return S_OK;
1360
+ COM_TRY_END
1361
+ }
1362
+
1363
+ STDMETHODIMP CHandler::GetNumRawProps(UInt32 *numProps)
1364
+ {
1365
+ *numProps = 0;
1366
+ return S_OK;
1367
+ }
1368
+
1369
+ STDMETHODIMP CHandler::GetRawPropInfo(UInt32 /* index */, BSTR *name, PROPID *propID)
1370
+ {
1371
+ *name = NULL;
1372
+ *propID = 0;
1373
+ return S_OK;
1374
+ }
1375
+
1376
+ STDMETHODIMP CHandler::GetParent(UInt32 index, UInt32 *parent, UInt32 *parentType)
1377
+ {
1378
+ const CRef &ref = Refs[index];
1379
+ *parentType = ref.IsAltStream() ?
1380
+ NParentType::kAltStream :
1381
+ NParentType::kDir;
1382
+ *parent = (UInt32)(Int32)ref.Parent;
1383
+ return S_OK;
1384
+ }
1385
+
1386
+ STDMETHODIMP CHandler::GetRawProp(UInt32 index, PROPID propID, const void **data, UInt32 *dataSize, UInt32 *propType)
1387
+ {
1388
+ *data = NULL;
1389
+ *dataSize = 0;
1390
+ *propType = 0;
1391
+ #ifdef MY_CPU_LE
1392
+ if (propID == kpidName)
1393
+ {
1394
+ const CRef &ref = Refs[index];
1395
+ const UString *s;
1396
+ if (ref.IsResource)
1397
+ s = &ResFileName;
1398
+ else if (ref.AttrIndex >= 0)
1399
+ s = &Attrs[ref.AttrIndex].Name;
1400
+ else
1401
+ s = &Items[ref.ItemIndex].Name;
1402
+ *data = (const wchar_t *)(*s);
1403
+ *dataSize = (s->Len() + 1) * sizeof(wchar_t);
1404
+ *propType = PROP_DATA_TYPE_wchar_t_PTR_Z_LE;
1405
+ return S_OK;
1406
+ }
1407
+ #endif
1408
+ return S_OK;
1409
+ }
1410
+
1411
+ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
1412
+ {
1413
+ COM_TRY_BEGIN
1414
+ NWindows::NCOM::CPropVariant prop;
1415
+ const CRef &ref = Refs[index];
1416
+ const CItem &item = Items[ref.ItemIndex];
1417
+ switch (propID)
1418
+ {
1419
+ case kpidPath: GetItemPath(index, prop); break;
1420
+ case kpidName:
1421
+ const UString *s;
1422
+ if (ref.IsResource)
1423
+ s = &ResFileName;
1424
+ else if (ref.AttrIndex >= 0)
1425
+ s = &Attrs[ref.AttrIndex].Name;
1426
+ else
1427
+ s = &item.Name;
1428
+ prop = *s;
1429
+ break;
1430
+ case kpidPackSize:
1431
+ {
1432
+ UInt64 size;
1433
+ if (ref.AttrIndex >= 0)
1434
+ size = Attrs[ref.AttrIndex].Size;
1435
+ else if (item.IsDir())
1436
+ break;
1437
+ else if (item.UseAttr)
1438
+ {
1439
+ if (item.Method == kMethod_Resource)
1440
+ size = item.ResourceFork.NumBlocks << Header.BlockSizeLog;
1441
+ else
1442
+ size = item.PackSize;
1443
+ }
1444
+ else
1445
+ size = item.GetFork(ref.IsResource).NumBlocks << Header.BlockSizeLog;
1446
+ prop = size;
1447
+ break;
1448
+ }
1449
+ case kpidSize:
1450
+ {
1451
+ UInt64 size;
1452
+ if (ref.AttrIndex >= 0)
1453
+ size = Attrs[ref.AttrIndex].Size;
1454
+ else if (item.IsDir())
1455
+ break;
1456
+ else if (item.UseAttr)
1457
+ size = item.UnpackSize;
1458
+ else
1459
+ size = item.GetFork(ref.IsResource).Size;
1460
+ prop = size;
1461
+ break;
1462
+ }
1463
+ case kpidIsDir: prop = item.IsDir(); break;
1464
+ case kpidIsAltStream: prop = ref.IsAltStream(); break;
1465
+
1466
+ case kpidCTime: HfsTimeToProp(item.CTime, prop); break;
1467
+ case kpidMTime: HfsTimeToProp(item.MTime, prop); break;
1468
+ case kpidATime: HfsTimeToProp(item.ATime, prop); break;
1469
+
1470
+ case kpidPosixAttrib: if (ref.AttrIndex < 0) prop = (UInt32)item.FileMode; break;
1471
+ }
1472
+ prop.Detach(value);
1473
+ return S_OK;
1474
+ COM_TRY_END
1475
+ }
1476
+
1477
+ STDMETHODIMP CHandler::Open(IInStream *inStream,
1478
+ const UInt64 * /* maxCheckStartPosition */,
1479
+ IArchiveOpenCallback *callback)
1480
+ {
1481
+ COM_TRY_BEGIN
1482
+ Close();
1483
+ RINOK(Open2(inStream, callback));
1484
+ _stream = inStream;
1485
+ return S_OK;
1486
+ COM_TRY_END
1487
+ }
1488
+
1489
+ STDMETHODIMP CHandler::Close()
1490
+ {
1491
+ _stream.Release();
1492
+ Clear();
1493
+ return S_OK;
1494
+ }
1495
+
1496
+ static const UInt32 kCompressionBlockSize = 1 << 16;
1497
+
1498
+ HRESULT CHandler::ExtractZlibFile(
1499
+ ISequentialOutStream *outStream,
1500
+ const CItem &item,
1501
+ NCompress::NZlib::CDecoder *_zlibDecoderSpec,
1502
+ CByteBuffer &buf,
1503
+ UInt64 progressStart,
1504
+ IArchiveExtractCallback *extractCallback)
1505
+ {
1506
+ CMyComPtr<ISequentialInStream> inStream;
1507
+ const CFork &fork = item.ResourceFork;
1508
+ RINOK(GetForkStream(fork, &inStream));
1509
+ const unsigned kHeaderSize = 0x100 + 8;
1510
+ RINOK(ReadStream_FALSE(inStream, buf, kHeaderSize));
1511
+ UInt32 dataPos = Get32(buf);
1512
+ UInt32 mapPos = Get32(buf + 4);
1513
+ UInt32 dataSize = Get32(buf + 8);
1514
+ UInt32 mapSize = Get32(buf + 12);
1515
+
1516
+ const UInt32 kResMapSize = 50;
1517
+
1518
+ if (mapSize != kResMapSize
1519
+ || dataPos + dataSize != mapPos
1520
+ || mapPos + mapSize != fork.Size)
1521
+ return S_FALSE;
1522
+
1523
+ UInt32 dataSize2 = Get32(buf + 0x100);
1524
+ if (4 + dataSize2 != dataSize || dataSize2 < 8)
1525
+ return S_FALSE;
1526
+
1527
+ UInt32 numBlocks = GetUi32(buf + 0x100 + 4);
1528
+ if (((dataSize2 - 4) >> 3) < numBlocks)
1529
+ return S_FALSE;
1530
+ if (item.UnpackSize > (UInt64)numBlocks * kCompressionBlockSize)
1531
+ return S_FALSE;
1532
+
1533
+ if (item.UnpackSize + kCompressionBlockSize < (UInt64)numBlocks * kCompressionBlockSize)
1534
+ return S_FALSE;
1535
+
1536
+ UInt32 tableSize = (numBlocks << 3);
1537
+
1538
+ CByteBuffer tableBuf(tableSize);
1539
+
1540
+ RINOK(ReadStream_FALSE(inStream, tableBuf, tableSize));
1541
+
1542
+ UInt32 prev = 4 + tableSize;
1543
+
1544
+ UInt32 i;
1545
+ for (i = 0; i < numBlocks; i++)
1546
+ {
1547
+ UInt32 offset = GetUi32(tableBuf + i * 8);
1548
+ UInt32 size = GetUi32(tableBuf + i * 8 + 4);
1549
+ if (size == 0)
1550
+ return S_FALSE;
1551
+ if (prev != offset)
1552
+ return S_FALSE;
1553
+ if (offset > dataSize2 ||
1554
+ size > dataSize2 - offset)
1555
+ return S_FALSE;
1556
+ prev = offset + size;
1557
+ }
1558
+
1559
+ if (prev != dataSize2)
1560
+ return S_FALSE;
1561
+
1562
+ CBufInStream *bufInStreamSpec = new CBufInStream;
1563
+ CMyComPtr<ISequentialInStream> bufInStream = bufInStreamSpec;
1564
+
1565
+ UInt64 outPos = 0;
1566
+ for (i = 0; i < numBlocks; i++)
1567
+ {
1568
+ UInt64 rem = item.UnpackSize - outPos;
1569
+ if (rem == 0)
1570
+ return S_FALSE;
1571
+ UInt32 blockSize = kCompressionBlockSize;
1572
+ if (rem < kCompressionBlockSize)
1573
+ blockSize = (UInt32)rem;
1574
+
1575
+ UInt32 size = GetUi32(tableBuf + i * 8 + 4);
1576
+
1577
+ if (size > buf.Size() || size > kCompressionBlockSize + 1)
1578
+ return S_FALSE;
1579
+
1580
+ RINOK(ReadStream_FALSE(inStream, buf, size));
1581
+
1582
+ if ((buf[0] & 0xF) == 0xF)
1583
+ {
1584
+ // that code was not tested. Are there HFS archives with uncompressed block
1585
+ if (size - 1 != blockSize)
1586
+ return S_FALSE;
1587
+
1588
+ if (outStream)
1589
+ {
1590
+ RINOK(WriteStream(outStream, buf, blockSize));
1591
+ }
1592
+ }
1593
+ else
1594
+ {
1595
+ UInt64 blockSize64 = blockSize;
1596
+ bufInStreamSpec->Init(buf, size);
1597
+ RINOK(_zlibDecoderSpec->Code(bufInStream, outStream, NULL, &blockSize64, NULL));
1598
+ if (_zlibDecoderSpec->GetOutputProcessedSize() != blockSize ||
1599
+ _zlibDecoderSpec->GetInputProcessedSize() != size)
1600
+ return S_FALSE;
1601
+ }
1602
+
1603
+ outPos += blockSize;
1604
+ UInt64 progressPos = progressStart + outPos;
1605
+ RINOK(extractCallback->SetCompleted(&progressPos));
1606
+ }
1607
+
1608
+ if (outPos != item.UnpackSize)
1609
+ return S_FALSE;
1610
+
1611
+ /* We check Resource Map
1612
+ Are there HFS files with another values in Resource Map ??? */
1613
+
1614
+ RINOK(ReadStream_FALSE(inStream, buf, mapSize));
1615
+ UInt32 types = Get16(buf + 24);
1616
+ UInt32 names = Get16(buf + 26);
1617
+ UInt32 numTypes = Get16(buf + 28);
1618
+ if (numTypes != 0 || types != 28 || names != kResMapSize)
1619
+ return S_FALSE;
1620
+ UInt32 resType = Get32(buf + 30);
1621
+ UInt32 numResources = Get16(buf + 34);
1622
+ UInt32 resListOffset = Get16(buf + 36);
1623
+ if (resType != 0x636D7066) // cmpf
1624
+ return S_FALSE;
1625
+ if (numResources != 0 || resListOffset != 10)
1626
+ return S_FALSE;
1627
+
1628
+ UInt32 entryId = Get16(buf + 38);
1629
+ UInt32 nameOffset = Get16(buf + 40);
1630
+ // Byte attrib = buf[42];
1631
+ UInt32 resourceOffset = Get32(buf + 42) & 0xFFFFFF;
1632
+ if (entryId != 1 || nameOffset != 0xFFFF || resourceOffset != 0)
1633
+ return S_FALSE;
1634
+
1635
+ return S_OK;
1636
+ }
1637
+
1638
+ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
1639
+ Int32 testMode, IArchiveExtractCallback *extractCallback)
1640
+ {
1641
+ COM_TRY_BEGIN
1642
+ bool allFilesMode = (numItems == (UInt32)(Int32)-1);
1643
+ if (allFilesMode)
1644
+ numItems = Refs.Size();
1645
+ if (numItems == 0)
1646
+ return S_OK;
1647
+ UInt32 i;
1648
+ UInt64 totalSize = 0;
1649
+ for (i = 0; i < numItems; i++)
1650
+ {
1651
+ const CRef &ref = Refs[allFilesMode ? i : indices[i]];
1652
+ totalSize += Get_UnpackSize_of_Ref(ref);
1653
+ }
1654
+ RINOK(extractCallback->SetTotal(totalSize));
1655
+
1656
+ UInt64 currentTotalSize = 0, currentItemSize = 0;
1657
+
1658
+ const size_t kBufSize = kCompressionBlockSize;
1659
+ CByteBuffer buf(kBufSize + 0x10); // we need 1 additional bytes for uncompressed chunk header
1660
+
1661
+ NCompress::NZlib::CDecoder *_zlibDecoderSpec = NULL;
1662
+ CMyComPtr<ICompressCoder> _zlibDecoder;
1663
+
1664
+ for (i = 0; i < numItems; i++, currentTotalSize += currentItemSize)
1665
+ {
1666
+ RINOK(extractCallback->SetCompleted(&currentTotalSize));
1667
+ UInt32 index = allFilesMode ? i : indices[i];
1668
+ const CRef &ref = Refs[index];
1669
+ const CItem &item = Items[ref.ItemIndex];
1670
+ currentItemSize = Get_UnpackSize_of_Ref(ref);
1671
+
1672
+ CMyComPtr<ISequentialOutStream> realOutStream;
1673
+ Int32 askMode = testMode ?
1674
+ NExtract::NAskMode::kTest :
1675
+ NExtract::NAskMode::kExtract;
1676
+ RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
1677
+
1678
+ if (ref.AttrIndex < 0 && item.IsDir())
1679
+ {
1680
+ RINOK(extractCallback->PrepareOperation(askMode));
1681
+ RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kOK));
1682
+ continue;
1683
+ }
1684
+ if (!testMode && !realOutStream)
1685
+ continue;
1686
+ RINOK(extractCallback->PrepareOperation(askMode));
1687
+ UInt64 pos = 0;
1688
+ int res = NExtract::NOperationResult::kDataError;
1689
+ if (ref.AttrIndex >= 0)
1690
+ {
1691
+ res = NExtract::NOperationResult::kOK;
1692
+ if (realOutStream)
1693
+ {
1694
+ const CAttr &attr = Attrs[ref.AttrIndex];
1695
+ RINOK(WriteStream(realOutStream, AttrBuf + attr.Pos, attr.Size));
1696
+ }
1697
+ }
1698
+ else if (item.UseAttr)
1699
+ {
1700
+ if (item.UseInlineData)
1701
+ {
1702
+ res = NExtract::NOperationResult::kOK;
1703
+ if (realOutStream)
1704
+ {
1705
+ RINOK(WriteStream(realOutStream, AttrBuf + item.DataPos, (size_t)item.UnpackSize));
1706
+ }
1707
+ }
1708
+ else
1709
+ {
1710
+ if (!_zlibDecoder)
1711
+ {
1712
+ _zlibDecoderSpec = new NCompress::NZlib::CDecoder();
1713
+ _zlibDecoder = _zlibDecoderSpec;
1714
+ }
1715
+
1716
+ if (item.Method == kMethod_Attr)
1717
+ {
1718
+ CBufInStream *bufInStreamSpec = new CBufInStream;
1719
+ CMyComPtr<ISequentialInStream> bufInStream = bufInStreamSpec;
1720
+ bufInStreamSpec->Init(AttrBuf + item.DataPos, item.PackSize);
1721
+
1722
+ HRESULT hres = _zlibDecoder->Code(bufInStream, realOutStream, NULL, &item.UnpackSize, NULL);
1723
+ if (hres != S_FALSE)
1724
+ {
1725
+ if (hres != S_OK)
1726
+ return hres;
1727
+ if (_zlibDecoderSpec->GetOutputProcessedSize() == item.UnpackSize &&
1728
+ _zlibDecoderSpec->GetInputProcessedSize() == item.PackSize)
1729
+ res = NExtract::NOperationResult::kOK;
1730
+ }
1731
+ }
1732
+ else
1733
+ {
1734
+ HRESULT hres = ExtractZlibFile(realOutStream, item, _zlibDecoderSpec, buf,
1735
+ currentTotalSize, extractCallback);
1736
+ if (hres != S_FALSE)
1737
+ {
1738
+ if (hres != S_OK)
1739
+ return hres;
1740
+ res = NExtract::NOperationResult::kOK;
1741
+ }
1742
+ }
1743
+ }
1744
+ }
1745
+ else
1746
+ {
1747
+ const CFork &fork = item.GetFork(ref.IsResource);
1748
+ if (fork.IsOk(Header.BlockSizeLog))
1749
+ {
1750
+ res = NExtract::NOperationResult::kOK;
1751
+ unsigned extentIndex;
1752
+ for (extentIndex = 0; extentIndex < fork.Extents.Size(); extentIndex++)
1753
+ {
1754
+ if (res != NExtract::NOperationResult::kOK)
1755
+ break;
1756
+ if (fork.Size == pos)
1757
+ break;
1758
+ const CExtent &e = fork.Extents[extentIndex];
1759
+ RINOK(_stream->Seek((UInt64)e.Pos << Header.BlockSizeLog, STREAM_SEEK_SET, NULL));
1760
+ UInt64 extentRem = (UInt64)e.NumBlocks << Header.BlockSizeLog;
1761
+ while (extentRem != 0)
1762
+ {
1763
+ UInt64 rem = fork.Size - pos;
1764
+ if (rem == 0)
1765
+ {
1766
+ // Here we check that there are no extra (empty) blocks in last extent.
1767
+ if (extentRem >= ((UInt64)1 << Header.BlockSizeLog))
1768
+ res = NExtract::NOperationResult::kDataError;
1769
+ break;
1770
+ }
1771
+ size_t cur = kBufSize;
1772
+ if (cur > rem)
1773
+ cur = (size_t)rem;
1774
+ if (cur > extentRem)
1775
+ cur = (size_t)extentRem;
1776
+ RINOK(ReadStream(_stream, buf, &cur));
1777
+ if (cur == 0)
1778
+ {
1779
+ res = NExtract::NOperationResult::kDataError;
1780
+ break;
1781
+ }
1782
+ if (realOutStream)
1783
+ {
1784
+ RINOK(WriteStream(realOutStream, buf, cur));
1785
+ }
1786
+ pos += cur;
1787
+ extentRem -= cur;
1788
+ UInt64 processed = currentTotalSize + pos;
1789
+ RINOK(extractCallback->SetCompleted(&processed));
1790
+ }
1791
+ }
1792
+ if (extentIndex != fork.Extents.Size() || fork.Size != pos)
1793
+ res = NExtract::NOperationResult::kDataError;
1794
+ }
1795
+ }
1796
+ realOutStream.Release();
1797
+ RINOK(extractCallback->SetOperationResult(res));
1798
+ }
1799
+ return S_OK;
1800
+ COM_TRY_END
1801
+ }
1802
+
1803
+ STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
1804
+ {
1805
+ *numItems = Refs.Size();
1806
+ return S_OK;
1807
+ }
1808
+
1809
+ HRESULT CHandler::GetForkStream(const CFork &fork, ISequentialInStream **stream)
1810
+ {
1811
+ *stream = 0;
1812
+
1813
+ if (!fork.IsOk(Header.BlockSizeLog))
1814
+ return S_FALSE;
1815
+
1816
+ CExtentsStream *extentStreamSpec = new CExtentsStream();
1817
+ CMyComPtr<ISequentialInStream> extentStream = extentStreamSpec;
1818
+
1819
+ UInt64 rem = fork.Size;
1820
+ UInt64 virt = 0;
1821
+
1822
+ FOR_VECTOR (i, fork.Extents)
1823
+ {
1824
+ const CExtent &e = fork.Extents[i];
1825
+ if (e.NumBlocks == 0)
1826
+ continue;
1827
+ UInt64 cur = ((UInt64)e.NumBlocks << Header.BlockSizeLog);
1828
+ if (cur > rem)
1829
+ {
1830
+ cur = rem;
1831
+ if (i != fork.Extents.Size() - 1)
1832
+ return S_FALSE;
1833
+ }
1834
+ CSeekExtent se;
1835
+ se.Phy = (UInt64)e.Pos << Header.BlockSizeLog;
1836
+ se.Virt = virt;
1837
+ virt += cur;
1838
+ rem -= cur;
1839
+ extentStreamSpec->Extents.Add(se);
1840
+ }
1841
+
1842
+ if (rem != 0)
1843
+ return S_FALSE;
1844
+
1845
+ CSeekExtent se;
1846
+ se.Phy = 0;
1847
+ se.Virt = virt;
1848
+ extentStreamSpec->Extents.Add(se);
1849
+ extentStreamSpec->Stream = _stream;
1850
+ extentStreamSpec->Init();
1851
+ *stream = extentStream.Detach();
1852
+ return S_OK;
1853
+ }
1854
+
1855
+ STDMETHODIMP CHandler::GetStream(UInt32 index, ISequentialInStream **stream)
1856
+ {
1857
+ *stream = 0;
1858
+
1859
+ const CRef &ref = Refs[index];
1860
+ if (ref.AttrIndex >= 0)
1861
+ return S_FALSE;
1862
+ const CItem &item = Items[ref.ItemIndex];
1863
+ if (item.IsDir() || item.UseAttr)
1864
+ return S_FALSE;
1865
+
1866
+ return GetForkStream(item.GetFork(ref.IsResource), stream);
1867
+ }
1868
+
1869
+ static const Byte k_Signature[] = {
1870
+ 4, 'H', '+', 0, 4,
1871
+ 4, 'H', 'X', 0, 5 };
1872
+
1873
+ REGISTER_ARC_I(
1874
+ "HFS", "hfs hfsx", 0, 0xE3,
1875
+ k_Signature,
1876
+ kHeaderPadSize,
1877
+ NArcInfoFlags::kMultiSignature,
1878
+ NULL)
1879
+
1880
+ }}