seven_zip_ruby_am 1.2.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (734) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +26 -0
  3. data/.travis.yml +35 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +39 -0
  6. data/README.md +210 -0
  7. data/Rakefile +67 -0
  8. data/ext/C/Types.h +254 -0
  9. data/ext/CPP/7zip/Archive/IArchive.h +234 -0
  10. data/ext/CPP/7zip/IDecl.h +15 -0
  11. data/ext/CPP/7zip/IPassword.h +24 -0
  12. data/ext/CPP/7zip/IProgress.h +33 -0
  13. data/ext/CPP/7zip/IStream.h +58 -0
  14. data/ext/CPP/7zip/PropID.h +76 -0
  15. data/ext/CPP/Common/MyCom.h +225 -0
  16. data/ext/CPP/Common/MyGuidDef.h +54 -0
  17. data/ext/CPP/Common/MyInitGuid.h +22 -0
  18. data/ext/CPP/Common/MyUnknown.h +13 -0
  19. data/ext/CPP/Common/MyWindows.h +204 -0
  20. data/ext/CPP/Common/Types.h +11 -0
  21. data/ext/CPP/Windows/PropVariant.h +56 -0
  22. data/ext/CPP/include_windows/basetyps.h +19 -0
  23. data/ext/CPP/include_windows/tchar.h +89 -0
  24. data/ext/CPP/include_windows/windows.h +194 -0
  25. data/ext/p7zip/Asm/x64/7zCrcT8U.asm +103 -0
  26. data/ext/p7zip/Asm/x86/7zCrcT8U.asm +101 -0
  27. data/ext/p7zip/C/7zBuf.h +39 -0
  28. data/ext/p7zip/C/7zBuf2.c +45 -0
  29. data/ext/p7zip/C/7zCrc.c +76 -0
  30. data/ext/p7zip/C/7zCrc.h +25 -0
  31. data/ext/p7zip/C/7zCrcOpt.c +34 -0
  32. data/ext/p7zip/C/7zCrcT8.c +43 -0
  33. data/ext/p7zip/C/7zStream.c +169 -0
  34. data/ext/p7zip/C/7zVersion.h +7 -0
  35. data/ext/p7zip/C/Aes.c +284 -0
  36. data/ext/p7zip/C/Aes.h +38 -0
  37. data/ext/p7zip/C/Alloc.back3 +238 -0
  38. data/ext/p7zip/C/Alloc.c +280 -0
  39. data/ext/p7zip/C/Alloc.c.back +243 -0
  40. data/ext/p7zip/C/Alloc.c.back2 +222 -0
  41. data/ext/p7zip/C/Alloc.h +27 -0
  42. data/ext/p7zip/C/Bra.c +133 -0
  43. data/ext/p7zip/C/Bra.h +68 -0
  44. data/ext/p7zip/C/Bra86.c +85 -0
  45. data/ext/p7zip/C/BraIA64.c +67 -0
  46. data/ext/p7zip/C/BwtSort.c +516 -0
  47. data/ext/p7zip/C/BwtSort.h +30 -0
  48. data/ext/p7zip/C/CpuArch.c +168 -0
  49. data/ext/p7zip/C/CpuArch.h +155 -0
  50. data/ext/p7zip/C/Delta.c +62 -0
  51. data/ext/p7zip/C/Delta.h +23 -0
  52. data/ext/p7zip/C/HuffEnc.c +146 -0
  53. data/ext/p7zip/C/HuffEnc.h +27 -0
  54. data/ext/p7zip/C/LzFind.c +761 -0
  55. data/ext/p7zip/C/LzFind.h +115 -0
  56. data/ext/p7zip/C/LzFindMt.c +793 -0
  57. data/ext/p7zip/C/LzFindMt.h +105 -0
  58. data/ext/p7zip/C/LzHash.h +54 -0
  59. data/ext/p7zip/C/Lzma2Dec.c +356 -0
  60. data/ext/p7zip/C/Lzma2Dec.h +84 -0
  61. data/ext/p7zip/C/Lzma2Enc.c +477 -0
  62. data/ext/p7zip/C/Lzma2Enc.h +66 -0
  63. data/ext/p7zip/C/LzmaDec.c +999 -0
  64. data/ext/p7zip/C/LzmaDec.h +231 -0
  65. data/ext/p7zip/C/LzmaEnc.c +2268 -0
  66. data/ext/p7zip/C/LzmaEnc.h +80 -0
  67. data/ext/p7zip/C/LzmaUtil/Lzma86Dec.c +61 -0
  68. data/ext/p7zip/C/LzmaUtil/Lzma86Dec.h +51 -0
  69. data/ext/p7zip/C/LzmaUtil/Lzma86Enc.c +113 -0
  70. data/ext/p7zip/C/LzmaUtil/Lzma86Enc.h +78 -0
  71. data/ext/p7zip/C/MtCoder.c +327 -0
  72. data/ext/p7zip/C/MtCoder.h +98 -0
  73. data/ext/p7zip/C/Ppmd.h +85 -0
  74. data/ext/p7zip/C/Ppmd7.c +708 -0
  75. data/ext/p7zip/C/Ppmd7.h +140 -0
  76. data/ext/p7zip/C/Ppmd7Dec.c +187 -0
  77. data/ext/p7zip/C/Ppmd7Enc.c +185 -0
  78. data/ext/p7zip/C/Ppmd8.c +1120 -0
  79. data/ext/p7zip/C/Ppmd8.h +133 -0
  80. data/ext/p7zip/C/Ppmd8Dec.c +155 -0
  81. data/ext/p7zip/C/Ppmd8Enc.c +161 -0
  82. data/ext/p7zip/C/RotateDefs.h +20 -0
  83. data/ext/p7zip/C/Sha256.c +204 -0
  84. data/ext/p7zip/C/Sha256.h +26 -0
  85. data/ext/p7zip/C/Sort.c +93 -0
  86. data/ext/p7zip/C/Sort.h +20 -0
  87. data/ext/p7zip/C/Threads.c +582 -0
  88. data/ext/p7zip/C/Threads.h +123 -0
  89. data/ext/p7zip/C/Types.h +254 -0
  90. data/ext/p7zip/C/Xz.c +88 -0
  91. data/ext/p7zip/C/Xz.h +252 -0
  92. data/ext/p7zip/C/XzCrc64.c +33 -0
  93. data/ext/p7zip/C/XzCrc64.h +26 -0
  94. data/ext/p7zip/C/XzDec.c +875 -0
  95. data/ext/p7zip/C/XzEnc.c +497 -0
  96. data/ext/p7zip/C/XzEnc.h +25 -0
  97. data/ext/p7zip/C/XzIn.c +306 -0
  98. data/ext/p7zip/CPP/7zip/Archive/7z/7zCompressionMode.cpp +3 -0
  99. data/ext/p7zip/CPP/7zip/Archive/7z/7zCompressionMode.h +50 -0
  100. data/ext/p7zip/CPP/7zip/Archive/7z/7zDecode.cpp +332 -0
  101. data/ext/p7zip/CPP/7zip/Archive/7z/7zDecode.h +68 -0
  102. data/ext/p7zip/CPP/7zip/Archive/7z/7zEncode.cpp +444 -0
  103. data/ext/p7zip/CPP/7zip/Archive/7z/7zEncode.h +55 -0
  104. data/ext/p7zip/CPP/7zip/Archive/7z/7zExtract.cpp +270 -0
  105. data/ext/p7zip/CPP/7zip/Archive/7z/7zFolderInStream.cpp +123 -0
  106. data/ext/p7zip/CPP/7zip/Archive/7z/7zFolderInStream.h +58 -0
  107. data/ext/p7zip/CPP/7zip/Archive/7z/7zFolderOutStream.cpp +149 -0
  108. data/ext/p7zip/CPP/7zip/Archive/7z/7zFolderOutStream.h +58 -0
  109. data/ext/p7zip/CPP/7zip/Archive/7z/7zHandler.cpp +482 -0
  110. data/ext/p7zip/CPP/7zip/Archive/7z/7zHandler.h +119 -0
  111. data/ext/p7zip/CPP/7zip/Archive/7z/7zHandlerOut.cpp +483 -0
  112. data/ext/p7zip/CPP/7zip/Archive/7z/7zHeader.cpp +14 -0
  113. data/ext/p7zip/CPP/7zip/Archive/7z/7zHeader.h +97 -0
  114. data/ext/p7zip/CPP/7zip/Archive/7z/7zIn.cpp +1276 -0
  115. data/ext/p7zip/CPP/7zip/Archive/7z/7zIn.h +245 -0
  116. data/ext/p7zip/CPP/7zip/Archive/7z/7zItem.h +268 -0
  117. data/ext/p7zip/CPP/7zip/Archive/7z/7zOut.cpp +866 -0
  118. data/ext/p7zip/CPP/7zip/Archive/7z/7zOut.h +152 -0
  119. data/ext/p7zip/CPP/7zip/Archive/7z/7zProperties.cpp +164 -0
  120. data/ext/p7zip/CPP/7zip/Archive/7z/7zProperties.h +22 -0
  121. data/ext/p7zip/CPP/7zip/Archive/7z/7zRegister.cpp +18 -0
  122. data/ext/p7zip/CPP/7zip/Archive/7z/7zSpecStream.cpp +24 -0
  123. data/ext/p7zip/CPP/7zip/Archive/7z/7zSpecStream.h +35 -0
  124. data/ext/p7zip/CPP/7zip/Archive/7z/7zUpdate.cpp +1216 -0
  125. data/ext/p7zip/CPP/7zip/Archive/7z/7zUpdate.h +88 -0
  126. data/ext/p7zip/CPP/7zip/Archive/ApmHandler.cpp +356 -0
  127. data/ext/p7zip/CPP/7zip/Archive/ArchiveExports.cpp +135 -0
  128. data/ext/p7zip/CPP/7zip/Archive/ArjHandler.cpp +798 -0
  129. data/ext/p7zip/CPP/7zip/Archive/Bz2Handler.cpp +423 -0
  130. data/ext/p7zip/CPP/7zip/Archive/Cab/CabBlockInStream.cpp +189 -0
  131. data/ext/p7zip/CPP/7zip/Archive/Cab/CabBlockInStream.h +44 -0
  132. data/ext/p7zip/CPP/7zip/Archive/Cab/CabHandler.cpp +929 -0
  133. data/ext/p7zip/CPP/7zip/Archive/Cab/CabHandler.h +28 -0
  134. data/ext/p7zip/CPP/7zip/Archive/Cab/CabHeader.cpp +15 -0
  135. data/ext/p7zip/CPP/7zip/Archive/Cab/CabHeader.h +44 -0
  136. data/ext/p7zip/CPP/7zip/Archive/Cab/CabIn.cpp +272 -0
  137. data/ext/p7zip/CPP/7zip/Archive/Cab/CabIn.h +161 -0
  138. data/ext/p7zip/CPP/7zip/Archive/Cab/CabItem.h +63 -0
  139. data/ext/p7zip/CPP/7zip/Archive/Cab/CabRegister.cpp +13 -0
  140. data/ext/p7zip/CPP/7zip/Archive/Chm/ChmHandler.cpp +721 -0
  141. data/ext/p7zip/CPP/7zip/Archive/Chm/ChmHandler.h +29 -0
  142. data/ext/p7zip/CPP/7zip/Archive/Chm/ChmHeader.cpp +24 -0
  143. data/ext/p7zip/CPP/7zip/Archive/Chm/ChmHeader.h +28 -0
  144. data/ext/p7zip/CPP/7zip/Archive/Chm/ChmIn.cpp +937 -0
  145. data/ext/p7zip/CPP/7zip/Archive/Chm/ChmIn.h +244 -0
  146. data/ext/p7zip/CPP/7zip/Archive/Chm/ChmRegister.cpp +13 -0
  147. data/ext/p7zip/CPP/7zip/Archive/Com/ComHandler.cpp +239 -0
  148. data/ext/p7zip/CPP/7zip/Archive/Com/ComHandler.h +28 -0
  149. data/ext/p7zip/CPP/7zip/Archive/Com/ComIn.cpp +389 -0
  150. data/ext/p7zip/CPP/7zip/Archive/Com/ComIn.h +119 -0
  151. data/ext/p7zip/CPP/7zip/Archive/Com/ComRegister.cpp +13 -0
  152. data/ext/p7zip/CPP/7zip/Archive/Common/CoderMixer2.cpp +121 -0
  153. data/ext/p7zip/CPP/7zip/Archive/Common/CoderMixer2.h +174 -0
  154. data/ext/p7zip/CPP/7zip/Archive/Common/CoderMixer2MT.cpp +240 -0
  155. data/ext/p7zip/CPP/7zip/Archive/Common/CoderMixer2MT.h +80 -0
  156. data/ext/p7zip/CPP/7zip/Archive/Common/CoderMixer2ST.cpp +239 -0
  157. data/ext/p7zip/CPP/7zip/Archive/Common/CoderMixer2ST.h +88 -0
  158. data/ext/p7zip/CPP/7zip/Archive/Common/CrossThreadProgress.cpp +15 -0
  159. data/ext/p7zip/CPP/7zip/Archive/Common/CrossThreadProgress.h +37 -0
  160. data/ext/p7zip/CPP/7zip/Archive/Common/DummyOutStream.cpp +22 -0
  161. data/ext/p7zip/CPP/7zip/Archive/Common/DummyOutStream.h +24 -0
  162. data/ext/p7zip/CPP/7zip/Archive/Common/FindSignature.cpp +62 -0
  163. data/ext/p7zip/CPP/7zip/Archive/Common/FindSignature.h +12 -0
  164. data/ext/p7zip/CPP/7zip/Archive/Common/HandlerOut.cpp +623 -0
  165. data/ext/p7zip/CPP/7zip/Archive/Common/HandlerOut.h +87 -0
  166. data/ext/p7zip/CPP/7zip/Archive/Common/InStreamWithCRC.cpp +42 -0
  167. data/ext/p7zip/CPP/7zip/Archive/Common/InStreamWithCRC.h +67 -0
  168. data/ext/p7zip/CPP/7zip/Archive/Common/ItemNameUtils.cpp +61 -0
  169. data/ext/p7zip/CPP/7zip/Archive/Common/ItemNameUtils.h +24 -0
  170. data/ext/p7zip/CPP/7zip/Archive/Common/MultiStream.cpp +190 -0
  171. data/ext/p7zip/CPP/7zip/Archive/Common/MultiStream.h +84 -0
  172. data/ext/p7zip/CPP/7zip/Archive/Common/OutStreamWithCRC.cpp +18 -0
  173. data/ext/p7zip/CPP/7zip/Archive/Common/OutStreamWithCRC.h +36 -0
  174. data/ext/p7zip/CPP/7zip/Archive/Common/OutStreamWithSha1.cpp +18 -0
  175. data/ext/p7zip/CPP/7zip/Archive/Common/OutStreamWithSha1.h +36 -0
  176. data/ext/p7zip/CPP/7zip/Archive/Common/ParseProperties.cpp +177 -0
  177. data/ext/p7zip/CPP/7zip/Archive/Common/ParseProperties.h +18 -0
  178. data/ext/p7zip/CPP/7zip/Archive/CpioHandler.cpp +624 -0
  179. data/ext/p7zip/CPP/7zip/Archive/CramfsHandler.cpp +644 -0
  180. data/ext/p7zip/CPP/7zip/Archive/DebHandler.cpp +413 -0
  181. data/ext/p7zip/CPP/7zip/Archive/DeflateProps.cpp +118 -0
  182. data/ext/p7zip/CPP/7zip/Archive/DeflateProps.h +35 -0
  183. data/ext/p7zip/CPP/7zip/Archive/DllExports2.cpp +76 -0
  184. data/ext/p7zip/CPP/7zip/Archive/DmgHandler.cpp +918 -0
  185. data/ext/p7zip/CPP/7zip/Archive/ElfHandler.cpp +534 -0
  186. data/ext/p7zip/CPP/7zip/Archive/FatHandler.cpp +996 -0
  187. data/ext/p7zip/CPP/7zip/Archive/FlvHandler.cpp +544 -0
  188. data/ext/p7zip/CPP/7zip/Archive/GzHandler.cpp +698 -0
  189. data/ext/p7zip/CPP/7zip/Archive/Hfs/HfsHandler.cpp +243 -0
  190. data/ext/p7zip/CPP/7zip/Archive/Hfs/HfsHandler.h +26 -0
  191. data/ext/p7zip/CPP/7zip/Archive/Hfs/HfsIn.cpp +480 -0
  192. data/ext/p7zip/CPP/7zip/Archive/Hfs/HfsIn.h +154 -0
  193. data/ext/p7zip/CPP/7zip/Archive/Hfs/HfsRegister.cpp +13 -0
  194. data/ext/p7zip/CPP/7zip/Archive/IArchive.h +234 -0
  195. data/ext/p7zip/CPP/7zip/Archive/Iso/IsoHandler.cpp +326 -0
  196. data/ext/p7zip/CPP/7zip/Archive/Iso/IsoHandler.h +30 -0
  197. data/ext/p7zip/CPP/7zip/Archive/Iso/IsoHeader.cpp +21 -0
  198. data/ext/p7zip/CPP/7zip/Archive/Iso/IsoHeader.h +61 -0
  199. data/ext/p7zip/CPP/7zip/Archive/Iso/IsoIn.cpp +453 -0
  200. data/ext/p7zip/CPP/7zip/Archive/Iso/IsoIn.h +315 -0
  201. data/ext/p7zip/CPP/7zip/Archive/Iso/IsoItem.h +141 -0
  202. data/ext/p7zip/CPP/7zip/Archive/Iso/IsoRegister.cpp +13 -0
  203. data/ext/p7zip/CPP/7zip/Archive/LzhHandler.cpp +775 -0
  204. data/ext/p7zip/CPP/7zip/Archive/LzmaHandler.cpp +430 -0
  205. data/ext/p7zip/CPP/7zip/Archive/MachoHandler.cpp +500 -0
  206. data/ext/p7zip/CPP/7zip/Archive/MbrHandler.cpp +507 -0
  207. data/ext/p7zip/CPP/7zip/Archive/MslzHandler.cpp +257 -0
  208. data/ext/p7zip/CPP/7zip/Archive/MubHandler.cpp +266 -0
  209. data/ext/p7zip/CPP/7zip/Archive/Nsis/NsisDecode.cpp +130 -0
  210. data/ext/p7zip/CPP/7zip/Archive/Nsis/NsisDecode.h +47 -0
  211. data/ext/p7zip/CPP/7zip/Archive/Nsis/NsisHandler.cpp +510 -0
  212. data/ext/p7zip/CPP/7zip/Archive/Nsis/NsisHandler.h +43 -0
  213. data/ext/p7zip/CPP/7zip/Archive/Nsis/NsisIn.cpp +1461 -0
  214. data/ext/p7zip/CPP/7zip/Archive/Nsis/NsisIn.h +181 -0
  215. data/ext/p7zip/CPP/7zip/Archive/Nsis/NsisRegister.cpp +13 -0
  216. data/ext/p7zip/CPP/7zip/Archive/NtfsHandler.cpp +1764 -0
  217. data/ext/p7zip/CPP/7zip/Archive/PeHandler.cpp +1752 -0
  218. data/ext/p7zip/CPP/7zip/Archive/PpmdHandler.cpp +456 -0
  219. data/ext/p7zip/CPP/7zip/Archive/Rar/RarHandler.cpp +869 -0
  220. data/ext/p7zip/CPP/7zip/Archive/Rar/RarHandler.h +66 -0
  221. data/ext/p7zip/CPP/7zip/Archive/Rar/RarHeader.cpp +21 -0
  222. data/ext/p7zip/CPP/7zip/Archive/Rar/RarHeader.h +205 -0
  223. data/ext/p7zip/CPP/7zip/Archive/Rar/RarIn.cpp +478 -0
  224. data/ext/p7zip/CPP/7zip/Archive/Rar/RarIn.h +123 -0
  225. data/ext/p7zip/CPP/7zip/Archive/Rar/RarItem.cpp +55 -0
  226. data/ext/p7zip/CPP/7zip/Archive/Rar/RarItem.h +79 -0
  227. data/ext/p7zip/CPP/7zip/Archive/Rar/RarRegister.cpp +13 -0
  228. data/ext/p7zip/CPP/7zip/Archive/Rar/RarVolumeInStream.cpp +78 -0
  229. data/ext/p7zip/CPP/7zip/Archive/Rar/RarVolumeInStream.h +49 -0
  230. data/ext/p7zip/CPP/7zip/Archive/RpmHandler.cpp +292 -0
  231. data/ext/p7zip/CPP/7zip/Archive/SplitHandler.cpp +366 -0
  232. data/ext/p7zip/CPP/7zip/Archive/SquashfsHandler.cpp +2155 -0
  233. data/ext/p7zip/CPP/7zip/Archive/SwfHandler.cpp +706 -0
  234. data/ext/p7zip/CPP/7zip/Archive/Tar/TarHandler.cpp +386 -0
  235. data/ext/p7zip/CPP/7zip/Archive/Tar/TarHandler.h +61 -0
  236. data/ext/p7zip/CPP/7zip/Archive/Tar/TarHandlerOut.cpp +122 -0
  237. data/ext/p7zip/CPP/7zip/Archive/Tar/TarHeader.cpp +25 -0
  238. data/ext/p7zip/CPP/7zip/Archive/Tar/TarHeader.h +108 -0
  239. data/ext/p7zip/CPP/7zip/Archive/Tar/TarIn.cpp +207 -0
  240. data/ext/p7zip/CPP/7zip/Archive/Tar/TarIn.h +17 -0
  241. data/ext/p7zip/CPP/7zip/Archive/Tar/TarItem.h +72 -0
  242. data/ext/p7zip/CPP/7zip/Archive/Tar/TarOut.cpp +187 -0
  243. data/ext/p7zip/CPP/7zip/Archive/Tar/TarOut.h +28 -0
  244. data/ext/p7zip/CPP/7zip/Archive/Tar/TarRegister.cpp +18 -0
  245. data/ext/p7zip/CPP/7zip/Archive/Tar/TarUpdate.cpp +139 -0
  246. data/ext/p7zip/CPP/7zip/Archive/Tar/TarUpdate.h +34 -0
  247. data/ext/p7zip/CPP/7zip/Archive/Udf/UdfHandler.cpp +451 -0
  248. data/ext/p7zip/CPP/7zip/Archive/Udf/UdfHandler.h +37 -0
  249. data/ext/p7zip/CPP/7zip/Archive/Udf/UdfIn.cpp +876 -0
  250. data/ext/p7zip/CPP/7zip/Archive/Udf/UdfIn.h +375 -0
  251. data/ext/p7zip/CPP/7zip/Archive/Udf/UdfRegister.cpp +13 -0
  252. data/ext/p7zip/CPP/7zip/Archive/VhdHandler.cpp +734 -0
  253. data/ext/p7zip/CPP/7zip/Archive/Wim/WimHandler.cpp +660 -0
  254. data/ext/p7zip/CPP/7zip/Archive/Wim/WimHandler.h +77 -0
  255. data/ext/p7zip/CPP/7zip/Archive/Wim/WimHandlerOut.cpp +639 -0
  256. data/ext/p7zip/CPP/7zip/Archive/Wim/WimIn.cpp +855 -0
  257. data/ext/p7zip/CPP/7zip/Archive/Wim/WimIn.h +297 -0
  258. data/ext/p7zip/CPP/7zip/Archive/Wim/WimRegister.cpp +18 -0
  259. data/ext/p7zip/CPP/7zip/Archive/XarHandler.cpp +588 -0
  260. data/ext/p7zip/CPP/7zip/Archive/XzHandler.cpp +707 -0
  261. data/ext/p7zip/CPP/7zip/Archive/ZHandler.cpp +161 -0
  262. data/ext/p7zip/CPP/7zip/Archive/Zip/ZipAddCommon.cpp +379 -0
  263. data/ext/p7zip/CPP/7zip/Archive/Zip/ZipAddCommon.h +56 -0
  264. data/ext/p7zip/CPP/7zip/Archive/Zip/ZipCompressionMode.h +42 -0
  265. data/ext/p7zip/CPP/7zip/Archive/Zip/ZipHandler.cpp +822 -0
  266. data/ext/p7zip/CPP/7zip/Archive/Zip/ZipHandler.h +101 -0
  267. data/ext/p7zip/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp +537 -0
  268. data/ext/p7zip/CPP/7zip/Archive/Zip/ZipHeader.cpp +36 -0
  269. data/ext/p7zip/CPP/7zip/Archive/Zip/ZipHeader.h +284 -0
  270. data/ext/p7zip/CPP/7zip/Archive/Zip/ZipIn.cpp +893 -0
  271. data/ext/p7zip/CPP/7zip/Archive/Zip/ZipIn.h +125 -0
  272. data/ext/p7zip/CPP/7zip/Archive/Zip/ZipItem.cpp +181 -0
  273. data/ext/p7zip/CPP/7zip/Archive/Zip/ZipItem.h +281 -0
  274. data/ext/p7zip/CPP/7zip/Archive/Zip/ZipItemEx.h +34 -0
  275. data/ext/p7zip/CPP/7zip/Archive/Zip/ZipOut.cpp +289 -0
  276. data/ext/p7zip/CPP/7zip/Archive/Zip/ZipOut.h +56 -0
  277. data/ext/p7zip/CPP/7zip/Archive/Zip/ZipRegister.cpp +18 -0
  278. data/ext/p7zip/CPP/7zip/Archive/Zip/ZipUpdate.cpp +1076 -0
  279. data/ext/p7zip/CPP/7zip/Archive/Zip/ZipUpdate.h +58 -0
  280. data/ext/p7zip/CPP/7zip/Bundles/Format7zFree/makefile +328 -0
  281. data/ext/p7zip/CPP/7zip/Bundles/Format7zFree/makefile.depend +4962 -0
  282. data/ext/p7zip/CPP/7zip/Bundles/Format7zFree/makefile.list +265 -0
  283. data/ext/p7zip/CPP/7zip/CMAKE/CMakeLists_7zFM.txt +163 -0
  284. data/ext/p7zip/CPP/7zip/CMAKE/CMakeLists_7zG.txt +131 -0
  285. data/ext/p7zip/CPP/7zip/CMAKE/CMakeLists_7za.txt +253 -0
  286. data/ext/p7zip/CPP/7zip/CMAKE/CMakeLists_ALL.txt +32 -0
  287. data/ext/p7zip/CPP/7zip/CMAKE/CMakeLists_Format7zFree.txt +290 -0
  288. data/ext/p7zip/CPP/7zip/CMAKE/generate.sh +37 -0
  289. data/ext/p7zip/CPP/7zip/CMAKE/generate_xcode.sh +32 -0
  290. data/ext/p7zip/CPP/7zip/Common/CWrappers.cpp +226 -0
  291. data/ext/p7zip/CPP/7zip/Common/CWrappers.h +109 -0
  292. data/ext/p7zip/CPP/7zip/Common/CreateCoder.cpp +293 -0
  293. data/ext/p7zip/CPP/7zip/Common/CreateCoder.h +98 -0
  294. data/ext/p7zip/CPP/7zip/Common/FilePathAutoRename.cpp +55 -0
  295. data/ext/p7zip/CPP/7zip/Common/FilePathAutoRename.h +10 -0
  296. data/ext/p7zip/CPP/7zip/Common/FileStreams.cpp +273 -0
  297. data/ext/p7zip/CPP/7zip/Common/FileStreams.h +134 -0
  298. data/ext/p7zip/CPP/7zip/Common/FilterCoder.cpp +247 -0
  299. data/ext/p7zip/CPP/7zip/Common/FilterCoder.h +128 -0
  300. data/ext/p7zip/CPP/7zip/Common/InBuffer.cpp +83 -0
  301. data/ext/p7zip/CPP/7zip/Common/InBuffer.h +81 -0
  302. data/ext/p7zip/CPP/7zip/Common/InOutTempBuffer.cpp +122 -0
  303. data/ext/p7zip/CPP/7zip/Common/InOutTempBuffer.h +48 -0
  304. data/ext/p7zip/CPP/7zip/Common/LimitedStreams.cpp +154 -0
  305. data/ext/p7zip/CPP/7zip/Common/LimitedStreams.h +125 -0
  306. data/ext/p7zip/CPP/7zip/Common/LockedStream.cpp +23 -0
  307. data/ext/p7zip/CPP/7zip/Common/LockedStream.h +38 -0
  308. data/ext/p7zip/CPP/7zip/Common/MemBlocks.cpp +183 -0
  309. data/ext/p7zip/CPP/7zip/Common/MemBlocks.h +71 -0
  310. data/ext/p7zip/CPP/7zip/Common/MethodId.cpp +27 -0
  311. data/ext/p7zip/CPP/7zip/Common/MethodId.h +10 -0
  312. data/ext/p7zip/CPP/7zip/Common/MethodProps.cpp +99 -0
  313. data/ext/p7zip/CPP/7zip/Common/MethodProps.h +41 -0
  314. data/ext/p7zip/CPP/7zip/Common/OffsetStream.cpp +35 -0
  315. data/ext/p7zip/CPP/7zip/Common/OffsetStream.h +25 -0
  316. data/ext/p7zip/CPP/7zip/Common/OutBuffer.cpp +116 -0
  317. data/ext/p7zip/CPP/7zip/Common/OutBuffer.h +64 -0
  318. data/ext/p7zip/CPP/7zip/Common/OutMemStream.cpp +142 -0
  319. data/ext/p7zip/CPP/7zip/Common/OutMemStream.h +96 -0
  320. data/ext/p7zip/CPP/7zip/Common/ProgressMt.cpp +53 -0
  321. data/ext/p7zip/CPP/7zip/Common/ProgressMt.h +46 -0
  322. data/ext/p7zip/CPP/7zip/Common/ProgressUtils.cpp +42 -0
  323. data/ext/p7zip/CPP/7zip/Common/ProgressUtils.h +34 -0
  324. data/ext/p7zip/CPP/7zip/Common/RegisterArc.h +32 -0
  325. data/ext/p7zip/CPP/7zip/Common/RegisterCodec.h +33 -0
  326. data/ext/p7zip/CPP/7zip/Common/StreamBinder.cpp +152 -0
  327. data/ext/p7zip/CPP/7zip/Common/StreamBinder.h +38 -0
  328. data/ext/p7zip/CPP/7zip/Common/StreamObjects.cpp +221 -0
  329. data/ext/p7zip/CPP/7zip/Common/StreamObjects.h +135 -0
  330. data/ext/p7zip/CPP/7zip/Common/StreamUtils.cpp +56 -0
  331. data/ext/p7zip/CPP/7zip/Common/StreamUtils.h +13 -0
  332. data/ext/p7zip/CPP/7zip/Common/VirtThread.cpp +46 -0
  333. data/ext/p7zip/CPP/7zip/Common/VirtThread.h +23 -0
  334. data/ext/p7zip/CPP/7zip/Compress/ArjDecoder1.cpp +309 -0
  335. data/ext/p7zip/CPP/7zip/Compress/ArjDecoder1.h +98 -0
  336. data/ext/p7zip/CPP/7zip/Compress/ArjDecoder2.cpp +90 -0
  337. data/ext/p7zip/CPP/7zip/Compress/ArjDecoder2.h +59 -0
  338. data/ext/p7zip/CPP/7zip/Compress/BZip2Const.h +54 -0
  339. data/ext/p7zip/CPP/7zip/Compress/BZip2Crc.cpp +26 -0
  340. data/ext/p7zip/CPP/7zip/Compress/BZip2Crc.h +31 -0
  341. data/ext/p7zip/CPP/7zip/Compress/BZip2Decoder.cpp +943 -0
  342. data/ext/p7zip/CPP/7zip/Compress/BZip2Decoder.h +205 -0
  343. data/ext/p7zip/CPP/7zip/Compress/BZip2Encoder.cpp +895 -0
  344. data/ext/p7zip/CPP/7zip/Compress/BZip2Encoder.h +245 -0
  345. data/ext/p7zip/CPP/7zip/Compress/BZip2Register.cpp +20 -0
  346. data/ext/p7zip/CPP/7zip/Compress/Bcj2Coder.cpp +386 -0
  347. data/ext/p7zip/CPP/7zip/Compress/Bcj2Coder.h +115 -0
  348. data/ext/p7zip/CPP/7zip/Compress/Bcj2Register.cpp +19 -0
  349. data/ext/p7zip/CPP/7zip/Compress/BcjCoder.cpp +15 -0
  350. data/ext/p7zip/CPP/7zip/Compress/BcjCoder.h +19 -0
  351. data/ext/p7zip/CPP/7zip/Compress/BcjRegister.cpp +19 -0
  352. data/ext/p7zip/CPP/7zip/Compress/BitlDecoder.cpp +24 -0
  353. data/ext/p7zip/CPP/7zip/Compress/BitlDecoder.h +141 -0
  354. data/ext/p7zip/CPP/7zip/Compress/BitlEncoder.h +57 -0
  355. data/ext/p7zip/CPP/7zip/Compress/BitmDecoder.h +66 -0
  356. data/ext/p7zip/CPP/7zip/Compress/BitmEncoder.h +50 -0
  357. data/ext/p7zip/CPP/7zip/Compress/BranchCoder.cpp +19 -0
  358. data/ext/p7zip/CPP/7zip/Compress/BranchCoder.h +44 -0
  359. data/ext/p7zip/CPP/7zip/Compress/BranchMisc.cpp +37 -0
  360. data/ext/p7zip/CPP/7zip/Compress/BranchMisc.h +14 -0
  361. data/ext/p7zip/CPP/7zip/Compress/BranchRegister.cpp +30 -0
  362. data/ext/p7zip/CPP/7zip/Compress/ByteSwap.cpp +73 -0
  363. data/ext/p7zip/CPP/7zip/Compress/CodecExports.cpp +160 -0
  364. data/ext/p7zip/CPP/7zip/Compress/CopyCoder.cpp +67 -0
  365. data/ext/p7zip/CPP/7zip/Compress/CopyCoder.h +34 -0
  366. data/ext/p7zip/CPP/7zip/Compress/CopyRegister.cpp +14 -0
  367. data/ext/p7zip/CPP/7zip/Compress/Deflate64Register.cpp +20 -0
  368. data/ext/p7zip/CPP/7zip/Compress/DeflateConst.h +134 -0
  369. data/ext/p7zip/CPP/7zip/Compress/DeflateDecoder.cpp +353 -0
  370. data/ext/p7zip/CPP/7zip/Compress/DeflateDecoder.h +157 -0
  371. data/ext/p7zip/CPP/7zip/Compress/DeflateEncoder.cpp +986 -0
  372. data/ext/p7zip/CPP/7zip/Compress/DeflateEncoder.h +211 -0
  373. data/ext/p7zip/CPP/7zip/Compress/DeflateRegister.cpp +21 -0
  374. data/ext/p7zip/CPP/7zip/Compress/DeltaFilter.cpp +112 -0
  375. data/ext/p7zip/CPP/7zip/Compress/DllExports.cpp +39 -0
  376. data/ext/p7zip/CPP/7zip/Compress/DllExports2.cpp +28 -0
  377. data/ext/p7zip/CPP/7zip/Compress/HuffmanDecoder.h +89 -0
  378. data/ext/p7zip/CPP/7zip/Compress/ImplodeDecoder.cpp +219 -0
  379. data/ext/p7zip/CPP/7zip/Compress/ImplodeDecoder.h +57 -0
  380. data/ext/p7zip/CPP/7zip/Compress/ImplodeHuffmanDecoder.cpp +89 -0
  381. data/ext/p7zip/CPP/7zip/Compress/ImplodeHuffmanDecoder.h +34 -0
  382. data/ext/p7zip/CPP/7zip/Compress/LZMA_Alone/LzmaAlone.cpp +531 -0
  383. data/ext/p7zip/CPP/7zip/Compress/LZMA_Alone/LzmaBench.cpp +1018 -0
  384. data/ext/p7zip/CPP/7zip/Compress/LZMA_Alone/LzmaBench.h +48 -0
  385. data/ext/p7zip/CPP/7zip/Compress/LZMA_Alone/LzmaBenchCon.cpp +311 -0
  386. data/ext/p7zip/CPP/7zip/Compress/LZMA_Alone/LzmaBenchCon.h +20 -0
  387. data/ext/p7zip/CPP/7zip/Compress/LZMA_Alone/makefile +173 -0
  388. data/ext/p7zip/CPP/7zip/Compress/LzOutWindow.cpp +14 -0
  389. data/ext/p7zip/CPP/7zip/Compress/LzOutWindow.h +66 -0
  390. data/ext/p7zip/CPP/7zip/Compress/LzhDecoder.cpp +220 -0
  391. data/ext/p7zip/CPP/7zip/Compress/LzhDecoder.h +106 -0
  392. data/ext/p7zip/CPP/7zip/Compress/Lzma2Decoder.cpp +189 -0
  393. data/ext/p7zip/CPP/7zip/Compress/Lzma2Decoder.h +73 -0
  394. data/ext/p7zip/CPP/7zip/Compress/Lzma2Encoder.cpp +94 -0
  395. data/ext/p7zip/CPP/7zip/Compress/Lzma2Encoder.h +36 -0
  396. data/ext/p7zip/CPP/7zip/Compress/Lzma2Register.cpp +20 -0
  397. data/ext/p7zip/CPP/7zip/Compress/LzmaDecoder.cpp +252 -0
  398. data/ext/p7zip/CPP/7zip/Compress/LzmaDecoder.h +84 -0
  399. data/ext/p7zip/CPP/7zip/Compress/LzmaEncoder.cpp +149 -0
  400. data/ext/p7zip/CPP/7zip/Compress/LzmaEncoder.h +36 -0
  401. data/ext/p7zip/CPP/7zip/Compress/LzmaRegister.cpp +20 -0
  402. data/ext/p7zip/CPP/7zip/Compress/Lzx.h +61 -0
  403. data/ext/p7zip/CPP/7zip/Compress/Lzx86Converter.cpp +90 -0
  404. data/ext/p7zip/CPP/7zip/Compress/Lzx86Converter.h +46 -0
  405. data/ext/p7zip/CPP/7zip/Compress/LzxDecoder.cpp +387 -0
  406. data/ext/p7zip/CPP/7zip/Compress/LzxDecoder.h +159 -0
  407. data/ext/p7zip/CPP/7zip/Compress/Mtf8.h +193 -0
  408. data/ext/p7zip/CPP/7zip/Compress/PpmdDecoder.cpp +167 -0
  409. data/ext/p7zip/CPP/7zip/Compress/PpmdDecoder.h +78 -0
  410. data/ext/p7zip/CPP/7zip/Compress/PpmdEncoder.cpp +119 -0
  411. data/ext/p7zip/CPP/7zip/Compress/PpmdEncoder.h +48 -0
  412. data/ext/p7zip/CPP/7zip/Compress/PpmdRegister.cpp +21 -0
  413. data/ext/p7zip/CPP/7zip/Compress/PpmdZip.cpp +223 -0
  414. data/ext/p7zip/CPP/7zip/Compress/PpmdZip.h +72 -0
  415. data/ext/p7zip/CPP/7zip/Compress/QuantumDecoder.cpp +175 -0
  416. data/ext/p7zip/CPP/7zip/Compress/QuantumDecoder.h +264 -0
  417. data/ext/p7zip/CPP/7zip/Compress/RangeCoder.h +205 -0
  418. data/ext/p7zip/CPP/7zip/Compress/RangeCoderBit.h +114 -0
  419. data/ext/p7zip/CPP/7zip/Compress/Rar/makefile +34 -0
  420. data/ext/p7zip/CPP/7zip/Compress/Rar/makefile.depend +158 -0
  421. data/ext/p7zip/CPP/7zip/Compress/Rar/makefile.list +64 -0
  422. data/ext/p7zip/CPP/7zip/Compress/Rar1Decoder.cpp +480 -0
  423. data/ext/p7zip/CPP/7zip/Compress/Rar1Decoder.h +88 -0
  424. data/ext/p7zip/CPP/7zip/Compress/Rar2Decoder.cpp +391 -0
  425. data/ext/p7zip/CPP/7zip/Compress/Rar2Decoder.h +174 -0
  426. data/ext/p7zip/CPP/7zip/Compress/Rar3Decoder.cpp +897 -0
  427. data/ext/p7zip/CPP/7zip/Compress/Rar3Decoder.h +267 -0
  428. data/ext/p7zip/CPP/7zip/Compress/Rar3Vm.cpp +1091 -0
  429. data/ext/p7zip/CPP/7zip/Compress/Rar3Vm.h +179 -0
  430. data/ext/p7zip/CPP/7zip/Compress/RarCodecsRegister.cpp +26 -0
  431. data/ext/p7zip/CPP/7zip/Compress/ShrinkDecoder.cpp +145 -0
  432. data/ext/p7zip/CPP/7zip/Compress/ShrinkDecoder.h +38 -0
  433. data/ext/p7zip/CPP/7zip/Compress/ZDecoder.cpp +159 -0
  434. data/ext/p7zip/CPP/7zip/Compress/ZDecoder.h +42 -0
  435. data/ext/p7zip/CPP/7zip/Compress/ZlibDecoder.cpp +89 -0
  436. data/ext/p7zip/CPP/7zip/Compress/ZlibDecoder.h +48 -0
  437. data/ext/p7zip/CPP/7zip/Compress/ZlibEncoder.cpp +61 -0
  438. data/ext/p7zip/CPP/7zip/Compress/ZlibEncoder.h +48 -0
  439. data/ext/p7zip/CPP/7zip/Crypto/7zAes.cpp +244 -0
  440. data/ext/p7zip/CPP/7zip/Crypto/7zAes.h +117 -0
  441. data/ext/p7zip/CPP/7zip/Crypto/7zAesRegister.cpp +18 -0
  442. data/ext/p7zip/CPP/7zip/Crypto/HmacSha1.cpp +109 -0
  443. data/ext/p7zip/CPP/7zip/Crypto/HmacSha1.h +39 -0
  444. data/ext/p7zip/CPP/7zip/Crypto/MyAes.cpp +48 -0
  445. data/ext/p7zip/CPP/7zip/Crypto/MyAes.h +38 -0
  446. data/ext/p7zip/CPP/7zip/Crypto/Pbkdf2HmacSha1.cpp +83 -0
  447. data/ext/p7zip/CPP/7zip/Crypto/Pbkdf2HmacSha1.h +21 -0
  448. data/ext/p7zip/CPP/7zip/Crypto/RandGen.cpp +107 -0
  449. data/ext/p7zip/CPP/7zip/Crypto/RandGen.h +21 -0
  450. data/ext/p7zip/CPP/7zip/Crypto/Rar20Crypto.cpp +133 -0
  451. data/ext/p7zip/CPP/7zip/Crypto/Rar20Crypto.h +50 -0
  452. data/ext/p7zip/CPP/7zip/Crypto/RarAes.cpp +134 -0
  453. data/ext/p7zip/CPP/7zip/Crypto/RarAes.h +47 -0
  454. data/ext/p7zip/CPP/7zip/Crypto/Sha1.cpp +229 -0
  455. data/ext/p7zip/CPP/7zip/Crypto/Sha1.h +68 -0
  456. data/ext/p7zip/CPP/7zip/Crypto/WzAes.cpp +221 -0
  457. data/ext/p7zip/CPP/7zip/Crypto/WzAes.h +125 -0
  458. data/ext/p7zip/CPP/7zip/Crypto/ZipCrypto.cpp +88 -0
  459. data/ext/p7zip/CPP/7zip/Crypto/ZipCrypto.h +56 -0
  460. data/ext/p7zip/CPP/7zip/Crypto/ZipStrong.cpp +164 -0
  461. data/ext/p7zip/CPP/7zip/Crypto/ZipStrong.h +47 -0
  462. data/ext/p7zip/CPP/7zip/Guid.txt +170 -0
  463. data/ext/p7zip/CPP/7zip/ICoder.h +186 -0
  464. data/ext/p7zip/CPP/7zip/IDecl.h +15 -0
  465. data/ext/p7zip/CPP/7zip/IPassword.h +24 -0
  466. data/ext/p7zip/CPP/7zip/IProgress.h +33 -0
  467. data/ext/p7zip/CPP/7zip/IStream.h +58 -0
  468. data/ext/p7zip/CPP/7zip/MyVersion.h +11 -0
  469. data/ext/p7zip/CPP/7zip/PREMAKE/generate.sh +18 -0
  470. data/ext/p7zip/CPP/7zip/PREMAKE/premake4.lua +263 -0
  471. data/ext/p7zip/CPP/7zip/PropID.h +76 -0
  472. data/ext/p7zip/CPP/7zip/QMAKE/7ZA/7ZA.pro +228 -0
  473. data/ext/p7zip/CPP/7zip/QMAKE/7ZA/7ZA_osx.pro +228 -0
  474. data/ext/p7zip/CPP/7zip/QMAKE/test_emul/test_emul.pro +26 -0
  475. data/ext/p7zip/CPP/7zip/TEST/TestUI/TestUI.cpp +560 -0
  476. data/ext/p7zip/CPP/7zip/TEST/TestUI/makefile +33 -0
  477. data/ext/p7zip/CPP/7zip/TEST/TestUI/makefile.depend +577 -0
  478. data/ext/p7zip/CPP/7zip/TEST/TestUI/makefile.list +16 -0
  479. data/ext/p7zip/CPP/Common/AutoPtr.h +35 -0
  480. data/ext/p7zip/CPP/Common/Buffer.h +77 -0
  481. data/ext/p7zip/CPP/Common/CRC.cpp +7 -0
  482. data/ext/p7zip/CPP/Common/C_FileIO.cpp +88 -0
  483. data/ext/p7zip/CPP/Common/C_FileIO.h +47 -0
  484. data/ext/p7zip/CPP/Common/ComTry.h +18 -0
  485. data/ext/p7zip/CPP/Common/CommandLineParser.cpp +230 -0
  486. data/ext/p7zip/CPP/Common/CommandLineParser.h +72 -0
  487. data/ext/p7zip/CPP/Common/Defs.h +20 -0
  488. data/ext/p7zip/CPP/Common/DynamicBuffer.h +50 -0
  489. data/ext/p7zip/CPP/Common/IntToString.cpp +77 -0
  490. data/ext/p7zip/CPP/Common/IntToString.h +19 -0
  491. data/ext/p7zip/CPP/Common/Lang.cpp +130 -0
  492. data/ext/p7zip/CPP/Common/Lang.h +28 -0
  493. data/ext/p7zip/CPP/Common/ListFileUtils.cpp +75 -0
  494. data/ext/p7zip/CPP/Common/ListFileUtils.h +11 -0
  495. data/ext/p7zip/CPP/Common/MyCom.h +225 -0
  496. data/ext/p7zip/CPP/Common/MyException.h +14 -0
  497. data/ext/p7zip/CPP/Common/MyGuidDef.h +54 -0
  498. data/ext/p7zip/CPP/Common/MyInitGuid.h +22 -0
  499. data/ext/p7zip/CPP/Common/MyMap.cpp +140 -0
  500. data/ext/p7zip/CPP/Common/MyMap.h +28 -0
  501. data/ext/p7zip/CPP/Common/MyString.cpp +206 -0
  502. data/ext/p7zip/CPP/Common/MyString.h +601 -0
  503. data/ext/p7zip/CPP/Common/MyUnknown.h +13 -0
  504. data/ext/p7zip/CPP/Common/MyVector.cpp +87 -0
  505. data/ext/p7zip/CPP/Common/MyVector.h +266 -0
  506. data/ext/p7zip/CPP/Common/MyWindows.cpp +111 -0
  507. data/ext/p7zip/CPP/Common/MyWindows.h +218 -0
  508. data/ext/p7zip/CPP/Common/MyXml.cpp +209 -0
  509. data/ext/p7zip/CPP/Common/MyXml.h +40 -0
  510. data/ext/p7zip/CPP/Common/NewHandler.h +16 -0
  511. data/ext/p7zip/CPP/Common/StdInStream.cpp +100 -0
  512. data/ext/p7zip/CPP/Common/StdInStream.h +32 -0
  513. data/ext/p7zip/CPP/Common/StdOutStream.cpp +93 -0
  514. data/ext/p7zip/CPP/Common/StdOutStream.h +35 -0
  515. data/ext/p7zip/CPP/Common/StringConvert.cpp +181 -0
  516. data/ext/p7zip/CPP/Common/StringConvert.h +73 -0
  517. data/ext/p7zip/CPP/Common/StringToInt.cpp +90 -0
  518. data/ext/p7zip/CPP/Common/StringToInt.h +18 -0
  519. data/ext/p7zip/CPP/Common/TextConfig.cpp +138 -0
  520. data/ext/p7zip/CPP/Common/TextConfig.h +22 -0
  521. data/ext/p7zip/CPP/Common/Types.h +11 -0
  522. data/ext/p7zip/CPP/Common/UTFConvert.cpp +145 -0
  523. data/ext/p7zip/CPP/Common/UTFConvert.h +11 -0
  524. data/ext/p7zip/CPP/Common/Wildcard.cpp +462 -0
  525. data/ext/p7zip/CPP/Common/Wildcard.h +80 -0
  526. data/ext/p7zip/CPP/Windows/COM.cpp +37 -0
  527. data/ext/p7zip/CPP/Windows/COM.h +69 -0
  528. data/ext/p7zip/CPP/Windows/Clipboard.cpp +160 -0
  529. data/ext/p7zip/CPP/Windows/Clipboard.h +28 -0
  530. data/ext/p7zip/CPP/Windows/CommonDialog.h +19 -0
  531. data/ext/p7zip/CPP/Windows/Control/ComboBox.h +82 -0
  532. data/ext/p7zip/CPP/Windows/Control/Controls.cpp +515 -0
  533. data/ext/p7zip/CPP/Windows/Control/Dialog.cpp +560 -0
  534. data/ext/p7zip/CPP/Windows/Control/Dialog.h +179 -0
  535. data/ext/p7zip/CPP/Windows/Control/DialogImpl.h +73 -0
  536. data/ext/p7zip/CPP/Windows/Control/Edit.h +24 -0
  537. data/ext/p7zip/CPP/Windows/Control/ListView.h +164 -0
  538. data/ext/p7zip/CPP/Windows/Control/ProgressBar.h +34 -0
  539. data/ext/p7zip/CPP/Windows/Control/Static.h +23 -0
  540. data/ext/p7zip/CPP/Windows/Control/StatusBar.h +56 -0
  541. data/ext/p7zip/CPP/Windows/Control/Window2.cpp +211 -0
  542. data/ext/p7zip/CPP/Windows/Control/Window2.h +111 -0
  543. data/ext/p7zip/CPP/Windows/DLL.cpp +193 -0
  544. data/ext/p7zip/CPP/Windows/DLL.h +48 -0
  545. data/ext/p7zip/CPP/Windows/Defs.h +17 -0
  546. data/ext/p7zip/CPP/Windows/Error.cpp +58 -0
  547. data/ext/p7zip/CPP/Windows/Error.h +33 -0
  548. data/ext/p7zip/CPP/Windows/FileDir.cpp +927 -0
  549. data/ext/p7zip/CPP/Windows/FileDir.h +115 -0
  550. data/ext/p7zip/CPP/Windows/FileFind.cpp +604 -0
  551. data/ext/p7zip/CPP/Windows/FileFind.h +126 -0
  552. data/ext/p7zip/CPP/Windows/FileIO.cpp +475 -0
  553. data/ext/p7zip/CPP/Windows/FileIO.h +110 -0
  554. data/ext/p7zip/CPP/Windows/FileName.cpp +50 -0
  555. data/ext/p7zip/CPP/Windows/FileName.h +27 -0
  556. data/ext/p7zip/CPP/Windows/Menu.h +4 -0
  557. data/ext/p7zip/CPP/Windows/NtCheck.h +44 -0
  558. data/ext/p7zip/CPP/Windows/PropVariant.cpp +243 -0
  559. data/ext/p7zip/CPP/Windows/PropVariant.h +56 -0
  560. data/ext/p7zip/CPP/Windows/PropVariantConversions.cpp +142 -0
  561. data/ext/p7zip/CPP/Windows/PropVariantConversions.h +14 -0
  562. data/ext/p7zip/CPP/Windows/PropVariantUtils.cpp +78 -0
  563. data/ext/p7zip/CPP/Windows/PropVariantUtils.h +28 -0
  564. data/ext/p7zip/CPP/Windows/Registry.cpp +313 -0
  565. data/ext/p7zip/CPP/Windows/Registry.h +113 -0
  566. data/ext/p7zip/CPP/Windows/ResourceString.h +22 -0
  567. data/ext/p7zip/CPP/Windows/Shell.h +21 -0
  568. data/ext/p7zip/CPP/Windows/Synchronization.cpp +157 -0
  569. data/ext/p7zip/CPP/Windows/Synchronization.h +187 -0
  570. data/ext/p7zip/CPP/Windows/Synchronization2.h +218 -0
  571. data/ext/p7zip/CPP/Windows/System.cpp +166 -0
  572. data/ext/p7zip/CPP/Windows/System.h +16 -0
  573. data/ext/p7zip/CPP/Windows/Thread.h +41 -0
  574. data/ext/p7zip/CPP/Windows/Time.cpp +88 -0
  575. data/ext/p7zip/CPP/Windows/Time.h +21 -0
  576. data/ext/p7zip/CPP/Windows/Window.cpp +101 -0
  577. data/ext/p7zip/CPP/Windows/Window.h +43 -0
  578. data/ext/p7zip/CPP/include_windows/basetyps.h +19 -0
  579. data/ext/p7zip/CPP/include_windows/tchar.h +89 -0
  580. data/ext/p7zip/CPP/include_windows/windows.h +194 -0
  581. data/ext/p7zip/CPP/myWindows/StdAfx.h +124 -0
  582. data/ext/p7zip/CPP/myWindows/config.h +67 -0
  583. data/ext/p7zip/CPP/myWindows/initguid.h +4 -0
  584. data/ext/p7zip/CPP/myWindows/makefile +21 -0
  585. data/ext/p7zip/CPP/myWindows/makefile.depend +32 -0
  586. data/ext/p7zip/CPP/myWindows/makefile.list +28 -0
  587. data/ext/p7zip/CPP/myWindows/myAddExeFlag.cpp +20 -0
  588. data/ext/p7zip/CPP/myWindows/myGetTickCount.cpp +8 -0
  589. data/ext/p7zip/CPP/myWindows/myPrivate.h +17 -0
  590. data/ext/p7zip/CPP/myWindows/mySplitCommandLine.cpp +82 -0
  591. data/ext/p7zip/CPP/myWindows/test_emul.cpp +745 -0
  592. data/ext/p7zip/CPP/myWindows/wine_GetXXXDefaultLangID.cpp +741 -0
  593. data/ext/p7zip/CPP/myWindows/wine_date_and_time.cpp +434 -0
  594. data/ext/p7zip/ChangeLog +914 -0
  595. data/ext/p7zip/DOCS/7zC.txt +194 -0
  596. data/ext/p7zip/DOCS/7zFormat.txt +469 -0
  597. data/ext/p7zip/DOCS/License.txt +52 -0
  598. data/ext/p7zip/DOCS/MANUAL/commands/add.htm +87 -0
  599. data/ext/p7zip/DOCS/MANUAL/commands/bench.htm +79 -0
  600. data/ext/p7zip/DOCS/MANUAL/commands/delete.htm +59 -0
  601. data/ext/p7zip/DOCS/MANUAL/commands/extract.htm +91 -0
  602. data/ext/p7zip/DOCS/MANUAL/commands/extract_full.htm +68 -0
  603. data/ext/p7zip/DOCS/MANUAL/commands/index.htm +33 -0
  604. data/ext/p7zip/DOCS/MANUAL/commands/list.htm +77 -0
  605. data/ext/p7zip/DOCS/MANUAL/commands/style.css +232 -0
  606. data/ext/p7zip/DOCS/MANUAL/commands/test.htm +46 -0
  607. data/ext/p7zip/DOCS/MANUAL/commands/update.htm +66 -0
  608. data/ext/p7zip/DOCS/MANUAL/exit_codes.htm +27 -0
  609. data/ext/p7zip/DOCS/MANUAL/index.htm +29 -0
  610. data/ext/p7zip/DOCS/MANUAL/style.css +232 -0
  611. data/ext/p7zip/DOCS/MANUAL/switches/ar_exclude.htm +56 -0
  612. data/ext/p7zip/DOCS/MANUAL/switches/ar_include.htm +83 -0
  613. data/ext/p7zip/DOCS/MANUAL/switches/ar_no.htm +52 -0
  614. data/ext/p7zip/DOCS/MANUAL/switches/charset.htm +49 -0
  615. data/ext/p7zip/DOCS/MANUAL/switches/exclude.htm +60 -0
  616. data/ext/p7zip/DOCS/MANUAL/switches/include.htm +87 -0
  617. data/ext/p7zip/DOCS/MANUAL/switches/index.htm +64 -0
  618. data/ext/p7zip/DOCS/MANUAL/switches/large_pages.htm +50 -0
  619. data/ext/p7zip/DOCS/MANUAL/switches/list_tech.htm +36 -0
  620. data/ext/p7zip/DOCS/MANUAL/switches/method.htm +625 -0
  621. data/ext/p7zip/DOCS/MANUAL/switches/output_dir.htm +53 -0
  622. data/ext/p7zip/DOCS/MANUAL/switches/overwrite.htm +56 -0
  623. data/ext/p7zip/DOCS/MANUAL/switches/password.htm +54 -0
  624. data/ext/p7zip/DOCS/MANUAL/switches/recurse.htm +83 -0
  625. data/ext/p7zip/DOCS/MANUAL/switches/sfx.htm +156 -0
  626. data/ext/p7zip/DOCS/MANUAL/switches/ssc.htm +50 -0
  627. data/ext/p7zip/DOCS/MANUAL/switches/stdin.htm +55 -0
  628. data/ext/p7zip/DOCS/MANUAL/switches/stdout.htm +50 -0
  629. data/ext/p7zip/DOCS/MANUAL/switches/stop_switch.htm +31 -0
  630. data/ext/p7zip/DOCS/MANUAL/switches/style.css +232 -0
  631. data/ext/p7zip/DOCS/MANUAL/switches/type.htm +83 -0
  632. data/ext/p7zip/DOCS/MANUAL/switches/update.htm +176 -0
  633. data/ext/p7zip/DOCS/MANUAL/switches/volume.htm +49 -0
  634. data/ext/p7zip/DOCS/MANUAL/switches/working_dir.htm +55 -0
  635. data/ext/p7zip/DOCS/MANUAL/switches/yes.htm +48 -0
  636. data/ext/p7zip/DOCS/MANUAL/syntax.htm +120 -0
  637. data/ext/p7zip/DOCS/Methods.txt +152 -0
  638. data/ext/p7zip/DOCS/copying.txt +504 -0
  639. data/ext/p7zip/DOCS/history.txt +456 -0
  640. data/ext/p7zip/DOCS/lzma.txt +598 -0
  641. data/ext/p7zip/DOCS/readme.txt +181 -0
  642. data/ext/p7zip/DOCS/unRarLicense.txt +41 -0
  643. data/ext/p7zip/README +358 -0
  644. data/ext/p7zip/TODO +39 -0
  645. data/ext/p7zip/contrib/VirtualFileSystemForMidnightCommander/ChangeLog +41 -0
  646. data/ext/p7zip/contrib/VirtualFileSystemForMidnightCommander/readme +21 -0
  647. data/ext/p7zip/contrib/VirtualFileSystemForMidnightCommander/readme.u7z +30 -0
  648. data/ext/p7zip/contrib/VirtualFileSystemForMidnightCommander/u7z +133 -0
  649. data/ext/p7zip/contrib/gzip-like_CLI_wrapper_for_7z/README +21 -0
  650. data/ext/p7zip/contrib/gzip-like_CLI_wrapper_for_7z/check/check.sh +117 -0
  651. data/ext/p7zip/contrib/gzip-like_CLI_wrapper_for_7z/check/files.tar +0 -0
  652. data/ext/p7zip/contrib/gzip-like_CLI_wrapper_for_7z/man1/p7zip.1 +33 -0
  653. data/ext/p7zip/contrib/gzip-like_CLI_wrapper_for_7z/p7zip +144 -0
  654. data/ext/p7zip/contrib/qnx630sp3/qnx630sp3-shared +14 -0
  655. data/ext/p7zip/contrib/qnx630sp3/qnx630sp3-static +10 -0
  656. data/ext/p7zip/install.sh +206 -0
  657. data/ext/p7zip/install_local_context_menu.sh +18 -0
  658. data/ext/p7zip/integration_context_menu.txt +51 -0
  659. data/ext/p7zip/makefile +181 -0
  660. data/ext/p7zip/makefile.aix_gcc +22 -0
  661. data/ext/p7zip/makefile.beos +18 -0
  662. data/ext/p7zip/makefile.crc32 +8 -0
  663. data/ext/p7zip/makefile.cygwin +20 -0
  664. data/ext/p7zip/makefile.cygwin_asm +21 -0
  665. data/ext/p7zip/makefile.djgpp_old +21 -0
  666. data/ext/p7zip/makefile.djgpp_watt +47 -0
  667. data/ext/p7zip/makefile.freebsd5 +20 -0
  668. data/ext/p7zip/makefile.freebsd6 +20 -0
  669. data/ext/p7zip/makefile.glb +39 -0
  670. data/ext/p7zip/makefile.gprof +18 -0
  671. data/ext/p7zip/makefile.hpux-acc +17 -0
  672. data/ext/p7zip/makefile.hpux-acc_64 +19 -0
  673. data/ext/p7zip/makefile.hpux-gcc +21 -0
  674. data/ext/p7zip/makefile.linux_amd64 +22 -0
  675. data/ext/p7zip/makefile.linux_amd64_asm +24 -0
  676. data/ext/p7zip/makefile.linux_amd64_asm_icc +27 -0
  677. data/ext/p7zip/makefile.linux_any_cpu +22 -0
  678. data/ext/p7zip/makefile.linux_any_cpu_gcc_4.X +24 -0
  679. data/ext/p7zip/makefile.linux_clang_amd64 +22 -0
  680. data/ext/p7zip/makefile.linux_cross_arm +22 -0
  681. data/ext/p7zip/makefile.linux_gcc_2.95_no_need_for_libstdc +20 -0
  682. data/ext/p7zip/makefile.linux_other +23 -0
  683. data/ext/p7zip/makefile.linux_s390x +23 -0
  684. data/ext/p7zip/makefile.linux_x86_asm_gcc_4.X +26 -0
  685. data/ext/p7zip/makefile.linux_x86_asm_gcc_4.X_fltk +26 -0
  686. data/ext/p7zip/makefile.linux_x86_asm_gcc_mudflap_4.X +26 -0
  687. data/ext/p7zip/makefile.linux_x86_asm_icc +25 -0
  688. data/ext/p7zip/makefile.linux_x86_icc +24 -0
  689. data/ext/p7zip/makefile.machine_base +22 -0
  690. data/ext/p7zip/makefile.macosx_32bits +20 -0
  691. data/ext/p7zip/makefile.macosx_32bits_asm +23 -0
  692. data/ext/p7zip/makefile.macosx_32bits_ppc +21 -0
  693. data/ext/p7zip/makefile.macosx_64bits +20 -0
  694. data/ext/p7zip/makefile.macosx_llvm_64bits +20 -0
  695. data/ext/p7zip/makefile.netbsd +21 -0
  696. data/ext/p7zip/makefile.netware_asm_gcc_3.X +41 -0
  697. data/ext/p7zip/makefile.oldmake +174 -0
  698. data/ext/p7zip/makefile.openbsd +20 -0
  699. data/ext/p7zip/makefile.openbsd_no_port +20 -0
  700. data/ext/p7zip/makefile.qnx_shared.bin +21 -0
  701. data/ext/p7zip/makefile.qnx_static +21 -0
  702. data/ext/p7zip/makefile.rules +661 -0
  703. data/ext/p7zip/makefile.solaris_sparc_CC_32 +21 -0
  704. data/ext/p7zip/makefile.solaris_sparc_CC_64 +23 -0
  705. data/ext/p7zip/makefile.solaris_sparc_gcc +21 -0
  706. data/ext/p7zip/makefile.solaris_x86 +19 -0
  707. data/ext/p7zip/makefile.tru64 +22 -0
  708. data/ext/seven_zip_ruby/extconf.rb +194 -0
  709. data/ext/seven_zip_ruby/guid_defs.h +29 -0
  710. data/ext/seven_zip_ruby/mutex.h +10 -0
  711. data/ext/seven_zip_ruby/posix/mutex.h +94 -0
  712. data/ext/seven_zip_ruby/seven_zip_archive.cpp +1854 -0
  713. data/ext/seven_zip_ruby/seven_zip_archive.h +548 -0
  714. data/ext/seven_zip_ruby/util_common.cpp +28 -0
  715. data/ext/seven_zip_ruby/util_common.h +467 -0
  716. data/ext/seven_zip_ruby/utils.cpp +575 -0
  717. data/ext/seven_zip_ruby/utils.h +25 -0
  718. data/ext/seven_zip_ruby/win32/mutex.h +130 -0
  719. data/lib/seven_zip_ruby.rb +27 -0
  720. data/lib/seven_zip_ruby/7z.dll +0 -0
  721. data/lib/seven_zip_ruby/7z.sfx +0 -0
  722. data/lib/seven_zip_ruby/7z64.dll +0 -0
  723. data/lib/seven_zip_ruby/7zCon.sfx +0 -0
  724. data/lib/seven_zip_ruby/archive_info.rb +21 -0
  725. data/lib/seven_zip_ruby/entry_info.rb +46 -0
  726. data/lib/seven_zip_ruby/exception.rb +10 -0
  727. data/lib/seven_zip_ruby/seven_zip_reader.rb +537 -0
  728. data/lib/seven_zip_ruby/seven_zip_writer.rb +502 -0
  729. data/lib/seven_zip_ruby/update_info.rb +116 -0
  730. data/lib/seven_zip_ruby/version.rb +3 -0
  731. data/seven_zip_ruby.gemspec +34 -0
  732. data/spec/seven_zip_ruby_spec.rb +702 -0
  733. data/spec/seven_zip_ruby_spec_helper.rb +129 -0
  734. metadata +823 -0
@@ -0,0 +1,181 @@
1
+ // NsisIn.h
2
+
3
+ #ifndef __ARCHIVE_NSIS_IN_H
4
+ #define __ARCHIVE_NSIS_IN_H
5
+
6
+ #include "Common/Buffer.h"
7
+ #include "Common/MyCom.h"
8
+ #include "Common/StringConvert.h"
9
+
10
+ #include "NsisDecode.h"
11
+
12
+ // #define NSIS_SCRIPT
13
+
14
+ namespace NArchive {
15
+ namespace NNsis {
16
+
17
+ const int kSignatureSize = 16;
18
+ #define NSIS_SIGNATURE { 0xEF, 0xBE, 0xAD, 0xDE, 0x4E, 0x75, 0x6C, 0x6C, 0x73, 0x6F, 0x66, 0x74, 0x49, 0x6E, 0x73, 0x74}
19
+
20
+ extern Byte kSignature[kSignatureSize];
21
+
22
+ const UInt32 kFlagsMask = 0xF;
23
+ namespace NFlags
24
+ {
25
+ const UInt32 kUninstall = 1;
26
+ const UInt32 kSilent = 2;
27
+ const UInt32 kNoCrc = 4;
28
+ const UInt32 kForceCrc = 8;
29
+ }
30
+
31
+ struct CFirstHeader
32
+ {
33
+ UInt32 Flags;
34
+ UInt32 HeaderLength;
35
+
36
+ UInt32 ArchiveSize;
37
+
38
+ bool ThereIsCrc() const
39
+ {
40
+ if ((Flags & NFlags::kForceCrc ) != 0)
41
+ return true;
42
+ return ((Flags & NFlags::kNoCrc) == 0);
43
+ }
44
+
45
+ UInt32 GetDataSize() const { return ArchiveSize - (ThereIsCrc() ? 4 : 0); }
46
+ };
47
+
48
+
49
+ struct CBlockHeader
50
+ {
51
+ UInt32 Offset;
52
+ UInt32 Num;
53
+ };
54
+
55
+ struct CItem
56
+ {
57
+ AString PrefixA;
58
+ UString PrefixU;
59
+ AString NameA;
60
+ UString NameU;
61
+ FILETIME MTime;
62
+ bool IsUnicode;
63
+ bool UseFilter;
64
+ bool IsCompressed;
65
+ bool SizeIsDefined;
66
+ bool CompressedSizeIsDefined;
67
+ bool EstimatedSizeIsDefined;
68
+ UInt32 Pos;
69
+ UInt32 Size;
70
+ UInt32 CompressedSize;
71
+ UInt32 EstimatedSize;
72
+ UInt32 DictionarySize;
73
+
74
+ CItem(): IsUnicode(false), UseFilter(false), IsCompressed(true), SizeIsDefined(false),
75
+ CompressedSizeIsDefined(false), EstimatedSizeIsDefined(false), Size(0), DictionarySize(1) {}
76
+
77
+ bool IsINSTDIR() const
78
+ {
79
+ return (PrefixA.Length() >= 3 || PrefixU.Length() >= 3);
80
+ }
81
+
82
+ UString GetReducedName(bool unicode) const
83
+ {
84
+ UString s;
85
+ if (unicode)
86
+ s = PrefixU;
87
+ else
88
+ s = MultiByteToUnicodeString(PrefixA);
89
+ if (s.Length() > 0)
90
+ if (s[s.Length() - 1] != L'\\')
91
+ s += L'\\';
92
+ if (unicode)
93
+ s += NameU;
94
+ else
95
+ s += MultiByteToUnicodeString(NameA);
96
+ const int len = 9;
97
+ if (s.Left(len).CompareNoCase(L"$INSTDIR\\") == 0)
98
+ s = s.Mid(len);
99
+ return s;
100
+ }
101
+ };
102
+
103
+ class CInArchive
104
+ {
105
+ UInt64 _archiveSize;
106
+ CMyComPtr<IInStream> _stream;
107
+
108
+ Byte ReadByte();
109
+ UInt32 ReadUInt32();
110
+ HRESULT Open2(
111
+ DECL_EXTERNAL_CODECS_LOC_VARS2
112
+ );
113
+ void ReadBlockHeader(CBlockHeader &bh);
114
+ AString ReadStringA(UInt32 pos) const;
115
+ UString ReadStringU(UInt32 pos) const;
116
+ AString ReadString2A(UInt32 pos) const;
117
+ UString ReadString2U(UInt32 pos) const;
118
+ AString ReadString2(UInt32 pos) const;
119
+ AString ReadString2Qw(UInt32 pos) const;
120
+ HRESULT ReadEntries(const CBlockHeader &bh);
121
+ HRESULT Parse();
122
+
123
+ CByteBuffer _data;
124
+ UInt64 _size;
125
+
126
+ size_t _posInData;
127
+
128
+ UInt32 _stringsPos;
129
+
130
+
131
+ bool _headerIsCompressed;
132
+ UInt32 _nonSolidStartOffset;
133
+ public:
134
+ HRESULT Open(
135
+ DECL_EXTERNAL_CODECS_LOC_VARS
136
+ IInStream *inStream, const UInt64 *maxCheckStartPosition);
137
+ void Clear();
138
+
139
+ UInt64 StreamOffset;
140
+ CDecoder Decoder;
141
+ CObjectVector<CItem> Items;
142
+ CFirstHeader FirstHeader;
143
+ NMethodType::EEnum Method;
144
+ UInt32 DictionarySize;
145
+ bool IsSolid;
146
+ bool UseFilter;
147
+ bool FilterFlag;
148
+ bool IsUnicode;
149
+
150
+ #ifdef NSIS_SCRIPT
151
+ AString Script;
152
+ #endif
153
+ UInt32 GetOffset() const { return IsSolid ? 4 : 0; }
154
+ UInt64 GetDataPos(int index)
155
+ {
156
+ const CItem &item = Items[index];
157
+ return GetOffset() + FirstHeader.HeaderLength + item.Pos;
158
+ }
159
+
160
+ UInt64 GetPosOfSolidItem(int index) const
161
+ {
162
+ const CItem &item = Items[index];
163
+ return 4 + FirstHeader.HeaderLength + item.Pos;
164
+ }
165
+
166
+ UInt64 GetPosOfNonSolidItem(int index) const
167
+ {
168
+ const CItem &item = Items[index];
169
+ return StreamOffset + _nonSolidStartOffset + 4 + item.Pos;
170
+ }
171
+
172
+ void Release()
173
+ {
174
+ Decoder.Release();
175
+ }
176
+
177
+ };
178
+
179
+ }}
180
+
181
+ #endif
@@ -0,0 +1,13 @@
1
+ // NsisRegister.cpp
2
+
3
+ #include "StdAfx.h"
4
+
5
+ #include "../../Common/RegisterArc.h"
6
+
7
+ #include "NsisHandler.h"
8
+ static IInArchive *CreateArc() { return new NArchive::NNsis::CHandler; }
9
+
10
+ static CArcInfo g_ArcInfo =
11
+ { L"Nsis", L"", 0, 0x9, NSIS_SIGNATURE, NArchive::NNsis::kSignatureSize, false, CreateArc, 0 };
12
+
13
+ REGISTER_ARC(Nsis)
@@ -0,0 +1,1764 @@
1
+ // NtfsHandler.cpp
2
+
3
+ #include "StdAfx.h"
4
+
5
+ // #define SHOW_DEBUG_INFO
6
+ // #define SHOW_DEBUG_INFO2
7
+
8
+ #if defined(SHOW_DEBUG_INFO) || defined(SHOW_DEBUG_INFO2)
9
+ #include <stdio.h>
10
+ #endif
11
+
12
+ #include "../../../C/CpuArch.h"
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"
19
+
20
+ #include "Windows/PropVariant.h"
21
+ #include "Windows/Time.h"
22
+
23
+ #include "../Common/ProgressUtils.h"
24
+ #include "../Common/RegisterArc.h"
25
+ #include "../Common/StreamUtils.h"
26
+
27
+ #include "../Compress/CopyCoder.h"
28
+
29
+ #include "Common/DummyOutStream.h"
30
+
31
+ #ifdef SHOW_DEBUG_INFO
32
+ #define PRF(x) x
33
+ #else
34
+ #define PRF(x)
35
+ #endif
36
+
37
+ #ifdef SHOW_DEBUG_INFO2
38
+ #define PRF2(x) x
39
+ #else
40
+ #define PRF2(x)
41
+ #endif
42
+
43
+ #define Get16(p) GetUi16(p)
44
+ #define Get32(p) GetUi32(p)
45
+ #define Get64(p) GetUi64(p)
46
+
47
+ #define G16(p, dest) dest = Get16(p);
48
+ #define G32(p, dest) dest = Get32(p);
49
+ #define G64(p, dest) dest = Get64(p);
50
+
51
+ namespace NArchive {
52
+ namespace Ntfs {
53
+
54
+ static const UInt32 kNumSysRecs = 16;
55
+ static const UInt32 kRecIndex_Volume = 3;
56
+ static const UInt32 kRecIndex_BadClus = 8;
57
+
58
+ struct CHeader
59
+ {
60
+ Byte SectorSizeLog;
61
+ Byte ClusterSizeLog;
62
+ // Byte MediaType;
63
+ UInt32 NumHiddenSectors;
64
+ UInt64 NumClusters;
65
+ UInt64 MftCluster;
66
+ UInt64 SerialNumber;
67
+ UInt16 SectorsPerTrack;
68
+ UInt16 NumHeads;
69
+
70
+ UInt64 GetPhySize() const { return NumClusters << ClusterSizeLog; }
71
+ UInt32 ClusterSize() const { return (UInt32)1 << ClusterSizeLog; }
72
+ bool Parse(const Byte *p);
73
+ };
74
+
75
+ static int GetLog(UInt32 num)
76
+ {
77
+ for (int i = 0; i < 31; i++)
78
+ if (((UInt32)1 << i) == num)
79
+ return i;
80
+ return -1;
81
+ }
82
+
83
+ bool CHeader::Parse(const Byte *p)
84
+ {
85
+ if (p[0x1FE] != 0x55 || p[0x1FF] != 0xAA)
86
+ return false;
87
+
88
+ int codeOffset = 0;
89
+ switch (p[0])
90
+ {
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;
93
+ default: return false;
94
+ }
95
+ Byte sectorsPerClusterLog;
96
+
97
+ if (memcmp(p + 3, "NTFS ", 8) != 0)
98
+ return false;
99
+ {
100
+ int s = GetLog(Get16(p + 11));
101
+ if (s < 9 || s > 12)
102
+ return false;
103
+ SectorSizeLog = (Byte)s;
104
+ s = GetLog(p[13]);
105
+ if (s < 0)
106
+ return false;
107
+ sectorsPerClusterLog = (Byte)s;
108
+ ClusterSizeLog = SectorSizeLog + sectorsPerClusterLog;
109
+ }
110
+
111
+ for (int i = 14; i < 21; i++)
112
+ if (p[i] != 0)
113
+ return false;
114
+
115
+ // MediaType = p[21];
116
+ if (Get16(p + 22) != 0) // NumFatSectors
117
+ return false;
118
+ G16(p + 24, SectorsPerTrack);
119
+ G16(p + 26, NumHeads);
120
+ G32(p + 28, NumHiddenSectors);
121
+ if (Get32(p + 32) != 0) // NumSectors32
122
+ return false;
123
+
124
+ // DriveNumber = p[0x24];
125
+ if (p[0x25] != 0) // CurrentHead
126
+ return false;
127
+ /*
128
+ NTFS-HDD: p[0x26] = 0x80
129
+ NTFS-FLASH: p[0x26] = 0
130
+ */
131
+ if (p[0x26] != 0x80 && p[0x26] != 0) // ExtendedBootSig
132
+ return false;
133
+ if (p[0x27] != 0) // reserved
134
+ return false;
135
+ UInt64 numSectors = Get64(p + 0x28);
136
+ NumClusters = numSectors >> sectorsPerClusterLog;
137
+
138
+ G64(p + 0x30, MftCluster);
139
+ // G64(p + 0x38, Mft2Cluster);
140
+ G64(p + 0x48, SerialNumber);
141
+ UInt32 numClustersInMftRec;
142
+ UInt32 numClustersInIndexBlock;
143
+ G32(p + 0x40, numClustersInMftRec);
144
+ G32(p + 0x44, numClustersInIndexBlock);
145
+ return (numClustersInMftRec < 256 && numClustersInIndexBlock < 256);
146
+ }
147
+
148
+ struct CMftRef
149
+ {
150
+ UInt64 Val;
151
+ UInt64 GetIndex() const { return Val & (((UInt64)1 << 48) - 1); }
152
+ UInt16 GetNumber() const { return (UInt16)(Val >> 48); }
153
+ bool IsBaseItself() const { return Val == 0; }
154
+ };
155
+
156
+ #define ATNAME(n) ATTR_TYPE_ ## n
157
+ #define DEF_ATTR_TYPE(v, n) ATNAME(n) = v
158
+
159
+ enum
160
+ {
161
+ DEF_ATTR_TYPE(0x00, UNUSED),
162
+ DEF_ATTR_TYPE(0x10, STANDARD_INFO),
163
+ DEF_ATTR_TYPE(0x20, ATTRIBUTE_LIST),
164
+ DEF_ATTR_TYPE(0x30, FILE_NAME),
165
+ DEF_ATTR_TYPE(0x40, OBJECT_ID),
166
+ DEF_ATTR_TYPE(0x50, SECURITY_DESCRIPTOR),
167
+ DEF_ATTR_TYPE(0x60, VOLUME_NAME),
168
+ DEF_ATTR_TYPE(0x70, VOLUME_INFO),
169
+ DEF_ATTR_TYPE(0x80, DATA),
170
+ DEF_ATTR_TYPE(0x90, INDEX_ROOT),
171
+ DEF_ATTR_TYPE(0xA0, INDEX_ALLOCATION),
172
+ DEF_ATTR_TYPE(0xB0, BITMAP),
173
+ DEF_ATTR_TYPE(0xC0, REPARSE_POINT),
174
+ DEF_ATTR_TYPE(0xD0, EA_INFO),
175
+ DEF_ATTR_TYPE(0xE0, EA),
176
+ DEF_ATTR_TYPE(0xF0, PROPERTY_SET),
177
+ DEF_ATTR_TYPE(0x100, LOGGED_UTILITY_STREAM),
178
+ DEF_ATTR_TYPE(0x1000, FIRST_USER_DEFINED_ATTRIBUTE)
179
+ };
180
+
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;
185
+
186
+ struct CFileNameAttr
187
+ {
188
+ CMftRef ParentDirRef;
189
+ // UInt64 CTime;
190
+ // UInt64 MTime;
191
+ // UInt64 ThisRecMTime;
192
+ // UInt64 ATime;
193
+ // UInt64 AllocatedSize;
194
+ // UInt64 DataSize;
195
+ // UInt16 PackedEaSize;
196
+ UString Name;
197
+ UInt32 Attrib;
198
+ Byte NameType;
199
+
200
+ bool IsDos() const { return NameType == kFileNameType_Dos; }
201
+ bool Parse(const Byte *p, unsigned size);
202
+ };
203
+
204
+ static void GetString(const Byte *p, unsigned length, UString &res)
205
+ {
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();
211
+ }
212
+
213
+ bool CFileNameAttr::Parse(const Byte *p, unsigned size)
214
+ {
215
+ if (size < 0x42)
216
+ return false;
217
+ G64(p + 0x00, ParentDirRef.Val);
218
+ // G64(p + 0x08, CTime);
219
+ // G64(p + 0x10, MTime);
220
+ // G64(p + 0x18, ThisRecMTime);
221
+ // G64(p + 0x20, ATime);
222
+ // G64(p + 0x28, AllocatedSize);
223
+ // G64(p + 0x30, DataSize);
224
+ G32(p + 0x38, Attrib);
225
+ // G16(p + 0x3C, PackedEaSize);
226
+ NameType = p[0x41];
227
+ unsigned length = p[0x40];
228
+ if (0x42 + length > size)
229
+ return false;
230
+ GetString(p + 0x42, length, Name);
231
+ return true;
232
+ }
233
+
234
+ struct CSiAttr
235
+ {
236
+ UInt64 CTime;
237
+ UInt64 MTime;
238
+ // UInt64 ThisRecMTime;
239
+ UInt64 ATime;
240
+ UInt32 Attrib;
241
+
242
+ /*
243
+ UInt32 MaxVersions;
244
+ UInt32 Version;
245
+ UInt32 ClassId;
246
+ UInt32 OwnerId;
247
+ UInt32 SecurityId;
248
+ UInt64 QuotaCharged;
249
+ */
250
+
251
+ bool Parse(const Byte *p, unsigned size);
252
+ };
253
+
254
+ bool CSiAttr::Parse(const Byte *p, unsigned size)
255
+ {
256
+ if (size < 0x24)
257
+ return false;
258
+ G64(p + 0x00, CTime);
259
+ G64(p + 0x08, MTime);
260
+ // G64(p + 0x10, ThisRecMTime);
261
+ G64(p + 0x18, ATime);
262
+ G32(p + 0x20, Attrib);
263
+ return true;
264
+ }
265
+
266
+ static const UInt64 kEmptyExtent = (UInt64)(Int64)-1;
267
+
268
+ struct CExtent
269
+ {
270
+ UInt64 Virt;
271
+ UInt64 Phy;
272
+
273
+ bool IsEmpty() const { return Phy == kEmptyExtent; }
274
+ };
275
+
276
+ struct CVolInfo
277
+ {
278
+ Byte MajorVer;
279
+ Byte MinorVer;
280
+ // UInt16 Flags;
281
+
282
+ bool Parse(const Byte *p, unsigned size);
283
+ };
284
+
285
+ bool CVolInfo::Parse(const Byte *p, unsigned size)
286
+ {
287
+ if (size < 12)
288
+ return false;
289
+ MajorVer = p[8];
290
+ MinorVer = p[9];
291
+ // Flags = Get16(p + 10);
292
+ return true;
293
+ }
294
+
295
+ struct CAttr
296
+ {
297
+ UInt32 Type;
298
+ // UInt32 Length;
299
+ UString Name;
300
+ // UInt16 Flags;
301
+ // UInt16 Instance;
302
+ CByteBuffer Data;
303
+ Byte NonResident;
304
+
305
+ // Non-Resident
306
+ Byte CompressionUnit;
307
+ UInt64 LowVcn;
308
+ UInt64 HighVcn;
309
+ UInt64 AllocatedSize;
310
+ UInt64 Size;
311
+ UInt64 PackSize;
312
+ UInt64 InitializedSize;
313
+
314
+ // Resident
315
+ // UInt16 ResidentFlags;
316
+
317
+ bool IsCompressionUnitSupported() const { return CompressionUnit == 0 || CompressionUnit == 4; }
318
+
319
+ 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(); }
325
+ UInt64 GetPackSize() const
326
+ {
327
+ if (!NonResident)
328
+ return Data.GetCapacity();
329
+ if (CompressionUnit != 0)
330
+ return PackSize;
331
+ return AllocatedSize;
332
+ }
333
+ };
334
+
335
+ #define RINOZ(x) { int __tt = (x); if (__tt != 0) return __tt; }
336
+
337
+ static int CompareAttr(void *const *elem1, void *const *elem2, void *)
338
+ {
339
+ const CAttr &a1 = *(*((const CAttr **)elem1));
340
+ const CAttr &a2 = *(*((const CAttr **)elem2));
341
+ RINOZ(MyCompare(a1.Type, a2.Type));
342
+ RINOZ(MyCompare(a1.Name, a2.Name));
343
+ return MyCompare(a1.LowVcn, a2.LowVcn);
344
+ }
345
+
346
+ UInt32 CAttr::Parse(const Byte *p, unsigned size)
347
+ {
348
+ if (size < 4)
349
+ return 0;
350
+ G32(p, Type);
351
+ if (Type == 0xFFFFFFFF)
352
+ return 4;
353
+ if (size < 0x18)
354
+ return 0;
355
+ PRF(printf(" T=%2X", Type));
356
+
357
+ UInt32 length = Get32(p + 0x04);
358
+ PRF(printf(" L=%3d", length));
359
+ if (length > size)
360
+ return 0;
361
+ NonResident = p[0x08];
362
+ {
363
+ int nameLength = p[9];
364
+ UInt32 nameOffset = Get16(p + 0x0A);
365
+ if (nameLength != 0)
366
+ {
367
+ if (nameOffset + nameLength * 2 > length)
368
+ return 0;
369
+ GetString(p + nameOffset, nameLength, Name);
370
+ PRF(printf(" N=%S", Name));
371
+ }
372
+ }
373
+
374
+ // G16(p + 0x0C, Flags);
375
+ // G16(p + 0x0E, Instance);
376
+ // PRF(printf(" F=%4X", Flags));
377
+ // PRF(printf(" Inst=%d", Instance));
378
+
379
+ UInt32 dataSize;
380
+ UInt32 offs;
381
+ if (NonResident)
382
+ {
383
+ if (length < 0x40)
384
+ return 0;
385
+ PRF(printf(" NR"));
386
+ G64(p + 0x10, LowVcn);
387
+ G64(p + 0x18, HighVcn);
388
+ G64(p + 0x28, AllocatedSize);
389
+ G64(p + 0x30, Size);
390
+ G64(p + 0x38, InitializedSize);
391
+ G16(p + 0x20, offs);
392
+ CompressionUnit = p[0x22];
393
+
394
+ PackSize = Size;
395
+ if (CompressionUnit != 0)
396
+ {
397
+ if (length < 0x48)
398
+ return 0;
399
+ G64(p + 0x40, PackSize);
400
+ PRF(printf(" PS=%I64x", PackSize));
401
+ }
402
+
403
+ // PRF(printf("\n"));
404
+ PRF(printf(" ASize=%4I64d", AllocatedSize));
405
+ PRF(printf(" Size=%I64d", Size));
406
+ PRF(printf(" IS=%I64d", InitializedSize));
407
+ PRF(printf(" Low=%I64d", LowVcn));
408
+ PRF(printf(" High=%I64d", HighVcn));
409
+ PRF(printf(" CU=%d", (int)CompressionUnit));
410
+ dataSize = length - offs;
411
+ }
412
+ else
413
+ {
414
+ if (length < 0x18)
415
+ return 0;
416
+ PRF(printf(" RES"));
417
+ dataSize = Get32(p + 0x10);
418
+ PRF(printf(" dataSize=%3d", dataSize));
419
+ offs = Get16(p + 0x14);
420
+ // G16(p + 0x16, ResidentFlags);
421
+ // PRF(printf(" ResFlags=%4X", ResidentFlags));
422
+ }
423
+ if (offs > length || dataSize > length || length - dataSize < offs)
424
+ return 0;
425
+ Data.SetCapacity(dataSize);
426
+ memcpy(Data, p + offs, dataSize);
427
+ #ifdef SHOW_DEBUG_INFO
428
+ PRF(printf(" : "));
429
+ for (unsigned i = 0; i < Data.GetCapacity(); i++)
430
+ {
431
+ PRF(printf(" %02X", (int)Data[i]));
432
+ }
433
+ #endif
434
+ return length;
435
+ }
436
+
437
+ bool CAttr::ParseExtents(CRecordVector<CExtent> &extents, UInt64 numClustersMax, int compressionUnit) const
438
+ {
439
+ const Byte *p = Data;
440
+ unsigned size = (unsigned)Data.GetCapacity();
441
+ UInt64 vcn = LowVcn;
442
+ UInt64 lcn = 0;
443
+ UInt64 highVcn1 = HighVcn + 1;
444
+ if (LowVcn != extents.Back().Virt || highVcn1 > (UInt64)1 << 63)
445
+ return false;
446
+
447
+ extents.DeleteBack();
448
+
449
+ PRF2(printf("\n# ParseExtents # LowVcn = %4I64X # HighVcn = %4I64X", LowVcn, HighVcn));
450
+
451
+ while (size > 0)
452
+ {
453
+ Byte b = *p++;
454
+ size--;
455
+ if (b == 0)
456
+ break;
457
+ UInt32 num = b & 0xF;
458
+ if (num == 0 || num > 8 || num > size)
459
+ return false;
460
+
461
+ int i;
462
+ UInt64 vSize = p[num - 1];
463
+ for (i = (int)num - 2; i >= 0; i--)
464
+ vSize = (vSize << 8) | p[i];
465
+ if (vSize == 0)
466
+ return false;
467
+ p += num;
468
+ size -= num;
469
+ if ((highVcn1 - vcn) < vSize)
470
+ return false;
471
+
472
+ num = (b >> 4) & 0xF;
473
+ if (num > 8 || num > size)
474
+ return false;
475
+ CExtent e;
476
+ e.Virt = vcn;
477
+ if (num == 0)
478
+ {
479
+ if (compressionUnit == 0)
480
+ return false;
481
+ e.Phy = kEmptyExtent;
482
+ }
483
+ else
484
+ {
485
+ Int64 v = (signed char)p[num - 1];
486
+ for (i = (int)num - 2; i >= 0; i--)
487
+ v = (v << 8) | p[i];
488
+ p += num;
489
+ size -= num;
490
+ lcn += v;
491
+ if (lcn > numClustersMax)
492
+ return false;
493
+ e.Phy = lcn;
494
+ }
495
+ extents.Add(e);
496
+ vcn += vSize;
497
+ }
498
+ CExtent e;
499
+ e.Phy = kEmptyExtent;
500
+ e.Virt = vcn;
501
+ extents.Add(e);
502
+ return (highVcn1 == vcn);
503
+ }
504
+
505
+ static const UInt64 kEmptyTag = (UInt64)(Int64)-1;
506
+
507
+ static const int kNumCacheChunksLog = 1;
508
+ static const UInt32 kNumCacheChunks = (1 << kNumCacheChunksLog);
509
+
510
+ class CInStream:
511
+ public IInStream,
512
+ public CMyUnknownImp
513
+ {
514
+ UInt64 _virtPos;
515
+ UInt64 _physPos;
516
+ UInt64 _curRem;
517
+ bool _sparseMode;
518
+ size_t _compressedPos;
519
+
520
+ UInt64 _tags[kNumCacheChunks];
521
+ int _chunkSizeLog;
522
+ CByteBuffer _inBuf;
523
+ CByteBuffer _outBuf;
524
+ public:
525
+ CMyComPtr<IInStream> Stream;
526
+ UInt64 Size;
527
+ UInt64 InitializedSize;
528
+ int BlockSizeLog;
529
+ int CompressionUnit;
530
+ bool InUse;
531
+ CRecordVector<CExtent> Extents;
532
+
533
+ HRESULT SeekToPhys() { return Stream->Seek(_physPos, STREAM_SEEK_SET, NULL); }
534
+
535
+ UInt32 GetCuSize() const { return (UInt32)1 << (BlockSizeLog + CompressionUnit); }
536
+ HRESULT InitAndSeek(int compressionUnit)
537
+ {
538
+ CompressionUnit = compressionUnit;
539
+ if (compressionUnit != 0)
540
+ {
541
+ UInt32 cuSize = GetCuSize();
542
+ _inBuf.SetCapacity(cuSize);
543
+ _chunkSizeLog = BlockSizeLog + CompressionUnit;
544
+ _outBuf.SetCapacity(kNumCacheChunks << _chunkSizeLog);
545
+ }
546
+ for (int i = 0; i < kNumCacheChunks; i++)
547
+ _tags[i] = kEmptyTag;
548
+
549
+ _sparseMode = false;
550
+ _curRem = 0;
551
+ _virtPos = 0;
552
+ _physPos = 0;
553
+ const CExtent &e = Extents[0];
554
+ if (!e.IsEmpty())
555
+ _physPos = e.Phy << BlockSizeLog;
556
+ return SeekToPhys();
557
+ }
558
+
559
+ MY_UNKNOWN_IMP1(IInStream)
560
+
561
+ STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
562
+ STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
563
+ };
564
+
565
+ static size_t Lznt1Dec(Byte *dest, size_t outBufLim, size_t destLen, const Byte *src, size_t srcLen)
566
+ {
567
+ size_t destSize = 0;
568
+ while (destSize < destLen)
569
+ {
570
+ if (srcLen < 2 || (destSize & 0xFFF) != 0)
571
+ 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)
582
+ {
583
+ if (comprSize != (1 << 12))
584
+ break;
585
+ memcpy(dest + destSize, src, comprSize);
586
+ src += comprSize;
587
+ destSize += comprSize;
588
+ }
589
+ else
590
+ {
591
+ if (destSize + (1 << 12) > outBufLim || (src[0] & 1) != 0)
592
+ return 0;
593
+ int numDistBits = 4;
594
+ UInt32 sbOffset = 0;
595
+ UInt32 pos = 0;
596
+
597
+ do
598
+ {
599
+ comprSize--;
600
+ for (UInt32 mask = src[pos++] | 0x100; mask > 1 && comprSize > 0; mask >>= 1)
601
+ {
602
+ if ((mask & 1) == 0)
603
+ {
604
+ if (sbOffset >= (1 << 12))
605
+ return 0;
606
+ dest[destSize++] = src[pos++];
607
+ sbOffset++;
608
+ comprSize--;
609
+ }
610
+ else
611
+ {
612
+ if (comprSize < 2)
613
+ return 0;
614
+ UInt32 v = Get16(src + pos);
615
+ pos += 2;
616
+ comprSize -= 2;
617
+
618
+ while (((sbOffset - 1) >> numDistBits) != 0)
619
+ numDistBits++;
620
+
621
+ UInt32 len = (v & (0xFFFF >> numDistBits)) + 3;
622
+ if (sbOffset + len > (1 << 12))
623
+ return 0;
624
+ UInt32 dist = (v >> (16 - numDistBits));
625
+ if (dist >= sbOffset)
626
+ return 0;
627
+ Int32 offs = -1 - dist;
628
+ Byte *p = dest + destSize;
629
+ for (UInt32 t = 0; t < len; t++)
630
+ p[t] = p[t + offs];
631
+ destSize += len;
632
+ sbOffset += len;
633
+ }
634
+ }
635
+ }
636
+ while (comprSize > 0);
637
+ src += pos;
638
+ }
639
+ }
640
+ return destSize;
641
+ }
642
+
643
+ STDMETHODIMP CInStream::Read(void *data, UInt32 size, UInt32 *processedSize)
644
+ {
645
+ if (processedSize != NULL)
646
+ *processedSize = 0;
647
+ if (_virtPos >= Size)
648
+ return (Size == _virtPos) ? S_OK: E_FAIL;
649
+ if (size == 0)
650
+ return S_OK;
651
+ UInt64 rem = Size - _virtPos;
652
+ if (size > rem)
653
+ size = (UInt32)rem;
654
+ if (_virtPos >= InitializedSize)
655
+ {
656
+ memset((Byte *)data, 0, size);
657
+ _virtPos += size;
658
+ *processedSize = size;
659
+ return S_OK;
660
+ }
661
+ rem = InitializedSize - _virtPos;
662
+ if (size > rem)
663
+ size = (UInt32)rem;
664
+
665
+ while (_curRem == 0)
666
+ {
667
+ UInt64 cacheTag = _virtPos >> _chunkSizeLog;
668
+ UInt32 cacheIndex = (UInt32)cacheTag & (kNumCacheChunks - 1);
669
+ if (_tags[cacheIndex] == cacheTag)
670
+ {
671
+ UInt32 chunkSize = (UInt32)1 << _chunkSizeLog;
672
+ UInt32 offset = (UInt32)_virtPos & (chunkSize - 1);
673
+ UInt32 cur = MyMin(chunkSize - offset, size);
674
+ memcpy(data, _outBuf + (cacheIndex << _chunkSizeLog) + offset, cur);
675
+ *processedSize = cur;
676
+ _virtPos += cur;
677
+ return S_OK;
678
+ }
679
+
680
+ PRF2(printf("\nVirtPos = %6d", _virtPos));
681
+
682
+ UInt32 comprUnitSize = (UInt32)1 << CompressionUnit;
683
+ UInt64 virtBlock = _virtPos >> BlockSizeLog;
684
+ UInt64 virtBlock2 = virtBlock & ~((UInt64)comprUnitSize - 1);
685
+
686
+ int left = 0, right = Extents.Size();
687
+ for (;;)
688
+ {
689
+ int mid = (left + right) / 2;
690
+ if (mid == left)
691
+ break;
692
+ if (virtBlock2 < Extents[mid].Virt)
693
+ right = mid;
694
+ else
695
+ left = mid;
696
+ }
697
+
698
+ bool isCompressed = false;
699
+ UInt64 virtBlock2End = virtBlock2 + comprUnitSize;
700
+ if (CompressionUnit != 0)
701
+ for (int i = left; i < Extents.Size(); i++)
702
+ {
703
+ const CExtent &e = Extents[i];
704
+ if (e.Virt >= virtBlock2End)
705
+ break;
706
+ if (e.IsEmpty())
707
+ {
708
+ isCompressed = true;
709
+ break;
710
+ }
711
+ }
712
+
713
+ int i;
714
+ for (i = left; Extents[i + 1].Virt <= virtBlock; i++);
715
+
716
+ _sparseMode = false;
717
+ if (!isCompressed)
718
+ {
719
+ const CExtent &e = Extents[i];
720
+ UInt64 newPos = (e.Phy << BlockSizeLog) + _virtPos - (e.Virt << BlockSizeLog);
721
+ if (newPos != _physPos)
722
+ {
723
+ _physPos = newPos;
724
+ RINOK(SeekToPhys());
725
+ }
726
+ UInt64 next = Extents[i + 1].Virt;
727
+ if (next > virtBlock2End)
728
+ next &= ~((UInt64)comprUnitSize - 1);
729
+ next <<= BlockSizeLog;
730
+ if (next > Size)
731
+ next = Size;
732
+ _curRem = next - _virtPos;
733
+ break;
734
+ }
735
+ bool thereArePhy = false;
736
+ for (int i2 = left; i2 < Extents.Size(); i2++)
737
+ {
738
+ const CExtent &e = Extents[i2];
739
+ if (e.Virt >= virtBlock2End)
740
+ break;
741
+ if (!e.IsEmpty())
742
+ {
743
+ thereArePhy = true;
744
+ break;
745
+ }
746
+ }
747
+ if (!thereArePhy)
748
+ {
749
+ _curRem = (Extents[i + 1].Virt << BlockSizeLog) - _virtPos;
750
+ _sparseMode = true;
751
+ break;
752
+ }
753
+
754
+ size_t offs = 0;
755
+ UInt64 curVirt = virtBlock2;
756
+ for (i = left; i < Extents.Size(); i++)
757
+ {
758
+ const CExtent &e = Extents[i];
759
+ if (e.IsEmpty())
760
+ break;
761
+ if (e.Virt >= virtBlock2End)
762
+ return S_FALSE;
763
+ UInt64 newPos = (e.Phy + (curVirt - e.Virt)) << BlockSizeLog;
764
+ if (newPos != _physPos)
765
+ {
766
+ _physPos = newPos;
767
+ RINOK(SeekToPhys());
768
+ }
769
+ UInt64 numChunks = Extents[i + 1].Virt - curVirt;
770
+ if (curVirt + numChunks > virtBlock2End)
771
+ numChunks = virtBlock2End - curVirt;
772
+ size_t compressed = (size_t)numChunks << BlockSizeLog;
773
+ RINOK(ReadStream_FALSE(Stream, _inBuf + offs, compressed));
774
+ curVirt += numChunks;
775
+ _physPos += compressed;
776
+ offs += compressed;
777
+ }
778
+ size_t destLenMax = GetCuSize();
779
+ size_t destLen = destLenMax;
780
+ UInt64 rem = Size - (virtBlock2 << BlockSizeLog);
781
+ if (destLen > rem)
782
+ destLen = (size_t)rem;
783
+
784
+ Byte *dest = _outBuf + (cacheIndex << _chunkSizeLog);
785
+ size_t destSizeRes = Lznt1Dec(dest, destLenMax, destLen, _inBuf, offs);
786
+ _tags[cacheIndex] = cacheTag;
787
+
788
+ // some files in Vista have destSize > destLen
789
+ if (destSizeRes < destLen)
790
+ {
791
+ memset(dest, 0, destLenMax);
792
+ if (InUse)
793
+ return S_FALSE;
794
+ }
795
+ }
796
+ if (size > _curRem)
797
+ size = (UInt32)_curRem;
798
+ HRESULT res = S_OK;
799
+ if (_sparseMode)
800
+ memset(data, 0, size);
801
+ else
802
+ {
803
+ res = Stream->Read(data, size, &size);
804
+ _physPos += size;
805
+ }
806
+ if (processedSize != NULL)
807
+ *processedSize = size;
808
+ _virtPos += size;
809
+ _curRem -= size;
810
+ return res;
811
+ }
812
+
813
+ STDMETHODIMP CInStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition)
814
+ {
815
+ UInt64 newVirtPos = offset;
816
+ switch(seekOrigin)
817
+ {
818
+ case STREAM_SEEK_SET: break;
819
+ case STREAM_SEEK_CUR: newVirtPos += _virtPos; break;
820
+ case STREAM_SEEK_END: newVirtPos += Size; break;
821
+ default: return STG_E_INVALIDFUNCTION;
822
+ }
823
+ if (_virtPos != newVirtPos)
824
+ _curRem = 0;
825
+ _virtPos = newVirtPos;
826
+ 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;
859
+ return S_OK;
860
+ }
861
+
862
+ STDMETHODIMP CByteBufStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition)
863
+ {
864
+ switch(seekOrigin)
865
+ {
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;
870
+ }
871
+ if (newPosition)
872
+ *newPosition = _virtPos;
873
+ return S_OK;
874
+ }
875
+
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
+ const CAttr &attr0 = attrs[attrIndex];
884
+
885
+ if (attr0.AllocatedSize < attr0.Size ||
886
+ (attrs[attrIndexLim - 1].HighVcn + 1) != (attr0.AllocatedSize >> clusterSizeLog) ||
887
+ (attr0.AllocatedSize & ((1 << clusterSizeLog) - 1)) != 0)
888
+ return S_FALSE;
889
+
890
+ for (int i = attrIndex; i < attrIndexLim; i++)
891
+ if (!attrs[i].ParseExtents(Extents, numPhysClusters, attr0.CompressionUnit))
892
+ return S_FALSE;
893
+
894
+ UInt64 packSizeCalc = 0;
895
+ for (int k = 0; k < Extents.Size(); k++)
896
+ {
897
+ CExtent &e = Extents[k];
898
+ if (!e.IsEmpty())
899
+ packSizeCalc += (Extents[k + 1].Virt - e.Virt) << clusterSizeLog;
900
+ PRF2(printf("\nSize = %4I64X", Extents[k + 1].Virt - e.Virt));
901
+ PRF2(printf(" Pos = %4I64X", e.Phy));
902
+ }
903
+
904
+ if (attr0.CompressionUnit != 0)
905
+ {
906
+ if (packSizeCalc != attr0.PackSize)
907
+ return S_FALSE;
908
+ }
909
+ else
910
+ {
911
+ if (packSizeCalc != attr0.AllocatedSize)
912
+ return S_FALSE;
913
+ }
914
+ return S_OK;
915
+ }
916
+
917
+ struct CDataRef
918
+ {
919
+ int Start;
920
+ int Num;
921
+ };
922
+
923
+ static const UInt32 kMagic_FILE = 0x454c4946;
924
+ static const UInt32 kMagic_BAAD = 0x44414142;
925
+
926
+ struct CMftRec
927
+ {
928
+ UInt32 Magic;
929
+ // UInt64 Lsn;
930
+ UInt16 SeqNumber;
931
+ UInt16 Flags;
932
+ // UInt16 LinkCount;
933
+ // UInt16 NextAttrInstance;
934
+ CMftRef BaseMftRef;
935
+ // UInt32 ThisRecNumber;
936
+ UInt32 MyNumNameLinks;
937
+
938
+ CObjectVector<CAttr> DataAttrs;
939
+ CObjectVector<CFileNameAttr> FileNames;
940
+ CRecordVector<CDataRef> DataRefs;
941
+
942
+ CSiAttr SiAttr;
943
+
944
+ void MoveAttrsFrom(CMftRec &src)
945
+ {
946
+ DataAttrs += src.DataAttrs;
947
+ FileNames += src.FileNames;
948
+ src.DataAttrs.ClearAndFree();
949
+ src.FileNames.ClearAndFree();
950
+ }
951
+
952
+ UInt64 GetPackSize() const
953
+ {
954
+ UInt64 res = 0;
955
+ for (int i = 0; i < DataRefs.Size(); i++)
956
+ res += DataAttrs[DataRefs[i].Start].GetPackSize();
957
+ return res;
958
+ }
959
+
960
+ bool Parse(Byte *p, int sectorSizeLog, UInt32 numSectors, UInt32 recNumber, CObjectVector<CAttr> *attrs);
961
+
962
+ bool IsEmpty() const { return (Magic <= 2); }
963
+ bool IsFILE() const { return (Magic == kMagic_FILE); }
964
+ bool IsBAAD() const { return (Magic == kMagic_BAAD); }
965
+
966
+ bool InUse() const { return (Flags & 1) != 0; }
967
+ bool IsDir() const { return (Flags & 2) != 0; }
968
+
969
+ void ParseDataNames();
970
+ HRESULT GetStream(IInStream *mainStream, int dataIndex,
971
+ int clusterSizeLog, UInt64 numPhysClusters, IInStream **stream) const;
972
+ int GetNumExtents(int dataIndex, int clusterSizeLog, UInt64 numPhysClusters) const;
973
+
974
+ UInt64 GetSize(int dataIndex) const { return DataAttrs[DataRefs[dataIndex].Start].GetSize(); }
975
+
976
+ CMftRec(): MyNumNameLinks(0) {}
977
+ };
978
+
979
+ void CMftRec::ParseDataNames()
980
+ {
981
+ DataRefs.Clear();
982
+ DataAttrs.Sort(CompareAttr, 0);
983
+
984
+ for (int i = 0; i < DataAttrs.Size();)
985
+ {
986
+ CDataRef ref;
987
+ ref.Start = i;
988
+ for (i++; i < DataAttrs.Size(); i++)
989
+ if (DataAttrs[ref.Start].Name != DataAttrs[i].Name)
990
+ break;
991
+ ref.Num = i - ref.Start;
992
+ DataRefs.Add(ref);
993
+ }
994
+ }
995
+
996
+ HRESULT CMftRec::GetStream(IInStream *mainStream, int dataIndex,
997
+ int clusterSizeLog, UInt64 numPhysClusters, IInStream **destStream) const
998
+ {
999
+ *destStream = 0;
1000
+ CByteBufStream *streamSpec = new CByteBufStream;
1001
+ CMyComPtr<IInStream> streamTemp = streamSpec;
1002
+
1003
+ if (dataIndex < 0)
1004
+ return E_FAIL;
1005
+
1006
+ if (dataIndex < DataRefs.Size())
1007
+ {
1008
+ const CDataRef &ref = DataRefs[dataIndex];
1009
+ int numNonResident = 0;
1010
+ int i;
1011
+ for (i = ref.Start; i < ref.Start + ref.Num; i++)
1012
+ if (DataAttrs[i].NonResident)
1013
+ numNonResident++;
1014
+
1015
+ const CAttr &attr0 = DataAttrs[ref.Start];
1016
+
1017
+ if (numNonResident != 0 || ref.Num != 1)
1018
+ {
1019
+ if (numNonResident != ref.Num || !attr0.IsCompressionUnitSupported())
1020
+ 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();
1031
+ return S_OK;
1032
+ }
1033
+ streamSpec->Buf = attr0.Data;
1034
+ }
1035
+ streamSpec->Init();
1036
+ *destStream = streamTemp.Detach();
1037
+ return S_OK;
1038
+ }
1039
+
1040
+ int CMftRec::GetNumExtents(int dataIndex, int clusterSizeLog, UInt64 numPhysClusters) const
1041
+ {
1042
+ if (dataIndex < 0)
1043
+ return 0;
1044
+ {
1045
+ const CDataRef &ref = DataRefs[dataIndex];
1046
+ int numNonResident = 0;
1047
+ int i;
1048
+ for (i = ref.Start; i < ref.Start + ref.Num; i++)
1049
+ if (DataAttrs[i].NonResident)
1050
+ numNonResident++;
1051
+
1052
+ const CAttr &attr0 = DataAttrs[ref.Start];
1053
+
1054
+ if (numNonResident != 0 || ref.Num != 1)
1055
+ {
1056
+ if (numNonResident != ref.Num || !attr0.IsCompressionUnitSupported())
1057
+ return 0; // error;
1058
+ CRecordVector<CExtent> extents;
1059
+ if (DataParseExtents(clusterSizeLog, DataAttrs, ref.Start, ref.Start + ref.Num, numPhysClusters, extents) != S_OK)
1060
+ return 0; // error;
1061
+ return extents.Size() - 1;
1062
+ }
1063
+ // if (attr0.Data.GetCapacity() != 0)
1064
+ // return 1;
1065
+ return 0;
1066
+ }
1067
+ }
1068
+
1069
+ bool CMftRec::Parse(Byte *p, int sectorSizeLog, UInt32 numSectors, UInt32 recNumber,
1070
+ CObjectVector<CAttr> *attrs)
1071
+ {
1072
+ G32(p, Magic);
1073
+ if (!IsFILE())
1074
+ return IsEmpty() || IsBAAD();
1075
+
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
+
1085
+ UInt16 usn = Get16(p + usaOffset);
1086
+ // PRF(printf("\nusn = %d", usn));
1087
+ for (UInt32 i = 1; i < numUsaItems; i++)
1088
+ {
1089
+ void *pp = p + (i << sectorSizeLog) - 2;
1090
+ if (Get16(pp) != usn)
1091
+ return false;
1092
+ SetUi16(pp, Get16(p + usaOffset + i * 2));
1093
+ }
1094
+
1095
+ // G64(p + 0x08, Lsn);
1096
+ G16(p + 0x10, SeqNumber);
1097
+ // G16(p + 0x12, LinkCount);
1098
+ // PRF(printf(" L=%d", LinkCount));
1099
+ UInt32 attrOffs = Get16(p + 0x14);
1100
+ G16(p + 0x16, Flags);
1101
+ PRF(printf(" F=%4X", Flags));
1102
+
1103
+ UInt32 bytesInUse = Get32(p + 0x18);
1104
+ UInt32 bytesAlloc = Get32(p + 0x1C);
1105
+ G64(p + 0x20, BaseMftRef.Val);
1106
+ if (BaseMftRef.Val != 0)
1107
+ {
1108
+ PRF(printf(" BaseRef=%d", (int)BaseMftRef.Val));
1109
+ // return false; // Check it;
1110
+ }
1111
+ // G16(p + 0x28, NextAttrInstance);
1112
+ if (usaOffset >= 0x30)
1113
+ if (Get32(p + 0x2C) != recNumber) // NTFS 3.1+
1114
+ return false;
1115
+
1116
+ UInt32 limit = numSectors << sectorSizeLog;
1117
+ if (attrOffs >= limit || (attrOffs & 7) != 0 || bytesInUse > limit
1118
+ || bytesAlloc != limit)
1119
+ return false;
1120
+
1121
+
1122
+ for (UInt32 t = attrOffs; t < limit;)
1123
+ {
1124
+ CAttr attr;
1125
+ // PRF(printf("\n %2d:", Attrs.Size()));
1126
+ PRF(printf("\n"));
1127
+ UInt32 length = attr.Parse(p + t, limit - t);
1128
+ if (length == 0 || limit - t < length)
1129
+ return false;
1130
+ t += length;
1131
+ if (attr.Type == 0xFFFFFFFF)
1132
+ break;
1133
+ switch(attr.Type)
1134
+ {
1135
+ case ATTR_TYPE_FILE_NAME:
1136
+ {
1137
+ CFileNameAttr fna;
1138
+ if (!attr.ParseFileName(fna))
1139
+ return false;
1140
+ FileNames.Add(fna);
1141
+ PRF(printf(" flags = %4x", (int)fna.NameType));
1142
+ PRF(printf("\n %S", fna.Name));
1143
+ break;
1144
+ }
1145
+ case ATTR_TYPE_STANDARD_INFO:
1146
+ if (!attr.ParseSi(SiAttr))
1147
+ return false;
1148
+ break;
1149
+ case ATTR_TYPE_DATA:
1150
+ DataAttrs.Add(attr);
1151
+ break;
1152
+ default:
1153
+ if (attrs)
1154
+ attrs->Add(attr);
1155
+ break;
1156
+ }
1157
+ }
1158
+
1159
+ return true;
1160
+ }
1161
+
1162
+ struct CItem
1163
+ {
1164
+ int RecIndex;
1165
+ int DataIndex;
1166
+ CMftRef ParentRef;
1167
+ UString Name;
1168
+ UInt32 Attrib;
1169
+
1170
+ bool IsDir() const { return (DataIndex < 0); }
1171
+ };
1172
+
1173
+ struct CDatabase
1174
+ {
1175
+ CHeader Header;
1176
+ CObjectVector<CItem> Items;
1177
+ CObjectVector<CMftRec> Recs;
1178
+ CMyComPtr<IInStream> InStream;
1179
+ IArchiveOpenCallback *OpenCallback;
1180
+
1181
+ CByteBuffer ByteBuf;
1182
+
1183
+ CObjectVector<CAttr> VolAttrs;
1184
+
1185
+ ~CDatabase() { ClearAndClose(); }
1186
+
1187
+ void Clear();
1188
+ void ClearAndClose();
1189
+
1190
+ UString GetItemPath(Int32 index) const;
1191
+ HRESULT Open();
1192
+ HRESULT ReadDir(Int32 parent, UInt32 cluster, int level);
1193
+
1194
+ HRESULT SeekToCluster(UInt64 cluster);
1195
+
1196
+ int FindMtfRec(const CMftRef &ref) const
1197
+ {
1198
+ UInt64 val = ref.GetIndex();
1199
+ int left = 0, right = Items.Size();
1200
+ while (left != right)
1201
+ {
1202
+ int mid = (left + right) / 2;
1203
+ UInt64 midValue = Items[mid].RecIndex;
1204
+ if (val == midValue)
1205
+ return mid;
1206
+ if (val < midValue)
1207
+ right = mid;
1208
+ else
1209
+ left = mid + 1;
1210
+ }
1211
+ return -1;
1212
+ }
1213
+
1214
+ };
1215
+
1216
+ HRESULT CDatabase::SeekToCluster(UInt64 cluster)
1217
+ {
1218
+ return InStream->Seek(cluster << Header.ClusterSizeLog, STREAM_SEEK_SET, NULL);
1219
+ }
1220
+
1221
+ void CDatabase::Clear()
1222
+ {
1223
+ Items.Clear();
1224
+ Recs.Clear();
1225
+ }
1226
+
1227
+ void CDatabase::ClearAndClose()
1228
+ {
1229
+ Clear();
1230
+ InStream.Release();
1231
+ }
1232
+
1233
+ #define MY_DIR_PREFIX(x) L"[" x L"]" WSTRING_PATH_SEPARATOR
1234
+
1235
+ UString CDatabase::GetItemPath(Int32 index) const
1236
+ {
1237
+ 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;
1251
+ }
1252
+
1253
+ HRESULT CDatabase::Open()
1254
+ {
1255
+ 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
+
1267
+ SeekToCluster(Header.MftCluster);
1268
+
1269
+ CMftRec mftRec;
1270
+ UInt32 numSectorsInRec;
1271
+ int recSizeLog;
1272
+ CMyComPtr<IInStream> mftStream;
1273
+ {
1274
+ UInt32 blockSize = 1 << 12;
1275
+ ByteBuf.SetCapacity(blockSize);
1276
+ 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);
1283
+ if (!mftRec.Parse(ByteBuf, Header.SectorSizeLog, numSectorsInRec, NULL, 0))
1284
+ return S_FALSE;
1285
+ if (!mftRec.IsFILE())
1286
+ return S_FALSE;
1287
+ mftRec.ParseDataNames();
1288
+ if (mftRec.DataRefs.IsEmpty())
1289
+ return S_FALSE;
1290
+ RINOK(mftRec.GetStream(InStream, 0, Header.ClusterSizeLog, Header.NumClusters, &mftStream));
1291
+ if (!mftStream)
1292
+ return S_FALSE;
1293
+ }
1294
+
1295
+ UInt64 mftSize = mftRec.DataAttrs[0].Size;
1296
+ if ((mftSize >> 4) > Header.GetPhySize())
1297
+ return S_FALSE;
1298
+
1299
+ UInt64 numFiles = mftSize >> recSizeLog;
1300
+ if (numFiles > (1 << 30))
1301
+ return S_FALSE;
1302
+ if (OpenCallback)
1303
+ {
1304
+ RINOK(OpenCallback->SetTotal(&numFiles, &mftSize));
1305
+ }
1306
+ const UInt32 kBufSize = (1 << 15);
1307
+ if (kBufSize < (1 << recSizeLog))
1308
+ return S_FALSE;
1309
+
1310
+ ByteBuf.SetCapacity((size_t)kBufSize);
1311
+ Recs.Reserve((int)numFiles);
1312
+ for (UInt64 pos64 = 0;;)
1313
+ {
1314
+ if (OpenCallback)
1315
+ {
1316
+ UInt64 numFiles = Recs.Size();
1317
+ if ((numFiles & 0x3FF) == 0)
1318
+ {
1319
+ RINOK(OpenCallback->SetCompleted(&numFiles, &pos64));
1320
+ }
1321
+ }
1322
+ UInt32 readSize = kBufSize;
1323
+ UInt64 rem = mftSize - pos64;
1324
+ if (readSize > rem)
1325
+ readSize = (UInt32)rem;
1326
+ if (readSize < ((UInt32)1 << recSizeLog))
1327
+ break;
1328
+ RINOK(ReadStream_FALSE(mftStream, ByteBuf, (size_t)readSize));
1329
+ pos64 += readSize;
1330
+ for (int i = 0; ((UInt32)(i + 1) << recSizeLog) <= readSize; i++)
1331
+ {
1332
+ PRF(printf("\n---------------------"));
1333
+ PRF(printf("\n%5d:", Recs.Size()));
1334
+ Byte *p = ByteBuf + ((UInt32)i << recSizeLog);
1335
+ CMftRec rec;
1336
+ if (!rec.Parse(p, Header.SectorSizeLog, numSectorsInRec, (UInt32)Recs.Size(),
1337
+ (Recs.Size() == kRecIndex_Volume) ? &VolAttrs: NULL))
1338
+ return S_FALSE;
1339
+ Recs.Add(rec);
1340
+ }
1341
+ }
1342
+
1343
+ int i;
1344
+ for (i = 0; i < Recs.Size(); i++)
1345
+ {
1346
+ CMftRec &rec = Recs[i];
1347
+ if (!rec.BaseMftRef.IsBaseItself())
1348
+ {
1349
+ UInt64 refIndex = rec.BaseMftRef.GetIndex();
1350
+ if (refIndex > (UInt32)Recs.Size())
1351
+ return S_FALSE;
1352
+ CMftRec &refRec = Recs[(int)refIndex];
1353
+ bool moveAttrs = (refRec.SeqNumber == rec.BaseMftRef.GetNumber() && refRec.BaseMftRef.IsBaseItself());
1354
+ if (rec.InUse() && refRec.InUse())
1355
+ {
1356
+ if (!moveAttrs)
1357
+ return S_FALSE;
1358
+ }
1359
+ else if (rec.InUse() || refRec.InUse())
1360
+ moveAttrs = false;
1361
+ if (moveAttrs)
1362
+ refRec.MoveAttrsFrom(rec);
1363
+ }
1364
+ }
1365
+
1366
+ for (i = 0; i < Recs.Size(); i++)
1367
+ Recs[i].ParseDataNames();
1368
+
1369
+ for (i = 0; i < Recs.Size(); i++)
1370
+ {
1371
+ CMftRec &rec = Recs[i];
1372
+ if (!rec.IsFILE() || !rec.BaseMftRef.IsBaseItself())
1373
+ continue;
1374
+ int numNames = 0;
1375
+ // printf("\n%4d: ", i);
1376
+ for (int t = 0; t < rec.FileNames.Size(); t++)
1377
+ {
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();
1383
+
1384
+ // For hard linked files we show substreams only for first Name.
1385
+ if (numDatas > 1 && numNames > 0)
1386
+ numDatas = 1;
1387
+ numNames++;
1388
+
1389
+ if (rec.IsDir())
1390
+ {
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);
1399
+ }
1400
+ for (int di = 0; di < numDatas; di++)
1401
+ {
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())
1407
+ {
1408
+ // $BadClus:$Bad is sparse file for all clusters. So we skip it.
1409
+ if (i == kRecIndex_BadClus && subName == L"$Bad")
1410
+ continue;
1411
+ item.Name += L":";
1412
+ item.Name += subName;
1413
+ item.Attrib = fna.Attrib;
1414
+ }
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
+
1424
+ Items.Add(item);
1425
+ rec.MyNumNameLinks++;
1426
+ }
1427
+ }
1428
+ rec.FileNames.ClearAndFree();
1429
+ }
1430
+
1431
+ return S_OK;
1432
+ }
1433
+
1434
+ class CHandler:
1435
+ public IInArchive,
1436
+ public IInArchiveGetStream,
1437
+ public CMyUnknownImp,
1438
+ CDatabase
1439
+ {
1440
+ public:
1441
+ MY_UNKNOWN_IMP2(IInArchive, IInArchiveGetStream)
1442
+ INTERFACE_IInArchive(;)
1443
+ STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **stream);
1444
+ };
1445
+
1446
+ STDMETHODIMP CHandler::GetStream(UInt32 index, ISequentialInStream **stream)
1447
+ {
1448
+ COM_TRY_BEGIN
1449
+ IInStream *stream2;
1450
+ const CItem &item = Items[index];
1451
+ const CMftRec &rec = Recs[item.RecIndex];
1452
+ HRESULT res = rec.GetStream(InStream, item.DataIndex, Header.ClusterSizeLog, Header.NumClusters, &stream2);
1453
+ *stream = (ISequentialInStream *)stream2;
1454
+ return res;
1455
+ COM_TRY_END
1456
+ }
1457
+
1458
+ static const STATPROPSTG kProps[] =
1459
+ {
1460
+ { NULL, kpidPath, VT_BSTR},
1461
+ { NULL, kpidIsDir, VT_BOOL},
1462
+ { NULL, kpidSize, VT_UI8},
1463
+ { NULL, kpidPackSize, VT_UI8},
1464
+ { NULL, kpidMTime, VT_FILETIME},
1465
+ { NULL, kpidCTime, VT_FILETIME},
1466
+ { NULL, kpidATime, VT_FILETIME},
1467
+ { NULL, kpidAttrib, VT_UI4},
1468
+ { NULL, kpidLinks, VT_UI4},
1469
+ { NULL, kpidNumBlocks, VT_UI4}
1470
+ };
1471
+
1472
+ static const STATPROPSTG kArcProps[] =
1473
+ {
1474
+ { NULL, kpidVolumeName, VT_BSTR},
1475
+ { NULL, kpidFileSystem, VT_BSTR},
1476
+ { NULL, kpidClusterSize, VT_UI4},
1477
+ { NULL, kpidPhySize, VT_UI8},
1478
+ { NULL, kpidHeadersSize, VT_UI8},
1479
+ { NULL, kpidCTime, VT_FILETIME},
1480
+
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}
1486
+ };
1487
+
1488
+ IMP_IInArchive_Props
1489
+ IMP_IInArchive_ArcProps
1490
+
1491
+ static void NtfsTimeToProp(UInt64 t, NWindows::NCOM::CPropVariant &prop)
1492
+ {
1493
+ FILETIME ft;
1494
+ ft.dwLowDateTime = (DWORD)t;
1495
+ ft.dwHighDateTime = (DWORD)(t >> 32);
1496
+ prop = ft;
1497
+ }
1498
+
1499
+ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
1500
+ {
1501
+ COM_TRY_BEGIN
1502
+ NWindows::NCOM::CPropVariant prop;
1503
+
1504
+ const CMftRec *volRec = (Recs.Size() > kRecIndex_Volume ? &Recs[kRecIndex_Volume] : NULL);
1505
+
1506
+ switch(propID)
1507
+ {
1508
+ case kpidClusterSize: prop = Header.ClusterSize(); break;
1509
+ case kpidPhySize: prop = Header.GetPhySize(); break;
1510
+ /*
1511
+ case kpidHeadersSize:
1512
+ {
1513
+ UInt64 val = 0;
1514
+ for (int i = 0; i < kNumSysRecs; i++)
1515
+ {
1516
+ printf("\n%2d: %8I64d ", i, Recs[i].GetPackSize());
1517
+ if (i == 8)
1518
+ i = i
1519
+ val += Recs[i].GetPackSize();
1520
+ }
1521
+ prop = val;
1522
+ break;
1523
+ }
1524
+ */
1525
+ case kpidCTime: if (volRec) NtfsTimeToProp(volRec->SiAttr.CTime, prop); break;break;
1526
+ case kpidVolumeName:
1527
+ {
1528
+ for (int i = 0; i < VolAttrs.Size(); i++)
1529
+ {
1530
+ const CAttr &attr = VolAttrs[i];
1531
+ if (attr.Type == ATTR_TYPE_VOLUME_NAME)
1532
+ {
1533
+ UString name;
1534
+ GetString(attr.Data, (int)attr.Data.GetCapacity() / 2, name);
1535
+ prop = name;
1536
+ break;
1537
+ }
1538
+ }
1539
+ break;
1540
+ }
1541
+ case kpidFileSystem:
1542
+ {
1543
+ AString s = "NTFS";
1544
+ for (int i = 0; i < VolAttrs.Size(); i++)
1545
+ {
1546
+ const CAttr &attr = VolAttrs[i];
1547
+ if (attr.Type == ATTR_TYPE_VOLUME_INFO)
1548
+ {
1549
+ CVolInfo vi;
1550
+ if (attr.ParseVolInfo(vi))
1551
+ {
1552
+ s += ' ';
1553
+ char temp[16];
1554
+ ConvertUInt32ToString(vi.MajorVer, temp);
1555
+ s += temp;
1556
+ s += '.';
1557
+ ConvertUInt32ToString(vi.MinorVer, temp);
1558
+ s += temp;
1559
+ }
1560
+ break;
1561
+ }
1562
+ }
1563
+ prop = s;
1564
+ break;
1565
+ }
1566
+ case kpidSectorSize: prop = (UInt32)1 << Header.SectorSizeLog; break;
1567
+ case kpidId: prop = Header.SerialNumber; break;
1568
+ // case kpidMediaType: prop = Header.MediaType; break;
1569
+ // case kpidSectorsPerTrack: prop = Header.SectorsPerTrack; break;
1570
+ // case kpidNumHeads: prop = Header.NumHeads; break;
1571
+ // case kpidHiddenSectors: prop = Header.NumHiddenSectors; break;
1572
+ }
1573
+ prop.Detach(value);
1574
+ return S_OK;
1575
+ COM_TRY_END
1576
+ }
1577
+
1578
+ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
1579
+ {
1580
+ COM_TRY_BEGIN
1581
+ NWindows::NCOM::CPropVariant prop;
1582
+ const CItem &item = Items[index];
1583
+ const CMftRec &rec = Recs[item.RecIndex];
1584
+
1585
+ const CAttr *data= NULL;
1586
+ if (item.DataIndex >= 0)
1587
+ data = &rec.DataAttrs[rec.DataRefs[item.DataIndex].Start];
1588
+
1589
+ switch(propID)
1590
+ {
1591
+ case kpidPath:
1592
+ {
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;
1602
+ break;
1603
+ }
1604
+
1605
+ case kpidIsDir: prop = item.IsDir(); break;
1606
+ case kpidMTime: NtfsTimeToProp(rec.SiAttr.MTime, prop); break;
1607
+
1608
+ case kpidCTime: NtfsTimeToProp(rec.SiAttr.CTime, prop); break;
1609
+ case kpidATime: NtfsTimeToProp(rec.SiAttr.ATime, prop); break;
1610
+ case kpidAttrib:
1611
+ prop = item.Attrib;
1612
+ 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;
1616
+ case kpidNumBlocks: if (data) prop = (UInt32)rec.GetNumExtents(item.DataIndex, Header.ClusterSizeLog, Header.NumClusters); break;
1617
+ }
1618
+ prop.Detach(value);
1619
+ return S_OK;
1620
+ COM_TRY_END
1621
+ }
1622
+
1623
+ STDMETHODIMP CHandler::Open(IInStream *stream, const UInt64 *, IArchiveOpenCallback *callback)
1624
+ {
1625
+ COM_TRY_BEGIN
1626
+ {
1627
+ OpenCallback = callback;
1628
+ InStream = stream;
1629
+ HRESULT res;
1630
+ try
1631
+ {
1632
+ res = CDatabase::Open();
1633
+ if (res == S_OK)
1634
+ return S_OK;
1635
+ }
1636
+ catch(...)
1637
+ {
1638
+ Close();
1639
+ throw;
1640
+ }
1641
+ Close();
1642
+ return res;
1643
+ }
1644
+ COM_TRY_END
1645
+ }
1646
+
1647
+ STDMETHODIMP CHandler::Close()
1648
+ {
1649
+ ClearAndClose();
1650
+ return S_OK;
1651
+ }
1652
+
1653
+ STDMETHODIMP CHandler::Extract(const UInt32 *indices, UInt32 numItems,
1654
+ Int32 testMode, IArchiveExtractCallback *extractCallback)
1655
+ {
1656
+ COM_TRY_BEGIN
1657
+ bool allFilesMode = (numItems == (UInt32)-1);
1658
+ if (allFilesMode)
1659
+ numItems = Items.Size();
1660
+ if (numItems == 0)
1661
+ return S_OK;
1662
+ UInt32 i;
1663
+ UInt64 totalSize = 0;
1664
+ for (i = 0; i < numItems; i++)
1665
+ {
1666
+ const CItem &item = Items[allFilesMode ? i : indices[i]];
1667
+ const CMftRec &rec = Recs[item.RecIndex];
1668
+ if (!rec.IsDir())
1669
+ totalSize += rec.GetSize(item.DataIndex);
1670
+ }
1671
+ RINOK(extractCallback->SetTotal(totalSize));
1672
+
1673
+ UInt64 totalPackSize;
1674
+ totalSize = totalPackSize = 0;
1675
+
1676
+ CByteBuffer buf;
1677
+ UInt32 clusterSize = Header.ClusterSize();
1678
+ buf.SetCapacity(clusterSize);
1679
+
1680
+ NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder();
1681
+ CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;
1682
+
1683
+ CLocalProgress *lps = new CLocalProgress;
1684
+ CMyComPtr<ICompressProgressInfo> progress = lps;
1685
+ lps->Init(extractCallback, false);
1686
+
1687
+ CDummyOutStream *outStreamSpec = new CDummyOutStream;
1688
+ CMyComPtr<ISequentialOutStream> outStream(outStreamSpec);
1689
+
1690
+ for (i = 0; i < numItems; i++)
1691
+ {
1692
+ lps->InSize = totalPackSize;
1693
+ lps->OutSize = totalSize;
1694
+ RINOK(lps->SetCur());
1695
+ CMyComPtr<ISequentialOutStream> realOutStream;
1696
+ Int32 askMode = testMode ?
1697
+ NExtract::NAskMode::kTest :
1698
+ NExtract::NAskMode::kExtract;
1699
+ Int32 index = allFilesMode ? i : indices[i];
1700
+ RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
1701
+
1702
+ const CItem &item = Items[index];
1703
+ if (item.IsDir())
1704
+ {
1705
+ RINOK(extractCallback->PrepareOperation(askMode));
1706
+ RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kOK));
1707
+ continue;
1708
+ }
1709
+
1710
+ if (!testMode && !realOutStream)
1711
+ continue;
1712
+ RINOK(extractCallback->PrepareOperation(askMode));
1713
+
1714
+ outStreamSpec->SetStream(realOutStream);
1715
+ realOutStream.Release();
1716
+ outStreamSpec->Init();
1717
+
1718
+ const CMftRec &rec = Recs[item.RecIndex];
1719
+ const CAttr &data = rec.DataAttrs[rec.DataRefs[item.DataIndex].Start];
1720
+
1721
+ int res = NExtract::NOperationResult::kDataError;
1722
+ {
1723
+ CMyComPtr<IInStream> inStream;
1724
+ HRESULT hres = rec.GetStream(InStream, item.DataIndex, Header.ClusterSizeLog, Header.NumClusters, &inStream);
1725
+ if (hres == S_FALSE)
1726
+ res = NExtract::NOperationResult::kUnSupportedMethod;
1727
+ else
1728
+ {
1729
+ RINOK(hres);
1730
+ if (inStream)
1731
+ {
1732
+ HRESULT hres = copyCoder->Code(inStream, outStream, NULL, NULL, progress);
1733
+ if (hres != S_OK && hres != S_FALSE)
1734
+ {
1735
+ RINOK(hres);
1736
+ }
1737
+ if (/* copyCoderSpec->TotalSize == item.GetSize() && */ hres == S_OK)
1738
+ res = NExtract::NOperationResult::kOK;
1739
+ }
1740
+ }
1741
+ }
1742
+ totalPackSize += data.GetPackSize();
1743
+ totalSize += data.GetSize();
1744
+ outStreamSpec->ReleaseStream();
1745
+ RINOK(extractCallback->SetOperationResult(res));
1746
+ }
1747
+ return S_OK;
1748
+ COM_TRY_END
1749
+ }
1750
+
1751
+ STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
1752
+ {
1753
+ *numItems = Items.Size();
1754
+ return S_OK;
1755
+ }
1756
+
1757
+ static IInArchive *CreateArc() { return new CHandler; }
1758
+
1759
+ static CArcInfo g_ArcInfo =
1760
+ { L"NTFS", L"ntfs img", 0, 0xD9, { 'N', 'T', 'F', 'S', ' ', ' ', ' ', ' ', 0 }, 9, false, CreateArc, 0 };
1761
+
1762
+ REGISTER_ARC(Fat)
1763
+
1764
+ }}