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
@@ -11,17 +11,18 @@
11
11
 
12
12
  #include "../../../C/CpuArch.h"
13
13
 
14
- #include "Common/Buffer.h"
15
- #include "Common/ComTry.h"
16
- #include "Common/IntToString.h"
17
- #include "Common/MyCom.h"
18
- #include "Common/StringConvert.h"
14
+ #include "../../Common/ComTry.h"
15
+ #include "../../Common/IntToString.h"
16
+ #include "../../Common/MyBuffer.h"
17
+ #include "../../Common/MyCom.h"
19
18
 
20
- #include "Windows/PropVariant.h"
21
- #include "Windows/Time.h"
19
+ #include "../../Windows/PropVariant.h"
20
+ #include "../../Windows/TimeUtils.h"
22
21
 
22
+ #include "../Common/MethodProps.h"
23
23
  #include "../Common/ProgressUtils.h"
24
24
  #include "../Common/RegisterArc.h"
25
+ #include "../Common/StreamObjects.h"
25
26
  #include "../Common/StreamUtils.h"
26
27
 
27
28
  #include "../Compress/CopyCoder.h"
@@ -30,8 +31,10 @@
30
31
 
31
32
  #ifdef SHOW_DEBUG_INFO
32
33
  #define PRF(x) x
34
+ #define PRF_UTF16(x) PRF(printf("%S", x))
33
35
  #else
34
36
  #define PRF(x)
37
+ #define PRF_UTF16(x)
35
38
  #endif
36
39
 
37
40
  #ifdef SHOW_DEBUG_INFO2
@@ -48,26 +51,37 @@
48
51
  #define G32(p, dest) dest = Get32(p);
49
52
  #define G64(p, dest) dest = Get64(p);
50
53
 
54
+ using namespace NWindows;
55
+
51
56
  namespace NArchive {
52
57
  namespace Ntfs {
53
58
 
54
- static const UInt32 kNumSysRecs = 16;
55
- static const UInt32 kRecIndex_Volume = 3;
56
- static const UInt32 kRecIndex_BadClus = 8;
59
+ static const wchar_t *kVirtualFolder_System = L"[SYSTEM]";
60
+ static const wchar_t *kVirtualFolder_Lost_Normal = L"[LOST]";
61
+ static const wchar_t *kVirtualFolder_Lost_Deleted = L"[UNKNOWN]";
62
+
63
+ static const unsigned kNumSysRecs = 16;
64
+
65
+ static const unsigned kRecIndex_Volume = 3;
66
+ static const unsigned kRecIndex_RootDir = 5;
67
+ static const unsigned kRecIndex_BadClus = 8;
68
+ static const unsigned kRecIndex_Security = 9;
57
69
 
58
70
  struct CHeader
59
71
  {
60
- Byte SectorSizeLog;
61
- Byte ClusterSizeLog;
72
+ unsigned SectorSizeLog;
73
+ unsigned ClusterSizeLog;
62
74
  // Byte MediaType;
63
75
  UInt32 NumHiddenSectors;
76
+ UInt64 NumSectors;
64
77
  UInt64 NumClusters;
65
78
  UInt64 MftCluster;
66
79
  UInt64 SerialNumber;
67
80
  UInt16 SectorsPerTrack;
68
81
  UInt16 NumHeads;
69
82
 
70
- UInt64 GetPhySize() const { return NumClusters << ClusterSizeLog; }
83
+ UInt64 GetPhySize_Clusters() const { return NumClusters << ClusterSizeLog; }
84
+ UInt64 GetPhySize_Max() const { return (NumSectors + 1) << SectorSizeLog; }
71
85
  UInt32 ClusterSize() const { return (UInt32)1 << ClusterSizeLog; }
72
86
  bool Parse(const Byte *p);
73
87
  };
@@ -85,39 +99,42 @@ bool CHeader::Parse(const Byte *p)
85
99
  if (p[0x1FE] != 0x55 || p[0x1FF] != 0xAA)
86
100
  return false;
87
101
 
88
- int codeOffset = 0;
102
+ // int codeOffset = 0;
89
103
  switch (p[0])
90
104
  {
91
- case 0xE9: codeOffset = 3 + (Int16)Get16(p + 1); break;
92
- case 0xEB: if (p[2] != 0x90) return false; codeOffset = 2 + (signed char)p[1]; break;
105
+ case 0xE9: /* codeOffset = 3 + (Int16)Get16(p + 1); */ break;
106
+ case 0xEB: if (p[2] != 0x90) return false; /* codeOffset = 2 + (int)(signed char)p[1]; */ break;
93
107
  default: return false;
94
108
  }
95
- Byte sectorsPerClusterLog;
109
+ unsigned sectorsPerClusterLog;
96
110
 
97
111
  if (memcmp(p + 3, "NTFS ", 8) != 0)
98
112
  return false;
99
113
  {
100
- int s = GetLog(Get16(p + 11));
101
- if (s < 9 || s > 12)
114
+ int t = GetLog(Get16(p + 11));
115
+ if (t < 9 || t > 12)
102
116
  return false;
103
- SectorSizeLog = (Byte)s;
104
- s = GetLog(p[13]);
105
- if (s < 0)
117
+ SectorSizeLog = t;
118
+ t = GetLog(p[13]);
119
+ if (t < 0)
106
120
  return false;
107
- sectorsPerClusterLog = (Byte)s;
121
+ sectorsPerClusterLog = t;
108
122
  ClusterSizeLog = SectorSizeLog + sectorsPerClusterLog;
123
+ if (ClusterSizeLog > 30)
124
+ return false;
109
125
  }
110
126
 
111
127
  for (int i = 14; i < 21; i++)
112
128
  if (p[i] != 0)
113
129
  return false;
114
130
 
115
- // MediaType = p[21];
131
+ if (p[21] != 0xF8) // MediaType = Fixed_Disk
132
+ return false;
116
133
  if (Get16(p + 22) != 0) // NumFatSectors
117
134
  return false;
118
- G16(p + 24, SectorsPerTrack);
119
- G16(p + 26, NumHeads);
120
- G32(p + 28, NumHiddenSectors);
135
+ G16(p + 24, SectorsPerTrack); // 63 usually
136
+ G16(p + 26, NumHeads); // 255
137
+ G32(p + 28, NumHiddenSectors); // 63 (XP) / 2048 (Vista and win7) / (0 on media that are not partitioned ?)
121
138
  if (Get32(p + 32) != 0) // NumSectors32
122
139
  return false;
123
140
 
@@ -132,15 +149,19 @@ bool CHeader::Parse(const Byte *p)
132
149
  return false;
133
150
  if (p[0x27] != 0) // reserved
134
151
  return false;
135
- UInt64 numSectors = Get64(p + 0x28);
136
- NumClusters = numSectors >> sectorsPerClusterLog;
152
+
153
+ NumSectors = Get64(p + 0x28);
154
+ if (NumSectors >= ((UInt64)1 << (62 - SectorSizeLog)))
155
+ return false;
156
+
157
+ NumClusters = NumSectors >> sectorsPerClusterLog;
137
158
 
138
159
  G64(p + 0x30, MftCluster);
139
160
  // G64(p + 0x38, Mft2Cluster);
140
161
  G64(p + 0x48, SerialNumber);
141
162
  UInt32 numClustersInMftRec;
142
163
  UInt32 numClustersInIndexBlock;
143
- G32(p + 0x40, numClustersInMftRec);
164
+ G32(p + 0x40, numClustersInMftRec); // -10 means 2 ^10 = 1024 bytes.
144
165
  G32(p + 0x44, numClustersInIndexBlock);
145
166
  return (numClustersInMftRec < 256 && numClustersInIndexBlock < 256);
146
167
  }
@@ -148,6 +169,7 @@ bool CHeader::Parse(const Byte *p)
148
169
  struct CMftRef
149
170
  {
150
171
  UInt64 Val;
172
+
151
173
  UInt64 GetIndex() const { return Val & (((UInt64)1 << 48) - 1); }
152
174
  UInt16 GetNumber() const { return (UInt16)(Val >> 48); }
153
175
  bool IsBaseItself() const { return Val == 0; }
@@ -178,36 +200,56 @@ enum
178
200
  DEF_ATTR_TYPE(0x1000, FIRST_USER_DEFINED_ATTRIBUTE)
179
201
  };
180
202
 
181
- static const Byte kFileNameType_Posix = 0;
182
- static const Byte kFileNameType_Win32 = 1;
183
- static const Byte kFileNameType_Dos = 2;
184
- static const Byte kFileNameType_Win32Dos = 3;
203
+
204
+ /* WinXP-64:
205
+ Probably only one short name (dos name) per record is allowed.
206
+ There are no short names for hard links.
207
+ The pair (Win32,Dos) can be in any order.
208
+ Posix name can be after or before Win32 name
209
+ */
210
+
211
+ static const Byte kFileNameType_Posix = 0; // for hard links
212
+ static const Byte kFileNameType_Win32 = 1; // after Dos name
213
+ static const Byte kFileNameType_Dos = 2; // short name
214
+ static const Byte kFileNameType_Win32Dos = 3; // short and full name are same
185
215
 
186
216
  struct CFileNameAttr
187
217
  {
188
218
  CMftRef ParentDirRef;
219
+
220
+ // Probably these timestamps don't contain some useful timestamps. So we don't use them
189
221
  // UInt64 CTime;
190
222
  // UInt64 MTime;
191
- // UInt64 ThisRecMTime;
223
+ // UInt64 ThisRecMTime; // xp-64: the time of previous name change (not last name change. why?)
192
224
  // UInt64 ATime;
193
225
  // UInt64 AllocatedSize;
194
226
  // UInt64 DataSize;
195
227
  // UInt16 PackedEaSize;
196
- UString Name;
228
+ UString2 Name;
197
229
  UInt32 Attrib;
198
230
  Byte NameType;
199
-
231
+
200
232
  bool IsDos() const { return NameType == kFileNameType_Dos; }
233
+ bool IsWin32() const { return (NameType == kFileNameType_Win32); }
234
+
201
235
  bool Parse(const Byte *p, unsigned size);
202
236
  };
203
237
 
204
- static void GetString(const Byte *p, unsigned length, UString &res)
238
+ static void GetString(const Byte *p, unsigned len, UString2 &res)
205
239
  {
206
- wchar_t *s = res.GetBuffer(length);
207
- for (unsigned i = 0; i < length; i++)
208
- s[i] = Get16(p + i * 2);
209
- s[length] = 0;
210
- res.ReleaseBuffer();
240
+ if (len == 0 && res.IsEmpty())
241
+ return;
242
+ wchar_t *s = res.GetBuf(len);
243
+ unsigned i;
244
+ for (i = 0; i < len; i++)
245
+ {
246
+ wchar_t c = Get16(p + i * 2);
247
+ if (c == 0)
248
+ break;
249
+ s[i] = c;
250
+ }
251
+ s[i] = 0;
252
+ res.ReleaseBuf_SetLen(i);
211
253
  }
212
254
 
213
255
  bool CFileNameAttr::Parse(const Byte *p, unsigned size)
@@ -224,10 +266,11 @@ bool CFileNameAttr::Parse(const Byte *p, unsigned size)
224
266
  G32(p + 0x38, Attrib);
225
267
  // G16(p + 0x3C, PackedEaSize);
226
268
  NameType = p[0x41];
227
- unsigned length = p[0x40];
228
- if (0x42 + length > size)
269
+ unsigned len = p[0x40];
270
+ if (0x42 + len > size)
229
271
  return false;
230
- GetString(p + 0x42, length, Name);
272
+ if (len != 0)
273
+ GetString(p + 0x42, len, Name);
231
274
  return true;
232
275
  }
233
276
 
@@ -244,9 +287,9 @@ struct CSiAttr
244
287
  UInt32 Version;
245
288
  UInt32 ClassId;
246
289
  UInt32 OwnerId;
247
- UInt32 SecurityId;
248
- UInt64 QuotaCharged;
249
290
  */
291
+ UInt32 SecurityId; // SecurityId = 0 is possible ?
292
+ // UInt64 QuotaCharged;
250
293
 
251
294
  bool Parse(const Byte *p, unsigned size);
252
295
  };
@@ -260,6 +303,9 @@ bool CSiAttr::Parse(const Byte *p, unsigned size)
260
303
  // G64(p + 0x10, ThisRecMTime);
261
304
  G64(p + 0x18, ATime);
262
305
  G32(p + 0x20, Attrib);
306
+ SecurityId = 0;
307
+ if (size >= 0x38)
308
+ G32(p + 0x34, SecurityId);
263
309
  return true;
264
310
  }
265
311
 
@@ -295,8 +341,8 @@ bool CVolInfo::Parse(const Byte *p, unsigned size)
295
341
  struct CAttr
296
342
  {
297
343
  UInt32 Type;
298
- // UInt32 Length;
299
- UString Name;
344
+ // UInt32 Len;
345
+ UString2 Name;
300
346
  // UInt16 Flags;
301
347
  // UInt16 Instance;
302
348
  CByteBuffer Data;
@@ -317,15 +363,15 @@ struct CAttr
317
363
  bool IsCompressionUnitSupported() const { return CompressionUnit == 0 || CompressionUnit == 4; }
318
364
 
319
365
  UInt32 Parse(const Byte *p, unsigned size);
320
- bool ParseFileName(CFileNameAttr &a) const { return a.Parse(Data, (unsigned)Data.GetCapacity()); }
321
- bool ParseSi(CSiAttr &a) const { return a.Parse(Data, (unsigned)Data.GetCapacity()); }
322
- bool ParseVolInfo(CVolInfo &a) const { return a.Parse(Data, (unsigned)Data.GetCapacity()); }
323
- bool ParseExtents(CRecordVector<CExtent> &extents, UInt64 numClustersMax, int compressionUnit) const;
324
- UInt64 GetSize() const { return NonResident ? Size : Data.GetCapacity(); }
366
+ bool ParseFileName(CFileNameAttr &a) const { return a.Parse(Data, (unsigned)Data.Size()); }
367
+ bool ParseSi(CSiAttr &a) const { return a.Parse(Data, (unsigned)Data.Size()); }
368
+ bool ParseVolInfo(CVolInfo &a) const { return a.Parse(Data, (unsigned)Data.Size()); }
369
+ bool ParseExtents(CRecordVector<CExtent> &extents, UInt64 numClustersMax, unsigned compressionUnit) const;
370
+ UInt64 GetSize() const { return NonResident ? Size : Data.Size(); }
325
371
  UInt64 GetPackSize() const
326
372
  {
327
373
  if (!NonResident)
328
- return Data.GetCapacity();
374
+ return Data.Size();
329
375
  if (CompressionUnit != 0)
330
376
  return PackSize;
331
377
  return AllocatedSize;
@@ -339,7 +385,17 @@ static int CompareAttr(void *const *elem1, void *const *elem2, void *)
339
385
  const CAttr &a1 = *(*((const CAttr **)elem1));
340
386
  const CAttr &a2 = *(*((const CAttr **)elem2));
341
387
  RINOZ(MyCompare(a1.Type, a2.Type));
342
- RINOZ(MyCompare(a1.Name, a2.Name));
388
+ if (a1.Name.IsEmpty())
389
+ {
390
+ if (!a2.Name.IsEmpty())
391
+ return -1;
392
+ }
393
+ else if (a2.Name.IsEmpty())
394
+ return 1;
395
+ else
396
+ {
397
+ RINOZ(wcscmp(a1.Name.GetRawPtr(), a2.Name.GetRawPtr()));
398
+ }
343
399
  return MyCompare(a1.LowVcn, a2.LowVcn);
344
400
  }
345
401
 
@@ -349,25 +405,28 @@ UInt32 CAttr::Parse(const Byte *p, unsigned size)
349
405
  return 0;
350
406
  G32(p, Type);
351
407
  if (Type == 0xFFFFFFFF)
352
- return 4;
408
+ return 8; // required size is 4, but attributes are 8 bytes aligned. So we return 8
353
409
  if (size < 0x18)
354
410
  return 0;
355
411
  PRF(printf(" T=%2X", Type));
356
-
357
- UInt32 length = Get32(p + 0x04);
358
- PRF(printf(" L=%3d", length));
359
- if (length > size)
412
+
413
+ UInt32 len = Get32(p + 0x04);
414
+ PRF(printf(" L=%3d", len));
415
+ if (len > size)
416
+ return 0;
417
+ if ((len & 7) != 0)
360
418
  return 0;
361
419
  NonResident = p[0x08];
362
420
  {
363
- int nameLength = p[9];
421
+ unsigned nameLen = p[9];
364
422
  UInt32 nameOffset = Get16(p + 0x0A);
365
- if (nameLength != 0)
423
+ if (nameLen != 0)
366
424
  {
367
- if (nameOffset + nameLength * 2 > length)
425
+ if (nameOffset + nameLen * 2 > len)
368
426
  return 0;
369
- GetString(p + nameOffset, nameLength, Name);
370
- PRF(printf(" N=%S", Name));
427
+ GetString(p + nameOffset, nameLen, Name);
428
+ PRF(printf(" N="));
429
+ PRF_UTF16(Name);
371
430
  }
372
431
  }
373
432
 
@@ -380,7 +439,7 @@ UInt32 CAttr::Parse(const Byte *p, unsigned size)
380
439
  UInt32 offs;
381
440
  if (NonResident)
382
441
  {
383
- if (length < 0x40)
442
+ if (len < 0x40)
384
443
  return 0;
385
444
  PRF(printf(" NR"));
386
445
  G64(p + 0x10, LowVcn);
@@ -394,7 +453,7 @@ UInt32 CAttr::Parse(const Byte *p, unsigned size)
394
453
  PackSize = Size;
395
454
  if (CompressionUnit != 0)
396
455
  {
397
- if (length < 0x48)
456
+ if (len < 0x48)
398
457
  return 0;
399
458
  G64(p + 0x40, PackSize);
400
459
  PRF(printf(" PS=%I64x", PackSize));
@@ -406,12 +465,12 @@ UInt32 CAttr::Parse(const Byte *p, unsigned size)
406
465
  PRF(printf(" IS=%I64d", InitializedSize));
407
466
  PRF(printf(" Low=%I64d", LowVcn));
408
467
  PRF(printf(" High=%I64d", HighVcn));
409
- PRF(printf(" CU=%d", (int)CompressionUnit));
410
- dataSize = length - offs;
468
+ PRF(printf(" CU=%d", (unsigned)CompressionUnit));
469
+ dataSize = len - offs;
411
470
  }
412
471
  else
413
472
  {
414
- if (length < 0x18)
473
+ if (len < 0x18)
415
474
  return 0;
416
475
  PRF(printf(" RES"));
417
476
  dataSize = Get32(p + 0x10);
@@ -420,24 +479,23 @@ UInt32 CAttr::Parse(const Byte *p, unsigned size)
420
479
  // G16(p + 0x16, ResidentFlags);
421
480
  // PRF(printf(" ResFlags=%4X", ResidentFlags));
422
481
  }
423
- if (offs > length || dataSize > length || length - dataSize < offs)
482
+ if (offs > len || dataSize > len || len - dataSize < offs)
424
483
  return 0;
425
- Data.SetCapacity(dataSize);
426
- memcpy(Data, p + offs, dataSize);
484
+ Data.CopyFrom(p + offs, dataSize);
427
485
  #ifdef SHOW_DEBUG_INFO
428
486
  PRF(printf(" : "));
429
- for (unsigned i = 0; i < Data.GetCapacity(); i++)
487
+ for (unsigned i = 0; i < Data.Size(); i++)
430
488
  {
431
- PRF(printf(" %02X", (int)Data[i]));
489
+ PRF(printf(" %02X", (unsigned)Data[i]));
432
490
  }
433
491
  #endif
434
- return length;
492
+ return len;
435
493
  }
436
494
 
437
- bool CAttr::ParseExtents(CRecordVector<CExtent> &extents, UInt64 numClustersMax, int compressionUnit) const
495
+ bool CAttr::ParseExtents(CRecordVector<CExtent> &extents, UInt64 numClustersMax, unsigned compressionUnit) const
438
496
  {
439
497
  const Byte *p = Data;
440
- unsigned size = (unsigned)Data.GetCapacity();
498
+ unsigned size = (unsigned)Data.Size();
441
499
  UInt64 vcn = LowVcn;
442
500
  UInt64 lcn = 0;
443
501
  UInt64 highVcn1 = HighVcn + 1;
@@ -458,10 +516,11 @@ bool CAttr::ParseExtents(CRecordVector<CExtent> &extents, UInt64 numClustersMax,
458
516
  if (num == 0 || num > 8 || num > size)
459
517
  return false;
460
518
 
461
- int i;
462
- UInt64 vSize = p[num - 1];
463
- for (i = (int)num - 2; i >= 0; i--)
464
- vSize = (vSize << 8) | p[i];
519
+ UInt64 vSize = 0;
520
+ {
521
+ unsigned i = num;
522
+ do vSize = (vSize << 8) | p[--i]; while (i);
523
+ }
465
524
  if (vSize == 0)
466
525
  return false;
467
526
  p += num;
@@ -483,8 +542,10 @@ bool CAttr::ParseExtents(CRecordVector<CExtent> &extents, UInt64 numClustersMax,
483
542
  else
484
543
  {
485
544
  Int64 v = (signed char)p[num - 1];
486
- for (i = (int)num - 2; i >= 0; i--)
487
- v = (v << 8) | p[i];
545
+ {
546
+ for (unsigned i = num - 1; i != 0;)
547
+ v = (v << 8) | p[--i];
548
+ }
488
549
  p += num;
489
550
  size -= num;
490
551
  lcn += v;
@@ -504,8 +565,8 @@ bool CAttr::ParseExtents(CRecordVector<CExtent> &extents, UInt64 numClustersMax,
504
565
 
505
566
  static const UInt64 kEmptyTag = (UInt64)(Int64)-1;
506
567
 
507
- static const int kNumCacheChunksLog = 1;
508
- static const UInt32 kNumCacheChunks = (1 << kNumCacheChunksLog);
568
+ static const unsigned kNumCacheChunksLog = 1;
569
+ static const size_t kNumCacheChunks = (1 << kNumCacheChunksLog);
509
570
 
510
571
  class CInStream:
511
572
  public IInStream,
@@ -515,35 +576,35 @@ class CInStream:
515
576
  UInt64 _physPos;
516
577
  UInt64 _curRem;
517
578
  bool _sparseMode;
518
- size_t _compressedPos;
519
-
579
+
580
+
581
+ unsigned _chunkSizeLog;
520
582
  UInt64 _tags[kNumCacheChunks];
521
- int _chunkSizeLog;
522
583
  CByteBuffer _inBuf;
523
584
  CByteBuffer _outBuf;
524
585
  public:
525
- CMyComPtr<IInStream> Stream;
526
586
  UInt64 Size;
527
587
  UInt64 InitializedSize;
528
- int BlockSizeLog;
529
- int CompressionUnit;
530
- bool InUse;
588
+ unsigned BlockSizeLog;
589
+ unsigned CompressionUnit;
531
590
  CRecordVector<CExtent> Extents;
591
+ bool InUse;
592
+ CMyComPtr<IInStream> Stream;
532
593
 
533
594
  HRESULT SeekToPhys() { return Stream->Seek(_physPos, STREAM_SEEK_SET, NULL); }
534
595
 
535
596
  UInt32 GetCuSize() const { return (UInt32)1 << (BlockSizeLog + CompressionUnit); }
536
- HRESULT InitAndSeek(int compressionUnit)
597
+ HRESULT InitAndSeek(unsigned compressionUnit)
537
598
  {
538
599
  CompressionUnit = compressionUnit;
600
+ _chunkSizeLog = BlockSizeLog + CompressionUnit;
539
601
  if (compressionUnit != 0)
540
602
  {
541
603
  UInt32 cuSize = GetCuSize();
542
- _inBuf.SetCapacity(cuSize);
543
- _chunkSizeLog = BlockSizeLog + CompressionUnit;
544
- _outBuf.SetCapacity(kNumCacheChunks << _chunkSizeLog);
604
+ _inBuf.Alloc(cuSize);
605
+ _outBuf.Alloc(kNumCacheChunks << _chunkSizeLog);
545
606
  }
546
- for (int i = 0; i < kNumCacheChunks; i++)
607
+ for (size_t i = 0; i < kNumCacheChunks; i++)
547
608
  _tags[i] = kEmptyTag;
548
609
 
549
610
  _sparseMode = false;
@@ -569,28 +630,31 @@ static size_t Lznt1Dec(Byte *dest, size_t outBufLim, size_t destLen, const Byte
569
630
  {
570
631
  if (srcLen < 2 || (destSize & 0xFFF) != 0)
571
632
  break;
572
- UInt32 v = Get16(src);
573
- if (v == 0)
574
- break;
575
- src += 2;
576
- srcLen -= 2;
577
- UInt32 comprSize = (v & 0xFFF) + 1;
578
- if (comprSize > srcLen)
579
- break;
580
- srcLen -= comprSize;
581
- if ((v & 0x8000) == 0)
633
+ UInt32 comprSize;
582
634
  {
583
- if (comprSize != (1 << 12))
635
+ const UInt32 v = Get16(src);
636
+ if (v == 0)
637
+ break;
638
+ src += 2;
639
+ srcLen -= 2;
640
+ comprSize = (v & 0xFFF) + 1;
641
+ if (comprSize > srcLen)
584
642
  break;
585
- memcpy(dest + destSize, src, comprSize);
586
- src += comprSize;
587
- destSize += comprSize;
643
+ srcLen -= comprSize;
644
+ if ((v & 0x8000) == 0)
645
+ {
646
+ if (comprSize != (1 << 12))
647
+ break;
648
+ memcpy(dest + destSize, src, comprSize);
649
+ src += comprSize;
650
+ destSize += comprSize;
651
+ continue;
652
+ }
588
653
  }
589
- else
590
654
  {
591
655
  if (destSize + (1 << 12) > outBufLim || (src[0] & 1) != 0)
592
656
  return 0;
593
- int numDistBits = 4;
657
+ unsigned numDistBits = 4;
594
658
  UInt32 sbOffset = 0;
595
659
  UInt32 pos = 0;
596
660
 
@@ -611,7 +675,7 @@ static size_t Lznt1Dec(Byte *dest, size_t outBufLim, size_t destLen, const Byte
611
675
  {
612
676
  if (comprSize < 2)
613
677
  return 0;
614
- UInt32 v = Get16(src + pos);
678
+ const UInt32 v = Get16(src + pos);
615
679
  pos += 2;
616
680
  comprSize -= 2;
617
681
 
@@ -642,15 +706,18 @@ static size_t Lznt1Dec(Byte *dest, size_t outBufLim, size_t destLen, const Byte
642
706
 
643
707
  STDMETHODIMP CInStream::Read(void *data, UInt32 size, UInt32 *processedSize)
644
708
  {
645
- if (processedSize != NULL)
709
+ if (processedSize)
646
710
  *processedSize = 0;
647
711
  if (_virtPos >= Size)
648
712
  return (Size == _virtPos) ? S_OK: E_FAIL;
649
713
  if (size == 0)
650
714
  return S_OK;
651
- UInt64 rem = Size - _virtPos;
652
- if (size > rem)
653
- size = (UInt32)rem;
715
+ {
716
+ const UInt64 rem = Size - _virtPos;
717
+ if (size > rem)
718
+ size = (UInt32)rem;
719
+ }
720
+
654
721
  if (_virtPos >= InitializedSize)
655
722
  {
656
723
  memset((Byte *)data, 0, size);
@@ -658,9 +725,12 @@ STDMETHODIMP CInStream::Read(void *data, UInt32 size, UInt32 *processedSize)
658
725
  *processedSize = size;
659
726
  return S_OK;
660
727
  }
661
- rem = InitializedSize - _virtPos;
662
- if (size > rem)
663
- size = (UInt32)rem;
728
+
729
+ {
730
+ const UInt64 rem = InitializedSize - _virtPos;
731
+ if (size > rem)
732
+ size = (UInt32)rem;
733
+ }
664
734
 
665
735
  while (_curRem == 0)
666
736
  {
@@ -678,15 +748,15 @@ STDMETHODIMP CInStream::Read(void *data, UInt32 size, UInt32 *processedSize)
678
748
  }
679
749
 
680
750
  PRF2(printf("\nVirtPos = %6d", _virtPos));
681
-
751
+
682
752
  UInt32 comprUnitSize = (UInt32)1 << CompressionUnit;
683
753
  UInt64 virtBlock = _virtPos >> BlockSizeLog;
684
754
  UInt64 virtBlock2 = virtBlock & ~((UInt64)comprUnitSize - 1);
685
-
686
- int left = 0, right = Extents.Size();
755
+
756
+ unsigned left = 0, right = Extents.Size();
687
757
  for (;;)
688
758
  {
689
- int mid = (left + right) / 2;
759
+ unsigned mid = (left + right) / 2;
690
760
  if (mid == left)
691
761
  break;
692
762
  if (virtBlock2 < Extents[mid].Virt)
@@ -694,11 +764,11 @@ STDMETHODIMP CInStream::Read(void *data, UInt32 size, UInt32 *processedSize)
694
764
  else
695
765
  left = mid;
696
766
  }
697
-
767
+
698
768
  bool isCompressed = false;
699
769
  UInt64 virtBlock2End = virtBlock2 + comprUnitSize;
700
770
  if (CompressionUnit != 0)
701
- for (int i = left; i < Extents.Size(); i++)
771
+ for (unsigned i = left; i < Extents.Size(); i++)
702
772
  {
703
773
  const CExtent &e = Extents[i];
704
774
  if (e.Virt >= virtBlock2End)
@@ -710,9 +780,9 @@ STDMETHODIMP CInStream::Read(void *data, UInt32 size, UInt32 *processedSize)
710
780
  }
711
781
  }
712
782
 
713
- int i;
783
+ unsigned i;
714
784
  for (i = left; Extents[i + 1].Virt <= virtBlock; i++);
715
-
785
+
716
786
  _sparseMode = false;
717
787
  if (!isCompressed)
718
788
  {
@@ -733,7 +803,7 @@ STDMETHODIMP CInStream::Read(void *data, UInt32 size, UInt32 *processedSize)
733
803
  break;
734
804
  }
735
805
  bool thereArePhy = false;
736
- for (int i2 = left; i2 < Extents.Size(); i2++)
806
+ for (unsigned i2 = left; i2 < Extents.Size(); i2++)
737
807
  {
738
808
  const CExtent &e = Extents[i2];
739
809
  if (e.Virt >= virtBlock2End)
@@ -750,7 +820,7 @@ STDMETHODIMP CInStream::Read(void *data, UInt32 size, UInt32 *processedSize)
750
820
  _sparseMode = true;
751
821
  break;
752
822
  }
753
-
823
+
754
824
  size_t offs = 0;
755
825
  UInt64 curVirt = virtBlock2;
756
826
  for (i = left; i < Extents.Size(); i++)
@@ -777,7 +847,7 @@ STDMETHODIMP CInStream::Read(void *data, UInt32 size, UInt32 *processedSize)
777
847
  }
778
848
  size_t destLenMax = GetCuSize();
779
849
  size_t destLen = destLenMax;
780
- UInt64 rem = Size - (virtBlock2 << BlockSizeLog);
850
+ const UInt64 rem = Size - (virtBlock2 << BlockSizeLog);
781
851
  if (destLen > rem)
782
852
  destLen = (size_t)rem;
783
853
 
@@ -803,96 +873,57 @@ STDMETHODIMP CInStream::Read(void *data, UInt32 size, UInt32 *processedSize)
803
873
  res = Stream->Read(data, size, &size);
804
874
  _physPos += size;
805
875
  }
806
- if (processedSize != NULL)
876
+ if (processedSize)
807
877
  *processedSize = size;
808
878
  _virtPos += size;
809
879
  _curRem -= size;
810
880
  return res;
811
881
  }
812
-
882
+
813
883
  STDMETHODIMP CInStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition)
814
884
  {
815
- UInt64 newVirtPos = offset;
816
- switch(seekOrigin)
885
+ switch (seekOrigin)
817
886
  {
818
887
  case STREAM_SEEK_SET: break;
819
- case STREAM_SEEK_CUR: newVirtPos += _virtPos; break;
820
- case STREAM_SEEK_END: newVirtPos += Size; break;
888
+ case STREAM_SEEK_CUR: offset += _virtPos; break;
889
+ case STREAM_SEEK_END: offset += Size; break;
821
890
  default: return STG_E_INVALIDFUNCTION;
822
891
  }
823
- if (_virtPos != newVirtPos)
892
+ if (offset < 0)
893
+ return HRESULT_WIN32_ERROR_NEGATIVE_SEEK;
894
+ if (_virtPos != (UInt64)offset)
895
+ {
824
896
  _curRem = 0;
825
- _virtPos = newVirtPos;
897
+ _virtPos = offset;
898
+ }
826
899
  if (newPosition)
827
- *newPosition = newVirtPos;
828
- return S_OK;
829
- }
830
-
831
- class CByteBufStream:
832
- public IInStream,
833
- public CMyUnknownImp
834
- {
835
- UInt64 _virtPos;
836
- public:
837
- CByteBuffer Buf;
838
- void Init() { _virtPos = 0; }
839
-
840
- MY_UNKNOWN_IMP1(IInStream)
841
-
842
- STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
843
- STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
844
- };
845
-
846
- STDMETHODIMP CByteBufStream::Read(void *data, UInt32 size, UInt32 *processedSize)
847
- {
848
- if (processedSize != NULL)
849
- *processedSize = 0;
850
- if (_virtPos >= Buf.GetCapacity())
851
- return (_virtPos == Buf.GetCapacity()) ? S_OK: E_FAIL;
852
- UInt64 rem = Buf.GetCapacity() - _virtPos;
853
- if (rem < size)
854
- size = (UInt32)rem;
855
- memcpy(data, Buf + (size_t)_virtPos, size);
856
- if (processedSize != NULL)
857
- *processedSize = size;
858
- _virtPos += size;
900
+ *newPosition = offset;
859
901
  return S_OK;
860
902
  }
861
903
 
862
- STDMETHODIMP CByteBufStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition)
904
+ static HRESULT DataParseExtents(unsigned clusterSizeLog, const CObjectVector<CAttr> &attrs,
905
+ unsigned attrIndex, unsigned attrIndexLim, UInt64 numPhysClusters, CRecordVector<CExtent> &Extents)
863
906
  {
864
- switch(seekOrigin)
865
907
  {
866
- case STREAM_SEEK_SET: _virtPos = offset; break;
867
- case STREAM_SEEK_CUR: _virtPos += offset; break;
868
- case STREAM_SEEK_END: _virtPos = Buf.GetCapacity() + offset; break;
869
- default: return STG_E_INVALIDFUNCTION;
908
+ CExtent e;
909
+ e.Virt = 0;
910
+ e.Phy = kEmptyExtent;
911
+ Extents.Add(e);
870
912
  }
871
- if (newPosition)
872
- *newPosition = _virtPos;
873
- return S_OK;
874
- }
875
913
 
876
- static HRESULT DataParseExtents(int clusterSizeLog, const CObjectVector<CAttr> &attrs,
877
- int attrIndex, int attrIndexLim, UInt64 numPhysClusters, CRecordVector<CExtent> &Extents)
878
- {
879
- CExtent e;
880
- e.Virt = 0;
881
- e.Phy = kEmptyExtent;
882
- Extents.Add(e);
883
914
  const CAttr &attr0 = attrs[attrIndex];
884
915
 
885
916
  if (attr0.AllocatedSize < attr0.Size ||
886
917
  (attrs[attrIndexLim - 1].HighVcn + 1) != (attr0.AllocatedSize >> clusterSizeLog) ||
887
918
  (attr0.AllocatedSize & ((1 << clusterSizeLog) - 1)) != 0)
888
919
  return S_FALSE;
889
-
890
- for (int i = attrIndex; i < attrIndexLim; i++)
920
+
921
+ for (unsigned i = attrIndex; i < attrIndexLim; i++)
891
922
  if (!attrs[i].ParseExtents(Extents, numPhysClusters, attr0.CompressionUnit))
892
923
  return S_FALSE;
893
924
 
894
925
  UInt64 packSizeCalc = 0;
895
- for (int k = 0; k < Extents.Size(); k++)
926
+ FOR_VECTOR (k, Extents)
896
927
  {
897
928
  CExtent &e = Extents[k];
898
929
  if (!e.IsEmpty())
@@ -900,7 +931,7 @@ static HRESULT DataParseExtents(int clusterSizeLog, const CObjectVector<CAttr> &
900
931
  PRF2(printf("\nSize = %4I64X", Extents[k + 1].Virt - e.Virt));
901
932
  PRF2(printf(" Pos = %4I64X", e.Phy));
902
933
  }
903
-
934
+
904
935
  if (attr0.CompressionUnit != 0)
905
936
  {
906
937
  if (packSizeCalc != attr0.PackSize)
@@ -916,31 +947,71 @@ static HRESULT DataParseExtents(int clusterSizeLog, const CObjectVector<CAttr> &
916
947
 
917
948
  struct CDataRef
918
949
  {
919
- int Start;
920
- int Num;
950
+ unsigned Start;
951
+ unsigned Num;
921
952
  };
922
953
 
923
- static const UInt32 kMagic_FILE = 0x454c4946;
954
+ static const UInt32 kMagic_FILE = 0x454C4946;
924
955
  static const UInt32 kMagic_BAAD = 0x44414142;
925
956
 
926
957
  struct CMftRec
927
958
  {
928
959
  UInt32 Magic;
929
960
  // UInt64 Lsn;
930
- UInt16 SeqNumber;
961
+ UInt16 SeqNumber; // Number of times this mft record has been reused
931
962
  UInt16 Flags;
932
963
  // UInt16 LinkCount;
933
964
  // UInt16 NextAttrInstance;
934
965
  CMftRef BaseMftRef;
935
966
  // UInt32 ThisRecNumber;
967
+
936
968
  UInt32 MyNumNameLinks;
969
+ int MyItemIndex; // index in Items[] of main item for that record, or -1 if there is no item for that record
937
970
 
938
971
  CObjectVector<CAttr> DataAttrs;
939
972
  CObjectVector<CFileNameAttr> FileNames;
940
973
  CRecordVector<CDataRef> DataRefs;
974
+ // CAttr SecurityAttr;
941
975
 
942
976
  CSiAttr SiAttr;
943
977
 
978
+ CByteBuffer ReparseData;
979
+
980
+ int FindWin32Name_for_DosName(unsigned dosNameIndex) const
981
+ {
982
+ const CFileNameAttr &cur = FileNames[dosNameIndex];
983
+ if (cur.IsDos())
984
+ for (unsigned i = 0; i < FileNames.Size(); i++)
985
+ {
986
+ const CFileNameAttr &next = FileNames[i];
987
+ if (next.IsWin32() && cur.ParentDirRef.Val == next.ParentDirRef.Val)
988
+ return i;
989
+ }
990
+ return -1;
991
+ }
992
+
993
+ int FindDosName(unsigned nameIndex) const
994
+ {
995
+ const CFileNameAttr &cur = FileNames[nameIndex];
996
+ if (cur.IsWin32())
997
+ for (unsigned i = 0; i < FileNames.Size(); i++)
998
+ {
999
+ const CFileNameAttr &next = FileNames[i];
1000
+ if (next.IsDos() && cur.ParentDirRef.Val == next.ParentDirRef.Val)
1001
+ return i;
1002
+ }
1003
+ return -1;
1004
+ }
1005
+
1006
+ /*
1007
+ bool IsAltStream(int dataIndex) const
1008
+ {
1009
+ return dataIndex >= 0 && (
1010
+ (IsDir() ||
1011
+ !DataAttrs[DataRefs[dataIndex].Start].Name.IsEmpty()));
1012
+ }
1013
+ */
1014
+
944
1015
  void MoveAttrsFrom(CMftRec &src)
945
1016
  {
946
1017
  DataAttrs += src.DataAttrs;
@@ -952,12 +1023,12 @@ struct CMftRec
952
1023
  UInt64 GetPackSize() const
953
1024
  {
954
1025
  UInt64 res = 0;
955
- for (int i = 0; i < DataRefs.Size(); i++)
1026
+ FOR_VECTOR (i, DataRefs)
956
1027
  res += DataAttrs[DataRefs[i].Start].GetPackSize();
957
1028
  return res;
958
1029
  }
959
1030
 
960
- bool Parse(Byte *p, int sectorSizeLog, UInt32 numSectors, UInt32 recNumber, CObjectVector<CAttr> *attrs);
1031
+ bool Parse(Byte *p, unsigned sectorSizeLog, UInt32 numSectors, UInt32 recNumber, CObjectVector<CAttr> *attrs);
961
1032
 
962
1033
  bool IsEmpty() const { return (Magic <= 2); }
963
1034
  bool IsFILE() const { return (Magic == kMagic_FILE); }
@@ -968,12 +1039,12 @@ struct CMftRec
968
1039
 
969
1040
  void ParseDataNames();
970
1041
  HRESULT GetStream(IInStream *mainStream, int dataIndex,
971
- int clusterSizeLog, UInt64 numPhysClusters, IInStream **stream) const;
972
- int GetNumExtents(int dataIndex, int clusterSizeLog, UInt64 numPhysClusters) const;
1042
+ unsigned clusterSizeLog, UInt64 numPhysClusters, IInStream **stream) const;
1043
+ unsigned GetNumExtents(int dataIndex, unsigned clusterSizeLog, UInt64 numPhysClusters) const;
973
1044
 
974
- UInt64 GetSize(int dataIndex) const { return DataAttrs[DataRefs[dataIndex].Start].GetSize(); }
1045
+ UInt64 GetSize(unsigned dataIndex) const { return DataAttrs[DataRefs[dataIndex].Start].GetSize(); }
975
1046
 
976
- CMftRec(): MyNumNameLinks(0) {}
1047
+ CMftRec(): MyNumNameLinks(0), MyItemIndex(-1) {}
977
1048
  };
978
1049
 
979
1050
  void CMftRec::ParseDataNames()
@@ -981,7 +1052,7 @@ void CMftRec::ParseDataNames()
981
1052
  DataRefs.Clear();
982
1053
  DataAttrs.Sort(CompareAttr, 0);
983
1054
 
984
- for (int i = 0; i < DataAttrs.Size();)
1055
+ for (unsigned i = 0; i < DataAttrs.Size();)
985
1056
  {
986
1057
  CDataRef ref;
987
1058
  ref.Start = i;
@@ -994,63 +1065,63 @@ void CMftRec::ParseDataNames()
994
1065
  }
995
1066
 
996
1067
  HRESULT CMftRec::GetStream(IInStream *mainStream, int dataIndex,
997
- int clusterSizeLog, UInt64 numPhysClusters, IInStream **destStream) const
1068
+ unsigned clusterSizeLog, UInt64 numPhysClusters, IInStream **destStream) const
998
1069
  {
999
1070
  *destStream = 0;
1000
- CByteBufStream *streamSpec = new CByteBufStream;
1071
+ CBufferInStream *streamSpec = new CBufferInStream;
1001
1072
  CMyComPtr<IInStream> streamTemp = streamSpec;
1002
1073
 
1003
- if (dataIndex < 0)
1004
- return E_FAIL;
1005
-
1006
- if (dataIndex < DataRefs.Size())
1074
+ if (dataIndex >= 0)
1075
+ if ((unsigned)dataIndex < DataRefs.Size())
1007
1076
  {
1008
1077
  const CDataRef &ref = DataRefs[dataIndex];
1009
- int numNonResident = 0;
1010
- int i;
1078
+ unsigned numNonResident = 0;
1079
+ unsigned i;
1011
1080
  for (i = ref.Start; i < ref.Start + ref.Num; i++)
1012
1081
  if (DataAttrs[i].NonResident)
1013
1082
  numNonResident++;
1014
1083
 
1015
1084
  const CAttr &attr0 = DataAttrs[ref.Start];
1016
-
1085
+
1017
1086
  if (numNonResident != 0 || ref.Num != 1)
1018
1087
  {
1019
1088
  if (numNonResident != ref.Num || !attr0.IsCompressionUnitSupported())
1020
1089
  return S_FALSE;
1021
- CInStream *streamSpec = new CInStream;
1022
- CMyComPtr<IInStream> streamTemp = streamSpec;
1023
- RINOK(DataParseExtents(clusterSizeLog, DataAttrs, ref.Start, ref.Start + ref.Num, numPhysClusters, streamSpec->Extents));
1024
- streamSpec->Size = attr0.Size;
1025
- streamSpec->InitializedSize = attr0.InitializedSize;
1026
- streamSpec->Stream = mainStream;
1027
- streamSpec->BlockSizeLog = clusterSizeLog;
1028
- streamSpec->InUse = InUse();
1029
- RINOK(streamSpec->InitAndSeek(attr0.CompressionUnit));
1030
- *destStream = streamTemp.Detach();
1090
+ CInStream *ss = new CInStream;
1091
+ CMyComPtr<IInStream> streamTemp2 = ss;
1092
+ RINOK(DataParseExtents(clusterSizeLog, DataAttrs, ref.Start, ref.Start + ref.Num, numPhysClusters, ss->Extents));
1093
+ ss->Size = attr0.Size;
1094
+ ss->InitializedSize = attr0.InitializedSize;
1095
+ ss->Stream = mainStream;
1096
+ ss->BlockSizeLog = clusterSizeLog;
1097
+ ss->InUse = InUse();
1098
+ RINOK(ss->InitAndSeek(attr0.CompressionUnit));
1099
+ *destStream = streamTemp2.Detach();
1031
1100
  return S_OK;
1032
1101
  }
1102
+
1033
1103
  streamSpec->Buf = attr0.Data;
1034
1104
  }
1105
+
1035
1106
  streamSpec->Init();
1036
1107
  *destStream = streamTemp.Detach();
1037
1108
  return S_OK;
1038
1109
  }
1039
1110
 
1040
- int CMftRec::GetNumExtents(int dataIndex, int clusterSizeLog, UInt64 numPhysClusters) const
1111
+ unsigned CMftRec::GetNumExtents(int dataIndex, unsigned clusterSizeLog, UInt64 numPhysClusters) const
1041
1112
  {
1042
1113
  if (dataIndex < 0)
1043
1114
  return 0;
1044
1115
  {
1045
1116
  const CDataRef &ref = DataRefs[dataIndex];
1046
- int numNonResident = 0;
1047
- int i;
1117
+ unsigned numNonResident = 0;
1118
+ unsigned i;
1048
1119
  for (i = ref.Start; i < ref.Start + ref.Num; i++)
1049
1120
  if (DataAttrs[i].NonResident)
1050
1121
  numNonResident++;
1051
1122
 
1052
1123
  const CAttr &attr0 = DataAttrs[ref.Start];
1053
-
1124
+
1054
1125
  if (numNonResident != 0 || ref.Num != 1)
1055
1126
  {
1056
1127
  if (numNonResident != ref.Num || !attr0.IsCompressionUnitSupported())
@@ -1060,36 +1131,57 @@ int CMftRec::GetNumExtents(int dataIndex, int clusterSizeLog, UInt64 numPhysClus
1060
1131
  return 0; // error;
1061
1132
  return extents.Size() - 1;
1062
1133
  }
1063
- // if (attr0.Data.GetCapacity() != 0)
1134
+ // if (attr0.Data.Size() != 0)
1064
1135
  // return 1;
1065
1136
  return 0;
1066
1137
  }
1067
1138
  }
1068
1139
 
1069
- bool CMftRec::Parse(Byte *p, int sectorSizeLog, UInt32 numSectors, UInt32 recNumber,
1140
+ bool CMftRec::Parse(Byte *p, unsigned sectorSizeLog, UInt32 numSectors, UInt32 recNumber,
1070
1141
  CObjectVector<CAttr> *attrs)
1071
1142
  {
1072
1143
  G32(p, Magic);
1073
1144
  if (!IsFILE())
1074
1145
  return IsEmpty() || IsBAAD();
1075
1146
 
1076
- UInt32 usaOffset;
1077
- UInt32 numUsaItems;
1078
- G16(p + 0x04, usaOffset);
1079
- G16(p + 0x06, numUsaItems);
1080
-
1081
- if ((usaOffset & 1) != 0 || usaOffset + numUsaItems * 2 > ((UInt32)1 << sectorSizeLog) - 2 ||
1082
- numUsaItems == 0 || numUsaItems - 1 != numSectors)
1083
- return false;
1084
1147
 
1085
- UInt16 usn = Get16(p + usaOffset);
1086
- // PRF(printf("\nusn = %d", usn));
1087
- for (UInt32 i = 1; i < numUsaItems; i++)
1088
1148
  {
1089
- void *pp = p + (i << sectorSizeLog) - 2;
1090
- if (Get16(pp) != usn)
1149
+ UInt32 usaOffset;
1150
+ UInt32 numUsaItems;
1151
+ G16(p + 0x04, usaOffset);
1152
+ G16(p + 0x06, numUsaItems);
1153
+
1154
+ /* NTFS stores (usn) to 2 last bytes in each sector (before writing record to disk).
1155
+ Original values of these two bytes are stored in table.
1156
+ So we restore original data from table */
1157
+
1158
+ if ((usaOffset & 1) != 0
1159
+ || usaOffset + numUsaItems * 2 > ((UInt32)1 << sectorSizeLog) - 2
1160
+ || numUsaItems == 0
1161
+ || numUsaItems - 1 != numSectors)
1091
1162
  return false;
1092
- SetUi16(pp, Get16(p + usaOffset + i * 2));
1163
+
1164
+ if (usaOffset >= 0x30) // NTFS 3.1+
1165
+ {
1166
+ UInt32 iii = Get32(p + 0x2C);
1167
+ if (iii != recNumber)
1168
+ {
1169
+ // ntfs-3g probably writes 0 (that probably is incorrect value) to this field for unused records.
1170
+ // so we support that "bad" case.
1171
+ if (iii != 0)
1172
+ return false;
1173
+ }
1174
+ }
1175
+
1176
+ UInt16 usn = Get16(p + usaOffset);
1177
+ // PRF(printf("\nusn = %d", usn));
1178
+ for (UInt32 i = 1; i < numUsaItems; i++)
1179
+ {
1180
+ void *pp = p + (i << sectorSizeLog) - 2;
1181
+ if (Get16(pp) != usn)
1182
+ return false;
1183
+ SetUi16(pp, Get16(p + usaOffset + i * 2));
1184
+ }
1093
1185
  }
1094
1186
 
1095
1187
  // G64(p + 0x08, Lsn);
@@ -1109,28 +1201,36 @@ bool CMftRec::Parse(Byte *p, int sectorSizeLog, UInt32 numSectors, UInt32 recNum
1109
1201
  // return false; // Check it;
1110
1202
  }
1111
1203
  // G16(p + 0x28, NextAttrInstance);
1112
- if (usaOffset >= 0x30)
1113
- if (Get32(p + 0x2C) != recNumber) // NTFS 3.1+
1114
- return false;
1115
1204
 
1116
1205
  UInt32 limit = numSectors << sectorSizeLog;
1117
- if (attrOffs >= limit || (attrOffs & 7) != 0 || bytesInUse > limit
1206
+ if (attrOffs >= limit
1207
+ || (attrOffs & 7) != 0
1208
+ || (bytesInUse & 7) != 0
1209
+ || bytesInUse > limit
1118
1210
  || bytesAlloc != limit)
1119
1211
  return false;
1120
1212
 
1213
+ limit = bytesInUse;
1121
1214
 
1122
- for (UInt32 t = attrOffs; t < limit;)
1215
+ for (UInt32 t = attrOffs;;)
1123
1216
  {
1217
+ if (t >= limit)
1218
+ return false;
1219
+
1124
1220
  CAttr attr;
1125
1221
  // PRF(printf("\n %2d:", Attrs.Size()));
1126
1222
  PRF(printf("\n"));
1127
- UInt32 length = attr.Parse(p + t, limit - t);
1128
- if (length == 0 || limit - t < length)
1223
+ UInt32 len = attr.Parse(p + t, limit - t);
1224
+ if (len == 0 || limit - t < len)
1129
1225
  return false;
1130
- t += length;
1226
+ t += len;
1131
1227
  if (attr.Type == 0xFFFFFFFF)
1228
+ {
1229
+ if (t != limit)
1230
+ return false;
1132
1231
  break;
1133
- switch(attr.Type)
1232
+ }
1233
+ switch (attr.Type)
1134
1234
  {
1135
1235
  case ATTR_TYPE_FILE_NAME:
1136
1236
  {
@@ -1138,8 +1238,8 @@ bool CMftRec::Parse(Byte *p, int sectorSizeLog, UInt32 numSectors, UInt32 recNum
1138
1238
  if (!attr.ParseFileName(fna))
1139
1239
  return false;
1140
1240
  FileNames.Add(fna);
1141
- PRF(printf(" flags = %4x", (int)fna.NameType));
1142
- PRF(printf("\n %S", fna.Name));
1241
+ PRF(printf(" flags = %4x\n ", (int)fna.NameType));
1242
+ PRF_UTF16(fna.Name);
1143
1243
  break;
1144
1244
  }
1145
1245
  case ATTR_TYPE_STANDARD_INFO:
@@ -1149,6 +1249,14 @@ bool CMftRec::Parse(Byte *p, int sectorSizeLog, UInt32 numSectors, UInt32 recNum
1149
1249
  case ATTR_TYPE_DATA:
1150
1250
  DataAttrs.Add(attr);
1151
1251
  break;
1252
+ case ATTR_TYPE_REPARSE_POINT:
1253
+ ReparseData = attr.Data;
1254
+ break;
1255
+ /*
1256
+ case ATTR_TYPE_SECURITY_DESCRIPTOR:
1257
+ SecurityAttr = attr;
1258
+ break;
1259
+ */
1152
1260
  default:
1153
1261
  if (attrs)
1154
1262
  attrs->Add(attr);
@@ -1159,56 +1267,140 @@ bool CMftRec::Parse(Byte *p, int sectorSizeLog, UInt32 numSectors, UInt32 recNum
1159
1267
  return true;
1160
1268
  }
1161
1269
 
1270
+ /*
1271
+ NTFS probably creates empty DATA_ATTRIBUTE for empty file,
1272
+ But it doesn't do it for
1273
+ $Secure (:$SDS),
1274
+ $Extend\$Quota
1275
+ $Extend\$ObjId
1276
+ $Extend\$Reparse
1277
+ */
1278
+
1279
+ static const int k_Item_DataIndex_IsEmptyFile = -1; // file without unnamed data stream
1280
+ static const int k_Item_DataIndex_IsDir = -2;
1281
+
1282
+ // static const int k_ParentFolderIndex_Root = -1;
1283
+ static const int k_ParentFolderIndex_Lost = -2;
1284
+ static const int k_ParentFolderIndex_Deleted = -3;
1285
+
1162
1286
  struct CItem
1163
1287
  {
1164
- int RecIndex;
1165
- int DataIndex;
1166
- CMftRef ParentRef;
1167
- UString Name;
1168
- UInt32 Attrib;
1169
-
1170
- bool IsDir() const { return (DataIndex < 0); }
1288
+ unsigned RecIndex; // index in Recs array
1289
+ unsigned NameIndex; // index in CMftRec::FileNames
1290
+
1291
+ int DataIndex; /* index in CMftRec::DataRefs
1292
+ -1: file without unnamed data stream
1293
+ -2: for directories */
1294
+
1295
+ int ParentFolder; /* index in Items array
1296
+ -1: for root items
1297
+ -2: [LOST] folder
1298
+ -3: [UNKNOWN] folder (deleted lost) */
1299
+ int ParentHost; /* index in Items array, if it's AltStream
1300
+ -1: if it's not AltStream */
1301
+
1302
+ CItem(): DataIndex(k_Item_DataIndex_IsDir), ParentFolder(-1), ParentHost(-1) {}
1303
+
1304
+ bool IsAltStream() const { return ParentHost != -1; }
1305
+ bool IsDir() const { return DataIndex == k_Item_DataIndex_IsDir; }
1306
+ // check it !!!
1307
+ // probably NTFS for empty file still creates empty DATA_ATTRIBUTE
1308
+ // But it doesn't do it for $Secure:$SDS
1171
1309
  };
1172
1310
 
1173
1311
  struct CDatabase
1174
1312
  {
1175
- CHeader Header;
1176
- CObjectVector<CItem> Items;
1313
+ CRecordVector<CItem> Items;
1177
1314
  CObjectVector<CMftRec> Recs;
1178
1315
  CMyComPtr<IInStream> InStream;
1316
+ CHeader Header;
1317
+ unsigned RecSizeLog;
1318
+ UInt64 PhySize;
1319
+
1179
1320
  IArchiveOpenCallback *OpenCallback;
1180
1321
 
1181
1322
  CByteBuffer ByteBuf;
1182
1323
 
1183
1324
  CObjectVector<CAttr> VolAttrs;
1184
1325
 
1326
+ CByteBuffer SecurData;
1327
+ CRecordVector<size_t> SecurOffsets;
1328
+
1329
+ bool _showSystemFiles;
1330
+ bool _showDeletedFiles;
1331
+ CObjectVector<UString2> VirtFolderNames;
1332
+ UString EmptyString;
1333
+
1334
+ int _systemFolderIndex;
1335
+ int _lostFolderIndex_Normal;
1336
+ int _lostFolderIndex_Deleted;
1337
+
1338
+ // bool _headerWarning;
1339
+
1340
+ bool ThereAreAltStreams;
1341
+
1342
+ void InitProps()
1343
+ {
1344
+ _showSystemFiles = true;
1345
+ // we show SystemFiles by default since it's difficult to track $Extend\* system files
1346
+ // it must be fixed later
1347
+ _showDeletedFiles = false;
1348
+ }
1349
+
1350
+ CDatabase() { InitProps(); }
1185
1351
  ~CDatabase() { ClearAndClose(); }
1186
1352
 
1187
1353
  void Clear();
1188
1354
  void ClearAndClose();
1189
1355
 
1190
- UString GetItemPath(Int32 index) const;
1356
+ void GetItemPath(unsigned index, NCOM::CPropVariant &path) const;
1191
1357
  HRESULT Open();
1192
- HRESULT ReadDir(Int32 parent, UInt32 cluster, int level);
1193
1358
 
1194
1359
  HRESULT SeekToCluster(UInt64 cluster);
1195
1360
 
1196
- int FindMtfRec(const CMftRef &ref) const
1361
+ int FindDirItemForMtfRec(UInt64 recIndex) const
1197
1362
  {
1198
- UInt64 val = ref.GetIndex();
1199
- int left = 0, right = Items.Size();
1363
+ if (recIndex >= Recs.Size())
1364
+ return -1;
1365
+ const CMftRec &rec = Recs[(unsigned)recIndex];
1366
+ if (!rec.IsDir())
1367
+ return -1;
1368
+ return rec.MyItemIndex;
1369
+ /*
1370
+ unsigned left = 0, right = Items.Size();
1200
1371
  while (left != right)
1201
1372
  {
1202
- int mid = (left + right) / 2;
1203
- UInt64 midValue = Items[mid].RecIndex;
1204
- if (val == midValue)
1205
- return mid;
1206
- if (val < midValue)
1373
+ unsigned mid = (left + right) / 2;
1374
+ const CItem &item = Items[mid];
1375
+ UInt64 midValue = item.RecIndex;
1376
+ if (recIndex == midValue)
1377
+ {
1378
+ // if item is not dir (file or alt stream we don't return it)
1379
+ // if (item.DataIndex < 0)
1380
+ if (item.IsDir())
1381
+ return mid;
1382
+ right = mid;
1383
+ }
1384
+ else if (recIndex < midValue)
1207
1385
  right = mid;
1208
1386
  else
1209
1387
  left = mid + 1;
1210
1388
  }
1211
1389
  return -1;
1390
+ */
1391
+ }
1392
+
1393
+ bool FindSecurityDescritor(UInt32 id, UInt64 &offset, UInt32 &size) const;
1394
+
1395
+ HRESULT ParseSecuritySDS_2();
1396
+ void ParseSecuritySDS()
1397
+ {
1398
+ HRESULT res = ParseSecuritySDS_2();
1399
+ if (res != S_OK)
1400
+ {
1401
+ SecurOffsets.Clear();
1402
+ SecurData.Free();
1403
+ }
1212
1404
  }
1213
1405
 
1214
1406
  };
@@ -1222,6 +1414,15 @@ void CDatabase::Clear()
1222
1414
  {
1223
1415
  Items.Clear();
1224
1416
  Recs.Clear();
1417
+ SecurOffsets.Clear();
1418
+ SecurData.Free();
1419
+ VirtFolderNames.Clear();
1420
+ _systemFolderIndex = -1;
1421
+ _lostFolderIndex_Normal = -1;
1422
+ _lostFolderIndex_Deleted = -1;
1423
+ ThereAreAltStreams = false;
1424
+ // _headerWarning = false;
1425
+ PhySize = 0;
1225
1426
  }
1226
1427
 
1227
1428
  void CDatabase::ClearAndClose()
@@ -1230,56 +1431,262 @@ void CDatabase::ClearAndClose()
1230
1431
  InStream.Release();
1231
1432
  }
1232
1433
 
1233
- #define MY_DIR_PREFIX(x) L"[" x L"]" WSTRING_PATH_SEPARATOR
1234
-
1235
- UString CDatabase::GetItemPath(Int32 index) const
1434
+ void CDatabase::GetItemPath(unsigned index, NCOM::CPropVariant &path) const
1236
1435
  {
1237
1436
  const CItem *item = &Items[index];
1238
- UString name = item->Name;
1239
- for (int j = 0; j < 256; j++)
1240
- {
1241
- CMftRef ref = item->ParentRef;
1242
- index = FindMtfRec(ref);
1243
- if (ref.GetIndex() == 5)
1244
- return name;
1245
- if (index < 0 || Recs[Items[index].RecIndex].SeqNumber != ref.GetNumber())
1246
- return MY_DIR_PREFIX(L"UNKNOWN") + name;
1247
- item = &Items[index];
1248
- name = item->Name + WCHAR_PATH_SEPARATOR + name;
1249
- }
1250
- return MY_DIR_PREFIX(L"BAD") + name;
1437
+ unsigned size = 0;
1438
+ const CMftRec &rec = Recs[item->RecIndex];
1439
+ size += rec.FileNames[item->NameIndex].Name.Len();
1440
+
1441
+ bool isAltStream = item->IsAltStream();
1442
+
1443
+ if (isAltStream)
1444
+ {
1445
+ const CAttr &data = rec.DataAttrs[rec.DataRefs[item->DataIndex].Start];
1446
+ if (item->RecIndex == kRecIndex_RootDir)
1447
+ {
1448
+ wchar_t *s = path.AllocBstr(data.Name.Len() + 1);
1449
+ s[0] = L':';
1450
+ if (!data.Name.IsEmpty())
1451
+ MyStringCopy(s + 1, data.Name.GetRawPtr());
1452
+ return;
1453
+ }
1454
+
1455
+ size += data.Name.Len();
1456
+ size++;
1457
+ }
1458
+
1459
+ for (unsigned i = 0;; i++)
1460
+ {
1461
+ if (i > 256)
1462
+ {
1463
+ path = "[TOO-LONG]";
1464
+ return;
1465
+ }
1466
+ const wchar_t *servName;
1467
+ if (item->RecIndex < kNumSysRecs
1468
+ /* && item->RecIndex != kRecIndex_RootDir */)
1469
+ servName = kVirtualFolder_System;
1470
+ else
1471
+ {
1472
+ int index2 = item->ParentFolder;
1473
+ if (index2 >= 0)
1474
+ {
1475
+ item = &Items[index2];
1476
+ size += Recs[item->RecIndex].FileNames[item->NameIndex].Name.Len() + 1;
1477
+ continue;
1478
+ }
1479
+ if (index2 == -1)
1480
+ break;
1481
+ servName = (index2 == k_ParentFolderIndex_Lost) ?
1482
+ kVirtualFolder_Lost_Normal :
1483
+ kVirtualFolder_Lost_Deleted;
1484
+ }
1485
+ size += MyStringLen(servName) + 1;
1486
+ break;
1487
+ }
1488
+
1489
+ wchar_t *s = path.AllocBstr(size);
1490
+
1491
+ item = &Items[index];
1492
+
1493
+ bool needColon = false;
1494
+ if (isAltStream)
1495
+ {
1496
+ const UString2 &name = rec.DataAttrs[rec.DataRefs[item->DataIndex].Start].Name;
1497
+ if (!name.IsEmpty())
1498
+ {
1499
+ size -= name.Len();
1500
+ MyStringCopy(s + size, name.GetRawPtr());
1501
+ }
1502
+ s[--size] = ':';
1503
+ needColon = true;
1504
+ }
1505
+
1506
+ {
1507
+ const UString2 &name = rec.FileNames[item->NameIndex].Name;
1508
+ unsigned len = name.Len();
1509
+ if (len != 0)
1510
+ MyStringCopy(s + size - len, name.GetRawPtr());
1511
+ if (needColon)
1512
+ s[size] = ':';
1513
+ size -= len;
1514
+ }
1515
+
1516
+ for (;;)
1517
+ {
1518
+ const wchar_t *servName;
1519
+ if (item->RecIndex < kNumSysRecs
1520
+ /* && && item->RecIndex != kRecIndex_RootDir */)
1521
+ servName = kVirtualFolder_System;
1522
+ else
1523
+ {
1524
+ int index2 = item->ParentFolder;
1525
+ if (index2 >= 0)
1526
+ {
1527
+ item = &Items[index2];
1528
+ const UString2 &name = Recs[item->RecIndex].FileNames[item->NameIndex].Name;
1529
+ unsigned len = name.Len();
1530
+ size--;
1531
+ if (len != 0)
1532
+ {
1533
+ size -= len;
1534
+ MyStringCopy(s + size, name.GetRawPtr());
1535
+ }
1536
+ s[size + len] = WCHAR_PATH_SEPARATOR;
1537
+ continue;
1538
+ }
1539
+ if (index2 == -1)
1540
+ break;
1541
+ servName = (index2 == k_ParentFolderIndex_Lost) ?
1542
+ kVirtualFolder_Lost_Normal :
1543
+ kVirtualFolder_Lost_Deleted;
1544
+ }
1545
+ MyStringCopy(s, servName);
1546
+ s[MyStringLen(servName)] = WCHAR_PATH_SEPARATOR;
1547
+ break;
1548
+ }
1549
+ }
1550
+
1551
+ bool CDatabase::FindSecurityDescritor(UInt32 item, UInt64 &offset, UInt32 &size) const
1552
+ {
1553
+ offset = 0;
1554
+ size = 0;
1555
+ unsigned left = 0, right = SecurOffsets.Size();
1556
+ while (left != right)
1557
+ {
1558
+ unsigned mid = (left + right) / 2;
1559
+ size_t offs = SecurOffsets[mid];
1560
+ UInt32 midValue = Get32(((const Byte *)SecurData) + offs + 4);
1561
+ if (item == midValue)
1562
+ {
1563
+ offset = Get64((const Byte *)SecurData + offs + 8) + 20;
1564
+ size = Get32((const Byte *)SecurData + offs + 16) - 20;
1565
+ return true;
1566
+ }
1567
+ if (item < midValue)
1568
+ right = mid;
1569
+ else
1570
+ left = mid + 1;
1571
+ }
1572
+ return false;
1573
+ }
1574
+
1575
+ /*
1576
+ static int CompareIDs(const size_t *p1, const size_t *p2, void *data)
1577
+ {
1578
+ UInt32 id1 = Get32(((const Byte *)data) + *p1 + 4);
1579
+ UInt32 id2 = Get32(((const Byte *)data) + *p2 + 4);
1580
+ return MyCompare(id1, id2);
1581
+ }
1582
+ */
1583
+
1584
+ // security data contains duplication copy after each 256 KB.
1585
+ static const unsigned kSecureDuplicateStepBits = 18;
1586
+
1587
+ HRESULT CDatabase::ParseSecuritySDS_2()
1588
+ {
1589
+ const Byte *p = SecurData;
1590
+ size_t size = SecurData.Size();
1591
+ const size_t kDuplicateStep = (size_t)1 << kSecureDuplicateStepBits;
1592
+ const size_t kDuplicateMask = kDuplicateStep - 1;
1593
+ size_t lim = MyMin(size, kDuplicateStep);
1594
+ UInt32 idPrev = 0;
1595
+ for (size_t pos = 0; pos < size && size - pos >= 20;)
1596
+ {
1597
+ UInt32 id = Get32(p + pos + 4);
1598
+ UInt64 offs = Get64(p + pos + 8);
1599
+ UInt32 entrySize = Get32(p + pos + 16);
1600
+ if (offs == pos && entrySize >= 20 && lim - pos >= entrySize)
1601
+ {
1602
+ if (id <= idPrev)
1603
+ return S_FALSE;
1604
+ idPrev = id;
1605
+ SecurOffsets.Add(pos);
1606
+ pos += entrySize;
1607
+ pos = (pos + 0xF) & ~(size_t)0xF;
1608
+ if ((pos & kDuplicateMask) != 0)
1609
+ continue;
1610
+ }
1611
+ else
1612
+ pos = (pos + kDuplicateStep) & ~kDuplicateMask;
1613
+ pos += kDuplicateStep;
1614
+ lim = pos + kDuplicateStep;
1615
+ if (lim >= size)
1616
+ lim = size;
1617
+ }
1618
+ // we checked that IDs are sorted, so we don't need Sort
1619
+ // SecurOffsets.Sort(CompareIDs, (void *)p);
1620
+ return S_OK;
1251
1621
  }
1252
1622
 
1253
1623
  HRESULT CDatabase::Open()
1254
1624
  {
1255
1625
  Clear();
1256
-
1257
- static const UInt32 kHeaderSize = 512;
1258
- Byte buf[kHeaderSize];
1259
- RINOK(ReadStream_FALSE(InStream, buf, kHeaderSize));
1260
- if (!Header.Parse(buf))
1261
- return S_FALSE;
1262
- UInt64 fileSize;
1263
- RINOK(InStream->Seek(0, STREAM_SEEK_END, &fileSize));
1264
- if (fileSize < Header.GetPhySize())
1265
- return S_FALSE;
1266
-
1626
+
1627
+ /* NTFS layout:
1628
+ 1) main part (as specified by NumClusters). Only that part is available, if we open "\\.\c:"
1629
+ 2) additional empty sectors (as specified by NumSectors)
1630
+ 3) the copy of first sector (boot sector)
1631
+
1632
+ We support both cases:
1633
+ - the file with only main part
1634
+ - full file (as raw data on partition), including the copy
1635
+ of first sector (boot sector) at the end of data
1636
+
1637
+ We don't support the case, when only the copy of boot sector
1638
+ at the end was detected as NTFS signature.
1639
+ */
1640
+
1641
+ {
1642
+ static const UInt32 kHeaderSize = 512;
1643
+ Byte buf[kHeaderSize];
1644
+ RINOK(ReadStream_FALSE(InStream, buf, kHeaderSize));
1645
+ if (!Header.Parse(buf))
1646
+ return S_FALSE;
1647
+
1648
+ UInt64 fileSize;
1649
+ RINOK(InStream->Seek(0, STREAM_SEEK_END, &fileSize));
1650
+ PhySize = Header.GetPhySize_Clusters();
1651
+ if (fileSize < PhySize)
1652
+ return S_FALSE;
1653
+
1654
+ UInt64 phySizeMax = Header.GetPhySize_Max();
1655
+ if (fileSize >= phySizeMax)
1656
+ {
1657
+ RINOK(InStream->Seek(Header.NumSectors << Header.SectorSizeLog, STREAM_SEEK_SET, NULL));
1658
+ Byte buf2[kHeaderSize];
1659
+ if (ReadStream_FALSE(InStream, buf2, kHeaderSize) == S_OK)
1660
+ {
1661
+ if (memcmp(buf, buf2, kHeaderSize) == 0)
1662
+ PhySize = phySizeMax;
1663
+ // else _headerWarning = true;
1664
+ }
1665
+ }
1666
+ }
1667
+
1267
1668
  SeekToCluster(Header.MftCluster);
1268
1669
 
1269
1670
  CMftRec mftRec;
1270
1671
  UInt32 numSectorsInRec;
1271
- int recSizeLog;
1672
+
1272
1673
  CMyComPtr<IInStream> mftStream;
1273
1674
  {
1274
1675
  UInt32 blockSize = 1 << 12;
1275
- ByteBuf.SetCapacity(blockSize);
1676
+ ByteBuf.Alloc(blockSize);
1276
1677
  RINOK(ReadStream_FALSE(InStream, ByteBuf, blockSize));
1277
-
1278
- UInt32 allocSize = Get32(ByteBuf + 0x1C);
1279
- recSizeLog = GetLog(allocSize);
1280
- if (recSizeLog < Header.SectorSizeLog)
1281
- return false;
1282
- numSectorsInRec = 1 << (recSizeLog - Header.SectorSizeLog);
1678
+
1679
+ {
1680
+ UInt32 allocSize = Get32(ByteBuf + 0x1C);
1681
+ int t = GetLog(allocSize);
1682
+ if (t < (int)Header.SectorSizeLog)
1683
+ return S_FALSE;
1684
+ RecSizeLog = t;
1685
+ if (RecSizeLog > 15)
1686
+ return S_FALSE;
1687
+ }
1688
+
1689
+ numSectorsInRec = 1 << (RecSizeLog - Header.SectorSizeLog);
1283
1690
  if (!mftRec.Parse(ByteBuf, Header.SectorSizeLog, numSectorsInRec, 0, NULL))
1284
1691
  return S_FALSE;
1285
1692
  if (!mftRec.IsFILE())
@@ -1292,55 +1699,121 @@ HRESULT CDatabase::Open()
1292
1699
  return S_FALSE;
1293
1700
  }
1294
1701
 
1702
+ // CObjectVector<CAttr> SecurityAttrs;
1703
+
1295
1704
  UInt64 mftSize = mftRec.DataAttrs[0].Size;
1296
- if ((mftSize >> 4) > Header.GetPhySize())
1705
+ if ((mftSize >> 4) > Header.GetPhySize_Clusters())
1297
1706
  return S_FALSE;
1298
1707
 
1299
- UInt64 numFiles = mftSize >> recSizeLog;
1300
- if (numFiles > (1 << 30))
1708
+ const size_t kBufSize = (1 << 15);
1709
+ const size_t recSize = ((size_t)1 << RecSizeLog);
1710
+ if (kBufSize < recSize)
1301
1711
  return S_FALSE;
1302
- if (OpenCallback)
1712
+
1303
1713
  {
1304
- RINOK(OpenCallback->SetTotal(&numFiles, &mftSize));
1714
+ const UInt64 numFiles = mftSize >> RecSizeLog;
1715
+ if (numFiles > (1 << 30))
1716
+ return S_FALSE;
1717
+ if (OpenCallback)
1718
+ {
1719
+ RINOK(OpenCallback->SetTotal(&numFiles, &mftSize));
1720
+ }
1721
+
1722
+ ByteBuf.Alloc(kBufSize);
1723
+ Recs.ClearAndReserve((unsigned)numFiles);
1305
1724
  }
1306
- const UInt32 kBufSize = (1 << 15);
1307
- if (kBufSize < (1 << recSizeLog))
1308
- return S_FALSE;
1309
1725
 
1310
- ByteBuf.SetCapacity((size_t)kBufSize);
1311
- Recs.Reserve((int)numFiles);
1312
1726
  for (UInt64 pos64 = 0;;)
1313
1727
  {
1314
1728
  if (OpenCallback)
1315
1729
  {
1316
- UInt64 numFiles = Recs.Size();
1730
+ const UInt64 numFiles = Recs.Size();
1317
1731
  if ((numFiles & 0x3FF) == 0)
1318
1732
  {
1319
1733
  RINOK(OpenCallback->SetCompleted(&numFiles, &pos64));
1320
1734
  }
1321
1735
  }
1322
- UInt32 readSize = kBufSize;
1323
- UInt64 rem = mftSize - pos64;
1324
- if (readSize > rem)
1325
- readSize = (UInt32)rem;
1326
- if (readSize < ((UInt32)1 << recSizeLog))
1736
+ size_t readSize = kBufSize;
1737
+ {
1738
+ const UInt64 rem = mftSize - pos64;
1739
+ if (readSize > rem)
1740
+ readSize = (size_t)rem;
1741
+ }
1742
+ if (readSize < recSize)
1327
1743
  break;
1328
- RINOK(ReadStream_FALSE(mftStream, ByteBuf, (size_t)readSize));
1744
+ RINOK(ReadStream_FALSE(mftStream, ByteBuf, readSize));
1329
1745
  pos64 += readSize;
1330
- for (int i = 0; ((UInt32)(i + 1) << recSizeLog) <= readSize; i++)
1746
+
1747
+ for (size_t i = 0; readSize >= recSize; i += recSize, readSize -= recSize)
1331
1748
  {
1332
1749
  PRF(printf("\n---------------------"));
1333
1750
  PRF(printf("\n%5d:", Recs.Size()));
1334
- Byte *p = ByteBuf + ((UInt32)i << recSizeLog);
1751
+
1752
+ Byte *p = ByteBuf + i;
1335
1753
  CMftRec rec;
1336
- if (!rec.Parse(p, Header.SectorSizeLog, numSectorsInRec, (UInt32)Recs.Size(),
1337
- (Recs.Size() == kRecIndex_Volume) ? &VolAttrs: NULL))
1754
+
1755
+ CObjectVector<CAttr> *attrs = NULL;
1756
+ unsigned recIndex = Recs.Size();
1757
+ switch (recIndex)
1758
+ {
1759
+ case kRecIndex_Volume: attrs = &VolAttrs; break;
1760
+ // case kRecIndex_Security: attrs = &SecurityAttrs; break;
1761
+ }
1762
+
1763
+ if (!rec.Parse(p, Header.SectorSizeLog, numSectorsInRec, (UInt32)Recs.Size(), attrs))
1338
1764
  return S_FALSE;
1339
1765
  Recs.Add(rec);
1340
1766
  }
1341
1767
  }
1342
1768
 
1343
- int i;
1769
+ /*
1770
+ // that code looks too complex. And we can get security info without index parsing
1771
+ for (i = 0; i < SecurityAttrs.Size(); i++)
1772
+ {
1773
+ const CAttr &attr = SecurityAttrs[i];
1774
+ if (attr.Name == L"$SII")
1775
+ {
1776
+ if (attr.Type == ATTR_TYPE_INDEX_ROOT)
1777
+ {
1778
+ const Byte *data = attr.Data;
1779
+ size_t size = attr.Data.Size();
1780
+
1781
+ // Index Root
1782
+ UInt32 attrType = Get32(data);
1783
+ UInt32 collationRule = Get32(data + 4);
1784
+ UInt32 indexAllocationEtrySizeSize = Get32(data + 8);
1785
+ UInt32 clustersPerIndexRecord = Get32(data + 0xC);
1786
+ data += 0x10;
1787
+
1788
+ // Index Header
1789
+ UInt32 firstEntryOffset = Get32(data);
1790
+ UInt32 totalSize = Get32(data + 4);
1791
+ UInt32 allocSize = Get32(data + 8);
1792
+ UInt32 flags = Get32(data + 0xC);
1793
+
1794
+ int num = 0;
1795
+ for (int j = 0 ; j < num; j++)
1796
+ {
1797
+ if (Get32(data) != 0x1414 || // offset and size
1798
+ Get32(data + 4) != 0 ||
1799
+ Get32(data + 8) != 0x428) // KeySize / EntrySize
1800
+ break;
1801
+ UInt32 flags = Get32(data + 12);
1802
+ UInt32 id = Get32(data + 0x10);
1803
+ if (id = Get32(data + 0x18))
1804
+ break;
1805
+ UInt32 descriptorOffset = Get64(data + 0x1C);
1806
+ UInt32 descriptorSize = Get64(data + 0x24);
1807
+ data += 0x28;
1808
+ }
1809
+ // break;
1810
+ }
1811
+ }
1812
+ }
1813
+ */
1814
+
1815
+ unsigned i;
1816
+
1344
1817
  for (i = 0; i < Recs.Size(); i++)
1345
1818
  {
1346
1819
  CMftRec &rec = Recs[i];
@@ -1349,7 +1822,7 @@ HRESULT CDatabase::Open()
1349
1822
  UInt64 refIndex = rec.BaseMftRef.GetIndex();
1350
1823
  if (refIndex > (UInt32)Recs.Size())
1351
1824
  return S_FALSE;
1352
- CMftRec &refRec = Recs[(int)refIndex];
1825
+ CMftRec &refRec = Recs[(unsigned)refIndex];
1353
1826
  bool moveAttrs = (refRec.SeqNumber == rec.BaseMftRef.GetNumber() && refRec.BaseMftRef.IsBaseItself());
1354
1827
  if (rec.InUse() && refRec.InUse())
1355
1828
  {
@@ -1365,87 +1838,346 @@ HRESULT CDatabase::Open()
1365
1838
 
1366
1839
  for (i = 0; i < Recs.Size(); i++)
1367
1840
  Recs[i].ParseDataNames();
1368
-
1841
+
1369
1842
  for (i = 0; i < Recs.Size(); i++)
1370
1843
  {
1371
1844
  CMftRec &rec = Recs[i];
1372
1845
  if (!rec.IsFILE() || !rec.BaseMftRef.IsBaseItself())
1373
1846
  continue;
1374
- int numNames = 0;
1847
+ if (i < kNumSysRecs && !_showSystemFiles)
1848
+ continue;
1849
+ if (!rec.InUse() && !_showDeletedFiles)
1850
+ continue;
1851
+
1852
+ rec.MyNumNameLinks = rec.FileNames.Size();
1853
+
1375
1854
  // printf("\n%4d: ", i);
1376
- for (int t = 0; t < rec.FileNames.Size(); t++)
1855
+
1856
+ /* Actually DataAttrs / DataRefs are sorted by name.
1857
+ It can not be more than one unnamed stream in DataRefs
1858
+ And indexOfUnnamedStream <= 0.
1859
+ */
1860
+
1861
+ int indexOfUnnamedStream = -1;
1862
+ if (!rec.IsDir())
1377
1863
  {
1378
- const CFileNameAttr &fna = rec.FileNames[t];
1379
- // printf("%4d %S | ", (int)fna.NameType, fna.Name);
1380
- if (fna.IsDos())
1381
- continue;
1382
- int numDatas = rec.DataRefs.Size();
1864
+ FOR_VECTOR (di, rec.DataRefs)
1865
+ if (rec.DataAttrs[rec.DataRefs[di].Start].Name.IsEmpty())
1866
+ {
1867
+ indexOfUnnamedStream = di;
1868
+ break;
1869
+ }
1870
+ }
1871
+
1872
+ if (rec.FileNames.IsEmpty())
1873
+ {
1874
+ bool needShow = true;
1875
+ if (i < kNumSysRecs)
1876
+ {
1877
+ needShow = false;
1878
+ FOR_VECTOR (di, rec.DataRefs)
1879
+ if (rec.GetSize(di) != 0)
1880
+ {
1881
+ needShow = true;
1882
+ break;
1883
+ }
1884
+ }
1885
+ if (needShow)
1886
+ {
1887
+ CFileNameAttr &fna = rec.FileNames.AddNew();
1888
+ // we set incorrect ParentDirRef, that will place item to [LOST] folder
1889
+ fna.ParentDirRef.Val = (UInt64)(Int64)-1;
1890
+ char s[16 + 16];
1891
+ ConvertUInt32ToString(i, MyStpCpy(s, "[NONAME]-"));
1892
+ fna.Name.SetFromAscii(s);
1893
+ fna.NameType = kFileNameType_Win32Dos;
1894
+ fna.Attrib = 0;
1895
+ }
1896
+ }
1897
+
1898
+ // bool isMainName = true;
1383
1899
 
1384
- // For hard linked files we show substreams only for first Name.
1385
- if (numDatas > 1 && numNames > 0)
1386
- numDatas = 1;
1387
- numNames++;
1900
+ FOR_VECTOR (t, rec.FileNames)
1901
+ {
1902
+ #ifdef SHOW_DEBUG_INFO
1903
+ const CFileNameAttr &fna = rec.FileNames[t];
1904
+ #endif
1905
+ PRF(printf("\n %4d ", (int)fna.NameType));
1906
+ PRF_UTF16(fna.Name);
1907
+ // PRF(printf(" | "));
1388
1908
 
1389
- if (rec.IsDir())
1909
+ if (rec.FindWin32Name_for_DosName(t) >= 0)
1390
1910
  {
1391
- CItem item;
1392
- item.Name = fna.Name;
1393
- item.RecIndex = i;
1394
- item.DataIndex = -1;
1395
- item.ParentRef = fna.ParentDirRef;
1396
- item.Attrib = rec.SiAttr.Attrib | 0x10;
1397
- // item.Attrib = fna.Attrib;
1398
- Items.Add(item);
1911
+ rec.MyNumNameLinks--;
1912
+ continue;
1399
1913
  }
1400
- for (int di = 0; di < numDatas; di++)
1914
+
1915
+ CItem item;
1916
+ item.NameIndex = t;
1917
+ item.RecIndex = i;
1918
+ item.DataIndex = rec.IsDir() ?
1919
+ k_Item_DataIndex_IsDir :
1920
+ (indexOfUnnamedStream < 0 ?
1921
+ k_Item_DataIndex_IsEmptyFile :
1922
+ indexOfUnnamedStream);
1923
+
1924
+ if (rec.MyItemIndex < 0)
1925
+ rec.MyItemIndex = Items.Size();
1926
+ item.ParentHost = Items.Add(item);
1927
+
1928
+ /* we can use that code to reduce the number of alt streams:
1929
+ it will not show how alt streams for hard links. */
1930
+ // if (!isMainName) continue; isMainName = false;
1931
+
1932
+ unsigned numAltStreams = 0;
1933
+
1934
+ FOR_VECTOR (di, rec.DataRefs)
1401
1935
  {
1402
- CItem item;
1403
- item.Name = fna.Name;
1404
- item.Attrib = rec.SiAttr.Attrib;
1405
- const UString &subName = rec.DataAttrs[rec.DataRefs[di].Start].Name;
1406
- if (!subName.IsEmpty())
1936
+ if (!rec.IsDir() && (int)di == indexOfUnnamedStream)
1937
+ continue;
1938
+
1939
+ const UString2 &subName = rec.DataAttrs[rec.DataRefs[di].Start].Name;
1940
+
1941
+ PRF(printf("\n alt stream: "));
1942
+ PRF_UTF16(subName);
1943
+
1407
1944
  {
1408
1945
  // $BadClus:$Bad is sparse file for all clusters. So we skip it.
1409
1946
  if (i == kRecIndex_BadClus && subName == L"$Bad")
1410
1947
  continue;
1411
- item.Name += L":";
1412
- item.Name += subName;
1413
- item.Attrib = fna.Attrib;
1414
1948
  }
1415
-
1416
- PRF(printf("\n%3d", i));
1417
- PRF(printf(" attrib=%2x", rec.SiAttr.Attrib));
1418
- PRF(printf(" %S", item.Name));
1419
-
1420
- item.RecIndex = i;
1421
- item.DataIndex = di;
1422
- item.ParentRef = fna.ParentDirRef;
1423
1949
 
1950
+ numAltStreams++;
1951
+ ThereAreAltStreams = true;
1952
+ item.DataIndex = di;
1424
1953
  Items.Add(item);
1425
- rec.MyNumNameLinks++;
1426
1954
  }
1427
1955
  }
1428
- rec.FileNames.ClearAndFree();
1429
1956
  }
1430
-
1957
+
1958
+ if (Recs.Size() > kRecIndex_Security)
1959
+ {
1960
+ const CMftRec &rec = Recs[kRecIndex_Security];
1961
+ FOR_VECTOR (di, rec.DataRefs)
1962
+ {
1963
+ const CAttr &attr = rec.DataAttrs[rec.DataRefs[di].Start];
1964
+ if (attr.Name == L"$SDS")
1965
+ {
1966
+ CMyComPtr<IInStream> sdsStream;
1967
+ RINOK(rec.GetStream(InStream, di, Header.ClusterSizeLog, Header.NumClusters, &sdsStream));
1968
+ if (sdsStream)
1969
+ {
1970
+ UInt64 size64 = attr.GetSize();
1971
+ if (size64 < (UInt32)1 << 29)
1972
+ {
1973
+ size_t size = (size_t)size64;
1974
+ if ((((size + 1) >> kSecureDuplicateStepBits) & 1) != 0)
1975
+ {
1976
+ size -= (1 << kSecureDuplicateStepBits);
1977
+ SecurData.Alloc(size);
1978
+ if (ReadStream_FALSE(sdsStream, SecurData, size) == S_OK)
1979
+ {
1980
+ ParseSecuritySDS();
1981
+ break;
1982
+ }
1983
+ }
1984
+ }
1985
+ }
1986
+ break;
1987
+ }
1988
+ }
1989
+ }
1990
+
1991
+ bool thereAreUnknownFolders_Normal = false;
1992
+ bool thereAreUnknownFolders_Deleted = false;
1993
+
1994
+ for (i = 0; i < Items.Size(); i++)
1995
+ {
1996
+ CItem &item = Items[i];
1997
+ const CMftRec &rec = Recs[item.RecIndex];
1998
+ const CFileNameAttr &fn = rec.FileNames[item.NameIndex];
1999
+ const CMftRef &parentDirRef = fn.ParentDirRef;
2000
+ UInt64 refIndex = parentDirRef.GetIndex();
2001
+ if (refIndex == kRecIndex_RootDir)
2002
+ item.ParentFolder = -1;
2003
+ else
2004
+ {
2005
+ int index = FindDirItemForMtfRec(refIndex);
2006
+ if (index < 0 ||
2007
+ Recs[Items[index].RecIndex].SeqNumber != parentDirRef.GetNumber())
2008
+ {
2009
+ if (Recs[item.RecIndex].InUse())
2010
+ {
2011
+ thereAreUnknownFolders_Normal = true;
2012
+ index = k_ParentFolderIndex_Lost;
2013
+ }
2014
+ else
2015
+ {
2016
+ thereAreUnknownFolders_Deleted = true;
2017
+ index = k_ParentFolderIndex_Deleted;
2018
+ }
2019
+ }
2020
+ item.ParentFolder = index;
2021
+ }
2022
+ }
2023
+
2024
+ unsigned virtIndex = Items.Size();
2025
+ if (_showSystemFiles)
2026
+ {
2027
+ _systemFolderIndex = virtIndex++;
2028
+ VirtFolderNames.Add(kVirtualFolder_System);
2029
+ }
2030
+ if (thereAreUnknownFolders_Normal)
2031
+ {
2032
+ _lostFolderIndex_Normal = virtIndex++;
2033
+ VirtFolderNames.Add(kVirtualFolder_Lost_Normal);
2034
+ }
2035
+ if (thereAreUnknownFolders_Deleted)
2036
+ {
2037
+ _lostFolderIndex_Deleted = virtIndex++;
2038
+ VirtFolderNames.Add(kVirtualFolder_Lost_Deleted);
2039
+ }
2040
+
1431
2041
  return S_OK;
1432
2042
  }
1433
2043
 
1434
2044
  class CHandler:
1435
2045
  public IInArchive,
2046
+ public IArchiveGetRawProps,
1436
2047
  public IInArchiveGetStream,
2048
+ public ISetProperties,
1437
2049
  public CMyUnknownImp,
1438
2050
  CDatabase
1439
2051
  {
1440
2052
  public:
1441
- MY_UNKNOWN_IMP2(IInArchive, IInArchiveGetStream)
2053
+ MY_UNKNOWN_IMP4(
2054
+ IInArchive,
2055
+ IArchiveGetRawProps,
2056
+ IInArchiveGetStream,
2057
+ ISetProperties)
1442
2058
  INTERFACE_IInArchive(;)
2059
+ INTERFACE_IArchiveGetRawProps(;)
1443
2060
  STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **stream);
2061
+ STDMETHOD(SetProperties)(const wchar_t * const *names, const PROPVARIANT *values, UInt32 numProps);
1444
2062
  };
1445
2063
 
2064
+ STDMETHODIMP CHandler::GetNumRawProps(UInt32 *numProps)
2065
+ {
2066
+ *numProps = 2;
2067
+ return S_OK;
2068
+ }
2069
+
2070
+ STDMETHODIMP CHandler::GetRawPropInfo(UInt32 index, BSTR *name, PROPID *propID)
2071
+ {
2072
+ *name = NULL;
2073
+ *propID = index == 0 ? kpidNtReparse : kpidNtSecure;
2074
+ return S_OK;
2075
+ }
2076
+
2077
+ STDMETHODIMP CHandler::GetParent(UInt32 index, UInt32 *parent, UInt32 *parentType)
2078
+ {
2079
+ *parentType = NParentType::kDir;
2080
+ int par = -1;
2081
+
2082
+ if (index < Items.Size())
2083
+ {
2084
+ const CItem &item = Items[index];
2085
+
2086
+ if (item.ParentHost >= 0)
2087
+ {
2088
+ *parentType = NParentType::kAltStream;
2089
+ par = (item.RecIndex == kRecIndex_RootDir ? -1 : item.ParentHost);
2090
+ }
2091
+ else if (item.RecIndex < kNumSysRecs)
2092
+ {
2093
+ if (_showSystemFiles)
2094
+ par = _systemFolderIndex;
2095
+ }
2096
+ else if (item.ParentFolder >= 0)
2097
+ par = item.ParentFolder;
2098
+ else if (item.ParentFolder == k_ParentFolderIndex_Lost)
2099
+ par = _lostFolderIndex_Normal;
2100
+ else if (item.ParentFolder == k_ParentFolderIndex_Deleted)
2101
+ par = _lostFolderIndex_Deleted;
2102
+ }
2103
+ *parent = (UInt32)(Int32)par;
2104
+ return S_OK;
2105
+ }
2106
+
2107
+ STDMETHODIMP CHandler::GetRawProp(UInt32 index, PROPID propID, const void **data, UInt32 *dataSize, UInt32 *propType)
2108
+ {
2109
+ *data = NULL;
2110
+ *dataSize = 0;
2111
+ *propType = 0;
2112
+
2113
+ if (propID == kpidName)
2114
+ {
2115
+ #ifdef MY_CPU_LE
2116
+ const UString2 *s;
2117
+ if (index >= Items.Size())
2118
+ s = &VirtFolderNames[index - Items.Size()];
2119
+ else
2120
+ {
2121
+ const CItem &item = Items[index];
2122
+ const CMftRec &rec = Recs[item.RecIndex];
2123
+ if (item.IsAltStream())
2124
+ s = &rec.DataAttrs[rec.DataRefs[item.DataIndex].Start].Name;
2125
+ else
2126
+ s = &rec.FileNames[item.NameIndex].Name;
2127
+ }
2128
+ if (s->IsEmpty())
2129
+ *data = (const wchar_t *)EmptyString;
2130
+ else
2131
+ *data = s->GetRawPtr();
2132
+ *dataSize = (s->Len() + 1) * sizeof(wchar_t);
2133
+ *propType = PROP_DATA_TYPE_wchar_t_PTR_Z_LE;
2134
+ #endif
2135
+ return S_OK;
2136
+ }
2137
+
2138
+ if (propID == kpidNtReparse)
2139
+ {
2140
+ if (index >= Items.Size())
2141
+ return S_OK;
2142
+ const CItem &item = Items[index];
2143
+ const CMftRec &rec = Recs[item.RecIndex];
2144
+ const CByteBuffer &reparse = rec.ReparseData;
2145
+
2146
+ if (reparse.Size() != 0)
2147
+ {
2148
+ *dataSize = (UInt32)reparse.Size();
2149
+ *propType = NPropDataType::kRaw;
2150
+ *data = (const Byte *)reparse;
2151
+ }
2152
+ }
2153
+
2154
+ if (propID == kpidNtSecure)
2155
+ {
2156
+ if (index >= Items.Size())
2157
+ return S_OK;
2158
+ const CItem &item = Items[index];
2159
+ const CMftRec &rec = Recs[item.RecIndex];
2160
+ if (rec.SiAttr.SecurityId >= 0)
2161
+ {
2162
+ UInt64 offset;
2163
+ UInt32 size;
2164
+ if (FindSecurityDescritor(rec.SiAttr.SecurityId, offset, size))
2165
+ {
2166
+ *dataSize = size;
2167
+ *propType = NPropDataType::kRaw;
2168
+ *data = (const Byte *)SecurData + offset;
2169
+ }
2170
+ }
2171
+ }
2172
+ return S_OK;
2173
+ }
2174
+
1446
2175
  STDMETHODIMP CHandler::GetStream(UInt32 index, ISequentialInStream **stream)
1447
2176
  {
1448
2177
  COM_TRY_BEGIN
2178
+ *stream = 0;
2179
+ if (index >= Items.Size())
2180
+ return S_OK;
1449
2181
  IInStream *stream2;
1450
2182
  const CItem &item = Items[index];
1451
2183
  const CMftRec &rec = Recs[item.RecIndex];
@@ -1455,40 +2187,104 @@ STDMETHODIMP CHandler::GetStream(UInt32 index, ISequentialInStream **stream)
1455
2187
  COM_TRY_END
1456
2188
  }
1457
2189
 
1458
- static const STATPROPSTG kProps[] =
2190
+ /*
2191
+ enum
2192
+ {
2193
+ kpidLink2 = kpidUserDefined,
2194
+ kpidLinkType,
2195
+ kpidRecMTime,
2196
+ kpidRecMTime2,
2197
+ kpidMTime2,
2198
+ kpidCTime2,
2199
+ kpidATime2
2200
+ };
2201
+
2202
+ static const CStatProp kProps[] =
1459
2203
  {
1460
2204
  { NULL, kpidPath, VT_BSTR},
1461
- { NULL, kpidIsDir, VT_BOOL},
1462
2205
  { NULL, kpidSize, VT_UI8},
1463
2206
  { NULL, kpidPackSize, VT_UI8},
2207
+
2208
+ // { NULL, kpidLink, VT_BSTR},
2209
+
2210
+ // { "Link 2", kpidLink2, VT_BSTR},
2211
+ // { "Link Type", kpidLinkType, VT_UI2},
2212
+ { NULL, kpidINode, VT_UI8},
2213
+
1464
2214
  { NULL, kpidMTime, VT_FILETIME},
1465
2215
  { NULL, kpidCTime, VT_FILETIME},
1466
2216
  { NULL, kpidATime, VT_FILETIME},
2217
+
2218
+ // { "Record Modified", kpidRecMTime, VT_FILETIME},
2219
+
2220
+ // { "Modified 2", kpidMTime2, VT_FILETIME},
2221
+ // { "Created 2", kpidCTime2, VT_FILETIME},
2222
+ // { "Accessed 2", kpidATime2, VT_FILETIME},
2223
+ // { "Record Modified 2", kpidRecMTime2, VT_FILETIME},
2224
+
1467
2225
  { NULL, kpidAttrib, VT_UI4},
1468
- { NULL, kpidLinks, VT_UI4},
1469
- { NULL, kpidNumBlocks, VT_UI4}
2226
+ { NULL, kpidNumBlocks, VT_UI4},
2227
+ { NULL, kpidIsDeleted, VT_BOOL},
2228
+ };
2229
+ */
2230
+
2231
+ static const Byte kProps[] =
2232
+ {
2233
+ kpidPath,
2234
+ kpidIsDir,
2235
+ kpidSize,
2236
+ kpidPackSize,
2237
+ kpidMTime,
2238
+ kpidCTime,
2239
+ kpidATime,
2240
+ kpidAttrib,
2241
+ kpidLinks,
2242
+ kpidINode,
2243
+ kpidNumBlocks,
2244
+ kpidNumAltStreams,
2245
+ kpidIsAltStream,
2246
+ kpidShortName,
2247
+ kpidIsDeleted
1470
2248
  };
1471
2249
 
1472
- static const STATPROPSTG kArcProps[] =
2250
+ enum
2251
+ {
2252
+ kpidRecordSize = kpidUserDefined
2253
+ };
2254
+
2255
+ static const CStatProp kArcProps[] =
1473
2256
  {
1474
2257
  { NULL, kpidVolumeName, VT_BSTR},
1475
2258
  { NULL, kpidFileSystem, VT_BSTR},
1476
2259
  { NULL, kpidClusterSize, VT_UI4},
1477
- { NULL, kpidPhySize, VT_UI8},
2260
+ { NULL, kpidSectorSize, VT_UI4},
2261
+ { "Record Size", kpidRecordSize, VT_UI4},
1478
2262
  { NULL, kpidHeadersSize, VT_UI8},
1479
2263
  { NULL, kpidCTime, VT_FILETIME},
2264
+ { NULL, kpidId, VT_UI8},
2265
+ };
1480
2266
 
1481
- { NULL, kpidSectorSize, VT_UI4},
1482
- { NULL, kpidId, VT_UI8}
1483
- // { NULL, kpidSectorsPerTrack, VT_UI4},
1484
- // { NULL, kpidNumHeads, VT_UI4},
1485
- // { NULL, kpidHiddenSectors, VT_UI4}
2267
+ /*
2268
+ static const Byte kArcProps[] =
2269
+ {
2270
+ kpidVolumeName,
2271
+ kpidFileSystem,
2272
+ kpidClusterSize,
2273
+ kpidHeadersSize,
2274
+ kpidCTime,
2275
+
2276
+ kpidSectorSize,
2277
+ kpidId
2278
+ // kpidSectorsPerTrack,
2279
+ // kpidNumHeads,
2280
+ // kpidHiddenSectors
1486
2281
  };
2282
+ */
1487
2283
 
1488
2284
  IMP_IInArchive_Props
1489
- IMP_IInArchive_ArcProps
2285
+ IMP_IInArchive_ArcProps_WITH_NAME
1490
2286
 
1491
- static void NtfsTimeToProp(UInt64 t, NWindows::NCOM::CPropVariant &prop)
2287
+ static void NtfsTimeToProp(UInt64 t, NCOM::CPropVariant &prop)
1492
2288
  {
1493
2289
  FILETIME ft;
1494
2290
  ft.dwLowDateTime = (DWORD)t;
@@ -1499,19 +2295,19 @@ static void NtfsTimeToProp(UInt64 t, NWindows::NCOM::CPropVariant &prop)
1499
2295
  STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
1500
2296
  {
1501
2297
  COM_TRY_BEGIN
1502
- NWindows::NCOM::CPropVariant prop;
2298
+ NCOM::CPropVariant prop;
1503
2299
 
1504
2300
  const CMftRec *volRec = (Recs.Size() > kRecIndex_Volume ? &Recs[kRecIndex_Volume] : NULL);
1505
2301
 
1506
- switch(propID)
2302
+ switch (propID)
1507
2303
  {
1508
2304
  case kpidClusterSize: prop = Header.ClusterSize(); break;
1509
- case kpidPhySize: prop = Header.GetPhySize(); break;
2305
+ case kpidPhySize: prop = PhySize; break;
1510
2306
  /*
1511
2307
  case kpidHeadersSize:
1512
2308
  {
1513
2309
  UInt64 val = 0;
1514
- for (int i = 0; i < kNumSysRecs; i++)
2310
+ for (unsigned i = 0; i < kNumSysRecs; i++)
1515
2311
  {
1516
2312
  printf("\n%2d: %8I64d ", i, Recs[i].GetPackSize());
1517
2313
  if (i == 8)
@@ -1522,17 +2318,20 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
1522
2318
  break;
1523
2319
  }
1524
2320
  */
1525
- case kpidCTime: if (volRec) NtfsTimeToProp(volRec->SiAttr.CTime, prop); break;break;
2321
+ case kpidCTime: if (volRec) NtfsTimeToProp(volRec->SiAttr.CTime, prop); break;
2322
+ case kpidMTime: if (volRec) NtfsTimeToProp(volRec->SiAttr.MTime, prop); break;
2323
+ case kpidShortComment:
1526
2324
  case kpidVolumeName:
1527
2325
  {
1528
- for (int i = 0; i < VolAttrs.Size(); i++)
2326
+ FOR_VECTOR (i, VolAttrs)
1529
2327
  {
1530
2328
  const CAttr &attr = VolAttrs[i];
1531
2329
  if (attr.Type == ATTR_TYPE_VOLUME_NAME)
1532
2330
  {
1533
- UString name;
1534
- GetString(attr.Data, (int)attr.Data.GetCapacity() / 2, name);
1535
- prop = name;
2331
+ UString2 name;
2332
+ GetString(attr.Data, (unsigned)attr.Data.Size() / 2, name);
2333
+ if (!name.IsEmpty())
2334
+ prop = name.GetRawPtr();
1536
2335
  break;
1537
2336
  }
1538
2337
  }
@@ -1541,7 +2340,7 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
1541
2340
  case kpidFileSystem:
1542
2341
  {
1543
2342
  AString s = "NTFS";
1544
- for (int i = 0; i < VolAttrs.Size(); i++)
2343
+ FOR_VECTOR (i, VolAttrs)
1545
2344
  {
1546
2345
  const CAttr &attr = VolAttrs[i];
1547
2346
  if (attr.Type == ATTR_TYPE_VOLUME_INFO)
@@ -1549,7 +2348,7 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
1549
2348
  CVolInfo vi;
1550
2349
  if (attr.ParseVolInfo(vi))
1551
2350
  {
1552
- s += ' ';
2351
+ s.Add_Space();
1553
2352
  char temp[16];
1554
2353
  ConvertUInt32ToString(vi.MajorVer, temp);
1555
2354
  s += temp;
@@ -1564,7 +2363,32 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
1564
2363
  break;
1565
2364
  }
1566
2365
  case kpidSectorSize: prop = (UInt32)1 << Header.SectorSizeLog; break;
2366
+ case kpidRecordSize: prop = (UInt32)1 << RecSizeLog; break;
1567
2367
  case kpidId: prop = Header.SerialNumber; break;
2368
+
2369
+ case kpidIsTree: prop = true; break;
2370
+ case kpidIsDeleted: prop = _showDeletedFiles; break;
2371
+ case kpidIsAltStream: prop = ThereAreAltStreams; break;
2372
+ case kpidIsAux: prop = true; break;
2373
+ case kpidINode: prop = true; break;
2374
+
2375
+ case kpidWarning:
2376
+ if (_lostFolderIndex_Normal >= 0)
2377
+ prop = "There are lost files";
2378
+ break;
2379
+
2380
+ /*
2381
+ case kpidWarningFlags:
2382
+ {
2383
+ UInt32 flags = 0;
2384
+ if (_headerWarning)
2385
+ flags |= k_ErrorFlags_HeadersError;
2386
+ if (flags != 0)
2387
+ prop = flags;
2388
+ break;
2389
+ }
2390
+ */
2391
+
1568
2392
  // case kpidMediaType: prop = Header.MediaType; break;
1569
2393
  // case kpidSectorsPerTrack: prop = Header.SectorsPerTrack; break;
1570
2394
  // case kpidNumHeads: prop = Header.NumHeads; break;
@@ -1578,7 +2402,26 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
1578
2402
  STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
1579
2403
  {
1580
2404
  COM_TRY_BEGIN
1581
- NWindows::NCOM::CPropVariant prop;
2405
+ NCOM::CPropVariant prop;
2406
+ if (index >= Items.Size())
2407
+ {
2408
+ switch (propID)
2409
+ {
2410
+ case kpidName:
2411
+ case kpidPath:
2412
+ prop = VirtFolderNames[index - Items.Size()].GetRawPtr();
2413
+ break;
2414
+ case kpidIsDir: prop = true; break;
2415
+ case kpidIsAux: prop = true; break;
2416
+ case kpidIsDeleted:
2417
+ if ((int)index == _lostFolderIndex_Deleted)
2418
+ prop = true;
2419
+ break;
2420
+ }
2421
+ prop.Detach(value);
2422
+ return S_OK;
2423
+ }
2424
+
1582
2425
  const CItem &item = Items[index];
1583
2426
  const CMftRec &rec = Recs[item.RecIndex];
1584
2427
 
@@ -1586,33 +2429,145 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
1586
2429
  if (item.DataIndex >= 0)
1587
2430
  data = &rec.DataAttrs[rec.DataRefs[item.DataIndex].Start];
1588
2431
 
1589
- switch(propID)
2432
+ // const CFileNameAttr *fn = &rec.FileNames[item.NameIndex];
2433
+ /*
2434
+ if (rec.FileNames.Size() > 0)
2435
+ fn = &rec.FileNames[0];
2436
+ */
2437
+
2438
+ switch (propID)
1590
2439
  {
1591
2440
  case kpidPath:
2441
+ GetItemPath(index, prop);
2442
+ break;
2443
+
2444
+ /*
2445
+ case kpidLink:
2446
+ if (!rec.ReparseAttr.SubsName.IsEmpty())
2447
+ {
2448
+ prop = rec.ReparseAttr.SubsName;
2449
+ }
2450
+ break;
2451
+ case kpidLink2:
2452
+ if (!rec.ReparseAttr.PrintName.IsEmpty())
2453
+ {
2454
+ prop = rec.ReparseAttr.PrintName;
2455
+ }
2456
+ break;
2457
+
2458
+ case kpidLinkType:
2459
+ if (rec.ReparseAttr.Tag != 0)
2460
+ {
2461
+ prop = (rec.ReparseAttr.Tag & 0xFFFF);
2462
+ }
2463
+ break;
2464
+ */
2465
+
2466
+ case kpidINode:
1592
2467
  {
1593
- UString name = GetItemPath(index);
1594
- const wchar_t *prefix = NULL;
1595
- if (!rec.InUse())
1596
- prefix = MY_DIR_PREFIX(L"DELETED");
1597
- else if (item.RecIndex < kNumSysRecs)
1598
- prefix = MY_DIR_PREFIX(L"SYSTEM");
1599
- if (prefix)
1600
- name = prefix + name;
1601
- prop = name;
2468
+ // const CMftRec &rec = Recs[item.RecIndex];
2469
+ // prop = ((UInt64)rec.SeqNumber << 48) | item.RecIndex;
2470
+ prop = item.RecIndex;
2471
+ break;
2472
+ }
2473
+ case kpidStreamId:
2474
+ {
2475
+ if (item.DataIndex >= 0)
2476
+ prop = ((UInt64)item.RecIndex << 32) | (unsigned)item.DataIndex;
2477
+ break;
2478
+ }
2479
+
2480
+ case kpidName:
2481
+ {
2482
+ const UString2 *s;
2483
+ if (item.IsAltStream())
2484
+ s = &rec.DataAttrs[rec.DataRefs[item.DataIndex].Start].Name;
2485
+ else
2486
+ s = &rec.FileNames[item.NameIndex].Name;
2487
+ if (s->IsEmpty())
2488
+ prop = (const wchar_t *)EmptyString;
2489
+ else
2490
+ prop = s->GetRawPtr();
2491
+ break;
2492
+ }
2493
+
2494
+ case kpidShortName:
2495
+ {
2496
+ if (!item.IsAltStream())
2497
+ {
2498
+ int dosNameIndex = rec.FindDosName(item.NameIndex);
2499
+ if (dosNameIndex >= 0)
2500
+ {
2501
+ const UString2 &s = rec.FileNames[dosNameIndex].Name;
2502
+ if (s.IsEmpty())
2503
+ prop = (const wchar_t *)EmptyString;
2504
+ else
2505
+ prop = s.GetRawPtr();
2506
+ }
2507
+ }
1602
2508
  break;
1603
2509
  }
1604
2510
 
1605
2511
  case kpidIsDir: prop = item.IsDir(); break;
2512
+ case kpidIsAltStream: prop = item.IsAltStream(); break;
2513
+ case kpidIsDeleted: prop = !rec.InUse(); break;
2514
+ case kpidIsAux: prop = false; break;
2515
+
1606
2516
  case kpidMTime: NtfsTimeToProp(rec.SiAttr.MTime, prop); break;
1607
-
1608
2517
  case kpidCTime: NtfsTimeToProp(rec.SiAttr.CTime, prop); break;
1609
2518
  case kpidATime: NtfsTimeToProp(rec.SiAttr.ATime, prop); break;
2519
+ // case kpidRecMTime: if (fn) NtfsTimeToProp(rec.SiAttr.ThisRecMTime, prop); break;
2520
+
2521
+ /*
2522
+ case kpidMTime2: if (fn) NtfsTimeToProp(fn->MTime, prop); break;
2523
+ case kpidCTime2: if (fn) NtfsTimeToProp(fn->CTime, prop); break;
2524
+ case kpidATime2: if (fn) NtfsTimeToProp(fn->ATime, prop); break;
2525
+ case kpidRecMTime2: if (fn) NtfsTimeToProp(fn->ThisRecMTime, prop); break;
2526
+ */
2527
+
1610
2528
  case kpidAttrib:
1611
- prop = item.Attrib;
2529
+ {
2530
+ UInt32 attrib;
2531
+ /* WinXP-64: The CFileNameAttr::Attrib is not updated after some changes. Why?
2532
+ CSiAttr:attrib is updated better. So we use CSiAttr:Sttrib */
2533
+ /*
2534
+ if (fn)
2535
+ attrib = fn->Attrib;
2536
+ else
2537
+ */
2538
+ attrib = rec.SiAttr.Attrib;
2539
+ if (item.IsDir())
2540
+ attrib |= FILE_ATTRIBUTE_DIRECTORY;
2541
+
2542
+ /* some system entries can contain extra flags (Index View).
2543
+ // 0x10000000 (Directory)
2544
+ // 0x20000000 FILE_ATTR_VIEW_INDEX_PRESENT MFT_RECORD_IS_VIEW_INDEX (Index View)
2545
+ But we don't need them */
2546
+ attrib &= 0xFFFF;
2547
+
2548
+ prop = attrib;
2549
+ break;
2550
+ }
2551
+ case kpidLinks: if (rec.MyNumNameLinks != 1) prop = rec.MyNumNameLinks; break;
2552
+
2553
+ case kpidNumAltStreams:
2554
+ {
2555
+ if (!item.IsAltStream())
2556
+ {
2557
+ unsigned num = rec.DataRefs.Size();
2558
+ if (num > 0)
2559
+ {
2560
+ if (!rec.IsDir() && rec.DataAttrs[rec.DataRefs[0].Start].Name.IsEmpty())
2561
+ num--;
2562
+ if (num > 0)
2563
+ prop = num;
2564
+ }
2565
+ }
1612
2566
  break;
1613
- case kpidLinks: prop = rec.MyNumNameLinks; break;
1614
- case kpidSize: if (data) prop = data->GetSize(); break;
1615
- case kpidPackSize: if (data) prop = data->GetPackSize(); break;
2567
+ }
2568
+
2569
+ case kpidSize: if (data) prop = data->GetSize(); else if (!item.IsDir()) prop = (UInt64)0; break;
2570
+ case kpidPackSize: if (data) prop = data->GetPackSize(); else if (!item.IsDir()) prop = (UInt64)0; break;
1616
2571
  case kpidNumBlocks: if (data) prop = (UInt32)rec.GetNumExtents(item.DataIndex, Header.ClusterSizeLog, Header.NumClusters); break;
1617
2572
  }
1618
2573
  prop.Detach(value);
@@ -1654,7 +2609,7 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
1654
2609
  Int32 testMode, IArchiveExtractCallback *extractCallback)
1655
2610
  {
1656
2611
  COM_TRY_BEGIN
1657
- bool allFilesMode = (numItems == (UInt32)-1);
2612
+ bool allFilesMode = (numItems == (UInt32)(Int32)-1);
1658
2613
  if (allFilesMode)
1659
2614
  numItems = Items.Size();
1660
2615
  if (numItems == 0)
@@ -1663,19 +2618,21 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
1663
2618
  UInt64 totalSize = 0;
1664
2619
  for (i = 0; i < numItems; i++)
1665
2620
  {
2621
+ UInt32 index = allFilesMode ? i : indices[i];
2622
+ if (index >= (UInt32)Items.Size())
2623
+ continue;
1666
2624
  const CItem &item = Items[allFilesMode ? i : indices[i]];
1667
2625
  const CMftRec &rec = Recs[item.RecIndex];
1668
- if (!rec.IsDir())
2626
+ if (item.DataIndex >= 0)
1669
2627
  totalSize += rec.GetSize(item.DataIndex);
1670
2628
  }
1671
2629
  RINOK(extractCallback->SetTotal(totalSize));
1672
2630
 
1673
2631
  UInt64 totalPackSize;
1674
2632
  totalSize = totalPackSize = 0;
1675
-
1676
- CByteBuffer buf;
2633
+
1677
2634
  UInt32 clusterSize = Header.ClusterSize();
1678
- buf.SetCapacity(clusterSize);
2635
+ CByteBuffer buf(clusterSize);
1679
2636
 
1680
2637
  NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder();
1681
2638
  CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;
@@ -1696,17 +2653,18 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
1696
2653
  Int32 askMode = testMode ?
1697
2654
  NExtract::NAskMode::kTest :
1698
2655
  NExtract::NAskMode::kExtract;
1699
- Int32 index = allFilesMode ? i : indices[i];
2656
+ UInt32 index = allFilesMode ? i : indices[i];
1700
2657
  RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
1701
2658
 
1702
- const CItem &item = Items[index];
1703
- if (item.IsDir())
2659
+ if (index >= (UInt32)Items.Size() || Items[index].IsDir())
1704
2660
  {
1705
2661
  RINOK(extractCallback->PrepareOperation(askMode));
1706
2662
  RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kOK));
1707
2663
  continue;
1708
2664
  }
1709
2665
 
2666
+ const CItem &item = Items[index];
2667
+
1710
2668
  if (!testMode && !realOutStream)
1711
2669
  continue;
1712
2670
  RINOK(extractCallback->PrepareOperation(askMode));
@@ -1716,20 +2674,19 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
1716
2674
  outStreamSpec->Init();
1717
2675
 
1718
2676
  const CMftRec &rec = Recs[item.RecIndex];
1719
- const CAttr &data = rec.DataAttrs[rec.DataRefs[item.DataIndex].Start];
1720
2677
 
1721
2678
  int res = NExtract::NOperationResult::kDataError;
1722
2679
  {
1723
2680
  CMyComPtr<IInStream> inStream;
1724
2681
  HRESULT hres = rec.GetStream(InStream, item.DataIndex, Header.ClusterSizeLog, Header.NumClusters, &inStream);
1725
2682
  if (hres == S_FALSE)
1726
- res = NExtract::NOperationResult::kUnSupportedMethod;
2683
+ res = NExtract::NOperationResult::kUnsupportedMethod;
1727
2684
  else
1728
2685
  {
1729
2686
  RINOK(hres);
1730
2687
  if (inStream)
1731
2688
  {
1732
- HRESULT hres = copyCoder->Code(inStream, outStream, NULL, NULL, progress);
2689
+ hres = copyCoder->Code(inStream, outStream, NULL, NULL, progress);
1733
2690
  if (hres != S_OK && hres != S_FALSE)
1734
2691
  {
1735
2692
  RINOK(hres);
@@ -1739,8 +2696,12 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
1739
2696
  }
1740
2697
  }
1741
2698
  }
1742
- totalPackSize += data.GetPackSize();
1743
- totalSize += data.GetSize();
2699
+ if (item.DataIndex >= 0)
2700
+ {
2701
+ const CAttr &data = rec.DataAttrs[rec.DataRefs[item.DataIndex].Start];
2702
+ totalPackSize += data.GetPackSize();
2703
+ totalSize += data.GetSize();
2704
+ }
1744
2705
  outStreamSpec->ReleaseStream();
1745
2706
  RINOK(extractCallback->SetOperationResult(res));
1746
2707
  }
@@ -1750,15 +2711,44 @@ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
1750
2711
 
1751
2712
  STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
1752
2713
  {
1753
- *numItems = Items.Size();
2714
+ *numItems = Items.Size() + VirtFolderNames.Size();
1754
2715
  return S_OK;
1755
2716
  }
1756
2717
 
1757
- static IInArchive *CreateArc() { return new CHandler; }
2718
+ STDMETHODIMP CHandler::SetProperties(const wchar_t * const *names, const PROPVARIANT *values, UInt32 numProps)
2719
+ {
2720
+ InitProps();
2721
+
2722
+ for (UInt32 i = 0; i < numProps; i++)
2723
+ {
2724
+ UString name = names[i];
2725
+ name.MakeLower_Ascii();
2726
+ if (name.IsEmpty())
2727
+ return E_INVALIDARG;
2728
+
2729
+ const PROPVARIANT &prop = values[i];
2730
+
2731
+ if (name.IsEqualTo("ld"))
2732
+ {
2733
+ RINOK(PROPVARIANT_to_bool(prop, _showDeletedFiles));
2734
+ }
2735
+ else if (name.IsEqualTo("ls"))
2736
+ {
2737
+ RINOK(PROPVARIANT_to_bool(prop, _showSystemFiles));
2738
+ }
2739
+ else
2740
+ return E_INVALIDARG;
2741
+ }
2742
+ return S_OK;
2743
+ }
1758
2744
 
1759
- static CArcInfo g_ArcInfo =
1760
- { L"NTFS", L"ntfs img", 0, 0xD9, { 'N', 'T', 'F', 'S', ' ', ' ', ' ', ' ', 0 }, 9, false, CreateArc, 0 };
2745
+ static const Byte k_Signature[] = { 'N', 'T', 'F', 'S', ' ', ' ', ' ', ' ', 0 };
1761
2746
 
1762
- REGISTER_ARC(Fat)
2747
+ REGISTER_ARC_I(
2748
+ "NTFS", "ntfs img", 0, 0xD9,
2749
+ k_Signature,
2750
+ 3,
2751
+ 0,
2752
+ NULL)
1763
2753
 
1764
2754
  }}