Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/kornelski/7z.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/CPP/7zip
diff options
context:
space:
mode:
Diffstat (limited to 'CPP/7zip')
-rwxr-xr-xCPP/7zip/Archive/7z/7z.dsp640
-rwxr-xr-xCPP/7zip/Archive/7z/7z.dsw29
-rwxr-xr-xCPP/7zip/Archive/7z/7zCompressionMode.h2
-rwxr-xr-xCPP/7zip/Archive/7z/7zDecode.cpp49
-rwxr-xr-xCPP/7zip/Archive/7z/7zDecode.h4
-rwxr-xr-xCPP/7zip/Archive/7z/7zEncode.cpp8
-rwxr-xr-xCPP/7zip/Archive/7z/7zExtract.cpp92
-rwxr-xr-xCPP/7zip/Archive/7z/7zFolderInStream.cpp2
-rwxr-xr-xCPP/7zip/Archive/7z/7zFolderInStream.h6
-rwxr-xr-xCPP/7zip/Archive/7z/7zFolderOutStream.cpp33
-rwxr-xr-xCPP/7zip/Archive/7z/7zFolderOutStream.h4
-rwxr-xr-xCPP/7zip/Archive/7z/7zHandler.cpp419
-rwxr-xr-xCPP/7zip/Archive/7z/7zHandler.h43
-rwxr-xr-xCPP/7zip/Archive/7z/7zHandlerOut.cpp207
-rwxr-xr-xCPP/7zip/Archive/7z/7zHeader.cpp6
-rwxr-xr-xCPP/7zip/Archive/7z/7zHeader.h17
-rwxr-xr-xCPP/7zip/Archive/7z/7zIn.cpp493
-rwxr-xr-xCPP/7zip/Archive/7z/7zIn.h46
-rwxr-xr-xCPP/7zip/Archive/7z/7zItem.h208
-rwxr-xr-xCPP/7zip/Archive/7z/7zOut.cpp866
-rwxr-xr-xCPP/7zip/Archive/7z/7zOut.h133
-rwxr-xr-xCPP/7zip/Archive/7z/7zProperties.cpp30
-rwxr-xr-xCPP/7zip/Archive/7z/7zProperties.h2
-rwxr-xr-xCPP/7zip/Archive/7z/7zSpecStream.cpp2
-rwxr-xr-xCPP/7zip/Archive/7z/7zSpecStream.h2
-rwxr-xr-xCPP/7zip/Archive/7z/7zUpdate.cpp498
-rwxr-xr-xCPP/7zip/Archive/7z/7zUpdate.h52
-rwxr-xr-xCPP/7zip/Archive/7z/makefile111
-rwxr-xr-xCPP/7zip/Archive/7z/resource.rc11
-rwxr-xr-xCPP/7zip/Archive/ArchiveExports.cpp10
-rwxr-xr-xCPP/7zip/Archive/Arj/ArjHandler.cpp311
-rwxr-xr-xCPP/7zip/Archive/Arj/ArjHeader.h121
-rwxr-xr-xCPP/7zip/Archive/Arj/ArjIn.cpp287
-rwxr-xr-xCPP/7zip/Archive/Arj/ArjIn.h75
-rwxr-xr-xCPP/7zip/Archive/Arj/ArjItem.h75
-rwxr-xr-xCPP/7zip/Archive/Arj/ArjRegister.cpp13
-rwxr-xr-xCPP/7zip/Archive/Arj/StdAfx.cpp3
-rwxr-xr-xCPP/7zip/Archive/ArjHandler.cpp792
-rwxr-xr-xCPP/7zip/Archive/BZip2/BZip2Handler.cpp8
-rwxr-xr-xCPP/7zip/Archive/BZip2/BZip2Handler.h10
-rwxr-xr-xCPP/7zip/Archive/BZip2/BZip2HandlerOut.cpp16
-rwxr-xr-xCPP/7zip/Archive/BZip2/BZip2Update.cpp6
-rwxr-xr-xCPP/7zip/Archive/BZip2/StdAfx.cpp3
-rwxr-xr-xCPP/7zip/Archive/Cab/CabBlockInStream.cpp8
-rwxr-xr-xCPP/7zip/Archive/Cab/CabBlockInStream.h2
-rwxr-xr-xCPP/7zip/Archive/Cab/CabHandler.cpp92
-rwxr-xr-xCPP/7zip/Archive/Cab/CabHandler.h2
-rwxr-xr-xCPP/7zip/Archive/Cab/CabHeader.cpp8
-rwxr-xr-xCPP/7zip/Archive/Cab/CabHeader.h8
-rwxr-xr-xCPP/7zip/Archive/Cab/CabIn.cpp61
-rwxr-xr-xCPP/7zip/Archive/Cab/CabIn.h8
-rwxr-xr-xCPP/7zip/Archive/Cab/CabItem.h23
-rwxr-xr-xCPP/7zip/Archive/Cab/StdAfx.cpp3
-rwxr-xr-xCPP/7zip/Archive/Chm/ChmHandler.cpp73
-rwxr-xr-xCPP/7zip/Archive/Chm/ChmHandler.h2
-rwxr-xr-xCPP/7zip/Archive/Chm/ChmHeader.cpp8
-rwxr-xr-xCPP/7zip/Archive/Chm/ChmIn.cpp96
-rwxr-xr-xCPP/7zip/Archive/Chm/ChmIn.h48
-rwxr-xr-xCPP/7zip/Archive/Chm/StdAfx.cpp3
-rwxr-xr-xCPP/7zip/Archive/Com/ComHandler.cpp36
-rwxr-xr-xCPP/7zip/Archive/Com/ComHandler.h2
-rwxr-xr-xCPP/7zip/Archive/Com/ComIn.cpp12
-rwxr-xr-xCPP/7zip/Archive/Com/ComIn.h4
-rwxr-xr-xCPP/7zip/Archive/Common/CoderMixer.cpp2
-rwxr-xr-xCPP/7zip/Archive/Common/CoderMixer2.cpp6
-rwxr-xr-xCPP/7zip/Archive/Common/CoderMixer2.h4
-rwxr-xr-xCPP/7zip/Archive/Common/CoderMixer2MT.cpp18
-rwxr-xr-xCPP/7zip/Archive/Common/CoderMixer2MT.h6
-rwxr-xr-xCPP/7zip/Archive/Common/CoderMixer2ST.cpp24
-rwxr-xr-xCPP/7zip/Archive/Common/CoderMixer2ST.h18
-rwxr-xr-xCPP/7zip/Archive/Common/CoderMixerMT.cpp10
-rwxr-xr-xCPP/7zip/Archive/Common/CoderMixerMT.h4
-rwxr-xr-xCPP/7zip/Archive/Common/CrossThreadProgress.h2
-rwxr-xr-xCPP/7zip/Archive/Common/DummyOutStream.h3
-rwxr-xr-xCPP/7zip/Archive/Common/FindSignature.cpp62
-rwxr-xr-xCPP/7zip/Archive/Common/FindSignature.h12
-rwxr-xr-xCPP/7zip/Archive/Common/HandlerOut.cpp134
-rwxr-xr-xCPP/7zip/Archive/Common/HandlerOut.h13
-rwxr-xr-xCPP/7zip/Archive/Common/InStreamWithCRC.h8
-rwxr-xr-xCPP/7zip/Archive/Common/ItemNameUtils.cpp2
-rwxr-xr-xCPP/7zip/Archive/Common/MultiStream.cpp10
-rwxr-xr-xCPP/7zip/Archive/Common/MultiStream.h4
-rwxr-xr-xCPP/7zip/Archive/Common/OutStreamWithCRC.h6
-rwxr-xr-xCPP/7zip/Archive/Common/OutStreamWithSha1.h2
-rwxr-xr-xCPP/7zip/Archive/Common/ParseProperties.cpp4
-rwxr-xr-xCPP/7zip/Archive/Cpio/CpioHandler.cpp71
-rwxr-xr-xCPP/7zip/Archive/Cpio/CpioHandler.h2
-rwxr-xr-xCPP/7zip/Archive/Cpio/CpioHeader.cpp2
-rwxr-xr-xCPP/7zip/Archive/Cpio/CpioHeader.h4
-rwxr-xr-xCPP/7zip/Archive/Cpio/CpioIn.cpp14
-rwxr-xr-xCPP/7zip/Archive/Cpio/CpioItem.h2
-rwxr-xr-xCPP/7zip/Archive/Cpio/StdAfx.cpp3
-rwxr-xr-xCPP/7zip/Archive/Deb/DebHandler.cpp202
-rwxr-xr-xCPP/7zip/Archive/Deb/DebHeader.cpp13
-rwxr-xr-xCPP/7zip/Archive/Deb/DebHeader.h38
-rwxr-xr-xCPP/7zip/Archive/Deb/DebIn.cpp156
-rwxr-xr-xCPP/7zip/Archive/Deb/DebIn.h28
-rwxr-xr-xCPP/7zip/Archive/Deb/DebItem.h32
-rwxr-xr-xCPP/7zip/Archive/Deb/DebRegister.cpp13
-rwxr-xr-xCPP/7zip/Archive/Deb/StdAfx.cpp3
-rwxr-xr-xCPP/7zip/Archive/Deb/StdAfx.h8
-rwxr-xr-xCPP/7zip/Archive/DebHandler.cpp411
-rwxr-xr-xCPP/7zip/Archive/DllExports.cpp4
-rwxr-xr-xCPP/7zip/Archive/DllExports2.cpp10
-rwxr-xr-xCPP/7zip/Archive/DmgHandler.cpp778
-rwxr-xr-xCPP/7zip/Archive/ElfHandler.cpp543
-rwxr-xr-xCPP/7zip/Archive/GZip/GZipHandler.cpp56
-rwxr-xr-xCPP/7zip/Archive/GZip/GZipHandler.h4
-rwxr-xr-xCPP/7zip/Archive/GZip/GZipHandlerOut.cpp46
-rwxr-xr-xCPP/7zip/Archive/GZip/GZipHeader.cpp2
-rwxr-xr-xCPP/7zip/Archive/GZip/GZipHeader.h12
-rwxr-xr-xCPP/7zip/Archive/GZip/GZipIn.cpp6
-rwxr-xr-xCPP/7zip/Archive/GZip/GZipItem.h2
-rwxr-xr-xCPP/7zip/Archive/GZip/GZipRegister.cpp2
-rwxr-xr-xCPP/7zip/Archive/GZip/GZipUpdate.cpp23
-rwxr-xr-xCPP/7zip/Archive/GZip/GZipUpdate.h2
-rwxr-xr-xCPP/7zip/Archive/GZip/StdAfx.cpp3
-rwxr-xr-xCPP/7zip/Archive/Hfs/HfsHandler.cpp244
-rwxr-xr-xCPP/7zip/Archive/Hfs/HfsHandler.h (renamed from CPP/7zip/Archive/Arj/ArjHandler.h)19
-rwxr-xr-xCPP/7zip/Archive/Hfs/HfsIn.cpp480
-rwxr-xr-xCPP/7zip/Archive/Hfs/HfsIn.h154
-rwxr-xr-xCPP/7zip/Archive/Hfs/HfsRegister.cpp13
-rwxr-xr-xCPP/7zip/Archive/IArchive.h73
-rwxr-xr-xCPP/7zip/Archive/Icons/7z.ico (renamed from CPP/7zip/Archive/7z/7z.ico)bin4710 -> 4710 bytes
-rwxr-xr-xCPP/7zip/Archive/Icons/arj.ico (renamed from CPP/7zip/Archive/Arj/arj.ico)bin3638 -> 3638 bytes
-rwxr-xr-xCPP/7zip/Archive/Icons/bz2.ico (renamed from CPP/7zip/Archive/BZip2/bz2.ico)bin3638 -> 3638 bytes
-rwxr-xr-xCPP/7zip/Archive/Icons/cab.ico (renamed from CPP/7zip/Archive/Cab/cab.ico)bin3638 -> 3638 bytes
-rwxr-xr-xCPP/7zip/Archive/Icons/cpio.ico (renamed from CPP/7zip/Archive/Cpio/cpio.ico)bin3638 -> 3638 bytes
-rwxr-xr-xCPP/7zip/Archive/Icons/deb.ico (renamed from CPP/7zip/Archive/Deb/deb.ico)bin3638 -> 3638 bytes
-rwxr-xr-xCPP/7zip/Archive/Icons/dmg.icobin0 -> 3638 bytes
-rwxr-xr-xCPP/7zip/Archive/Icons/gz.ico (renamed from CPP/7zip/Archive/GZip/gz.ico)bin3638 -> 3638 bytes
-rwxr-xr-xCPP/7zip/Archive/Icons/hfs.icobin0 -> 3638 bytes
-rwxr-xr-xCPP/7zip/Archive/Icons/iso.ico (renamed from CPP/7zip/Archive/Iso/Iso.ico)bin3638 -> 3638 bytes
-rwxr-xr-xCPP/7zip/Archive/Icons/lzh.ico (renamed from CPP/7zip/Archive/Lzh/lzh.ico)bin3638 -> 3638 bytes
-rwxr-xr-xCPP/7zip/Archive/Icons/lzma.ico (renamed from CPP/7zip/Archive/Lzma/lzma.ico)bin3638 -> 3638 bytes
-rwxr-xr-xCPP/7zip/Archive/Icons/rar.ico (renamed from CPP/7zip/Archive/Rar/rar.ico)bin3638 -> 3638 bytes
-rwxr-xr-xCPP/7zip/Archive/Icons/rpm.ico (renamed from CPP/7zip/Archive/RPM/rpm.ico)bin3638 -> 3638 bytes
-rwxr-xr-xCPP/7zip/Archive/Icons/split.ico (renamed from CPP/7zip/Archive/Split/Split.ico)bin3638 -> 3638 bytes
-rwxr-xr-xCPP/7zip/Archive/Icons/tar.ico (renamed from CPP/7zip/Archive/Tar/tar.ico)bin3638 -> 3638 bytes
-rwxr-xr-xCPP/7zip/Archive/Icons/wim.ico (renamed from CPP/7zip/Archive/Wim/wim.ico)bin3638 -> 3638 bytes
-rwxr-xr-xCPP/7zip/Archive/Icons/xar.icobin0 -> 3638 bytes
-rwxr-xr-xCPP/7zip/Archive/Icons/z.ico (renamed from CPP/7zip/Archive/Z/Z.ico)bin3638 -> 3638 bytes
-rwxr-xr-xCPP/7zip/Archive/Icons/zip.ico (renamed from CPP/7zip/Archive/Zip/zip.ico)bin3638 -> 3638 bytes
-rwxr-xr-xCPP/7zip/Archive/Iso/IsoHandler.cpp24
-rwxr-xr-xCPP/7zip/Archive/Iso/IsoHandler.h2
-rwxr-xr-xCPP/7zip/Archive/Iso/IsoHeader.cpp2
-rwxr-xr-xCPP/7zip/Archive/Iso/IsoIn.cpp58
-rwxr-xr-xCPP/7zip/Archive/Iso/IsoIn.h26
-rwxr-xr-xCPP/7zip/Archive/Iso/IsoItem.h38
-rwxr-xr-xCPP/7zip/Archive/Iso/StdAfx.cpp3
-rwxr-xr-xCPP/7zip/Archive/Lzh/LzhCRC.cpp4
-rwxr-xr-xCPP/7zip/Archive/Lzh/LzhCRC.h2
-rwxr-xr-xCPP/7zip/Archive/Lzh/LzhHandler.cpp85
-rwxr-xr-xCPP/7zip/Archive/Lzh/LzhHandler.h2
-rwxr-xr-xCPP/7zip/Archive/Lzh/LzhItem.h18
-rwxr-xr-xCPP/7zip/Archive/Lzh/LzhOutStreamWithCRC.h2
-rwxr-xr-xCPP/7zip/Archive/Lzh/StdAfx.cpp3
-rwxr-xr-xCPP/7zip/Archive/Lzma/LzmaFiltersDecode.cpp4
-rwxr-xr-xCPP/7zip/Archive/Lzma/LzmaFiltersDecode.h2
-rwxr-xr-xCPP/7zip/Archive/Lzma/LzmaHandler.cpp10
-rwxr-xr-xCPP/7zip/Archive/Lzma/LzmaHandler.h20
-rwxr-xr-xCPP/7zip/Archive/MachoHandler.cpp490
-rwxr-xr-xCPP/7zip/Archive/MubHandler.cpp264
-rwxr-xr-xCPP/7zip/Archive/Nsis/NsisHandler.cpp65
-rwxr-xr-xCPP/7zip/Archive/Nsis/NsisHandler.h2
-rwxr-xr-xCPP/7zip/Archive/Nsis/NsisIn.cpp353
-rwxr-xr-xCPP/7zip/Archive/Nsis/NsisIn.h31
-rwxr-xr-xCPP/7zip/Archive/Nsis/NsisRegister.cpp2
-rwxr-xr-xCPP/7zip/Archive/Nsis/StdAfx.cpp3
-rwxr-xr-xCPP/7zip/Archive/PeHandler.cpp892
-rwxr-xr-xCPP/7zip/Archive/RPM/RpmHandler.cpp152
-rwxr-xr-xCPP/7zip/Archive/RPM/RpmHandler.h30
-rwxr-xr-xCPP/7zip/Archive/RPM/RpmHeader.h63
-rwxr-xr-xCPP/7zip/Archive/RPM/RpmIn.cpp106
-rwxr-xr-xCPP/7zip/Archive/RPM/RpmIn.h15
-rwxr-xr-xCPP/7zip/Archive/RPM/RpmRegister.cpp13
-rwxr-xr-xCPP/7zip/Archive/RPM/StdAfx.cpp3
-rwxr-xr-xCPP/7zip/Archive/RPM/StdAfx.h8
-rwxr-xr-xCPP/7zip/Archive/Rar/RarHandler.cpp131
-rwxr-xr-xCPP/7zip/Archive/Rar/RarHandler.h6
-rwxr-xr-xCPP/7zip/Archive/Rar/RarHeader.h12
-rwxr-xr-xCPP/7zip/Archive/Rar/RarIn.cpp158
-rwxr-xr-xCPP/7zip/Archive/Rar/RarIn.h9
-rwxr-xr-xCPP/7zip/Archive/Rar/RarItem.cpp95
-rwxr-xr-xCPP/7zip/Archive/Rar/RarItem.h68
-rwxr-xr-xCPP/7zip/Archive/Rar/RarVolumeInStream.cpp8
-rwxr-xr-xCPP/7zip/Archive/Rar/RarVolumeInStream.h4
-rwxr-xr-xCPP/7zip/Archive/RpmHandler.cpp303
-rwxr-xr-xCPP/7zip/Archive/Split/SplitHandler.cpp21
-rwxr-xr-xCPP/7zip/Archive/Split/SplitHandler.h6
-rwxr-xr-xCPP/7zip/Archive/Split/SplitHandlerOut.cpp2
-rwxr-xr-xCPP/7zip/Archive/Split/StdAfx.cpp3
-rwxr-xr-xCPP/7zip/Archive/StdAfx.h1
-rwxr-xr-xCPP/7zip/Archive/Tar/StdAfx.cpp3
-rwxr-xr-xCPP/7zip/Archive/Tar/TarHandler.cpp206
-rwxr-xr-xCPP/7zip/Archive/Tar/TarHandler.h4
-rwxr-xr-xCPP/7zip/Archive/Tar/TarHandlerOut.cpp61
-rwxr-xr-xCPP/7zip/Archive/Tar/TarHeader.cpp2
-rwxr-xr-xCPP/7zip/Archive/Tar/TarHeader.h16
-rwxr-xr-xCPP/7zip/Archive/Tar/TarIn.cpp175
-rwxr-xr-xCPP/7zip/Archive/Tar/TarIn.h16
-rwxr-xr-xCPP/7zip/Archive/Tar/TarItem.h38
-rwxr-xr-xCPP/7zip/Archive/Tar/TarOut.cpp2
-rwxr-xr-xCPP/7zip/Archive/Tar/TarUpdate.cpp42
-rwxr-xr-xCPP/7zip/Archive/Tar/TarUpdate.h6
-rwxr-xr-xCPP/7zip/Archive/Udf/StdAfx.h (renamed from CPP/7zip/Archive/Arj/StdAfx.h)1
-rwxr-xr-xCPP/7zip/Archive/Udf/UdfHandler.cpp361
-rwxr-xr-xCPP/7zip/Archive/Udf/UdfHandler.h (renamed from CPP/7zip/Archive/Deb/DebHandler.h)28
-rwxr-xr-xCPP/7zip/Archive/Udf/UdfIn.cpp853
-rwxr-xr-xCPP/7zip/Archive/Udf/UdfIn.h368
-rwxr-xr-xCPP/7zip/Archive/Udf/UdfRegister.cpp13
-rwxr-xr-xCPP/7zip/Archive/Wim/WimHandler.cpp305
-rwxr-xr-xCPP/7zip/Archive/Wim/WimHandler.h26
-rwxr-xr-xCPP/7zip/Archive/Wim/WimIn.cpp279
-rwxr-xr-xCPP/7zip/Archive/Wim/WimIn.h99
-rwxr-xr-xCPP/7zip/Archive/XarHandler.cpp586
-rwxr-xr-xCPP/7zip/Archive/Z/StdAfx.cpp3
-rwxr-xr-xCPP/7zip/Archive/Z/StdAfx.h8
-rwxr-xr-xCPP/7zip/Archive/Z/ZHandler.h29
-rwxr-xr-xCPP/7zip/Archive/Z/ZRegister.cpp13
-rwxr-xr-xCPP/7zip/Archive/ZHandler.cpp (renamed from CPP/7zip/Archive/Z/ZHandler.cpp)55
-rwxr-xr-xCPP/7zip/Archive/Zip/StdAfx.cpp3
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipAddCommon.cpp32
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipAddCommon.h2
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipCompressionMode.h12
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipHandler.cpp161
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipHandler.h11
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipHandlerOut.cpp70
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipHeader.cpp6
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipHeader.h17
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipIn.cpp342
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipIn.h23
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipItem.cpp41
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipItem.h30
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipItemEx.h12
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipOut.cpp2
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipUpdate.cpp193
-rwxr-xr-xCPP/7zip/Archive/Zip/ZipUpdate.h4
-rwxr-xr-xCPP/7zip/Bundles/Alone/Alone.dsp32
-rwxr-xr-xCPP/7zip/Bundles/Alone/makefile15
-rwxr-xr-xCPP/7zip/Bundles/Alone7z/makefile1
-rwxr-xr-xCPP/7zip/Bundles/Format7z/resource.rc2
-rwxr-xr-xCPP/7zip/Bundles/Format7zExtract/resource.rc2
-rwxr-xr-xCPP/7zip/Bundles/Format7zExtractR/resource.rc2
-rwxr-xr-xCPP/7zip/Bundles/Format7zF/Format7z.dsp314
-rwxr-xr-xCPP/7zip/Bundles/Format7zF/makefile64
-rwxr-xr-xCPP/7zip/Bundles/Format7zF/resource.rc42
-rwxr-xr-xCPP/7zip/Bundles/Format7zR/resource.rc2
-rwxr-xr-xCPP/7zip/Bundles/SFXCon/Main.cpp58
-rwxr-xr-xCPP/7zip/Bundles/SFXSetup/ExtractCallback.cpp121
-rwxr-xr-xCPP/7zip/Bundles/SFXSetup/ExtractCallback.h37
-rwxr-xr-xCPP/7zip/Bundles/SFXSetup/ExtractEngine.cpp156
-rwxr-xr-xCPP/7zip/Bundles/SFXSetup/ExtractEngine.h11
-rwxr-xr-xCPP/7zip/Bundles/SFXSetup/Main.cpp30
-rwxr-xr-xCPP/7zip/Bundles/SFXSetup/SFXSetup.dsp12
-rwxr-xr-xCPP/7zip/Bundles/SFXSetup/makefile6
-rwxr-xr-xCPP/7zip/Bundles/SFXWin/Main.cpp61
-rwxr-xr-xCPP/7zip/Bundles/SFXWin/SFXWin.dsp16
-rwxr-xr-xCPP/7zip/Bundles/SFXWin/makefile2
-rwxr-xr-xCPP/7zip/Common/CreateCoder.cpp28
-rwxr-xr-xCPP/7zip/Common/CreateCoder.h2
-rwxr-xr-xCPP/7zip/Common/FilePathAutoRename.cpp2
-rwxr-xr-xCPP/7zip/Common/FileStreams.cpp16
-rwxr-xr-xCPP/7zip/Common/FileStreams.h17
-rwxr-xr-xCPP/7zip/Common/FilterCoder.cpp16
-rwxr-xr-xCPP/7zip/Common/FilterCoder.h12
-rwxr-xr-xCPP/7zip/Common/InBuffer.cpp8
-rwxr-xr-xCPP/7zip/Common/InBuffer.h36
-rwxr-xr-xCPP/7zip/Common/InMemStream.cpp4
-rwxr-xr-xCPP/7zip/Common/InMemStream.h10
-rwxr-xr-xCPP/7zip/Common/InOutTempBuffer.h2
-rwxr-xr-xCPP/7zip/Common/LSBFDecoder.h6
-rwxr-xr-xCPP/7zip/Common/LSBFEncoder.h6
-rwxr-xr-xCPP/7zip/Common/LimitedStreams.cpp21
-rwxr-xr-xCPP/7zip/Common/LimitedStreams.h33
-rwxr-xr-xCPP/7zip/Common/LockedStream.cpp2
-rwxr-xr-xCPP/7zip/Common/LockedStream.h2
-rwxr-xr-xCPP/7zip/Common/MSBFDecoder.h4
-rwxr-xr-xCPP/7zip/Common/MSBFEncoder.h4
-rwxr-xr-xCPP/7zip/Common/MemBlocks.cpp10
-rwxr-xr-xCPP/7zip/Common/MemBlocks.h8
-rwxr-xr-xCPP/7zip/Common/MethodProps.h2
-rwxr-xr-xCPP/7zip/Common/OffsetStream.cpp2
-rwxr-xr-xCPP/7zip/Common/OffsetStream.h2
-rwxr-xr-xCPP/7zip/Common/OutBuffer.cpp4
-rwxr-xr-xCPP/7zip/Common/OutBuffer.h6
-rwxr-xr-xCPP/7zip/Common/ProgressMt.h2
-rwxr-xr-xCPP/7zip/Common/ProgressUtils.h2
-rwxr-xr-xCPP/7zip/Common/RegisterArc.h2
-rwxr-xr-xCPP/7zip/Common/RegisterCodec.h4
-rwxr-xr-xCPP/7zip/Common/StdAfx.h2
-rwxr-xr-xCPP/7zip/Common/StreamBinder.cpp16
-rwxr-xr-xCPP/7zip/Common/StreamBinder.h2
-rwxr-xr-xCPP/7zip/Common/StreamObjects.cpp6
-rwxr-xr-xCPP/7zip/Common/StreamObjects.h16
-rwxr-xr-xCPP/7zip/Common/StreamUtils.cpp8
-rwxr-xr-xCPP/7zip/Common/VirtThread.h2
-rwxr-xr-xCPP/7zip/Compress/Arj/ArjDecoder1.cpp2
-rwxr-xr-xCPP/7zip/Compress/Arj/ArjDecoder1.h2
-rwxr-xr-xCPP/7zip/Compress/Arj/ArjDecoder2.cpp2
-rwxr-xr-xCPP/7zip/Compress/Arj/ArjDecoder2.h2
-rwxr-xr-xCPP/7zip/Compress/BWT/Mtf8.h14
-rwxr-xr-xCPP/7zip/Compress/BWT/StdAfx.h6
-rwxr-xr-xCPP/7zip/Compress/BZip2/BZip2CRC.h4
-rwxr-xr-xCPP/7zip/Compress/BZip2/BZip2Decoder.cpp202
-rwxr-xr-xCPP/7zip/Compress/BZip2/BZip2Decoder.h6
-rwxr-xr-xCPP/7zip/Compress/BZip2/BZip2Encoder.cpp64
-rwxr-xr-xCPP/7zip/Compress/BZip2/BZip2Encoder.h22
-rwxr-xr-xCPP/7zip/Compress/BZip2/StdAfx.cpp3
-rwxr-xr-xCPP/7zip/Compress/Branch/BranchCoder.h8
-rwxr-xr-xCPP/7zip/Compress/Branch/BranchMisc.cpp4
-rwxr-xr-xCPP/7zip/Compress/Branch/StdAfx.cpp3
-rwxr-xr-xCPP/7zip/Compress/Branch/x86.h6
-rwxr-xr-xCPP/7zip/Compress/Branch/x86_2.cpp20
-rwxr-xr-xCPP/7zip/Compress/Branch/x86_2.h10
-rwxr-xr-xCPP/7zip/Compress/ByteSwap/ByteSwap.h8
-rwxr-xr-xCPP/7zip/Compress/ByteSwap/StdAfx.cpp3
-rwxr-xr-xCPP/7zip/Compress/CodecExports.cpp6
-rwxr-xr-xCPP/7zip/Compress/Copy/CopyCoder.cpp6
-rwxr-xr-xCPP/7zip/Compress/Copy/CopyCoder.h4
-rwxr-xr-xCPP/7zip/Compress/Copy/StdAfx.cpp3
-rwxr-xr-xCPP/7zip/Compress/Copy/StdAfx.h2
-rwxr-xr-xCPP/7zip/Compress/Deflate/DeflateConst.h18
-rwxr-xr-xCPP/7zip/Compress/Deflate/DeflateDecoder.cpp25
-rwxr-xr-xCPP/7zip/Compress/Deflate/DeflateDecoder.h5
-rwxr-xr-xCPP/7zip/Compress/Deflate/DeflateEncoder.cpp128
-rwxr-xr-xCPP/7zip/Compress/Deflate/DeflateEncoder.h8
-rwxr-xr-xCPP/7zip/Compress/Deflate/StdAfx.cpp3
-rwxr-xr-xCPP/7zip/Compress/Deflate/ZlibDecoder.cpp94
-rwxr-xr-xCPP/7zip/Compress/Deflate/ZlibDecoder.h47
-rwxr-xr-xCPP/7zip/Compress/DllExports.cpp12
-rwxr-xr-xCPP/7zip/Compress/DllExports2.cpp2
-rwxr-xr-xCPP/7zip/Compress/Huffman/HuffmanDecoder.h8
-rwxr-xr-xCPP/7zip/Compress/Huffman/StdAfx.h6
-rwxr-xr-xCPP/7zip/Compress/Implode/ImplodeDecoder.cpp26
-rwxr-xr-xCPP/7zip/Compress/Implode/ImplodeDecoder.h6
-rwxr-xr-xCPP/7zip/Compress/Implode/ImplodeHuffmanDecoder.cpp6
-rwxr-xr-xCPP/7zip/Compress/Implode/ImplodeHuffmanDecoder.h4
-rwxr-xr-xCPP/7zip/Compress/Implode/StdAfx.cpp3
-rwxr-xr-xCPP/7zip/Compress/LZ/LZOutWindow.h8
-rwxr-xr-xCPP/7zip/Compress/LZ/StdAfx.h4
-rwxr-xr-xCPP/7zip/Compress/LZMA/LZMA.dsp403
-rwxr-xr-xCPP/7zip/Compress/LZMA/LZMA.dsw29
-rwxr-xr-xCPP/7zip/Compress/LZMA/LZMADecoder.cpp10
-rwxr-xr-xCPP/7zip/Compress/LZMA/LZMADecoder.h8
-rwxr-xr-xCPP/7zip/Compress/LZMA/LZMAEncoder.cpp16
-rwxr-xr-xCPP/7zip/Compress/LZMA/LZMAEncoder.h6
-rwxr-xr-xCPP/7zip/Compress/LZMA/makefile61
-rwxr-xr-xCPP/7zip/Compress/LZMA/resource.rc3
-rwxr-xr-xCPP/7zip/Compress/LZMA_Alone/LzmaAlone.cpp46
-rwxr-xr-xCPP/7zip/Compress/LZMA_Alone/LzmaBench.cpp68
-rwxr-xr-xCPP/7zip/Compress/LZMA_Alone/LzmaBench.h4
-rwxr-xr-xCPP/7zip/Compress/LZMA_Alone/LzmaBenchCon.cpp20
-rwxr-xr-xCPP/7zip/Compress/LZMA_Alone/makefile.gcc2
-rwxr-xr-xCPP/7zip/Compress/Lzh/LzhDecoder.cpp36
-rwxr-xr-xCPP/7zip/Compress/Lzh/LzhDecoder.h2
-rwxr-xr-xCPP/7zip/Compress/Lzx/Lzx.h2
-rwxr-xr-xCPP/7zip/Compress/Lzx/Lzx86Converter.cpp2
-rwxr-xr-xCPP/7zip/Compress/Lzx/Lzx86Converter.h2
-rwxr-xr-xCPP/7zip/Compress/Lzx/LzxDecoder.cpp12
-rwxr-xr-xCPP/7zip/Compress/Lzx/LzxDecoder.h16
-rwxr-xr-xCPP/7zip/Compress/PPMD/PPMDContext.h246
-rwxr-xr-xCPP/7zip/Compress/PPMD/PPMDDecode.h56
-rwxr-xr-xCPP/7zip/Compress/PPMD/PPMDDecoder.cpp4
-rwxr-xr-xCPP/7zip/Compress/PPMD/PPMDDecoder.h10
-rwxr-xr-xCPP/7zip/Compress/PPMD/PPMDEncode.h60
-rwxr-xr-xCPP/7zip/Compress/PPMD/PPMDEncoder.cpp18
-rwxr-xr-xCPP/7zip/Compress/PPMD/PPMDEncoder.h4
-rwxr-xr-xCPP/7zip/Compress/PPMD/PPMDSubAlloc.h56
-rwxr-xr-xCPP/7zip/Compress/PPMD/PPMDType.h2
-rwxr-xr-xCPP/7zip/Compress/PPMD/StdAfx.cpp3
-rwxr-xr-xCPP/7zip/Compress/Quantum/QuantumDecoder.cpp6
-rwxr-xr-xCPP/7zip/Compress/Quantum/QuantumDecoder.h24
-rwxr-xr-xCPP/7zip/Compress/RangeCoder/RangeCoder.h16
-rwxr-xr-xCPP/7zip/Compress/RangeCoder/RangeCoderBit.cpp2
-rwxr-xr-xCPP/7zip/Compress/RangeCoder/RangeCoderBitTree.h6
-rwxr-xr-xCPP/7zip/Compress/RangeCoder/RangeCoderOpt.h2
-rwxr-xr-xCPP/7zip/Compress/Rar/Rar1Decoder.cpp2
-rwxr-xr-xCPP/7zip/Compress/Rar/Rar1Decoder.h2
-rwxr-xr-xCPP/7zip/Compress/Rar/Rar2Decoder.cpp20
-rwxr-xr-xCPP/7zip/Compress/Rar/Rar2Decoder.h8
-rwxr-xr-xCPP/7zip/Compress/Rar/Rar3Decoder.cpp22
-rwxr-xr-xCPP/7zip/Compress/Rar/Rar3Decoder.h10
-rwxr-xr-xCPP/7zip/Compress/Rar/Rar3Vm.cpp34
-rwxr-xr-xCPP/7zip/Compress/Rar/Rar3Vm.h6
-rwxr-xr-xCPP/7zip/Compress/Shrink/ShrinkDecoder.cpp8
-rwxr-xr-xCPP/7zip/Compress/Shrink/ShrinkDecoder.h8
-rwxr-xr-xCPP/7zip/Compress/Shrink/StdAfx.cpp3
-rwxr-xr-xCPP/7zip/Compress/Z/StdAfx.cpp3
-rwxr-xr-xCPP/7zip/Compress/Z/ZDecoder.cpp94
-rwxr-xr-xCPP/7zip/Compress/Z/ZDecoder.h1
-rwxr-xr-xCPP/7zip/Crypto/7zAES/7zAES.cpp8
-rwxr-xr-xCPP/7zip/Crypto/7zAES/7zAES.h6
-rwxr-xr-xCPP/7zip/Crypto/7zAES/DllExports.cpp111
-rwxr-xr-xCPP/7zip/Crypto/7zAES/StdAfx.cpp3
-rwxr-xr-xCPP/7zip/Crypto/AES/MyAES.cpp4
-rwxr-xr-xCPP/7zip/Crypto/AES/MyAES.h8
-rwxr-xr-xCPP/7zip/Crypto/AES/StdAfx.cpp3
-rwxr-xr-xCPP/7zip/Crypto/Hash/HmacSha1.cpp10
-rwxr-xr-xCPP/7zip/Crypto/Hash/Pbkdf2HmacSha1.cpp4
-rwxr-xr-xCPP/7zip/Crypto/Hash/Pbkdf2HmacSha1.h4
-rwxr-xr-xCPP/7zip/Crypto/Hash/RandGen.cpp4
-rwxr-xr-xCPP/7zip/Crypto/Hash/RandGen.h2
-rwxr-xr-xCPP/7zip/Crypto/Hash/Sha1.cpp18
-rwxr-xr-xCPP/7zip/Crypto/Hash/Sha1.h8
-rwxr-xr-xCPP/7zip/Crypto/Rar20/Rar20Cipher.h2
-rwxr-xr-xCPP/7zip/Crypto/Rar20/Rar20Crypto.cpp6
-rwxr-xr-xCPP/7zip/Crypto/Rar20/Rar20Crypto.h4
-rwxr-xr-xCPP/7zip/Crypto/RarAES/RarAES.h6
-rwxr-xr-xCPP/7zip/Crypto/WzAES/StdAfx.cpp3
-rwxr-xr-xCPP/7zip/Crypto/WzAES/WzAES.cpp20
-rwxr-xr-xCPP/7zip/Crypto/WzAES/WzAES.h14
-rwxr-xr-xCPP/7zip/Crypto/Zip/ZipCipher.h4
-rwxr-xr-xCPP/7zip/Crypto/Zip/ZipCrypto.cpp4
-rwxr-xr-xCPP/7zip/Guid.txt18
-rwxr-xr-xCPP/7zip/ICoder.h14
-rwxr-xr-xCPP/7zip/IProgress.h9
-rwxr-xr-xCPP/7zip/IStream.h2
-rwxr-xr-xCPP/7zip/MyVersion.h10
-rwxr-xr-xCPP/7zip/PropID.h44
-rwxr-xr-xCPP/7zip/UI/Agent/Agent.cpp103
-rwxr-xr-xCPP/7zip/UI/Agent/Agent.h36
-rwxr-xr-xCPP/7zip/UI/Agent/AgentOut.cpp232
-rwxr-xr-xCPP/7zip/UI/Agent/AgentProxy.cpp16
-rwxr-xr-xCPP/7zip/UI/Agent/AgentProxy.h2
-rwxr-xr-xCPP/7zip/UI/Agent/ArchiveFolder.cpp20
-rwxr-xr-xCPP/7zip/UI/Agent/ArchiveFolderOpen.cpp4
-rwxr-xr-xCPP/7zip/UI/Agent/ArchiveFolderOut.cpp25
-rwxr-xr-xCPP/7zip/UI/Agent/UpdateCallbackAgent.cpp6
-rwxr-xr-xCPP/7zip/UI/Client7z/Client7z.cpp230
-rwxr-xr-xCPP/7zip/UI/Common/ArchiveCommandLine.cpp186
-rwxr-xr-xCPP/7zip/UI/Common/ArchiveCommandLine.h6
-rwxr-xr-xCPP/7zip/UI/Common/ArchiveExtractCallback.cpp53
-rwxr-xr-xCPP/7zip/UI/Common/ArchiveExtractCallback.h52
-rwxr-xr-xCPP/7zip/UI/Common/ArchiveName.cpp2
-rwxr-xr-xCPP/7zip/UI/Common/ArchiveOpenCallback.cpp66
-rwxr-xr-xCPP/7zip/UI/Common/ArchiveOpenCallback.h50
-rwxr-xr-xCPP/7zip/UI/Common/CompressCall.cpp32
-rwxr-xr-xCPP/7zip/UI/Common/CompressCall.h4
-rwxr-xr-xCPP/7zip/UI/Common/DefaultName.cpp9
-rwxr-xr-xCPP/7zip/UI/Common/DefaultName.h2
-rwxr-xr-xCPP/7zip/UI/Common/DirItem.h61
-rwxr-xr-xCPP/7zip/UI/Common/EnumDirItems.cpp265
-rwxr-xr-xCPP/7zip/UI/Common/EnumDirItems.h28
-rwxr-xr-xCPP/7zip/UI/Common/ExitCode.h2
-rwxr-xr-xCPP/7zip/UI/Common/Extract.cpp97
-rwxr-xr-xCPP/7zip/UI/Common/Extract.h12
-rwxr-xr-xCPP/7zip/UI/Common/ExtractMode.h2
-rwxr-xr-xCPP/7zip/UI/Common/ExtractingFilePath.cpp1
-rwxr-xr-xCPP/7zip/UI/Common/HandlerLoader.h8
-rwxr-xr-xCPP/7zip/UI/Common/IFileExtractCallback.h3
-rwxr-xr-xCPP/7zip/UI/Common/LoadCodecs.cpp116
-rwxr-xr-xCPP/7zip/UI/Common/LoadCodecs.h23
-rwxr-xr-xCPP/7zip/UI/Common/OpenArchive.cpp224
-rwxr-xr-xCPP/7zip/UI/Common/OpenArchive.h53
-rwxr-xr-xCPP/7zip/UI/Common/PropIDUtils.cpp12
-rwxr-xr-xCPP/7zip/UI/Common/SetProperties.cpp2
-rwxr-xr-xCPP/7zip/UI/Common/StdAfx.h2
-rwxr-xr-xCPP/7zip/UI/Common/Update.cpp149
-rwxr-xr-xCPP/7zip/UI/Common/Update.h9
-rwxr-xr-xCPP/7zip/UI/Common/UpdateAction.cpp10
-rwxr-xr-xCPP/7zip/UI/Common/UpdateAction.h2
-rwxr-xr-xCPP/7zip/UI/Common/UpdateCallback.cpp137
-rwxr-xr-xCPP/7zip/UI/Common/UpdateCallback.h26
-rwxr-xr-xCPP/7zip/UI/Common/UpdatePair.cpp125
-rwxr-xr-xCPP/7zip/UI/Common/UpdatePair.h11
-rwxr-xr-xCPP/7zip/UI/Common/UpdateProduce.cpp59
-rwxr-xr-xCPP/7zip/UI/Common/UpdateProduce.h22
-rwxr-xr-xCPP/7zip/UI/Common/WorkDir.cpp4
-rwxr-xr-xCPP/7zip/UI/Common/ZipRegistry.cpp24
-rwxr-xr-xCPP/7zip/UI/Common/ZipRegistry.h6
-rwxr-xr-xCPP/7zip/UI/Console/Console.dsp4
-rwxr-xr-xCPP/7zip/UI/Console/ConsoleClose.h2
-rwxr-xr-xCPP/7zip/UI/Console/ExtractCallbackConsole.cpp83
-rwxr-xr-xCPP/7zip/UI/Console/ExtractCallbackConsole.h20
-rwxr-xr-xCPP/7zip/UI/Console/List.cpp182
-rwxr-xr-xCPP/7zip/UI/Console/List.h9
-rwxr-xr-xCPP/7zip/UI/Console/Main.cpp79
-rwxr-xr-xCPP/7zip/UI/Console/MainAr.cpp10
-rwxr-xr-xCPP/7zip/UI/Console/OpenCallbackConsole.cpp26
-rwxr-xr-xCPP/7zip/UI/Console/OpenCallbackConsole.h13
-rwxr-xr-xCPP/7zip/UI/Console/PercentPrinter.cpp8
-rwxr-xr-xCPP/7zip/UI/Console/PercentPrinter.h2
-rwxr-xr-xCPP/7zip/UI/Console/StdAfx.h2
-rwxr-xr-xCPP/7zip/UI/Console/UpdateCallbackConsole.cpp24
-rwxr-xr-xCPP/7zip/UI/Console/UpdateCallbackConsole.h7
-rwxr-xr-xCPP/7zip/UI/Console/UserInputUtils.cpp4
-rwxr-xr-xCPP/7zip/UI/Console/afxres.h1
-rwxr-xr-xCPP/7zip/UI/Console/makefile1
-rwxr-xr-xCPP/7zip/UI/Explorer/ContextMenu.cpp235
-rwxr-xr-xCPP/7zip/UI/Explorer/ContextMenu.h10
-rwxr-xr-xCPP/7zip/UI/Explorer/ContextMenuFlags.h12
-rwxr-xr-xCPP/7zip/UI/Explorer/DllExports.cpp18
-rwxr-xr-xCPP/7zip/UI/Explorer/Explorer.dsp8
-rwxr-xr-xCPP/7zip/UI/Explorer/FoldersPage.cpp14
-rwxr-xr-xCPP/7zip/UI/Explorer/FoldersPage.rc10
-rwxr-xr-xCPP/7zip/UI/Explorer/MyMessages.cpp38
-rwxr-xr-xCPP/7zip/UI/Explorer/MyMessages.h24
-rwxr-xr-xCPP/7zip/UI/Explorer/OptionsDialog.cpp4
-rwxr-xr-xCPP/7zip/UI/Explorer/OptionsDialog.h4
-rwxr-xr-xCPP/7zip/UI/Explorer/RegistryContextMenu.cpp12
-rwxr-xr-xCPP/7zip/UI/Explorer/StdAfx.h4
-rwxr-xr-xCPP/7zip/UI/Explorer/SystemPage.cpp37
-rwxr-xr-xCPP/7zip/UI/Explorer/SystemPage.rc14
-rwxr-xr-xCPP/7zip/UI/Explorer/makefile1
-rwxr-xr-xCPP/7zip/UI/Explorer/resource.h44
-rwxr-xr-xCPP/7zip/UI/Far/ExtractEngine.cpp42
-rwxr-xr-xCPP/7zip/UI/Far/ExtractEngine.h31
-rwxr-xr-xCPP/7zip/UI/Far/Far.dsp4
-rwxr-xr-xCPP/7zip/UI/Far/FarUtils.cpp86
-rwxr-xr-xCPP/7zip/UI/Far/FarUtils.h34
-rwxr-xr-xCPP/7zip/UI/Far/Main.cpp248
-rwxr-xr-xCPP/7zip/UI/Far/Messages.h35
-rwxr-xr-xCPP/7zip/UI/Far/OverwriteDialog.cpp8
-rwxr-xr-xCPP/7zip/UI/Far/Plugin.cpp384
-rwxr-xr-xCPP/7zip/UI/Far/Plugin.h16
-rwxr-xr-xCPP/7zip/UI/Far/PluginCommon.cpp6
-rwxr-xr-xCPP/7zip/UI/Far/PluginDelete.cpp13
-rwxr-xr-xCPP/7zip/UI/Far/PluginRead.cpp65
-rwxr-xr-xCPP/7zip/UI/Far/PluginWrite.cpp98
-rwxr-xr-xCPP/7zip/UI/Far/ProgressBox.cpp142
-rwxr-xr-xCPP/7zip/UI/Far/ProgressBox.h27
-rwxr-xr-xCPP/7zip/UI/Far/UpdateCallback100.cpp21
-rwxr-xr-xCPP/7zip/UI/Far/UpdateCallback100.h31
-rwxr-xr-xCPP/7zip/UI/Far/makefile1
-rwxr-xr-xCPP/7zip/UI/FileManager/AboutDialog.cpp4
-rwxr-xr-xCPP/7zip/UI/FileManager/App.cpp249
-rwxr-xr-xCPP/7zip/UI/FileManager/App.h68
-rwxr-xr-xCPP/7zip/UI/FileManager/AppState.h2
-rwxr-xr-xCPP/7zip/UI/FileManager/ClassDefs.cpp2
-rwxr-xr-xCPP/7zip/UI/FileManager/ComboDialog.cpp10
-rwxr-xr-xCPP/7zip/UI/FileManager/CopyDialog.cpp17
-rwxr-xr-xCPP/7zip/UI/FileManager/CopyDialog.h4
-rwxr-xr-xCPP/7zip/UI/FileManager/CopyDialog.rc10
-rwxr-xr-xCPP/7zip/UI/FileManager/CopyDialogRes.h1
-rwxr-xr-xCPP/7zip/UI/FileManager/EditPage.cpp2
-rwxr-xr-xCPP/7zip/UI/FileManager/EnumFormatEtc.cpp6
-rwxr-xr-xCPP/7zip/UI/FileManager/ExtractCallback.cpp152
-rwxr-xr-xCPP/7zip/UI/FileManager/ExtractCallback.h27
-rwxr-xr-xCPP/7zip/UI/FileManager/FM.cpp148
-rwxr-xr-xCPP/7zip/UI/FileManager/FM.dsp4
-rwxr-xr-xCPP/7zip/UI/FileManager/FSDrives.cpp95
-rwxr-xr-xCPP/7zip/UI/FileManager/FSDrives.h2
-rwxr-xr-xCPP/7zip/UI/FileManager/FSFolder.cpp98
-rwxr-xr-xCPP/7zip/UI/FileManager/FSFolder.h4
-rwxr-xr-xCPP/7zip/UI/FileManager/FSFolderCopy.cpp38
-rwxr-xr-xCPP/7zip/UI/FileManager/FileFolderPluginOpen.cpp96
-rwxr-xr-xCPP/7zip/UI/FileManager/FileFolderPluginOpen.h4
-rwxr-xr-xCPP/7zip/UI/FileManager/FilePlugins.cpp2
-rwxr-xr-xCPP/7zip/UI/FileManager/FormatUtils.cpp8
-rwxr-xr-xCPP/7zip/UI/FileManager/FormatUtils.h4
-rwxr-xr-xCPP/7zip/UI/FileManager/IFolder.h12
-rwxr-xr-xCPP/7zip/UI/FileManager/LangPage.cpp4
-rwxr-xr-xCPP/7zip/UI/FileManager/LangPage.h2
-rwxr-xr-xCPP/7zip/UI/FileManager/LangUtils.cpp10
-rwxr-xr-xCPP/7zip/UI/FileManager/ListViewDialog.cpp20
-rwxr-xr-xCPP/7zip/UI/FileManager/ListViewDialog.rc2
-rwxr-xr-xCPP/7zip/UI/FileManager/MessagesDialog.cpp54
-rwxr-xr-xCPP/7zip/UI/FileManager/MessagesDialog.rc2
-rwxr-xr-xCPP/7zip/UI/FileManager/MyLoadMenu.cpp27
-rwxr-xr-xCPP/7zip/UI/FileManager/MyLoadMenu.h3
-rwxr-xr-xCPP/7zip/UI/FileManager/NetFolder.cpp39
-rwxr-xr-xCPP/7zip/UI/FileManager/NetFolder.h4
-rwxr-xr-xCPP/7zip/UI/FileManager/OpenCallback.cpp83
-rwxr-xr-xCPP/7zip/UI/FileManager/OpenCallback.h45
-rwxr-xr-xCPP/7zip/UI/FileManager/OverwriteDialog.cpp38
-rwxr-xr-xCPP/7zip/UI/FileManager/OverwriteDialog.h2
-rwxr-xr-xCPP/7zip/UI/FileManager/Panel.cpp300
-rwxr-xr-xCPP/7zip/UI/FileManager/Panel.h97
-rwxr-xr-xCPP/7zip/UI/FileManager/PanelCopy.cpp26
-rwxr-xr-xCPP/7zip/UI/FileManager/PanelCrc.cpp12
-rwxr-xr-xCPP/7zip/UI/FileManager/PanelDrag.cpp48
-rwxr-xr-xCPP/7zip/UI/FileManager/PanelFolderChange.cpp259
-rwxr-xr-xCPP/7zip/UI/FileManager/PanelItemOpen.cpp146
-rwxr-xr-xCPP/7zip/UI/FileManager/PanelItems.cpp70
-rwxr-xr-xCPP/7zip/UI/FileManager/PanelKey.cpp8
-rwxr-xr-xCPP/7zip/UI/FileManager/PanelListNotify.cpp36
-rwxr-xr-xCPP/7zip/UI/FileManager/PanelMenu.cpp79
-rwxr-xr-xCPP/7zip/UI/FileManager/PanelOperations.cpp188
-rwxr-xr-xCPP/7zip/UI/FileManager/PanelSelect.cpp6
-rwxr-xr-xCPP/7zip/UI/FileManager/PanelSort.cpp45
-rwxr-xr-xCPP/7zip/UI/FileManager/PanelSplitFile.cpp278
-rwxr-xr-xCPP/7zip/UI/FileManager/PasswordDialog.cpp10
-rwxr-xr-xCPP/7zip/UI/FileManager/PhysDriveFolder.cpp38
-rwxr-xr-xCPP/7zip/UI/FileManager/PhysDriveFolder.h6
-rwxr-xr-xCPP/7zip/UI/FileManager/PluginInterface.h16
-rwxr-xr-xCPP/7zip/UI/FileManager/PluginLoader.h6
-rwxr-xr-xCPP/7zip/UI/FileManager/PluginsPage.cpp25
-rwxr-xr-xCPP/7zip/UI/FileManager/PluginsPage.rc4
-rwxr-xr-xCPP/7zip/UI/FileManager/ProgressDialog.cpp35
-rwxr-xr-xCPP/7zip/UI/FileManager/ProgressDialog.h7
-rwxr-xr-xCPP/7zip/UI/FileManager/ProgressDialog2.cpp66
-rwxr-xr-xCPP/7zip/UI/FileManager/ProgressDialog2.h17
-rwxr-xr-xCPP/7zip/UI/FileManager/ProgressDialog2.rc8
-rwxr-xr-xCPP/7zip/UI/FileManager/PropertyName.cpp50
-rwxr-xr-xCPP/7zip/UI/FileManager/PropertyName.h2
-rwxr-xr-xCPP/7zip/UI/FileManager/PropertyName.rc14
-rwxr-xr-xCPP/7zip/UI/FileManager/PropertyNameRes.h15
-rwxr-xr-xCPP/7zip/UI/FileManager/RegistryAssociations.cpp20
-rwxr-xr-xCPP/7zip/UI/FileManager/RegistryAssociations.h6
-rwxr-xr-xCPP/7zip/UI/FileManager/RegistryPlugins.cpp4
-rwxr-xr-xCPP/7zip/UI/FileManager/RegistryPlugins.h2
-rwxr-xr-xCPP/7zip/UI/FileManager/RootFolder.cpp113
-rwxr-xr-xCPP/7zip/UI/FileManager/RootFolder.h8
-rwxr-xr-xCPP/7zip/UI/FileManager/SettingsPage.cpp4
-rwxr-xr-xCPP/7zip/UI/FileManager/SettingsPage.rc16
-rwxr-xr-xCPP/7zip/UI/FileManager/SplitDialog.cpp14
-rwxr-xr-xCPP/7zip/UI/FileManager/StringUtils.cpp2
-rwxr-xr-xCPP/7zip/UI/FileManager/SysIconUtils.cpp34
-rwxr-xr-xCPP/7zip/UI/FileManager/SysIconUtils.h8
-rwxr-xr-xCPP/7zip/UI/FileManager/SystemPage.cpp68
-rwxr-xr-xCPP/7zip/UI/FileManager/SystemPage.rc2
-rwxr-xr-xCPP/7zip/UI/FileManager/TextPairs.cpp8
-rwxr-xr-xCPP/7zip/UI/FileManager/UpdateCallback100.cpp29
-rwxr-xr-xCPP/7zip/UI/FileManager/UpdateCallback100.h28
-rwxr-xr-xCPP/7zip/UI/FileManager/ViewSettings.cpp2
-rwxr-xr-xCPP/7zip/UI/FileManager/ViewSettings.h16
-rwxr-xr-xCPP/7zip/UI/FileManager/makefile1
-rwxr-xr-xCPP/7zip/UI/FileManager/resource.h11
-rwxr-xr-xCPP/7zip/UI/FileManager/resource.rc23
-rwxr-xr-xCPP/7zip/UI/GUI/BenchmarkDialog.cpp52
-rwxr-xr-xCPP/7zip/UI/GUI/BenchmarkDialog.h6
-rwxr-xr-xCPP/7zip/UI/GUI/CompressDialog.cpp94
-rwxr-xr-xCPP/7zip/UI/GUI/CompressDialog.h6
-rwxr-xr-xCPP/7zip/UI/GUI/CompressDialog.rc4
-rwxr-xr-xCPP/7zip/UI/GUI/Extract.rc6
-rwxr-xr-xCPP/7zip/UI/GUI/ExtractDialog.cpp22
-rwxr-xr-xCPP/7zip/UI/GUI/ExtractGUI.cpp38
-rwxr-xr-xCPP/7zip/UI/GUI/ExtractGUI.h5
-rwxr-xr-xCPP/7zip/UI/GUI/ExtractRes.h4
-rwxr-xr-xCPP/7zip/UI/GUI/GUI.cpp161
-rwxr-xr-xCPP/7zip/UI/GUI/GUI.dsp12
-rwxr-xr-xCPP/7zip/UI/GUI/OpenCallbackGUI.cpp61
-rwxr-xr-xCPP/7zip/UI/GUI/OpenCallbackGUI.h35
-rwxr-xr-xCPP/7zip/UI/GUI/UpdateCallbackGUI.cpp91
-rwxr-xr-xCPP/7zip/UI/GUI/UpdateCallbackGUI.h10
-rwxr-xr-xCPP/7zip/UI/GUI/UpdateGUI.cpp38
-rwxr-xr-xCPP/7zip/UI/GUI/UpdateGUI.h4
-rwxr-xr-xCPP/7zip/UI/GUI/makefile2
-rwxr-xr-xCPP/7zip/UI/GUI/resource.h26
640 files changed, 19661 insertions, 11879 deletions
diff --git a/CPP/7zip/Archive/7z/7z.dsp b/CPP/7zip/Archive/7z/7z.dsp
new file mode 100755
index 00000000..bddb2673
--- /dev/null
+++ b/CPP/7zip/Archive/7z/7z.dsp
@@ -0,0 +1,640 @@
+# Microsoft Developer Studio Project File - Name="7z" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=7z - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "7z.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "7z.mak" CFG="7z - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "7z - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "7z - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "7z - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 1
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MY7Z_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MY7Z_EXPORTS" /D "COMPRESS_MT" /D "EXTERNAL_CODECS" /Yu"StdAfx.h" /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x419 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"C:\Program Files\7-zip\Formats\7z.dll" /opt:NOWIN98
+# SUBTRACT LINK32 /pdb:none
+
+!ELSEIF "$(CFG)" == "7z - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 1
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MY7Z_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "MY7Z_EXPORTS" /D "COMPRESS_MT" /D "EXTERNAL_CODECS" /Yu"StdAfx.h" /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x419 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"C:\Program Files\7-zip\Formats\7z.dll" /pdbtype:sept
+
+!ENDIF
+
+# Begin Target
+
+# Name "7z - Win32 Release"
+# Name "7z - Win32 Debug"
+# Begin Group "Spec"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\Archive.def
+# End Source File
+# Begin Source File
+
+SOURCE=..\ArchiveExports.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\DllExports.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\resource.rc
+# End Source File
+# Begin Source File
+
+SOURCE=.\StdAfx.cpp
+# ADD CPP /Yc"StdAfx.h"
+# End Source File
+# Begin Source File
+
+SOURCE=.\StdAfx.h
+# End Source File
+# End Group
+# Begin Group "Engine"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=.\7zCompressionMode.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\7zCompressionMode.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\7zDecode.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\7zDecode.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\7zEncode.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\7zEncode.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\7zExtract.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\7zFolderInStream.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\7zFolderInStream.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\7zFolderOutStream.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\7zFolderOutStream.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\7zHandler.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\7zHandler.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\7zHandlerOut.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\7zHeader.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\7zHeader.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\7zIn.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\7zIn.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\7zItem.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\7zOut.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\7zOut.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\7zProperties.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\7zProperties.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\7zRegister.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\7zSpecStream.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\7zSpecStream.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\7zUpdate.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\7zUpdate.h
+# End Source File
+# End Group
+# Begin Group "Interface"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\IArchive.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\ICoder.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\IMyUnknown.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\IPassword.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\IProgress.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\IStream.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\PropID.h
+# End Source File
+# End Group
+# Begin Group "Common"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\..\Common\Buffer.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\CRC.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\DynamicBuffer.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\IntToString.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\IntToString.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\MyString.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\MyString.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\MyVector.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\MyVector.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\NewHandler.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\NewHandler.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\StringConvert.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\StringConvert.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\StringToInt.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\StringToInt.h
+# End Source File
+# End Group
+# Begin Group "Archive Common"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\Common\CoderMixer2.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\CoderMixer2.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\CoderMixer2MT.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\CoderMixer2MT.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\CrossThreadProgress.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\CrossThreadProgress.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\HandlerOut.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\HandlerOut.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\InStreamWithCRC.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\InStreamWithCRC.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\ItemNameUtils.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\ItemNameUtils.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\MultiStream.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\MultiStream.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\OutStreamWithCRC.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\OutStreamWithCRC.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\ParseProperties.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\Common\ParseProperties.h
+# End Source File
+# End Group
+# Begin Group "7-Zip Common"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Common\CreateCoder.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\CreateCoder.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\FilterCoder.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\FilterCoder.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\InOutTempBuffer.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\InOutTempBuffer.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\LimitedStreams.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\LimitedStreams.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\LockedStream.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\LockedStream.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\MethodId.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\MethodId.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\MethodProps.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\MethodProps.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\OutBuffer.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\OutBuffer.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\ProgressUtils.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\ProgressUtils.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\RegisterArc.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\RegisterCodec.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\StreamBinder.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\StreamBinder.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\StreamObjects.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\StreamObjects.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\StreamUtils.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\StreamUtils.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\VirtThread.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\VirtThread.h
+# End Source File
+# End Group
+# Begin Group "Windows"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\..\Windows\DLL.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\DLL.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\FileDir.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\FileDir.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\FileFind.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\FileFind.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\FileIO.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\FileIO.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\FileName.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\Handle.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\PropVariant.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\PropVariant.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\Synchronization.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\Synchronization.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\System.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\System.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\Thread.h
+# End Source File
+# End Group
+# Begin Group "Compress"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Compress\Copy\CopyCoder.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\Copy\CopyCoder.h
+# End Source File
+# End Group
+# Begin Group "C"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\..\..\C\7zCrc.c
+# SUBTRACT CPP /YX /Yc /Yu
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\7zCrc.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\Alloc.c
+# SUBTRACT CPP /YX /Yc /Yu
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\Alloc.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\Threads.c
+# SUBTRACT CPP /YX /Yc /Yu
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\Threads.h
+# End Source File
+# End Group
+# End Target
+# End Project
diff --git a/CPP/7zip/Archive/7z/7z.dsw b/CPP/7zip/Archive/7z/7z.dsw
new file mode 100755
index 00000000..702a86c7
--- /dev/null
+++ b/CPP/7zip/Archive/7z/7z.dsw
@@ -0,0 +1,29 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "7z"=".\7z.dsp" - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/CPP/7zip/Archive/7z/7zCompressionMode.h b/CPP/7zip/Archive/7z/7zCompressionMode.h
index 5753606f..a7cf999c 100755
--- a/CPP/7zip/Archive/7z/7zCompressionMode.h
+++ b/CPP/7zip/Archive/7z/7zCompressionMode.h
@@ -40,7 +40,7 @@ struct CCompressionMethodMode
bool IsEmpty() const { return (Methods.IsEmpty() && !PasswordIsDefined); }
CCompressionMethodMode(): PasswordIsDefined(false)
#ifdef COMPRESS_MT
- , NumThreads(1)
+ , NumThreads(1)
#endif
{}
};
diff --git a/CPP/7zip/Archive/7z/7zDecode.cpp b/CPP/7zip/Archive/7z/7zDecode.cpp
index 0f81de40..13fe50c8 100755
--- a/CPP/7zip/Archive/7z/7zDecode.cpp
+++ b/CPP/7zip/Archive/7z/7zDecode.cpp
@@ -44,7 +44,7 @@ static void ConvertFolderItemInfoToBindInfo(const CFolder &folder,
bindInfo.InStreams.Add((UInt32)folder.PackStreams[i]);
}
-static bool AreCodersEqual(const NCoderMixer::CCoderStreamsInfo &a1,
+static bool AreCodersEqual(const NCoderMixer::CCoderStreamsInfo &a1,
const NCoderMixer::CCoderStreamsInfo &a2)
{
return (a1.NumInStreams == a2.NumInStreams) &&
@@ -94,17 +94,20 @@ HRESULT CDecoder::Decode(
IInStream *inStream,
UInt64 startPos,
const UInt64 *packSizes,
- const CFolder &folderInfo,
+ const CFolder &folderInfo,
ISequentialOutStream *outStream,
ICompressProgressInfo *compressProgress
#ifndef _NO_CRYPTO
- , ICryptoGetTextPassword *getTextPassword
+ , ICryptoGetTextPassword *getTextPassword, bool &passwordIsDefined
#endif
#ifdef COMPRESS_MT
, bool mtMode, UInt32 numThreads
#endif
)
{
+ #ifndef _NO_CRYPTO
+ passwordIsDefined = false;
+ #endif
CObjectVector< CMyComPtr<ISequentialInStream> > inStreams;
CLockedInStream lockedInStream;
@@ -112,13 +115,13 @@ HRESULT CDecoder::Decode(
for (int j = 0; j < folderInfo.PackStreams.Size(); j++)
{
- CLockedSequentialInStreamImp *lockedStreamImpSpec = new
+ CLockedSequentialInStreamImp *lockedStreamImpSpec = new
CLockedSequentialInStreamImp;
CMyComPtr<ISequentialInStream> lockedStreamImp = lockedStreamImpSpec;
lockedStreamImpSpec->Init(&lockedInStream, startPos);
startPos += packSizes[j];
- CLimitedSequentialInStream *streamSpec = new
+ CLimitedSequentialInStream *streamSpec = new
CLimitedSequentialInStream;
CMyComPtr<ISequentialInStream> inStream = streamSpec;
streamSpec->SetStream(lockedStreamImp);
@@ -212,7 +215,7 @@ HRESULT CDecoder::Decode(
int i;
_mixerCoderCommon->ReInit();
- UInt32 packStreamIndex = 0, unPackStreamIndex = 0;
+ UInt32 packStreamIndex = 0, unpackStreamIndex = 0;
UInt32 coderIndex = 0;
// UInt32 coder2Index = 0;
@@ -257,20 +260,20 @@ HRESULT CDecoder::Decode(
{
if (getTextPassword == 0)
return E_FAIL;
- CMyComBSTR password;
- RINOK(getTextPassword->CryptoGetTextPassword(&password));
+ CMyComBSTR passwordBSTR;
+ RINOK(getTextPassword->CryptoGetTextPassword(&passwordBSTR));
CByteBuffer buffer;
- UString unicodePassword(password);
- const UInt32 sizeInBytes = unicodePassword.Length() * 2;
+ passwordIsDefined = true;
+ UString password = passwordBSTR;
+ const UInt32 sizeInBytes = password.Length() * 2;
buffer.SetCapacity(sizeInBytes);
- for (int i = 0; i < unicodePassword.Length(); i++)
+ for (int i = 0; i < password.Length(); i++)
{
- wchar_t c = unicodePassword[i];
+ wchar_t c = password[i];
((Byte *)buffer)[i * 2] = (Byte)c;
((Byte *)buffer)[i * 2 + 1] = (Byte)(c >> 8);
}
- RINOK(cryptoSetPassword->CryptoSetPassword(
- (const Byte *)buffer, sizeInBytes));
+ RINOK(cryptoSetPassword->CryptoSetPassword((const Byte *)buffer, sizeInBytes));
}
}
#endif
@@ -280,19 +283,19 @@ HRESULT CDecoder::Decode(
UInt32 numInStreams = (UInt32)coderInfo.NumInStreams;
UInt32 numOutStreams = (UInt32)coderInfo.NumOutStreams;
CRecordVector<const UInt64 *> packSizesPointers;
- CRecordVector<const UInt64 *> unPackSizesPointers;
+ CRecordVector<const UInt64 *> unpackSizesPointers;
packSizesPointers.Reserve(numInStreams);
- unPackSizesPointers.Reserve(numOutStreams);
+ unpackSizesPointers.Reserve(numOutStreams);
UInt32 j;
- for (j = 0; j < numOutStreams; j++, unPackStreamIndex++)
- unPackSizesPointers.Add(&folderInfo.UnPackSizes[unPackStreamIndex]);
+ for (j = 0; j < numOutStreams; j++, unpackStreamIndex++)
+ unpackSizesPointers.Add(&folderInfo.UnpackSizes[unpackStreamIndex]);
for (j = 0; j < numInStreams; j++, packStreamIndex++)
{
int bindPairIndex = folderInfo.FindBindPairForInStream(packStreamIndex);
if (bindPairIndex >= 0)
packSizesPointers.Add(
- &folderInfo.UnPackSizes[(UInt32)folderInfo.BindPairs[bindPairIndex].OutIndex]);
+ &folderInfo.UnpackSizes[(UInt32)folderInfo.BindPairs[bindPairIndex].OutIndex]);
else
{
int index = folderInfo.FindPackStreamArrayIndex(packStreamIndex);
@@ -302,9 +305,9 @@ HRESULT CDecoder::Decode(
}
}
- _mixerCoderCommon->SetCoderInfo(i,
- &packSizesPointers.Front(),
- &unPackSizesPointers.Front());
+ _mixerCoderCommon->SetCoderInfo(i,
+ &packSizesPointers.Front(),
+ &unpackSizesPointers.Front());
}
UInt32 mainCoder, temp;
bindInfo.FindOutStream(bindInfo.OutStreams[0], mainCoder, temp);
@@ -323,7 +326,7 @@ HRESULT CDecoder::Decode(
for (i = 0; i < inStreams.Size(); i++)
inStreamPointers.Add(inStreams[i]);
ISequentialOutStream *outStreamPointer = outStream;
- return _mixerCoder->Code(&inStreamPointers.Front(), NULL,
+ return _mixerCoder->Code(&inStreamPointers.Front(), NULL,
inStreams.Size(), &outStreamPointer, NULL, 1, compressProgress);
}
diff --git a/CPP/7zip/Archive/7z/7zDecode.h b/CPP/7zip/Archive/7z/7zDecode.h
index 7c10dfe2..1057a525 100755
--- a/CPP/7zip/Archive/7z/7zDecode.h
+++ b/CPP/7zip/Archive/7z/7zDecode.h
@@ -51,11 +51,11 @@ public:
IInStream *inStream,
UInt64 startPos,
const UInt64 *packSizes,
- const CFolder &folder,
+ const CFolder &folder,
ISequentialOutStream *outStream,
ICompressProgressInfo *compressProgress
#ifndef _NO_CRYPTO
- , ICryptoGetTextPassword *getTextPasswordSpec
+ , ICryptoGetTextPassword *getTextPasswordSpec, bool &passwordIsDefined
#endif
#ifdef COMPRESS_MT
, bool mtMode, UInt32 numThreads
diff --git a/CPP/7zip/Archive/7z/7zEncode.cpp b/CPP/7zip/Archive/7z/7zEncode.cpp
index 3a5cfcd5..b5a43f56 100755
--- a/CPP/7zip/Archive/7z/7zEncode.cpp
+++ b/CPP/7zip/Archive/7z/7zEncode.cpp
@@ -164,7 +164,7 @@ HRESULT CEncoder::Encode(
}
for (i = 1; i < _bindInfo.OutStreams.Size(); i++)
{
- CSequentialOutTempBufferImp *tempBufferSpec =
+ CSequentialOutTempBufferImp *tempBufferSpec =
new CSequentialOutTempBufferImp;
CMyComPtr<ISequentialOutStream> tempBuffer = tempBufferSpec;
tempBufferSpec->Init(&inOutTempBuffers[i - 1]);
@@ -195,10 +195,10 @@ HRESULT CEncoder::Encode(
// UInt64 outStreamStartPos;
// RINOK(stream->Seek(0, STREAM_SEEK_CUR, &outStreamStartPos));
- CSequentialInStreamSizeCount2 *inStreamSizeCountSpec =
+ CSequentialInStreamSizeCount2 *inStreamSizeCountSpec =
new CSequentialInStreamSizeCount2;
CMyComPtr<ISequentialInStream> inStreamSizeCount = inStreamSizeCountSpec;
- CSequentialOutStreamSizeCount *outStreamSizeCountSpec =
+ CSequentialOutStreamSizeCount *outStreamSizeCountSpec =
new CSequentialOutStreamSizeCount;
CMyComPtr<ISequentialOutStream> outStreamSizeCount = outStreamSizeCountSpec;
@@ -275,7 +275,7 @@ HRESULT CEncoder::Encode(
streamSize = inStreamSizeCountSpec->GetSize();
else
streamSize = _mixerCoderSpec->GetWriteProcessedSize(binder);
- folderItem.UnPackSizes.Add(streamSize);
+ folderItem.UnpackSizes.Add(streamSize);
}
for (i = numMethods - 1; i >= 0; i--)
folderItem.Coders[numMethods - 1 - i].Properties = _codersInfo[i].Properties;
diff --git a/CPP/7zip/Archive/7z/7zExtract.cpp b/CPP/7zip/Archive/7z/7zExtract.cpp
index 42977097..06e9ef97 100755
--- a/CPP/7zip/Archive/7z/7zExtract.cpp
+++ b/CPP/7zip/Archive/7z/7zExtract.cpp
@@ -23,18 +23,18 @@ struct CExtractFolderInfo
CNum FileIndex;
CNum FolderIndex;
CBoolVector ExtractStatuses;
- UInt64 UnPackSize;
+ UInt64 UnpackSize;
CExtractFolderInfo(
#ifdef _7Z_VOL
- int volumeIndex,
+ int volumeIndex,
#endif
- CNum fileIndex, CNum folderIndex):
+ CNum fileIndex, CNum folderIndex):
#ifdef _7Z_VOL
VolumeIndex(volumeIndex),
#endif
FileIndex(fileIndex),
- FolderIndex(folderIndex),
- UnPackSize(0)
+ FolderIndex(folderIndex),
+ UnpackSize(0)
{
if (fileIndex != kNumNoIndex)
{
@@ -50,15 +50,15 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
COM_TRY_BEGIN
bool testMode = (testModeSpec != 0);
CMyComPtr<IArchiveExtractCallback> extractCallback = extractCallbackSpec;
- UInt64 importantTotalUnPacked = 0;
+ UInt64 importantTotalUnpacked = 0;
bool allFilesMode = (numItems == UInt32(-1));
if (allFilesMode)
- numItems =
+ numItems =
#ifdef _7Z_VOL
_refs.Size();
#else
- _database.Files.Size();
+ _db.Files.Size();
#endif
if(numItems == 0)
@@ -68,7 +68,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
if(_volumes.Size() != 1)
return E_FAIL;
const CVolume &volume = _volumes.Front();
- const CArchiveDatabaseEx &_database = volume.Database;
+ const CArchiveDatabaseEx &_db = volume.Database;
IInStream *_inStream = volume.Stream;
*/
@@ -87,25 +87,25 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
int volumeIndex = ref.VolumeIndex;
const CVolume &volume = _volumes[volumeIndex];
- const CArchiveDatabaseEx &database = volume.Database;
+ const CArchiveDatabaseEx &db = volume.Database;
UInt32 fileIndex = ref.ItemIndex;
#else
- const CArchiveDatabaseEx &database = _database;
+ const CArchiveDatabaseEx &db = _db;
UInt32 fileIndex = ref2Index;
#endif
- CNum folderIndex = database.FileIndexToFolderIndexMap[fileIndex];
+ CNum folderIndex = db.FileIndexToFolderIndexMap[fileIndex];
if (folderIndex == kNumNoIndex)
{
extractFolderInfoVector.Add(CExtractFolderInfo(
#ifdef _7Z_VOL
- volumeIndex,
+ volumeIndex,
#endif
fileIndex, kNumNoIndex));
continue;
}
- if (extractFolderInfoVector.IsEmpty() ||
- folderIndex != extractFolderInfoVector.Back().FolderIndex
+ if (extractFolderInfoVector.IsEmpty() ||
+ folderIndex != extractFolderInfoVector.Back().FolderIndex
#ifdef _7Z_VOL
|| volumeIndex != extractFolderInfoVector.Back().VolumeIndex
#endif
@@ -113,32 +113,32 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
{
extractFolderInfoVector.Add(CExtractFolderInfo(
#ifdef _7Z_VOL
- volumeIndex,
+ volumeIndex,
#endif
kNumNoIndex, folderIndex));
- const CFolder &folderInfo = database.Folders[folderIndex];
- UInt64 unPackSize = folderInfo.GetUnPackSize();
- importantTotalUnPacked += unPackSize;
- extractFolderInfoVector.Back().UnPackSize = unPackSize;
+ const CFolder &folderInfo = db.Folders[folderIndex];
+ UInt64 unpackSize = folderInfo.GetUnpackSize();
+ importantTotalUnpacked += unpackSize;
+ extractFolderInfoVector.Back().UnpackSize = unpackSize;
}
CExtractFolderInfo &efi = extractFolderInfoVector.Back();
// const CFolderInfo &folderInfo = m_dam_Folders[folderIndex];
- CNum startIndex = database.FolderStartFileIndex[folderIndex];
+ CNum startIndex = db.FolderStartFileIndex[folderIndex];
for (CNum index = efi.ExtractStatuses.Size();
index <= fileIndex - startIndex; index++)
{
- // UInt64 unPackSize = _database.Files[startIndex + index].UnPackSize;
+ // UInt64 unpackSize = _db.Files[startIndex + index].UnpackSize;
// Count partial_folder_size
- // efi.UnPackSize += unPackSize;
- // importantTotalUnPacked += unPackSize;
+ // efi.UnpackSize += unpackSize;
+ // importantTotalUnpacked += unpackSize;
efi.ExtractStatuses.Add(index == fileIndex - startIndex);
}
}
}
- extractCallback->SetTotal(importantTotalUnPacked);
+ extractCallback->SetTotal(importantTotalUnpacked);
CDecoder decoder(
#ifdef _ST_MODE
@@ -150,24 +150,24 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
// CDecoder1 decoder;
UInt64 currentTotalPacked = 0;
- UInt64 currentTotalUnPacked = 0;
- UInt64 totalFolderUnPacked;
+ UInt64 currentTotalUnpacked = 0;
+ UInt64 totalFolderUnpacked;
UInt64 totalFolderPacked;
CLocalProgress *lps = new CLocalProgress;
CMyComPtr<ICompressProgressInfo> progress = lps;
lps->Init(extractCallback, false);
- for(int i = 0; i < extractFolderInfoVector.Size(); i++,
- currentTotalUnPacked += totalFolderUnPacked,
+ for(int i = 0; i < extractFolderInfoVector.Size(); i++,
+ currentTotalUnpacked += totalFolderUnpacked,
currentTotalPacked += totalFolderPacked)
{
- lps->OutSize = currentTotalUnPacked;
+ lps->OutSize = currentTotalUnpacked;
lps->InSize = currentTotalPacked;
RINOK(lps->SetCur());
const CExtractFolderInfo &efi = extractFolderInfoVector[i];
- totalFolderUnPacked = efi.UnPackSize;
+ totalFolderUnpacked = efi.UnpackSize;
totalFolderPacked = 0;
@@ -176,25 +176,25 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
#ifdef _7Z_VOL
const CVolume &volume = _volumes[efi.VolumeIndex];
- const CArchiveDatabaseEx &database = volume.Database;
+ const CArchiveDatabaseEx &db = volume.Database;
#else
- const CArchiveDatabaseEx &database = _database;
+ const CArchiveDatabaseEx &db = _db;
#endif
CNum startIndex;
if (efi.FileIndex != kNumNoIndex)
startIndex = efi.FileIndex;
else
- startIndex = database.FolderStartFileIndex[efi.FolderIndex];
+ startIndex = db.FolderStartFileIndex[efi.FolderIndex];
- HRESULT result = folderOutStream->Init(&database,
+ HRESULT result = folderOutStream->Init(&db,
#ifdef _7Z_VOL
- volume.StartRef2Index,
+ volume.StartRef2Index,
#else
0,
#endif
- startIndex,
+ startIndex,
&efi.ExtractStatuses, extractCallback, testMode, _crcSize != 0);
RINOK(result);
@@ -203,12 +203,12 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
continue;
CNum folderIndex = efi.FolderIndex;
- const CFolder &folderInfo = database.Folders[folderIndex];
+ const CFolder &folderInfo = db.Folders[folderIndex];
- totalFolderPacked = _database.GetFolderFullPackSize(folderIndex);
+ totalFolderPacked = _db.GetFolderFullPackSize(folderIndex);
- CNum packStreamIndex = database.FolderStartPackStreamIndex[folderIndex];
- UInt64 folderStartPackPos = database.GetFolderStreamPos(folderIndex, 0);
+ CNum packStreamIndex = db.FolderStartPackStreamIndex[folderIndex];
+ UInt64 folderStartPackPos = db.GetFolderStreamPos(folderIndex, 0);
#ifndef _NO_CRYPTO
CMyComPtr<ICryptoGetTextPassword> getTextPassword;
@@ -218,6 +218,10 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
try
{
+ #ifndef _NO_CRYPTO
+ bool passwordIsDefined;
+ #endif
+
HRESULT result = decoder.Decode(
EXTERNAL_CODECS_VARS
#ifdef _7Z_VOL
@@ -225,13 +229,13 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
#else
_inStream,
#endif
- folderStartPackPos,
- &database.PackSizes[packStreamIndex],
+ folderStartPackPos,
+ &db.PackSizes[packStreamIndex],
folderInfo,
outStream,
progress
#ifndef _NO_CRYPTO
- , getTextPassword
+ , getTextPassword, passwordIsDefined
#endif
#ifdef COMPRESS_MT
, true, _numThreads
diff --git a/CPP/7zip/Archive/7z/7zFolderInStream.cpp b/CPP/7zip/Archive/7z/7zFolderInStream.cpp
index f60a7177..b029ae15 100755
--- a/CPP/7zip/Archive/7z/7zFolderInStream.cpp
+++ b/CPP/7zip/Archive/7z/7zFolderInStream.cpp
@@ -13,7 +13,7 @@ CFolderInStream::CFolderInStream()
_inStreamWithHash = _inStreamWithHashSpec;
}
-void CFolderInStream::Init(IArchiveUpdateCallback *updateCallback,
+void CFolderInStream::Init(IArchiveUpdateCallback *updateCallback,
const UInt32 *fileIndices, UInt32 numFiles)
{
_updateCallback = updateCallback;
diff --git a/CPP/7zip/Archive/7z/7zFolderInStream.h b/CPP/7zip/Archive/7z/7zFolderInStream.h
index 9a720c8b..68e2b27b 100755
--- a/CPP/7zip/Archive/7z/7zFolderInStream.h
+++ b/CPP/7zip/Archive/7z/7zFolderInStream.h
@@ -14,7 +14,7 @@
namespace NArchive {
namespace N7z {
-class CFolderInStream:
+class CFolderInStream:
public ISequentialInStream,
public ICompressGetSubStreamSize,
public CMyUnknownImp
@@ -47,7 +47,7 @@ private:
HRESULT CloseStream();
void AddDigest();
public:
- void Init(IArchiveUpdateCallback *updateCallback,
+ void Init(IArchiveUpdateCallback *updateCallback,
const UInt32 *fileIndices, UInt32 numFiles);
CRecordVector<bool> Processed;
CRecordVector<UInt32> CRCs;
@@ -55,7 +55,7 @@ public:
UInt64 GetFullSize() const
{
UInt64 size = 0;
- for (int i = 0; i < Sizes.Size(); i++)
+ for (int i = 0; i < Sizes.Size(); i++)
size += Sizes[i];
return size;
}
diff --git a/CPP/7zip/Archive/7z/7zFolderOutStream.cpp b/CPP/7zip/Archive/7z/7zFolderOutStream.cpp
index 6206ffec..61b938d0 100755
--- a/CPP/7zip/Archive/7z/7zFolderOutStream.cpp
+++ b/CPP/7zip/Archive/7z/7zFolderOutStream.cpp
@@ -17,7 +17,7 @@ HRESULT CFolderOutStream::Init(
const CArchiveDatabaseEx *archiveDatabase,
UInt32 ref2Offset,
UInt32 startIndex,
- const CBoolVector *extractStatuses,
+ const CBoolVector *extractStatuses,
IArchiveExtractCallback *extractCallback,
bool testMode,
bool checkCrc)
@@ -41,7 +41,7 @@ HRESULT CFolderOutStream::OpenFile()
{
Int32 askMode;
if((*_extractStatuses)[_currentIndex])
- askMode = _testMode ?
+ askMode = _testMode ?
NArchive::NExtract::NAskMode::kTest :
NArchive::NExtract::NAskMode::kExtract;
else
@@ -54,10 +54,10 @@ HRESULT CFolderOutStream::OpenFile()
_outStreamWithHashSpec->SetStream(realOutStream);
_outStreamWithHashSpec->Init(_checkCrc);
if (askMode == NArchive::NExtract::NAskMode::kExtract &&
- (!realOutStream))
+ (!realOutStream))
{
- const CFileItem &fileInfo = _archiveDatabase->Files[index];
- if (!fileInfo.IsAnti && !fileInfo.IsDirectory)
+ const CFileItem &fi = _archiveDatabase->Files[index];
+ if (!_archiveDatabase->IsItemAnti(index) && !fi.IsDir)
askMode = NArchive::NExtract::NAskMode::kSkip;
}
return _extractCallback->PrepareOperation(askMode);
@@ -68,18 +68,17 @@ HRESULT CFolderOutStream::WriteEmptyFiles()
for(;_currentIndex < _extractStatuses->Size(); _currentIndex++)
{
UInt32 index = _startIndex + _currentIndex;
- const CFileItem &fileInfo = _archiveDatabase->Files[index];
- if (!fileInfo.IsAnti && !fileInfo.IsDirectory && fileInfo.UnPackSize != 0)
+ const CFileItem &fi = _archiveDatabase->Files[index];
+ if (!_archiveDatabase->IsItemAnti(index) && !fi.IsDir && fi.Size != 0)
return S_OK;
RINOK(OpenFile());
- RINOK(_extractCallback->SetOperationResult(
- NArchive::NExtract::NOperationResult::kOK));
+ RINOK(_extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK));
_outStreamWithHashSpec->ReleaseStream();
}
return S_OK;
}
-STDMETHODIMP CFolderOutStream::Write(const void *data,
+STDMETHODIMP CFolderOutStream::Write(const void *data,
UInt32 size, UInt32 *processedSize)
{
UInt32 realProcessedSize = 0;
@@ -88,14 +87,14 @@ STDMETHODIMP CFolderOutStream::Write(const void *data,
if (_fileIsOpen)
{
UInt32 index = _startIndex + _currentIndex;
- const CFileItem &fileInfo = _archiveDatabase->Files[index];
- UInt64 fileSize = fileInfo.UnPackSize;
+ const CFileItem &fi = _archiveDatabase->Files[index];
+ UInt64 fileSize = fi.Size;
- UInt32 numBytesToWrite = (UInt32)MyMin(fileSize - _filePos,
+ UInt32 numBytesToWrite = (UInt32)MyMin(fileSize - _filePos,
UInt64(size - realProcessedSize));
UInt32 processedSizeLocal;
- RINOK(_outStreamWithHash->Write((const Byte *)data + realProcessedSize,
+ RINOK(_outStreamWithHash->Write((const Byte *)data + realProcessedSize,
numBytesToWrite, &processedSizeLocal));
_filePos += processedSizeLocal;
@@ -103,13 +102,13 @@ STDMETHODIMP CFolderOutStream::Write(const void *data,
if (_filePos == fileSize)
{
bool digestsAreEqual;
- if (fileInfo.IsFileCRCDefined && _checkCrc)
- digestsAreEqual = fileInfo.FileCRC == _outStreamWithHashSpec->GetCRC();
+ if (fi.CrcDefined && _checkCrc)
+ digestsAreEqual = fi.Crc == _outStreamWithHashSpec->GetCRC();
else
digestsAreEqual = true;
RINOK(_extractCallback->SetOperationResult(
- digestsAreEqual ?
+ digestsAreEqual ?
NArchive::NExtract::NOperationResult::kOK :
NArchive::NExtract::NOperationResult::kCRCError));
_outStreamWithHashSpec->ReleaseStream();
diff --git a/CPP/7zip/Archive/7z/7zFolderOutStream.h b/CPP/7zip/Archive/7z/7zFolderOutStream.h
index 8ca91e64..f54fba3e 100755
--- a/CPP/7zip/Archive/7z/7zFolderOutStream.h
+++ b/CPP/7zip/Archive/7z/7zFolderOutStream.h
@@ -12,7 +12,7 @@
namespace NArchive {
namespace N7z {
-class CFolderOutStream:
+class CFolderOutStream:
public ISequentialOutStream,
public CMyUnknownImp
{
@@ -47,7 +47,7 @@ public:
const CArchiveDatabaseEx *archiveDatabase,
UInt32 ref2Offset,
UInt32 startIndex,
- const CBoolVector *extractStatuses,
+ const CBoolVector *extractStatuses,
IArchiveExtractCallback *extractCallback,
bool testMode,
bool checkCrc);
diff --git a/CPP/7zip/Archive/7z/7zHandler.cpp b/CPP/7zip/Archive/7z/7zHandler.cpp
index bbef1ea5..76b3c72d 100755
--- a/CPP/7zip/Archive/7z/7zHandler.cpp
+++ b/CPP/7zip/Archive/7z/7zHandler.cpp
@@ -10,9 +10,6 @@
#include "../../../Windows/Defs.h"
#include "../Common/ItemNameUtils.h"
-#ifdef _7Z_VOL
-#include "../Common/MultiStream.h"
-#endif
#ifdef __7Z_SET_PROPERTIES
#ifdef EXTRACT_ONLY
@@ -35,9 +32,13 @@ CHandler::CHandler()
{
_crcSize = 4;
+ #ifndef _NO_CRYPTO
+ _passwordIsDefined = false;
+ #endif
+
#ifdef EXTRACT_ONLY
#ifdef COMPRESS_MT
- _numThreads = NWindows::NSystem::GetNumberOfProcessors();
+ _numThreads = NSystem::GetNumberOfProcessors();
#endif
#else
Init();
@@ -46,12 +47,7 @@ CHandler::CHandler()
STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
{
- *numItems =
- #ifdef _7Z_VOL
- _refs.Size();
- #else
- *numItems = _database.Files.Size();
- #endif
+ *numItems = _db.Files.Size();
return S_OK;
}
@@ -64,7 +60,7 @@ STDMETHODIMP CHandler::GetNumberOfProperties(UInt32 * /* numProperties */)
return E_NOTIMPL;
}
-STDMETHODIMP CHandler::GetPropertyInfo(UInt32 /* index */,
+STDMETHODIMP CHandler::GetPropertyInfo(UInt32 /* index */,
BSTR * /* name */, PROPID * /* propID */, VARTYPE * /* varType */)
{
return E_NOTIMPL;
@@ -73,17 +69,20 @@ STDMETHODIMP CHandler::GetPropertyInfo(UInt32 /* index */,
#else
-STATPROPSTG kArcProps[] =
+STATPROPSTG kArcProps[] =
{
{ NULL, kpidMethod, VT_BSTR},
{ NULL, kpidSolid, VT_BOOL},
- { NULL, kpidNumBlocks, VT_UI4}
+ { NULL, kpidNumBlocks, VT_UI4},
+ { NULL, kpidPhySize, VT_UI8},
+ { NULL, kpidHeadersSize, VT_UI8},
+ { NULL, kpidOffset, VT_UI8}
};
STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
{
COM_TRY_BEGIN
- NWindows::NCOM::CPropVariant prop;
+ NCOM::CPropVariant prop;
switch(propID)
{
case kpidMethod:
@@ -91,9 +90,9 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
UString resString;
CRecordVector<UInt64> ids;
int i;
- for (i = 0; i < _database.Folders.Size(); i++)
+ for (i = 0; i < _db.Folders.Size(); i++)
{
- const CFolder &f = _database.Folders[i];
+ const CFolder &f = _db.Folders[i];
for (int j = f.Coders.Size() - 1; j >= 0; j--)
ids.AddToUniqueSorted(f.Coders[j].MethodID);
}
@@ -109,11 +108,14 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
resString += L' ';
resString += methodName;
}
- prop = resString;
+ prop = resString;
break;
}
- case kpidSolid: prop = _database.IsSolid(); break;
- case kpidNumBlocks: prop = (UInt32)_database.Folders.Size(); break;
+ case kpidSolid: prop = _db.IsSolid(); break;
+ case kpidNumBlocks: prop = (UInt32)_db.Folders.Size(); break;
+ case kpidHeadersSize: prop = _db.HeadersSize; break;
+ case kpidPhySize: prop = _db.PhySize; break;
+ case kpidOffset: if (_db.ArchiveInfo.StartPosition != 0) prop = _db.ArchiveInfo.StartPosition; break;
}
prop.Detach(value);
return S_OK;
@@ -124,10 +126,16 @@ IMP_IInArchive_ArcProps
#endif
-static void MySetFileTime(bool timeDefined, FILETIME unixTime, NWindows::NCOM::CPropVariant &prop)
+static void SetPropFromUInt64Def(CUInt64DefVector &v, int index, NCOM::CPropVariant &prop)
{
- if (timeDefined)
- prop = unixTime;
+ UInt64 value;
+ if (v.GetItem(index, value))
+ {
+ FILETIME ft;
+ ft.dwLowDateTime = (DWORD)value;
+ ft.dwHighDateTime = (DWORD)(value >> 32);
+ prop = ft;
+ }
}
#ifndef _SFX
@@ -192,10 +200,10 @@ static inline UInt32 GetUInt32FromMemLE(const Byte *p)
bool CHandler::IsEncrypted(UInt32 index2) const
{
- CNum folderIndex = _database.FileIndexToFolderIndexMap[index2];
+ CNum folderIndex = _db.FileIndexToFolderIndexMap[index2];
if (folderIndex != kNumNoIndex)
{
- const CFolder &folderInfo = _database.Folders[folderIndex];
+ const CFolder &folderInfo = _db.Folders[folderIndex];
for (int i = folderInfo.Coders.Size() - 1; i >= 0; i--)
if (folderInfo.Coders[i].MethodID == k_AES)
return true;
@@ -206,7 +214,7 @@ bool CHandler::IsEncrypted(UInt32 index2) const
STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
{
COM_TRY_BEGIN
- NWindows::NCOM::CPropVariant prop;
+ NCOM::CPropVariant prop;
/*
const CRef2 &ref2 = _refs[index];
@@ -215,54 +223,31 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *va
const CRef &ref = ref2.Refs.Front();
*/
- #ifdef _7Z_VOL
- const CRef &ref = _refs[index];
- const CVolume &volume = _volumes[ref.VolumeIndex];
- const CArchiveDatabaseEx &_database = volume.Database;
- UInt32 index2 = ref.ItemIndex;
- const CFileItem &item = _database.Files[index2];
- #else
- const CFileItem &item = _database.Files[index];
+ const CFileItem &item = _db.Files[index];
UInt32 index2 = index;
- #endif
switch(propID)
{
case kpidPath:
- {
if (!item.Name.IsEmpty())
prop = NItemName::GetOSName(item.Name);
break;
- }
- case kpidIsFolder:
- prop = item.IsDirectory;
- break;
+ case kpidIsDir: prop = item.IsDir; break;
case kpidSize:
{
- prop = item.UnPackSize;
- // prop = ref2.UnPackSize;
+ prop = item.Size;
+ // prop = ref2.Size;
break;
}
- case kpidPosition:
- {
- /*
- if (ref2.Refs.Size() > 1)
- prop = ref2.StartPos;
- else
- */
- if (item.IsStartPosDefined)
- prop = item.StartPos;
- break;
- }
- case kpidPackedSize:
+ case kpidPackSize:
{
// prop = ref2.PackSize;
{
- CNum folderIndex = _database.FileIndexToFolderIndexMap[index2];
+ CNum folderIndex = _db.FileIndexToFolderIndexMap[index2];
if (folderIndex != kNumNoIndex)
{
- if (_database.FolderStartFileIndex[folderIndex] == (CNum)index2)
- prop = _database.GetFolderFullPackSize(folderIndex);
+ if (_db.FolderStartFileIndex[folderIndex] == (CNum)index2)
+ prop = _db.GetFolderFullPackSize(folderIndex);
/*
else
prop = (UInt64)0;
@@ -273,35 +258,21 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *va
}
break;
}
- case kpidLastAccessTime:
- MySetFileTime(item.IsLastAccessTimeDefined, item.LastAccessTime, prop);
- break;
- case kpidCreationTime:
- MySetFileTime(item.IsCreationTimeDefined, item.CreationTime, prop);
- break;
- case kpidLastWriteTime:
- MySetFileTime(item.IsLastWriteTimeDefined, item.LastWriteTime, prop);
- break;
- case kpidAttributes:
- if (item.AreAttributesDefined)
- prop = item.Attributes;
- break;
- case kpidCRC:
- if (item.IsFileCRCDefined)
- prop = item.FileCRC;
- break;
- case kpidEncrypted:
- {
- prop = IsEncrypted(index2);
- break;
- }
+ case kpidPosition: { UInt64 v; if (_db.StartPos.GetItem(index2, v)) prop = v; break; }
+ case kpidCTime: SetPropFromUInt64Def(_db.CTime, index2, prop); break;
+ case kpidATime: SetPropFromUInt64Def(_db.ATime, index2, prop); break;
+ case kpidMTime: SetPropFromUInt64Def(_db.MTime, index2, prop); break;
+ case kpidAttrib: if (item.AttribDefined) prop = item.Attrib; break;
+ case kpidCRC: if (item.CrcDefined) prop = item.Crc; break;
+ case kpidEncrypted: prop = IsEncrypted(index2); break;
+ case kpidIsAnti: prop = _db.IsItemAnti(index2); break;
#ifndef _SFX
case kpidMethod:
{
- CNum folderIndex = _database.FileIndexToFolderIndexMap[index2];
+ CNum folderIndex = _db.FileIndexToFolderIndexMap[index2];
if (folderIndex != kNumNoIndex)
{
- const CFolder &folderInfo = _database.Folders[folderIndex];
+ const CFolder &folderInfo = _db.Folders[folderIndex];
UString methodsString;
for (int i = folderInfo.Coders.Size() - 1; i >= 0; i--)
{
@@ -312,7 +283,7 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *va
{
UString methodName;
bool methodIsKnown = FindMethod(
- EXTERNAL_CODECS_VARS
+ EXTERNAL_CODECS_VARS
coderInfo.MethodID, methodName);
if (methodIsKnown)
@@ -398,7 +369,7 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *va
break;
case kpidBlock:
{
- CNum folderIndex = _database.FileIndexToFolderIndexMap[index2];
+ CNum folderIndex = _db.FileIndexToFolderIndexMap[index2];
if (folderIndex != kNumNoIndex)
prop = (UInt32)folderIndex;
}
@@ -409,14 +380,14 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *va
case kpidPackedSize3:
case kpidPackedSize4:
{
- CNum folderIndex = _database.FileIndexToFolderIndexMap[index2];
+ CNum folderIndex = _db.FileIndexToFolderIndexMap[index2];
if (folderIndex != kNumNoIndex)
{
- const CFolder &folderInfo = _database.Folders[folderIndex];
- if (_database.FolderStartFileIndex[folderIndex] == (CNum)index2 &&
+ const CFolder &folderInfo = _db.Folders[folderIndex];
+ if (_db.FolderStartFileIndex[folderIndex] == (CNum)index2 &&
folderInfo.PackStreams.Size() > (int)(propID - kpidPackedSize0))
{
- prop = _database.GetFolderPackStreamSize(folderIndex, propID - kpidPackedSize0);
+ prop = _db.GetFolderPackStreamSize(folderIndex, propID - kpidPackedSize0);
}
else
prop = (UInt64)0;
@@ -426,97 +397,14 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *va
}
break;
#endif
- case kpidIsAnti:
- prop = item.IsAnti;
- break;
}
prop.Detach(value);
return S_OK;
COM_TRY_END
}
-#ifdef _7Z_VOL
-
-static const wchar_t *kExt = L"7z";
-static const wchar_t *kAfterPart = L".7z";
-
-class CVolumeName
-{
- bool _first;
- UString _unchangedPart;
- UString _changedPart;
- UString _afterPart;
-public:
- bool InitName(const UString &name)
- {
- _first = true;
- int dotPos = name.ReverseFind('.');
- UString basePart = name;
- if (dotPos >= 0)
- {
- UString ext = name.Mid(dotPos + 1);
- if (ext.CompareNoCase(kExt)==0 ||
- ext.CompareNoCase(L"EXE") == 0)
- {
- _afterPart = kAfterPart;
- basePart = name.Left(dotPos);
- }
- }
-
- int numLetters = 1;
- bool splitStyle = false;
- if (basePart.Right(numLetters) == L"1")
- {
- while (numLetters < basePart.Length())
- {
- if (basePart[basePart.Length() - numLetters - 1] != '0')
- break;
- numLetters++;
- }
- }
- else
- return false;
- _unchangedPart = basePart.Left(basePart.Length() - numLetters);
- _changedPart = basePart.Right(numLetters);
- return true;
- }
-
- UString GetNextName()
- {
- UString newName;
- // if (_newStyle || !_first)
- {
- int i;
- int numLetters = _changedPart.Length();
- for (i = numLetters - 1; i >= 0; i--)
- {
- wchar_t c = _changedPart[i];
- if (c == L'9')
- {
- c = L'0';
- newName = c + newName;
- if (i == 0)
- newName = UString(L'1') + newName;
- continue;
- }
- c++;
- newName = UString(c) + newName;
- i--;
- for (; i >= 0; i--)
- newName = _changedPart[i] + newName;
- break;
- }
- _changedPart = newName;
- }
- _first = false;
- return _unchangedPart + _changedPart + _afterPart;
- }
-};
-
-#endif
-
STDMETHODIMP CHandler::Open(IInStream *stream,
- const UInt64 *maxCheckStartPosition,
+ const UInt64 *maxCheckStartPosition,
IArchiveOpenCallback *openArchiveCallback)
{
COM_TRY_BEGIN
@@ -527,11 +415,6 @@ STDMETHODIMP CHandler::Open(IInStream *stream,
try
{
CMyComPtr<IArchiveOpenCallback> openArchiveCallbackTemp = openArchiveCallback;
- #ifdef _7Z_VOL
- CVolumeName seqName;
-
- CMyComPtr<IArchiveOpenVolumeCallback> openVolumeCallback;
- #endif
#ifndef _NO_CRYPTO
CMyComPtr<ICryptoGetTextPassword> getTextPassword;
@@ -541,127 +424,22 @@ STDMETHODIMP CHandler::Open(IInStream *stream,
IID_ICryptoGetTextPassword, &getTextPassword);
}
#endif
- #ifdef _7Z_VOL
- if (openArchiveCallback)
- {
- openArchiveCallbackTemp.QueryInterface(IID_IArchiveOpenVolumeCallback, &openVolumeCallback);
- }
- for (;;)
- {
- CMyComPtr<IInStream> inStream;
- if (!_volumes.IsEmpty())
- {
- if (!openVolumeCallback)
- break;
- if(_volumes.Size() == 1)
- {
- UString baseName;
- {
- NCOM::CPropVariant prop;
- RINOK(openVolumeCallback->GetProperty(kpidName, &prop));
- if (prop.vt != VT_BSTR)
- break;
- baseName = prop.bstrVal;
- }
- seqName.InitName(baseName);
- }
-
- UString fullName = seqName.GetNextName();
- HRESULT result = openVolumeCallback->GetStream(fullName, &inStream);
- if (result == S_FALSE)
- break;
- if (result != S_OK)
- return result;
- if (!stream)
- break;
- }
- else
- inStream = stream;
-
- CInArchive archive;
- RINOK(archive.Open(inStream, maxCheckStartPosition));
-
- _volumes.Add(CVolume());
- CVolume &volume = _volumes.Back();
- CArchiveDatabaseEx &database = volume.Database;
- volume.Stream = inStream;
- volume.StartRef2Index = _refs.Size();
-
- HRESULT result = archive.ReadDatabase(database
- #ifndef _NO_CRYPTO
- , getTextPassword
- #endif
- );
- if (result != S_OK)
- {
- _volumes.Clear();
- return result;
- }
- database.Fill();
- for(int i = 0; i < database.Files.Size(); i++)
- {
- CRef refNew;
- refNew.VolumeIndex = _volumes.Size() - 1;
- refNew.ItemIndex = i;
- _refs.Add(refNew);
- /*
- const CFileItem &file = database.Files[i];
- int j;
- */
- /*
- for (j = _refs.Size() - 1; j >= 0; j--)
- {
- CRef2 &ref2 = _refs[j];
- const CRef &ref = ref2.Refs.Back();
- const CVolume &volume2 = _volumes[ref.VolumeIndex];
- const CArchiveDatabaseEx &database2 = volume2.Database;
- const CFileItem &file2 = database2.Files[ref.ItemIndex];
- if (file2.Name.CompareNoCase(file.Name) == 0)
- {
- if (!file.IsStartPosDefined)
- continue;
- if (file.StartPos != ref2.StartPos + ref2.UnPackSize)
- continue;
- ref2.Refs.Add(refNew);
- break;
- }
- }
- */
- /*
- j = -1;
- if (j < 0)
- {
- CRef2 ref2New;
- ref2New.Refs.Add(refNew);
- j = _refs.Add(ref2New);
- }
- CRef2 &ref2 = _refs[j];
- ref2.UnPackSize += file.UnPackSize;
- ref2.PackSize += database.GetFilePackSize(i);
- if (ref2.Refs.Size() == 1 && file.IsStartPosDefined)
- ref2.StartPos = file.StartPos;
- */
- }
- if (database.Files.Size() != 1)
- break;
- const CFileItem &file = database.Files.Front();
- if (!file.IsStartPosDefined)
- break;
- }
- #else
CInArchive archive;
RINOK(archive.Open(stream, maxCheckStartPosition));
+ #ifndef _NO_CRYPTO
+ _passwordIsDefined = false;
+ UString password;
+ #endif
HRESULT result = archive.ReadDatabase(
EXTERNAL_CODECS_VARS
- _database
+ _db
#ifndef _NO_CRYPTO
- , getTextPassword
+ , getTextPassword, _passwordIsDefined
#endif
);
RINOK(result);
- _database.Fill();
+ _db.Fill();
_inStream = stream;
- #endif
}
catch(...)
{
@@ -679,75 +457,12 @@ STDMETHODIMP CHandler::Open(IInStream *stream,
STDMETHODIMP CHandler::Close()
{
COM_TRY_BEGIN
- #ifdef _7Z_VOL
- _volumes.Clear();
- _refs.Clear();
- #else
_inStream.Release();
- _database.Clear();
- #endif
+ _db.Clear();
return S_OK;
COM_TRY_END
}
-#ifdef _7Z_VOL
-STDMETHODIMP CHandler::GetStream(UInt32 index, ISequentialInStream **stream)
-{
- if (index != 0)
- return E_INVALIDARG;
- *stream = 0;
- CMultiStream *streamSpec = new CMultiStream;
- CMyComPtr<ISequentialInStream> streamTemp = streamSpec;
-
- UInt64 pos = 0;
- const UString *fileName;
- for (int i = 0; i < _refs.Size(); i++)
- {
- const CRef &ref = _refs[i];
- const CVolume &volume = _volumes[ref.VolumeIndex];
- const CArchiveDatabaseEx &database = volume.Database;
- const CFileItem &file = database.Files[ref.ItemIndex];
- if (i == 0)
- fileName = &file.Name;
- else
- if (fileName->Compare(file.Name) != 0)
- return S_FALSE;
- if (!file.IsStartPosDefined)
- return S_FALSE;
- if (file.StartPos != pos)
- return S_FALSE;
- CNum folderIndex = database.FileIndexToFolderIndexMap[ref.ItemIndex];
- if (folderIndex == kNumNoIndex)
- {
- if (file.UnPackSize != 0)
- return E_FAIL;
- continue;
- }
- if (database.NumUnPackStreamsVector[folderIndex] != 1)
- return S_FALSE;
- const CFolder &folder = database.Folders[folderIndex];
- if (folder.Coders.Size() != 1)
- return S_FALSE;
- const CCoderInfo &coder = folder.Coders.Front();
- if (coder.NumInStreams != 1 || coder.NumOutStreams != 1)
- return S_FALSE;
- if (coder.MethodID != k_Copy)
- return S_FALSE;
-
- pos += file.UnPackSize;
- CMultiStream::CSubStreamInfo subStreamInfo;
- subStreamInfo.Stream = volume.Stream;
- subStreamInfo.Pos = database.GetFolderStreamPos(folderIndex, 0);
- subStreamInfo.Size = file.UnPackSize;
- streamSpec->Streams.Add(subStreamInfo);
- }
- streamSpec->Init();
- *stream = streamTemp.Detach();
- return S_OK;
-}
-#endif
-
-
#ifdef __7Z_SET_PROPERTIES
#ifdef EXTRACT_ONLY
@@ -783,7 +498,7 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *v
}
return S_OK;
COM_TRY_END
-}
+}
#endif
#endif
diff --git a/CPP/7zip/Archive/7z/7zHandler.h b/CPP/7zip/Archive/7z/7zHandler.h
index ad4df41f..9adf8464 100755
--- a/CPP/7zip/Archive/7z/7zHandler.h
+++ b/CPP/7zip/Archive/7z/7zHandler.h
@@ -18,56 +18,35 @@
namespace NArchive {
namespace N7z {
-#ifdef _7Z_VOL
-struct CRef
-{
- int VolumeIndex;
- int ItemIndex;
-};
-
-struct CVolume
-{
- int StartRef2Index;
- CMyComPtr<IInStream> Stream;
- CArchiveDatabaseEx Database;
-};
-#endif
-
#ifndef __7Z_SET_PROPERTIES
#ifdef EXTRACT_ONLY
#ifdef COMPRESS_MT
#define __7Z_SET_PROPERTIES
#endif
-#else
+#else
#define __7Z_SET_PROPERTIES
#endif
#endif
-class CHandler:
+class CHandler:
#ifndef EXTRACT_ONLY
public NArchive::COutHandler,
#endif
public IInArchive,
- #ifdef _7Z_VOL
- public IInArchiveGetStream,
- #endif
#ifdef __7Z_SET_PROPERTIES
- public ISetProperties,
+ public ISetProperties,
#endif
#ifndef EXTRACT_ONLY
- public IOutArchive,
+ public IOutArchive,
#endif
PUBLIC_ISetCompressCodecsInfo
public CMyUnknownImp
{
public:
MY_QUERYINTERFACE_BEGIN2(IInArchive)
- #ifdef _7Z_VOL
- MY_QUERYINTERFACE_ENTRY(IInArchiveGetStream)
- #endif
#ifdef __7Z_SET_PROPERTIES
MY_QUERYINTERFACE_ENTRY(ISetProperties)
#endif
@@ -80,10 +59,6 @@ public:
INTERFACE_IInArchive(;)
- #ifdef _7Z_VOL
- STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **stream);
- #endif
-
#ifdef __7Z_SET_PROPERTIES
STDMETHOD(SetProperties)(const wchar_t **names, const PROPVARIANT *values, Int32 numProperties);
#endif
@@ -97,12 +72,10 @@ public:
CHandler();
private:
- #ifdef _7Z_VOL
- CObjectVector<CVolume> _volumes;
- CObjectVector<CRef> _refs;
- #else
CMyComPtr<IInStream> _inStream;
- NArchive::N7z::CArchiveDatabaseEx _database;
+ NArchive::N7z::CArchiveDatabaseEx _db;
+ #ifndef _NO_CRYPTO
+ bool _passwordIsDefined;
#endif
#ifdef EXTRACT_ONLY
@@ -139,6 +112,8 @@ private:
void FillPopIDs();
#endif
+
+ DECL_EXTERNAL_CODECS_VARS
};
}}
diff --git a/CPP/7zip/Archive/7z/7zHandlerOut.cpp b/CPP/7zip/Archive/7z/7zHandlerOut.cpp
index af4b9427..ac9ef987 100755
--- a/CPP/7zip/Archive/7z/7zHandlerOut.cpp
+++ b/CPP/7zip/Archive/7z/7zHandlerOut.cpp
@@ -163,7 +163,7 @@ HRESULT CHandler::SetCompressionMethod(
for (int j = 0; j < methodFull.Properties.Size(); j++)
{
const CProp &prop = methodFull.Properties[j];
- if ((prop.Id == NCoderPropID::kDictionarySize ||
+ if ((prop.Id == NCoderPropID::kDictionarySize ||
prop.Id == NCoderPropID::kUsedMemorySize) && prop.Value.vt == VT_UI4)
{
_numSolidBytes = ((UInt64)prop.Value.ulVal) << 7;
@@ -185,17 +185,20 @@ HRESULT CHandler::SetCompressionMethod(
return S_OK;
}
-static HRESULT GetTime(IArchiveUpdateCallback *updateCallback, int index, PROPID propID, CArchiveFileTime &filetime, bool &filetimeIsDefined)
+static HRESULT GetTime(IArchiveUpdateCallback *updateCallback, int index, bool writeTime, PROPID propID, UInt64 &ft, bool &ftDefined)
{
- filetimeIsDefined = false;
- NCOM::CPropVariant propVariant;
- RINOK(updateCallback->GetProperty(index, propID, &propVariant));
- if (propVariant.vt == VT_FILETIME)
+ ft = 0;
+ ftDefined = false;
+ if (!writeTime)
+ return S_OK;
+ NCOM::CPropVariant prop;
+ RINOK(updateCallback->GetProperty(index, propID, &prop));
+ if (prop.vt == VT_FILETIME)
{
- filetime = propVariant.filetime;
- filetimeIsDefined = true;
+ ft = prop.filetime.dwLowDateTime | ((UInt64)prop.filetime.dwHighDateTime << 32);
+ ftDefined = true;
}
- else if (propVariant.vt != VT_EMPTY)
+ else if (prop.vt != VT_EMPTY)
return E_INVALIDARG;
return S_OK;
}
@@ -205,7 +208,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
{
COM_TRY_BEGIN
- const CArchiveDatabaseEx *database = 0;
+ const CArchiveDatabaseEx *db = 0;
#ifdef _7Z_VOL
if(_volumes.Size() > 1)
return E_FAIL;
@@ -213,139 +216,131 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
if (_volumes.Size() == 1)
{
volume = &_volumes.Front();
- database = &volume->Database;
+ db = &volume->Database;
}
#else
if (_inStream != 0)
- database = &_database;
+ db = &_db;
#endif
- // CRecordVector<bool> compressStatuses;
CObjectVector<CUpdateItem> updateItems;
- // CRecordVector<UInt32> copyIndices;
- // CMyComPtr<IUpdateCallback2> updateCallback2;
- // updateCallback->QueryInterface(&updateCallback2);
-
- for(UInt32 i = 0; i < numItems; i++)
+ for (UInt32 i = 0; i < numItems; i++)
{
Int32 newData;
Int32 newProperties;
UInt32 indexInArchive;
if (!updateCallback)
return E_FAIL;
- RINOK(updateCallback->GetUpdateItemInfo(i,
- &newData, &newProperties, &indexInArchive));
- CUpdateItem updateItem;
- updateItem.NewProperties = IntToBool(newProperties);
- updateItem.NewData = IntToBool(newData);
- updateItem.IndexInArchive = indexInArchive;
- updateItem.IndexInClient = i;
- updateItem.IsAnti = false;
- updateItem.Size = 0;
-
- if (updateItem.IndexInArchive != -1)
+ RINOK(updateCallback->GetUpdateItemInfo(i, &newData, &newProperties, &indexInArchive));
+ CUpdateItem ui;
+ ui.NewProperties = IntToBool(newProperties);
+ ui.NewData = IntToBool(newData);
+ ui.IndexInArchive = indexInArchive;
+ ui.IndexInClient = i;
+ ui.IsAnti = false;
+ ui.Size = 0;
+
+ if (ui.IndexInArchive != -1)
{
- const CFileItem &fileItem = database->Files[updateItem.IndexInArchive];
- updateItem.Name = fileItem.Name;
- updateItem.IsDirectory = fileItem.IsDirectory;
- updateItem.Size = fileItem.UnPackSize;
- updateItem.IsAnti = fileItem.IsAnti;
+ const CFileItem &fi = db->Files[ui.IndexInArchive];
+ ui.Name = fi.Name;
+ ui.IsDir = fi.IsDir;
+ ui.Size = fi.Size;
+ ui.IsAnti = db->IsItemAnti(ui.IndexInArchive);
- updateItem.CreationTime = fileItem.CreationTime;
- updateItem.IsCreationTimeDefined = fileItem.IsCreationTimeDefined;
- updateItem.LastWriteTime = fileItem.LastWriteTime;
- updateItem.IsLastWriteTimeDefined = fileItem.IsLastWriteTimeDefined;
- updateItem.LastAccessTime = fileItem.LastAccessTime;
- updateItem.IsLastAccessTimeDefined = fileItem.IsLastAccessTimeDefined;
+ ui.CTimeDefined = db->CTime.GetItem(ui.IndexInArchive, ui.CTime);
+ ui.ATimeDefined = db->ATime.GetItem(ui.IndexInArchive, ui.ATime);
+ ui.MTimeDefined = db->MTime.GetItem(ui.IndexInArchive, ui.MTime);
}
- if (updateItem.NewProperties)
+ if (ui.NewProperties)
{
bool nameIsDefined;
bool folderStatusIsDefined;
{
- NCOM::CPropVariant propVariant;
- RINOK(updateCallback->GetProperty(i, kpidAttributes, &propVariant));
- if (propVariant.vt == VT_EMPTY)
- updateItem.AttributesAreDefined = false;
- else if (propVariant.vt != VT_UI4)
+ NCOM::CPropVariant prop;
+ RINOK(updateCallback->GetProperty(i, kpidAttrib, &prop));
+ if (prop.vt == VT_EMPTY)
+ ui.AttribDefined = false;
+ else if (prop.vt != VT_UI4)
return E_INVALIDARG;
else
{
- updateItem.Attributes = propVariant.ulVal;
- updateItem.AttributesAreDefined = true;
+ ui.Attrib = prop.ulVal;
+ ui.AttribDefined = true;
}
}
- RINOK(GetTime(updateCallback, i, kpidCreationTime, updateItem.CreationTime, updateItem.IsCreationTimeDefined));
- RINOK(GetTime(updateCallback, i, kpidLastWriteTime, updateItem.LastWriteTime , updateItem.IsLastWriteTimeDefined));
- RINOK(GetTime(updateCallback, i, kpidLastAccessTime, updateItem.LastAccessTime, updateItem.IsLastAccessTimeDefined));
+ // we need MTime to sort files.
+ RINOK(GetTime(updateCallback, i, WriteCTime, kpidCTime, ui.CTime, ui.CTimeDefined));
+ RINOK(GetTime(updateCallback, i, WriteATime, kpidATime, ui.ATime, ui.ATimeDefined));
+ RINOK(GetTime(updateCallback, i, true, kpidMTime, ui.MTime, ui.MTimeDefined));
{
- NCOM::CPropVariant propVariant;
- RINOK(updateCallback->GetProperty(i, kpidPath, &propVariant));
- if (propVariant.vt == VT_EMPTY)
+ NCOM::CPropVariant prop;
+ RINOK(updateCallback->GetProperty(i, kpidPath, &prop));
+ if (prop.vt == VT_EMPTY)
nameIsDefined = false;
- else if (propVariant.vt != VT_BSTR)
+ else if (prop.vt != VT_BSTR)
return E_INVALIDARG;
else
{
- updateItem.Name = NItemName::MakeLegalName(propVariant.bstrVal);
+ ui.Name = NItemName::MakeLegalName(prop.bstrVal);
nameIsDefined = true;
}
}
{
- NCOM::CPropVariant propVariant;
- RINOK(updateCallback->GetProperty(i, kpidIsFolder, &propVariant));
- if (propVariant.vt == VT_EMPTY)
+ NCOM::CPropVariant prop;
+ RINOK(updateCallback->GetProperty(i, kpidIsDir, &prop));
+ if (prop.vt == VT_EMPTY)
folderStatusIsDefined = false;
- else if (propVariant.vt != VT_BOOL)
+ else if (prop.vt != VT_BOOL)
return E_INVALIDARG;
else
{
- updateItem.IsDirectory = (propVariant.boolVal != VARIANT_FALSE);
+ ui.IsDir = (prop.boolVal != VARIANT_FALSE);
folderStatusIsDefined = true;
}
}
{
- NCOM::CPropVariant propVariant;
- RINOK(updateCallback->GetProperty(i, kpidIsAnti, &propVariant));
- if (propVariant.vt == VT_EMPTY)
- updateItem.IsAnti = false;
- else if (propVariant.vt != VT_BOOL)
+ NCOM::CPropVariant prop;
+ RINOK(updateCallback->GetProperty(i, kpidIsAnti, &prop));
+ if (prop.vt == VT_EMPTY)
+ ui.IsAnti = false;
+ else if (prop.vt != VT_BOOL)
return E_INVALIDARG;
else
- updateItem.IsAnti = (propVariant.boolVal != VARIANT_FALSE);
+ ui.IsAnti = (prop.boolVal != VARIANT_FALSE);
}
- if (updateItem.IsAnti)
+ if (ui.IsAnti)
{
- updateItem.AttributesAreDefined = false;
+ ui.AttribDefined = false;
- updateItem.IsCreationTimeDefined = false;
- updateItem.IsLastWriteTimeDefined = false;
- updateItem.IsLastAccessTimeDefined = false;
+ ui.CTimeDefined = false;
+ ui.ATimeDefined = false;
+ ui.MTimeDefined = false;
- updateItem.Size = 0;
+ ui.Size = 0;
}
- if (!folderStatusIsDefined && updateItem.AttributesAreDefined)
- updateItem.SetDirectoryStatusFromAttributes();
+ if (!folderStatusIsDefined && ui.AttribDefined)
+ ui.SetDirStatusFromAttrib();
}
- if (updateItem.NewData)
+ if (ui.NewData)
{
- NCOM::CPropVariant propVariant;
- RINOK(updateCallback->GetProperty(i, kpidSize, &propVariant));
- if (propVariant.vt != VT_UI8)
+ NCOM::CPropVariant prop;
+ RINOK(updateCallback->GetProperty(i, kpidSize, &prop));
+ if (prop.vt != VT_UI8)
return E_INVALIDARG;
- updateItem.Size = (UInt64)propVariant.uhVal.QuadPart;
- if (updateItem.Size != 0 && updateItem.IsAnti)
+ ui.Size = (UInt64)prop.uhVal.QuadPart;
+ if (ui.Size != 0 && ui.IsAnti)
return E_INVALIDARG;
}
- updateItems.Add(updateItem);
+ updateItems.Add(ui);
}
CCompressionMethodMode methodMode, headerMethod;
@@ -359,10 +354,18 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
bool compressMainHeader = _compressHeaders; // check it
+ bool encryptHeaders = false;
+
if (methodMode.PasswordIsDefined)
{
- compressMainHeader = true;
- if(_encryptHeaders)
+ if (_encryptHeadersSpecified)
+ encryptHeaders = _encryptHeaders;
+ #ifndef _NO_CRYPTO
+ else
+ encryptHeaders = _passwordIsDefined;
+ #endif
+ compressMainHeader = true;
+ if(encryptHeaders)
RINOK(SetPassword(headerMethod, updateCallback));
}
@@ -371,32 +374,42 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
CUpdateOptions options;
options.Method = &methodMode;
- options.HeaderMethod = (_compressHeaders ||
- (methodMode.PasswordIsDefined && _encryptHeaders)) ?
- &headerMethod : 0;
+ options.HeaderMethod = (_compressHeaders || encryptHeaders) ? &headerMethod : 0;
options.UseFilters = _level != 0 && _autoFilter;
options.MaxFilter = _level >= 8;
options.HeaderOptions.CompressMainHeader = compressMainHeader;
- options.HeaderOptions.WriteModified = WriteModified;
- options.HeaderOptions.WriteCreated = WriteCreated;
- options.HeaderOptions.WriteAccessed = WriteAccessed;
+ options.HeaderOptions.WriteCTime = WriteCTime;
+ options.HeaderOptions.WriteATime = WriteATime;
+ options.HeaderOptions.WriteMTime = WriteMTime;
options.NumSolidFiles = _numSolidFiles;
options.NumSolidBytes = _numSolidBytes;
options.SolidExtension = _solidExtension;
options.RemoveSfxBlock = _removeSfxBlock;
options.VolumeMode = _volumeMode;
- return Update(
+
+ COutArchive archive;
+ CArchiveDatabase newDatabase;
+ HRESULT res = Update(
EXTERNAL_CODECS_VARS
#ifdef _7Z_VOL
- volume ? volume->Stream: 0,
- volume ? database: 0,
+ volume ? volume->Stream: 0,
+ volume ? db : 0,
#else
- _inStream,
- database,
+ _inStream,
+ db,
#endif
- updateItems, outStream, updateCallback, options);
+ updateItems,
+ archive, newDatabase, outStream, updateCallback, options);
+
+ RINOK(res);
+
+ updateItems.ClearAndFree();
+
+ return archive.WriteDatabase(EXTERNAL_CODECS_VARS
+ newDatabase, options.HeaderMethod, options.HeaderOptions);
+
COM_TRY_END
}
@@ -459,6 +472,6 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *v
return S_OK;
COM_TRY_END
-}
+}
}}
diff --git a/CPP/7zip/Archive/7z/7zHeader.cpp b/CPP/7zip/Archive/7z/7zHeader.cpp
index 425231fc..f232a23e 100755
--- a/CPP/7zip/Archive/7z/7zHeader.cpp
+++ b/CPP/7zip/Archive/7z/7zHeader.cpp
@@ -14,9 +14,9 @@ Byte kFinishSignature[kSignatureSize] = {'7' + 1, 'z', 0xBC, 0xAF, 0x27, 0x1C +
class SignatureInitializer
{
public:
- SignatureInitializer()
- {
- kSignature[0]--;
+ SignatureInitializer()
+ {
+ kSignature[0]--;
#ifdef _7Z_VOL
kFinishSignature[0]--;
#endif
diff --git a/CPP/7zip/Archive/7z/7zHeader.h b/CPP/7zip/Archive/7z/7zHeader.h
index e239ab23..30622b90 100755
--- a/CPP/7zip/Archive/7z/7zHeader.h
+++ b/CPP/7zip/Archive/7z/7zHeader.h
@@ -13,7 +13,7 @@ extern Byte kSignature[kSignatureSize];
// #define _7Z_VOL
// 7z-MultiVolume is not finished yet.
-// It can work already, but I still do not like some
+// It can work already, but I still do not like some
// things of that new multivolume format.
// So please keep it commented.
@@ -63,7 +63,7 @@ namespace NID
kFilesInfo,
kPackInfo,
- kUnPackInfo,
+ kUnpackInfo,
kSubStreamsInfo,
kSize,
@@ -71,23 +71,24 @@ namespace NID
kFolder,
- kCodersUnPackSize,
- kNumUnPackStream,
+ kCodersUnpackSize,
+ kNumUnpackStream,
kEmptyStream,
kEmptyFile,
kAnti,
kName,
- kCreationTime,
- kLastAccessTime,
- kLastWriteTime,
+ kCTime,
+ kATime,
+ kMTime,
kWinAttributes,
kComment,
kEncodedHeader,
- kStartPos
+ kStartPos,
+ kDummy
};
}
diff --git a/CPP/7zip/Archive/7z/7zIn.cpp b/CPP/7zip/Archive/7z/7zIn.cpp
index f892e0cd..6cf3fdf6 100755
--- a/CPP/7zip/Archive/7z/7zIn.cpp
+++ b/CPP/7zip/Archive/7z/7zIn.cpp
@@ -6,13 +6,17 @@
#include "7zDecode.h"
#include "../../Common/StreamObjects.h"
#include "../../Common/StreamUtils.h"
-extern "C"
-{
-#include "../../../../C/7zCrc.h"
-#include "../../../../C/CpuArch.h"
+extern "C"
+{
+ #include "../../../../C/7zCrc.h"
+ #include "../../../../C/CpuArch.h"
}
-// define FORMAT_7Z_RECOVERY if you want to recover multivolume archives with empty StartHeader
+#define Get16(p) GetUi16(p)
+#define Get32(p) GetUi32(p)
+#define Get64(p) GetUi64(p)
+
+// define FORMAT_7Z_RECOVERY if you want to recover multivolume archives with empty StartHeader
#ifndef _SFX
#define FORMAT_7Z_RECOVERY
#endif
@@ -36,7 +40,7 @@ public:
{
kUnsupportedVersion = 0,
kUnsupported,
- kIncorrect,
+ kIncorrect,
kEndOfData,
} Cause;
CInArchiveException(CCauseType cause): Cause(cause) {};
@@ -97,16 +101,6 @@ void CStreamSwitch::Set(CInArchive *archive, const CObjectVector<CByteBuffer> *d
}
}
-#ifdef LITTLE_ENDIAN_UNALIGN
-static inline UInt16 GetUInt16FromMem(const Byte *p) { return *(const UInt16 *)p; }
-static inline UInt32 GetUInt32FromMem(const Byte *p) { return *(const UInt32 *)p; }
-static inline UInt64 GetUInt64FromMem(const Byte *p) { return *(const UInt64 *)p; }
-#else
-static inline UInt16 GetUInt16FromMem(const Byte *p) { return p[0] | ((UInt16)p[1] << 8); }
-static inline UInt32 GetUInt32FromMem(const Byte *p) { return p[0] | ((UInt32)p[1] << 8) | ((UInt32)p[2] << 16) | ((UInt32)p[3] << 24); }
-static inline UInt64 GetUInt64FromMem(const Byte *p) { return GetUInt32FromMem(p) | ((UInt64)GetUInt32FromMem(p + 4) << 32); }
-#endif
-
Byte CInByte2::ReadByte()
{
if (_pos >= _size)
@@ -126,6 +120,7 @@ void CInByte2::SkeepData(UInt64 size)
{
if (size > _size - _pos)
ThrowEndOfData();
+ _pos += (size_t)size;
}
void CInByte2::SkeepData()
@@ -157,8 +152,8 @@ UInt64 CInByte2::ReadNumber()
}
CNum CInByte2::ReadNum()
-{
- UInt64 value = ReadNumber();
+{
+ UInt64 value = ReadNumber();
if (value > kNumMax)
ThrowUnsupported();
return (CNum)value;
@@ -168,7 +163,7 @@ UInt32 CInByte2::ReadUInt32()
{
if (_pos + 4 > _size)
ThrowEndOfData();
- UInt32 res = GetUInt32FromMem(_buffer + _pos);
+ UInt32 res = Get32(_buffer + _pos);
_pos += 4;
return res;
}
@@ -177,7 +172,7 @@ UInt64 CInByte2::ReadUInt64()
{
if (_pos + 8 > _size)
ThrowEndOfData();
- UInt64 res = GetUInt64FromMem(_buffer + _pos);
+ UInt64 res = Get64(_buffer + _pos);
_pos += 8;
return res;
}
@@ -200,9 +195,8 @@ void CInByte2::ReadString(UString &s)
ThrowUnsupported();
wchar_t *p = s.GetBuffer(len);
int i;
- for (i = 0; i < len; i++, buf += 2)
- p[i] = (wchar_t)GetUInt16FromMem(buf);
- p[i] = 0;
+ for (i = 0; i < len; i++, buf += 2)
+ p[i] = (wchar_t)Get16(buf);
s.ReleaseBuffer(len);
_pos += rem + 2;
}
@@ -234,23 +228,32 @@ HRESULT CInArchive::FindAndReadSignature(IInStream *stream, const UInt64 *search
if (searchHeaderSizeLimit != NULL)
if (curTestPos - _arhiveBeginStreamPosition > *searchHeaderSizeLimit)
break;
- UInt32 numReadBytes = kBufferSize - numPrevBytes;
- UInt32 processedSize;
- RINOK(stream->Read(buffer + numPrevBytes, numReadBytes, &processedSize));
- UInt32 numBytesInBuffer = numPrevBytes + processedSize;
- if (numBytesInBuffer < kHeaderSize)
- break;
- UInt32 numTests = numBytesInBuffer - kHeaderSize + 1;
- for(UInt32 pos = 0; pos < numTests; pos++, curTestPos++)
- {
+ do
+ {
+ UInt32 numReadBytes = kBufferSize - numPrevBytes;
+ UInt32 processedSize;
+ RINOK(stream->Read(buffer + numPrevBytes, numReadBytes, &processedSize));
+ numPrevBytes += processedSize;
+ if (processedSize == 0)
+ return S_FALSE;
+ }
+ while (numPrevBytes < kHeaderSize);
+ UInt32 numTests = numPrevBytes - kHeaderSize + 1;
+ for (UInt32 pos = 0; pos < numTests; pos++)
+ {
+ for (; buffer[pos] != '7' && pos < numTests; pos++);
+ if (pos == numTests)
+ break;
if (TestSignatureCandidate(buffer + pos))
{
memcpy(_header, buffer + pos, kHeaderSize);
+ curTestPos += pos;
_arhiveBeginStreamPosition = curTestPos;
return stream->Seek(curTestPos + kHeaderSize, STREAM_SEEK_SET, NULL);
}
}
- numPrevBytes = numBytesInBuffer - numTests;
+ curTestPos += numTests;
+ numPrevBytes -= numTests;
memmove(buffer, buffer + numTests, numPrevBytes);
}
return S_FALSE;
@@ -259,6 +262,7 @@ HRESULT CInArchive::FindAndReadSignature(IInStream *stream, const UInt64 *search
// S_FALSE means that file is not archive
HRESULT CInArchive::Open(IInStream *stream, const UInt64 *searchHeaderSizeLimit)
{
+ HeadersSize = 0;
Close();
RINOK(stream->Seek(0, STREAM_SEEK_CUR, &_arhiveBeginStreamPosition))
RINOK(FindAndReadSignature(stream, searchHeaderSizeLimit));
@@ -338,7 +342,7 @@ void CInArchive::GetNextFolderItem(CFolder &folder)
{
CBindPair bindPair;
bindPair.InIndex = ReadNum();
- bindPair.OutIndex = ReadNum();
+ bindPair.OutIndex = ReadNum();
folder.BindPairs.Add(bindPair);
}
@@ -354,7 +358,7 @@ void CInArchive::GetNextFolderItem(CFolder &folder)
}
}
else
- for(i = 0; i < numPackedStreams; i++)
+ for (i = 0; i < numPackedStreams; i++)
folder.PackStreams.Add(ReadNum());
}
@@ -372,13 +376,13 @@ void CInArchive::WaitAttribute(UInt64 attribute)
}
void CInArchive::ReadHashDigests(int numItems,
- CRecordVector<bool> &digestsDefined,
+ CRecordVector<bool> &digestsDefined,
CRecordVector<UInt32> &digests)
{
ReadBoolVector2(numItems, digestsDefined);
digests.Clear();
digests.Reserve(numItems);
- for(int i = 0; i < numItems; i++)
+ for (int i = 0; i < numItems; i++)
{
UInt32 crc = 0;
if (digestsDefined[i])
@@ -410,7 +414,7 @@ void CInArchive::ReadPackInfo(
break;
if (type == NID::kCRC)
{
- ReadHashDigests(numPackStreams, packCRCsDefined, packCRCs);
+ ReadHashDigests(numPackStreams, packCRCsDefined, packCRCs);
continue;
}
SkeepData();
@@ -421,7 +425,7 @@ void CInArchive::ReadPackInfo(
packCRCsDefined.Clear();
packCRCs.Reserve(numPackStreams);
packCRCs.Clear();
- for(CNum i = 0; i < numPackStreams; i++)
+ for (CNum i = 0; i < numPackStreams; i++)
{
packCRCsDefined.Add(false);
packCRCs.Add(0);
@@ -429,7 +433,7 @@ void CInArchive::ReadPackInfo(
}
}
-void CInArchive::ReadUnPackInfo(
+void CInArchive::ReadUnpackInfo(
const CObjectVector<CByteBuffer> *dataVector,
CObjectVector<CFolder> &folders)
{
@@ -441,23 +445,23 @@ void CInArchive::ReadUnPackInfo(
streamSwitch.Set(this, dataVector);
folders.Clear();
folders.Reserve(numFolders);
- for(CNum i = 0; i < numFolders; i++)
+ for (CNum i = 0; i < numFolders; i++)
{
folders.Add(CFolder());
GetNextFolderItem(folders.Back());
}
}
- WaitAttribute(NID::kCodersUnPackSize);
+ WaitAttribute(NID::kCodersUnpackSize);
CNum i;
for (i = 0; i < numFolders; i++)
{
CFolder &folder = folders[i];
CNum numOutStreams = folder.GetNumOutStreams();
- folder.UnPackSizes.Reserve(numOutStreams);
+ folder.UnpackSizes.Reserve(numOutStreams);
for (CNum j = 0; j < numOutStreams; j++)
- folder.UnPackSizes.Add(ReadNumber());
+ folder.UnpackSizes.Add(ReadNumber());
}
for (;;)
@@ -469,12 +473,12 @@ void CInArchive::ReadUnPackInfo(
{
CRecordVector<bool> crcsDefined;
CRecordVector<UInt32> crcs;
- ReadHashDigests(numFolders, crcsDefined, crcs);
- for(i = 0; i < numFolders; i++)
+ ReadHashDigests(numFolders, crcsDefined, crcs);
+ for (i = 0; i < numFolders; i++)
{
CFolder &folder = folders[i];
- folder.UnPackCRCDefined = crcsDefined[i];
- folder.UnPackCRC = crcs[i];
+ folder.UnpackCRCDefined = crcsDefined[i];
+ folder.UnpackCRC = crcs[i];
}
continue;
}
@@ -484,21 +488,21 @@ void CInArchive::ReadUnPackInfo(
void CInArchive::ReadSubStreamsInfo(
const CObjectVector<CFolder> &folders,
- CRecordVector<CNum> &numUnPackStreamsInFolders,
- CRecordVector<UInt64> &unPackSizes,
- CRecordVector<bool> &digestsDefined,
+ CRecordVector<CNum> &numUnpackStreamsInFolders,
+ CRecordVector<UInt64> &unpackSizes,
+ CRecordVector<bool> &digestsDefined,
CRecordVector<UInt32> &digests)
{
- numUnPackStreamsInFolders.Clear();
- numUnPackStreamsInFolders.Reserve(folders.Size());
+ numUnpackStreamsInFolders.Clear();
+ numUnpackStreamsInFolders.Reserve(folders.Size());
UInt64 type;
for (;;)
{
type = ReadID();
- if (type == NID::kNumUnPackStream)
+ if (type == NID::kNumUnpackStream)
{
- for(int i = 0; i < folders.Size(); i++)
- numUnPackStreamsInFolders.Add(ReadNum());
+ for (int i = 0; i < folders.Size(); i++)
+ numUnpackStreamsInFolders.Add(ReadNum());
continue;
}
if (type == NID::kCRC || type == NID::kSize)
@@ -508,16 +512,16 @@ void CInArchive::ReadSubStreamsInfo(
SkeepData();
}
- if (numUnPackStreamsInFolders.IsEmpty())
- for(int i = 0; i < folders.Size(); i++)
- numUnPackStreamsInFolders.Add(1);
+ if (numUnpackStreamsInFolders.IsEmpty())
+ for (int i = 0; i < folders.Size(); i++)
+ numUnpackStreamsInFolders.Add(1);
int i;
- for(i = 0; i < numUnPackStreamsInFolders.Size(); i++)
+ for (i = 0; i < numUnpackStreamsInFolders.Size(); i++)
{
// v3.13 incorrectly worked with empty folders
// v4.07: we check that folder is empty
- CNum numSubstreams = numUnPackStreamsInFolders[i];
+ CNum numSubstreams = numUnpackStreamsInFolders[i];
if (numSubstreams == 0)
continue;
UInt64 sum = 0;
@@ -525,20 +529,20 @@ void CInArchive::ReadSubStreamsInfo(
if (type == NID::kSize)
{
UInt64 size = ReadNumber();
- unPackSizes.Add(size);
+ unpackSizes.Add(size);
sum += size;
}
- unPackSizes.Add(folders[i].GetUnPackSize() - sum);
+ unpackSizes.Add(folders[i].GetUnpackSize() - sum);
}
if (type == NID::kSize)
type = ReadID();
int numDigests = 0;
int numDigestsTotal = 0;
- for(i = 0; i < folders.Size(); i++)
+ for (i = 0; i < folders.Size(); i++)
{
- CNum numSubstreams = numUnPackStreamsInFolders[i];
- if (numSubstreams != 1 || !folders[i].UnPackCRCDefined)
+ CNum numSubstreams = numUnpackStreamsInFolders[i];
+ if (numSubstreams != 1 || !folders[i].UnpackCRCDefined)
numDigests += numSubstreams;
numDigestsTotal += numSubstreams;
}
@@ -547,18 +551,18 @@ void CInArchive::ReadSubStreamsInfo(
{
if (type == NID::kCRC)
{
- CRecordVector<bool> digestsDefined2;
+ CRecordVector<bool> digestsDefined2;
CRecordVector<UInt32> digests2;
ReadHashDigests(numDigests, digestsDefined2, digests2);
int digestIndex = 0;
for (i = 0; i < folders.Size(); i++)
{
- CNum numSubstreams = numUnPackStreamsInFolders[i];
+ CNum numSubstreams = numUnpackStreamsInFolders[i];
const CFolder &folder = folders[i];
- if (numSubstreams == 1 && folder.UnPackCRCDefined)
+ if (numSubstreams == 1 && folder.UnpackCRCDefined)
{
digestsDefined.Add(true);
- digests.Add(folder.UnPackCRC);
+ digests.Add(folder.UnpackCRC);
}
else
for (CNum j = 0; j < numSubstreams; j++, digestIndex++)
@@ -595,9 +599,9 @@ void CInArchive::ReadStreamsInfo(
CRecordVector<bool> &packCRCsDefined,
CRecordVector<UInt32> &packCRCs,
CObjectVector<CFolder> &folders,
- CRecordVector<CNum> &numUnPackStreamsInFolders,
- CRecordVector<UInt64> &unPackSizes,
- CRecordVector<bool> &digestsDefined,
+ CRecordVector<CNum> &numUnpackStreamsInFolders,
+ CRecordVector<UInt64> &unpackSizes,
+ CRecordVector<bool> &digestsDefined,
CRecordVector<UInt32> &digests)
{
for (;;)
@@ -614,15 +618,15 @@ void CInArchive::ReadStreamsInfo(
ReadPackInfo(dataOffset, packSizes, packCRCsDefined, packCRCs);
break;
}
- case NID::kUnPackInfo:
+ case NID::kUnpackInfo:
{
- ReadUnPackInfo(dataVector, folders);
+ ReadUnpackInfo(dataVector, folders);
break;
}
case NID::kSubStreamsInfo:
{
- ReadSubStreamsInfo(folders, numUnPackStreamsInFolders,
- unPackSizes, digestsDefined, digests);
+ ReadSubStreamsInfo(folders, numUnpackStreamsInFolders,
+ unpackSizes, digestsDefined, digests);
break;
}
default:
@@ -637,7 +641,7 @@ void CInArchive::ReadBoolVector(int numItems, CBoolVector &v)
v.Reserve(numItems);
Byte b = 0;
Byte mask = 0;
- for(int i = 0; i < numItems; i++)
+ for (int i = 0; i < numItems; i++)
{
if (mask == 0)
{
@@ -663,54 +667,30 @@ void CInArchive::ReadBoolVector2(int numItems, CBoolVector &v)
v.Add(true);
}
-void CInArchive::ReadTime(const CObjectVector<CByteBuffer> &dataVector,
- CObjectVector<CFileItem> &files, UInt32 type)
+void CInArchive::ReadUInt64DefVector(const CObjectVector<CByteBuffer> &dataVector,
+ CUInt64DefVector &v, int numFiles)
{
- CBoolVector boolVector;
- ReadBoolVector2(files.Size(), boolVector);
+ ReadBoolVector2(numFiles, v.Defined);
CStreamSwitch streamSwitch;
streamSwitch.Set(this, &dataVector);
+ v.Values.Reserve(numFiles);
- for(int i = 0; i < files.Size(); i++)
+ for (int i = 0; i < numFiles; i++)
{
- CFileItem &file = files[i];
- CArchiveFileTime fileTime;
- fileTime.dwLowDateTime = 0;
- fileTime.dwHighDateTime = 0;
- bool defined = boolVector[i];
- if (defined)
- {
- fileTime.dwLowDateTime = ReadUInt32();
- fileTime.dwHighDateTime = ReadUInt32();
- }
- switch(type)
- {
- case NID::kCreationTime:
- file.IsCreationTimeDefined = defined;
- if (defined)
- file.CreationTime = fileTime;
- break;
- case NID::kLastWriteTime:
- file.IsLastWriteTimeDefined = defined;
- if (defined)
- file.LastWriteTime = fileTime;
- break;
- case NID::kLastAccessTime:
- file.IsLastAccessTimeDefined = defined;
- if (defined)
- file.LastAccessTime = fileTime;
- break;
- }
+ UInt64 t = 0;
+ if (v.Defined[i])
+ t = ReadUInt64();
+ v.Values.Add(t);
}
}
HRESULT CInArchive::ReadAndDecodePackedStreams(
DECL_EXTERNAL_CODECS_LOC_VARS
- UInt64 baseOffset,
+ UInt64 baseOffset,
UInt64 &dataOffset, CObjectVector<CByteBuffer> &dataVector
#ifndef _NO_CRYPTO
- , ICryptoGetTextPassword *getTextPassword
+ , ICryptoGetTextPassword *getTextPassword, bool &passwordIsDefined
#endif
)
{
@@ -719,23 +699,23 @@ HRESULT CInArchive::ReadAndDecodePackedStreams(
CRecordVector<UInt32> packCRCs;
CObjectVector<CFolder> folders;
- CRecordVector<CNum> numUnPackStreamsInFolders;
- CRecordVector<UInt64> unPackSizes;
+ CRecordVector<CNum> numUnpackStreamsInFolders;
+ CRecordVector<UInt64> unpackSizes;
CRecordVector<bool> digestsDefined;
CRecordVector<UInt32> digests;
- ReadStreamsInfo(NULL,
+ ReadStreamsInfo(NULL,
dataOffset,
- packSizes,
- packCRCsDefined,
- packCRCs,
+ packSizes,
+ packCRCsDefined,
+ packCRCs,
folders,
- numUnPackStreamsInFolders,
- unPackSizes,
- digestsDefined,
+ numUnpackStreamsInFolders,
+ unpackSizes,
+ digestsDefined,
digests);
- // database.ArchiveInfo.DataStartPosition2 += database.ArchiveInfo.StartPositionAfterHeader;
+ // db.ArchiveInfo.DataStartPosition2 += db.ArchiveInfo.StartPositionAfterHeader;
CNum packIndex = 0;
CDecoder decoder(
@@ -746,27 +726,27 @@ HRESULT CInArchive::ReadAndDecodePackedStreams(
#endif
);
UInt64 dataStartPos = baseOffset + dataOffset;
- for(int i = 0; i < folders.Size(); i++)
+ for (int i = 0; i < folders.Size(); i++)
{
const CFolder &folder = folders[i];
dataVector.Add(CByteBuffer());
CByteBuffer &data = dataVector.Back();
- UInt64 unPackSize64 = folder.GetUnPackSize();
- size_t unPackSize = (size_t)unPackSize64;
- if (unPackSize != unPackSize64)
+ UInt64 unpackSize64 = folder.GetUnpackSize();
+ size_t unpackSize = (size_t)unpackSize64;
+ if (unpackSize != unpackSize64)
ThrowUnsupported();
- data.SetCapacity(unPackSize);
+ data.SetCapacity(unpackSize);
CSequentialOutStreamImp2 *outStreamSpec = new CSequentialOutStreamImp2;
CMyComPtr<ISequentialOutStream> outStream = outStreamSpec;
- outStreamSpec->Init(data, unPackSize);
+ outStreamSpec->Init(data, unpackSize);
HRESULT result = decoder.Decode(
EXTERNAL_CODECS_LOC_VARS
- _stream, dataStartPos,
+ _stream, dataStartPos,
&packSizes[packIndex], folder, outStream, NULL
#ifndef _NO_CRYPTO
- , getTextPassword
+ , getTextPassword, passwordIsDefined
#endif
#ifdef COMPRESS_MT
, false, 1
@@ -774,20 +754,24 @@ HRESULT CInArchive::ReadAndDecodePackedStreams(
);
RINOK(result);
- if (folder.UnPackCRCDefined)
- if (CrcCalc(data, unPackSize) != folder.UnPackCRC)
+ if (folder.UnpackCRCDefined)
+ if (CrcCalc(data, unpackSize) != folder.UnpackCRC)
ThrowIncorrect();
- for (int j = 0; j < folder.PackStreams.Size(); j++)
- dataStartPos += packSizes[packIndex++];
+ for (int j = 0; j < folder.PackStreams.Size(); j++)
+ {
+ UInt64 packSize = packSizes[packIndex++];
+ dataStartPos += packSize;
+ HeadersSize += packSize;
+ }
}
return S_OK;
}
HRESULT CInArchive::ReadHeader(
DECL_EXTERNAL_CODECS_LOC_VARS
- CArchiveDatabaseEx &database
+ CArchiveDatabaseEx &db
#ifndef _NO_CRYPTO
- , ICryptoGetTextPassword *getTextPassword
+ , ICryptoGetTextPassword *getTextPassword, bool &passwordIsDefined
#endif
)
{
@@ -795,7 +779,7 @@ HRESULT CInArchive::ReadHeader(
if (type == NID::kArchiveProperties)
{
- ReadArchiveProperties(database.ArchiveInfo);
+ ReadArchiveProperties(db.ArchiveInfo);
type = ReadID();
}
@@ -805,50 +789,50 @@ HRESULT CInArchive::ReadHeader(
{
HRESULT result = ReadAndDecodePackedStreams(
EXTERNAL_CODECS_LOC_VARS
- database.ArchiveInfo.StartPositionAfterHeader,
- database.ArchiveInfo.DataStartPosition2,
+ db.ArchiveInfo.StartPositionAfterHeader,
+ db.ArchiveInfo.DataStartPosition2,
dataVector
#ifndef _NO_CRYPTO
- , getTextPassword
+ , getTextPassword, passwordIsDefined
#endif
);
RINOK(result);
- database.ArchiveInfo.DataStartPosition2 += database.ArchiveInfo.StartPositionAfterHeader;
+ db.ArchiveInfo.DataStartPosition2 += db.ArchiveInfo.StartPositionAfterHeader;
type = ReadID();
}
- CRecordVector<UInt64> unPackSizes;
+ CRecordVector<UInt64> unpackSizes;
CRecordVector<bool> digestsDefined;
CRecordVector<UInt32> digests;
if (type == NID::kMainStreamsInfo)
{
ReadStreamsInfo(&dataVector,
- database.ArchiveInfo.DataStartPosition,
- database.PackSizes,
- database.PackCRCsDefined,
- database.PackCRCs,
- database.Folders,
- database.NumUnPackStreamsVector,
- unPackSizes,
+ db.ArchiveInfo.DataStartPosition,
+ db.PackSizes,
+ db.PackCRCsDefined,
+ db.PackCRCs,
+ db.Folders,
+ db.NumUnpackStreamsVector,
+ unpackSizes,
digestsDefined,
digests);
- database.ArchiveInfo.DataStartPosition += database.ArchiveInfo.StartPositionAfterHeader;
+ db.ArchiveInfo.DataStartPosition += db.ArchiveInfo.StartPositionAfterHeader;
type = ReadID();
}
else
{
- for(int i = 0; i < database.Folders.Size(); i++)
+ for (int i = 0; i < db.Folders.Size(); i++)
{
- database.NumUnPackStreamsVector.Add(1);
- CFolder &folder = database.Folders[i];
- unPackSizes.Add(folder.GetUnPackSize());
- digestsDefined.Add(folder.UnPackCRCDefined);
- digests.Add(folder.UnPackCRC);
+ db.NumUnpackStreamsVector.Add(1);
+ CFolder &folder = db.Folders[i];
+ unpackSizes.Add(folder.GetUnpackSize());
+ digestsDefined.Add(folder.UnpackCRCDefined);
+ digests.Add(folder.UnpackCRC);
}
}
- database.Files.Clear();
+ db.Files.Clear();
if (type == NID::kEnd)
return S_OK;
@@ -856,20 +840,20 @@ HRESULT CInArchive::ReadHeader(
ThrowIncorrect();
CNum numFiles = ReadNum();
- database.Files.Reserve(numFiles);
+ db.Files.Reserve(numFiles);
CNum i;
- for(i = 0; i < numFiles; i++)
- database.Files.Add(CFileItem());
+ for (i = 0; i < numFiles; i++)
+ db.Files.Add(CFileItem());
- database.ArchiveInfo.FileInfoPopIDs.Add(NID::kSize);
- if (!database.PackSizes.IsEmpty())
- database.ArchiveInfo.FileInfoPopIDs.Add(NID::kPackInfo);
+ db.ArchiveInfo.FileInfoPopIDs.Add(NID::kSize);
+ if (!db.PackSizes.IsEmpty())
+ db.ArchiveInfo.FileInfoPopIDs.Add(NID::kPackInfo);
if (numFiles > 0 && !digests.IsEmpty())
- database.ArchiveInfo.FileInfoPopIDs.Add(NID::kCRC);
+ db.ArchiveInfo.FileInfoPopIDs.Add(NID::kCRC);
CBoolVector emptyStreamVector;
emptyStreamVector.Reserve((int)numFiles);
- for(i = 0; i < numFiles; i++)
+ for (i = 0; i < numFiles; i++)
emptyStreamVector.Add(false);
CBoolVector emptyFileVector;
CBoolVector antiFileVector;
@@ -881,6 +865,8 @@ HRESULT CInArchive::ReadHeader(
if (type == NID::kEnd)
break;
UInt64 size = ReadNumber();
+ size_t ppp = _inByteBack->_pos;
+ bool addPropIdToList = true;
bool isKnownType = true;
if (type > ((UInt32)1 << 30))
isKnownType = false;
@@ -890,37 +876,22 @@ HRESULT CInArchive::ReadHeader(
{
CStreamSwitch streamSwitch;
streamSwitch.Set(this, &dataVector);
- for(int i = 0; i < database.Files.Size(); i++)
- _inByteBack->ReadString(database.Files[i].Name);
+ for (int i = 0; i < db.Files.Size(); i++)
+ _inByteBack->ReadString(db.Files[i].Name);
break;
}
case NID::kWinAttributes:
{
CBoolVector boolVector;
- ReadBoolVector2(database.Files.Size(), boolVector);
- CStreamSwitch streamSwitch;
- streamSwitch.Set(this, &dataVector);
- for(i = 0; i < numFiles; i++)
- {
- CFileItem &file = database.Files[i];
- file.AreAttributesDefined = boolVector[i];
- if (file.AreAttributesDefined)
- file.Attributes = ReadUInt32();
- }
- break;
- }
- case NID::kStartPos:
- {
- CBoolVector boolVector;
- ReadBoolVector2(database.Files.Size(), boolVector);
+ ReadBoolVector2(db.Files.Size(), boolVector);
CStreamSwitch streamSwitch;
streamSwitch.Set(this, &dataVector);
- for(i = 0; i < numFiles; i++)
+ for (i = 0; i < numFiles; i++)
{
- CFileItem &file = database.Files[i];
- file.IsStartPosDefined = boolVector[i];
- if (file.IsStartPosDefined)
- file.StartPos = ReadUInt64();
+ CFileItem &file = db.Files[i];
+ file.AttribDefined = boolVector[i];
+ if (file.AttribDefined)
+ file.Attrib = ReadUInt32();
}
break;
}
@@ -939,55 +910,68 @@ HRESULT CInArchive::ReadHeader(
}
break;
}
- case NID::kEmptyFile:
- {
- ReadBoolVector(numEmptyStreams, emptyFileVector);
- break;
- }
- case NID::kAnti:
- {
- ReadBoolVector(numEmptyStreams, antiFileVector);
- break;
- }
- case NID::kCreationTime:
- case NID::kLastWriteTime:
- case NID::kLastAccessTime:
+ case NID::kEmptyFile: ReadBoolVector(numEmptyStreams, emptyFileVector); break;
+ case NID::kAnti: ReadBoolVector(numEmptyStreams, antiFileVector); break;
+ case NID::kStartPos: ReadUInt64DefVector(dataVector, db.StartPos, (int)numFiles); break;
+ case NID::kCTime: ReadUInt64DefVector(dataVector, db.CTime, (int)numFiles); break;
+ case NID::kATime: ReadUInt64DefVector(dataVector, db.ATime, (int)numFiles); break;
+ case NID::kMTime: ReadUInt64DefVector(dataVector, db.MTime, (int)numFiles); break;
+ case NID::kDummy:
{
- ReadTime(dataVector, database.Files, (UInt32)type);
+ for (UInt64 j = 0; j < size; j++)
+ if (ReadByte() != 0)
+ ThrowIncorrect();
+ addPropIdToList = false;
break;
}
default:
- isKnownType = false;
+ addPropIdToList = isKnownType = false;
}
if (isKnownType)
- database.ArchiveInfo.FileInfoPopIDs.Add(type);
+ {
+ if(addPropIdToList)
+ db.ArchiveInfo.FileInfoPopIDs.Add(type);
+ }
else
SkeepData(size);
+ bool checkRecordsSize = (db.ArchiveInfo.Version.Major > 0 ||
+ db.ArchiveInfo.Version.Minor > 2);
+ if (checkRecordsSize && _inByteBack->_pos - ppp != size)
+ ThrowIncorrect();
}
CNum emptyFileIndex = 0;
CNum sizeIndex = 0;
- for(i = 0; i < numFiles; i++)
+
+ CNum numAntiItems = 0;
+ for (i = 0; i < numEmptyStreams; i++)
+ if (antiFileVector[i])
+ numAntiItems++;
+
+ for (i = 0; i < numFiles; i++)
{
- CFileItem &file = database.Files[i];
+ CFileItem &file = db.Files[i];
+ bool isAnti;
file.HasStream = !emptyStreamVector[i];
- if(file.HasStream)
+ if (file.HasStream)
{
- file.IsDirectory = false;
- file.IsAnti = false;
- file.UnPackSize = unPackSizes[sizeIndex];
- file.FileCRC = digests[sizeIndex];
- file.IsFileCRCDefined = digestsDefined[sizeIndex];
+ file.IsDir = false;
+ isAnti = false;
+ file.Size = unpackSizes[sizeIndex];
+ file.Crc = digests[sizeIndex];
+ file.CrcDefined = digestsDefined[sizeIndex];
sizeIndex++;
}
else
{
- file.IsDirectory = !emptyFileVector[emptyFileIndex];
- file.IsAnti = antiFileVector[emptyFileIndex];
+ file.IsDir = !emptyFileVector[emptyFileIndex];
+ isAnti = antiFileVector[emptyFileIndex];
emptyFileIndex++;
- file.UnPackSize = 0;
- file.IsFileCRCDefined = false;
+ file.Size = 0;
+ file.CrcDefined = false;
}
+ if (numAntiItems != 0)
+ db.IsAnti.Add(isAnti);
}
return S_OK;
}
@@ -998,7 +982,7 @@ void CArchiveDatabaseEx::FillFolderStartPackStream()
FolderStartPackStreamIndex.Clear();
FolderStartPackStreamIndex.Reserve(Folders.Size());
CNum startPos = 0;
- for(int i = 0; i < Folders.Size(); i++)
+ for (int i = 0; i < Folders.Size(); i++)
{
FolderStartPackStreamIndex.Add(startPos);
startPos += (CNum)Folders[i].PackStreams.Size();
@@ -1010,7 +994,7 @@ void CArchiveDatabaseEx::FillStartPos()
PackStreamStartPositions.Clear();
PackStreamStartPositions.Reserve(PackSizes.Size());
UInt64 startPos = 0;
- for(int i = 0; i < PackSizes.Size(); i++)
+ for (int i = 0; i < PackSizes.Size(); i++)
{
PackStreamStartPositions.Add(startPos);
startPos += PackSizes[i];
@@ -1044,7 +1028,7 @@ void CArchiveDatabaseEx::FillFolderStartFileIndex()
if (folderIndex >= Folders.Size())
ThrowIncorrect();
FolderStartFileIndex.Add(i); // check it
- if (NumUnPackStreamsVector[folderIndex] != 0)
+ if (NumUnpackStreamsVector[folderIndex] != 0)
break;
folderIndex++;
}
@@ -1053,7 +1037,7 @@ void CArchiveDatabaseEx::FillFolderStartFileIndex()
if (emptyStream)
continue;
indexInFolder++;
- if (indexInFolder >= NumUnPackStreamsVector[folderIndex])
+ if (indexInFolder >= NumUnpackStreamsVector[folderIndex])
{
folderIndex++;
indexInFolder = 0;
@@ -1063,25 +1047,25 @@ void CArchiveDatabaseEx::FillFolderStartFileIndex()
HRESULT CInArchive::ReadDatabase2(
DECL_EXTERNAL_CODECS_LOC_VARS
- CArchiveDatabaseEx &database
+ CArchiveDatabaseEx &db
#ifndef _NO_CRYPTO
- , ICryptoGetTextPassword *getTextPassword
+ , ICryptoGetTextPassword *getTextPassword, bool &passwordIsDefined
#endif
)
{
- database.Clear();
- database.ArchiveInfo.StartPosition = _arhiveBeginStreamPosition;
+ db.Clear();
+ db.ArchiveInfo.StartPosition = _arhiveBeginStreamPosition;
- database.ArchiveInfo.Version.Major = _header[6];
- database.ArchiveInfo.Version.Minor = _header[7];
+ db.ArchiveInfo.Version.Major = _header[6];
+ db.ArchiveInfo.Version.Minor = _header[7];
- if (database.ArchiveInfo.Version.Major != kMajorVersion)
+ if (db.ArchiveInfo.Version.Major != kMajorVersion)
ThrowUnsupportedVersion();
- UInt32 crcFromArchive = GetUInt32FromMem(_header + 8);
- UInt64 nextHeaderOffset = GetUInt64FromMem(_header + 0xC);
- UInt64 nextHeaderSize = GetUInt64FromMem(_header + 0x14);
- UInt32 nextHeaderCRC = GetUInt32FromMem(_header + 0x1C);
+ UInt32 crcFromArchive = Get32(_header + 8);
+ UInt64 nextHeaderOffset = Get64(_header + 0xC);
+ UInt64 nextHeaderSize = Get64(_header + 0x14);
+ UInt32 nextHeaderCRC = Get32(_header + 0x1C);
UInt32 crc = CrcCalc(_header + 0xC, 20);
#ifdef FORMAT_7Z_RECOVERY
@@ -1097,16 +1081,15 @@ HRESULT CInArchive::ReadDatabase2(
checkSize = (int)(cur2 - cur);
RINOK(_stream->Seek(-checkSize, STREAM_SEEK_END, &cur2));
- UInt32 realProcessedSize;
- RINOK(_stream->Read(buf, (UInt32)kCheckSize, &realProcessedSize));
+ RINOK(ReadStream_FALSE(_stream, buf, (size_t)checkSize));
int i;
- for (i = (int)realProcessedSize - 2; i >= 0; i--)
+ for (i = (int)checkSize - 2; i >= 0; i--)
if (buf[i] == 0x17 && buf[i + 1] == 0x6 || buf[i] == 0x01 && buf[i + 1] == 0x04)
break;
if (i < 0)
return S_FALSE;
- nextHeaderSize = realProcessedSize - i;
+ nextHeaderSize = checkSize - i;
nextHeaderOffset = cur2 - cur + i;
nextHeaderCRC = CrcCalc(buf + i, (size_t)nextHeaderSize);
RINOK(_stream->Seek(cur, STREAM_SEEK_SET, NULL));
@@ -1117,7 +1100,7 @@ HRESULT CInArchive::ReadDatabase2(
crcFromArchive = crc;
#endif
- database.ArchiveInfo.StartPositionAfterHeader = _arhiveBeginStreamPosition + kHeaderSize;
+ db.ArchiveInfo.StartPositionAfterHeader = _arhiveBeginStreamPosition + kHeaderSize;
if (crc != crcFromArchive)
ThrowIncorrect();
@@ -1133,10 +1116,10 @@ HRESULT CInArchive::ReadDatabase2(
CByteBuffer buffer2;
buffer2.SetCapacity((size_t)nextHeaderSize);
- UInt32 realProcessedSize;
- RINOK(_stream->Read(buffer2, (UInt32)nextHeaderSize, &realProcessedSize));
- if (realProcessedSize != (UInt32)nextHeaderSize)
- return S_FALSE;
+ RINOK(ReadStream_FALSE(_stream, buffer2, (size_t)nextHeaderSize));
+ HeadersSize += kHeaderSize + nextHeaderSize;
+ db.PhySize = kHeaderSize + nextHeaderOffset + nextHeaderSize;
+
if (CrcCalc(buffer2, (UInt32)nextHeaderSize) != nextHeaderCRC)
ThrowIncorrect();
@@ -1145,20 +1128,18 @@ HRESULT CInArchive::ReadDatabase2(
CObjectVector<CByteBuffer> dataVector;
- for (;;)
+ UInt64 type = ReadID();
+ if (type != NID::kHeader)
{
- UInt64 type = ReadID();
- if (type == NID::kHeader)
- break;
if (type != NID::kEncodedHeader)
ThrowIncorrect();
HRESULT result = ReadAndDecodePackedStreams(
EXTERNAL_CODECS_LOC_VARS
- database.ArchiveInfo.StartPositionAfterHeader,
- database.ArchiveInfo.DataStartPosition2,
+ db.ArchiveInfo.StartPositionAfterHeader,
+ db.ArchiveInfo.DataStartPosition2,
dataVector
#ifndef _NO_CRYPTO
- , getTextPassword
+ , getTextPassword, passwordIsDefined
#endif
);
RINOK(result);
@@ -1168,31 +1149,35 @@ HRESULT CInArchive::ReadDatabase2(
ThrowIncorrect();
streamSwitch.Remove();
streamSwitch.Set(this, dataVector.Front());
+ if (ReadID() != NID::kHeader)
+ ThrowIncorrect();
}
+ db.HeadersSize = HeadersSize;
+
return ReadHeader(
EXTERNAL_CODECS_LOC_VARS
- database
+ db
#ifndef _NO_CRYPTO
- , getTextPassword
+ , getTextPassword, passwordIsDefined
#endif
);
}
HRESULT CInArchive::ReadDatabase(
DECL_EXTERNAL_CODECS_LOC_VARS
- CArchiveDatabaseEx &database
+ CArchiveDatabaseEx &db
#ifndef _NO_CRYPTO
- , ICryptoGetTextPassword *getTextPassword
+ , ICryptoGetTextPassword *getTextPassword, bool &passwordIsDefined
#endif
)
{
try
{
return ReadDatabase2(
- EXTERNAL_CODECS_LOC_VARS database
+ EXTERNAL_CODECS_LOC_VARS db
#ifndef _NO_CRYPTO
- , getTextPassword
+ , getTextPassword, passwordIsDefined
#endif
);
}
diff --git a/CPP/7zip/Archive/7z/7zIn.h b/CPP/7zip/Archive/7z/7zIn.h
index aae43506..86d0e339 100755
--- a/CPP/7zip/Archive/7z/7zIn.h
+++ b/CPP/7zip/Archive/7z/7zIn.h
@@ -36,6 +36,9 @@ struct CArchiveDatabaseEx: public CArchiveDatabase
CRecordVector<CNum> FolderStartFileIndex;
CRecordVector<CNum> FileIndexToFolderIndexMap;
+ UInt64 HeadersSize;
+ UInt64 PhySize;
+
void Clear()
{
CArchiveDatabase::Clear();
@@ -44,6 +47,9 @@ struct CArchiveDatabaseEx: public CArchiveDatabase
FolderStartPackStreamIndex.Clear();
FolderStartFileIndex.Clear();
FileIndexToFolderIndexMap.Clear();
+
+ HeadersSize = 0;
+ PhySize = 0;
}
void FillFolderStartPackStream();
@@ -63,7 +69,7 @@ struct CArchiveDatabaseEx: public CArchiveDatabase
PackStreamStartPositions[FolderStartPackStreamIndex[folderIndex] + indexInFolder];
}
- UInt64 GetFolderFullPackSize(int folderIndex) const
+ UInt64 GetFolderFullPackSize(int folderIndex) const
{
CNum packStreamIndex = FolderStartPackStreamIndex[folderIndex];
const CFolder &folder = Folders[folderIndex];
@@ -73,7 +79,7 @@ struct CArchiveDatabaseEx: public CArchiveDatabase
return size;
}
- UInt64 GetFolderPackStreamSize(int folderIndex, int streamIndex) const
+ UInt64 GetFolderPackStreamSize(int folderIndex, int streamIndex) const
{
return PackSizes[FolderStartPackStreamIndex[folderIndex] + streamIndex];
}
@@ -92,8 +98,8 @@ class CInByte2
{
const Byte *_buffer;
size_t _size;
- size_t _pos;
public:
+ size_t _pos;
void Init(const Byte *buffer, size_t size)
{
_buffer = buffer;
@@ -128,6 +134,8 @@ class CInArchive
Byte _header[kHeaderSize];
+ UInt64 HeadersSize;
+
void AddByteStream(const Byte *buffer, size_t size)
{
_inByteVector.Add(CInByte2());
@@ -167,15 +175,15 @@ private:
CRecordVector<bool> &packCRCsDefined,
CRecordVector<UInt32> &packCRCs);
- void ReadUnPackInfo(
+ void ReadUnpackInfo(
const CObjectVector<CByteBuffer> *dataVector,
CObjectVector<CFolder> &folders);
void ReadSubStreamsInfo(
const CObjectVector<CFolder> &folders,
- CRecordVector<CNum> &numUnPackStreamsInFolders,
- CRecordVector<UInt64> &unPackSizes,
- CRecordVector<bool> &digestsDefined,
+ CRecordVector<CNum> &numUnpackStreamsInFolders,
+ CRecordVector<UInt64> &unpackSizes,
+ CRecordVector<bool> &digestsDefined,
CRecordVector<UInt32> &digests);
void ReadStreamsInfo(
@@ -185,36 +193,36 @@ private:
CRecordVector<bool> &packCRCsDefined,
CRecordVector<UInt32> &packCRCs,
CObjectVector<CFolder> &folders,
- CRecordVector<CNum> &numUnPackStreamsInFolders,
- CRecordVector<UInt64> &unPackSizes,
- CRecordVector<bool> &digestsDefined,
+ CRecordVector<CNum> &numUnpackStreamsInFolders,
+ CRecordVector<UInt64> &unpackSizes,
+ CRecordVector<bool> &digestsDefined,
CRecordVector<UInt32> &digests);
void ReadBoolVector(int numItems, CBoolVector &v);
void ReadBoolVector2(int numItems, CBoolVector &v);
- void ReadTime(const CObjectVector<CByteBuffer> &dataVector,
- CObjectVector<CFileItem> &files, UInt32 type);
+ void ReadUInt64DefVector(const CObjectVector<CByteBuffer> &dataVector,
+ CUInt64DefVector &v, int numFiles);
HRESULT ReadAndDecodePackedStreams(
DECL_EXTERNAL_CODECS_LOC_VARS
UInt64 baseOffset, UInt64 &dataOffset,
CObjectVector<CByteBuffer> &dataVector
#ifndef _NO_CRYPTO
- , ICryptoGetTextPassword *getTextPassword
+ , ICryptoGetTextPassword *getTextPassword, bool &passwordIsDefined
#endif
);
HRESULT ReadHeader(
DECL_EXTERNAL_CODECS_LOC_VARS
- CArchiveDatabaseEx &database
+ CArchiveDatabaseEx &db
#ifndef _NO_CRYPTO
- ,ICryptoGetTextPassword *getTextPassword
+ ,ICryptoGetTextPassword *getTextPassword, bool &passwordIsDefined
#endif
);
HRESULT ReadDatabase2(
DECL_EXTERNAL_CODECS_LOC_VARS
- CArchiveDatabaseEx &database
+ CArchiveDatabaseEx &db
#ifndef _NO_CRYPTO
- ,ICryptoGetTextPassword *getTextPassword
+ ,ICryptoGetTextPassword *getTextPassword, bool &passwordIsDefined
#endif
);
public:
@@ -223,9 +231,9 @@ public:
HRESULT ReadDatabase(
DECL_EXTERNAL_CODECS_LOC_VARS
- CArchiveDatabaseEx &database
+ CArchiveDatabaseEx &db
#ifndef _NO_CRYPTO
- ,ICryptoGetTextPassword *getTextPassword
+ ,ICryptoGetTextPassword *getTextPassword, bool &passwordIsDefined
#endif
);
};
diff --git a/CPP/7zip/Archive/7z/7zItem.h b/CPP/7zip/Archive/7z/7zItem.h
index 31c5ce2d..763a159f 100755
--- a/CPP/7zip/Archive/7z/7zItem.h
+++ b/CPP/7zip/Archive/7z/7zItem.h
@@ -35,19 +35,19 @@ struct CFolder
CObjectVector<CCoderInfo> Coders;
CRecordVector<CBindPair> BindPairs;
CRecordVector<CNum> PackStreams;
- CRecordVector<UInt64> UnPackSizes;
- UInt32 UnPackCRC;
- bool UnPackCRCDefined;
+ CRecordVector<UInt64> UnpackSizes;
+ UInt32 UnpackCRC;
+ bool UnpackCRCDefined;
- CFolder(): UnPackCRCDefined(false) {}
+ CFolder(): UnpackCRCDefined(false) {}
- UInt64 GetUnPackSize() const // test it
- {
- if (UnPackSizes.IsEmpty())
+ UInt64 GetUnpackSize() const // test it
+ {
+ if (UnpackSizes.IsEmpty())
return 0;
- for (int i = UnPackSizes.Size() - 1; i >= 0; i--)
+ for (int i = UnpackSizes.Size() - 1; i >= 0; i--)
if (FindBindPairForOutStream(i) < 0)
- return UnPackSizes[i];
+ return UnpackSizes[i];
throw 1;
}
@@ -82,101 +82,171 @@ struct CFolder
}
};
-typedef FILETIME CArchiveFileTime;
+struct CUInt64DefVector
+{
+ CRecordVector<UInt64> Values;
+ CRecordVector<bool> Defined;
+
+ void Clear()
+ {
+ Values.Clear();
+ Defined.Clear();
+ }
+
+ void ReserveDown()
+ {
+ Values.ReserveDown();
+ Values.ReserveDown();
+ }
+
+ bool GetItem(int index, UInt64 &value) const
+ {
+ if (index < Defined.Size() && Defined[index])
+ {
+ value = Values[index];
+ return true;
+ }
+ value = 0;
+ return false;
+ }
+
+ void SetItem(int index, bool defined, UInt64 value)
+ {
+ while (index >= Defined.Size())
+ Defined.Add(false);
+ Defined[index] = defined;
+ if (!defined)
+ return;
+ while (index >= Values.Size())
+ Values.Add(0);
+ Values[index] = value;
+ }
+
+ bool CheckSize(int size) const { return Defined.Size() == size || Defined.Size() == 0; }
+};
-class CFileItem
+struct CFileItem
{
-public:
- CArchiveFileTime CreationTime;
- CArchiveFileTime LastWriteTime;
- CArchiveFileTime LastAccessTime;
- UInt64 UnPackSize;
- UInt64 StartPos;
- UInt32 Attributes;
- UInt32 FileCRC;
+ UInt64 Size;
+ UInt32 Attrib;
+ UInt32 Crc;
UString Name;
- bool HasStream; // Test it !!! it means that there is
+ bool HasStream; // Test it !!! it means that there is
// stream in some folder. It can be empty stream
- bool IsDirectory;
- bool IsAnti;
- bool IsFileCRCDefined;
- bool AreAttributesDefined;
- bool IsCreationTimeDefined;
- bool IsLastWriteTimeDefined;
- bool IsLastAccessTimeDefined;
- bool IsStartPosDefined;
-
- /*
- const bool HasStream() const {
- return !IsDirectory && !IsAnti && UnPackSize != 0; }
- */
- CFileItem():
+ bool IsDir;
+ bool CrcDefined;
+ bool AttribDefined;
+
+ CFileItem():
HasStream(true),
- IsDirectory(false),
- IsAnti(false),
- IsFileCRCDefined(false),
- AreAttributesDefined(false),
- IsCreationTimeDefined(false),
- IsLastWriteTimeDefined(false),
- IsLastAccessTimeDefined(false),
- IsStartPosDefined(false)
+ IsDir(false),
+ CrcDefined(false),
+ AttribDefined(false)
{}
- void SetAttributes(UInt32 attributes)
- {
- AreAttributesDefined = true;
- Attributes = attributes;
- }
- void SetCreationTime(const CArchiveFileTime &creationTime)
- {
- IsCreationTimeDefined = true;
- CreationTime = creationTime;
- }
- void SetLastWriteTime(const CArchiveFileTime &lastWriteTime)
+ void SetAttrib(UInt32 attrib)
{
- IsLastWriteTimeDefined = true;
- LastWriteTime = lastWriteTime;
- }
- void SetLastAccessTime(const CArchiveFileTime &lastAccessTime)
- {
- IsLastAccessTimeDefined = true;
- LastAccessTime = lastAccessTime;
+ AttribDefined = true;
+ Attrib = attrib;
}
};
+struct CFileItem2
+{
+ UInt64 CTime;
+ UInt64 ATime;
+ UInt64 MTime;
+ UInt64 StartPos;
+ bool CTimeDefined;
+ bool ATimeDefined;
+ bool MTimeDefined;
+ bool StartPosDefined;
+ bool IsAnti;
+};
+
struct CArchiveDatabase
{
CRecordVector<UInt64> PackSizes;
CRecordVector<bool> PackCRCsDefined;
CRecordVector<UInt32> PackCRCs;
CObjectVector<CFolder> Folders;
- CRecordVector<CNum> NumUnPackStreamsVector;
+ CRecordVector<CNum> NumUnpackStreamsVector;
CObjectVector<CFileItem> Files;
+
+ CUInt64DefVector CTime;
+ CUInt64DefVector ATime;
+ CUInt64DefVector MTime;
+ CUInt64DefVector StartPos;
+ CRecordVector<bool> IsAnti;
+
void Clear()
{
PackSizes.Clear();
PackCRCsDefined.Clear();
PackCRCs.Clear();
Folders.Clear();
- NumUnPackStreamsVector.Clear();
+ NumUnpackStreamsVector.Clear();
Files.Clear();
+ CTime.Clear();
+ ATime.Clear();
+ MTime.Clear();
+ StartPos.Clear();
+ IsAnti.Clear();
}
+
+ void ReserveDown()
+ {
+ PackSizes.ReserveDown();
+ PackCRCsDefined.ReserveDown();
+ PackCRCs.ReserveDown();
+ Folders.ReserveDown();
+ NumUnpackStreamsVector.ReserveDown();
+ Files.ReserveDown();
+ CTime.ReserveDown();
+ ATime.ReserveDown();
+ MTime.ReserveDown();
+ StartPos.ReserveDown();
+ IsAnti.ReserveDown();
+ }
+
bool IsEmpty() const
{
- return (PackSizes.IsEmpty() &&
- PackCRCsDefined.IsEmpty() &&
- PackCRCs.IsEmpty() &&
- Folders.IsEmpty() &&
- NumUnPackStreamsVector.IsEmpty() &&
+ return (PackSizes.IsEmpty() &&
+ PackCRCsDefined.IsEmpty() &&
+ PackCRCs.IsEmpty() &&
+ Folders.IsEmpty() &&
+ NumUnpackStreamsVector.IsEmpty() &&
Files.IsEmpty());
}
+
+ bool CheckNumFiles() const
+ {
+ int size = Files.Size();
+ return (
+ CTime.CheckSize(size) &&
+ ATime.CheckSize(size) &&
+ MTime.CheckSize(size) &&
+ StartPos.CheckSize(size) &&
+ (size == IsAnti.Size() || IsAnti.Size() == 0));
+ }
+
bool IsSolid() const
{
- for (int i = 0; i < NumUnPackStreamsVector.Size(); i++)
- if (NumUnPackStreamsVector[i] > 1)
+ for (int i = 0; i < NumUnpackStreamsVector.Size(); i++)
+ if (NumUnpackStreamsVector[i] > 1)
return true;
return false;
}
+ bool IsItemAnti(int index) const { return (index < IsAnti.Size() && IsAnti[index]); }
+ void SetItemAnti(int index, bool isAnti)
+ {
+ while (index >= IsAnti.Size())
+ IsAnti.Add(false);
+ IsAnti[index] = isAnti;
+ }
+
+ void GetFile(int index, CFileItem &file, CFileItem2 &file2) const;
+ void AddFile(const CFileItem &file, const CFileItem2 &file2);
};
}}
diff --git a/CPP/7zip/Archive/7z/7zOut.cpp b/CPP/7zip/Archive/7z/7zOut.cpp
index a00cdf5c..dae242a6 100755
--- a/CPP/7zip/Archive/7z/7zOut.cpp
+++ b/CPP/7zip/Archive/7z/7zOut.cpp
@@ -7,8 +7,8 @@
#include "7zOut.h"
-extern "C"
-{
+extern "C"
+{
#include "../../../../C/7zCrc.h"
}
@@ -19,7 +19,7 @@ static HRESULT WriteBytes(ISequentialOutStream *stream, const void *data, size_t
UInt32 curSize = (UInt32)MyMin(size, (size_t)0xFFFFFFFF);
UInt32 processedSize;
RINOK(stream->Write(data, curSize, &processedSize));
- if(processedSize == 0)
+ if (processedSize == 0)
return E_FAIL;
data = (const void *)((const Byte *)data + processedSize);
size -= processedSize;
@@ -35,45 +35,13 @@ HRESULT COutArchive::WriteDirect(const void *data, UInt32 size)
return ::WriteBytes(SeqStream, data, size);
}
-UInt32 CrcUpdateUInt32(UInt32 crc, UInt32 value)
-{
- for (int i = 0; i < 4; i++, value >>= 8)
- crc = CRC_UPDATE_BYTE(crc, (Byte)value);
- return crc;
-}
-
-UInt32 CrcUpdateUInt64(UInt32 crc, UInt64 value)
-{
- for (int i = 0; i < 8; i++, value >>= 8)
- crc = CRC_UPDATE_BYTE(crc, (Byte)value);
- return crc;
-}
-
-HRESULT COutArchive::WriteDirectUInt32(UInt32 value)
-{
- for (int i = 0; i < 4; i++)
- {
- RINOK(WriteDirectByte((Byte)value));
- value >>= 8;
- }
- return S_OK;
-}
-
-HRESULT COutArchive::WriteDirectUInt64(UInt64 value)
-{
- for (int i = 0; i < 8; i++)
- {
- RINOK(WriteDirectByte((Byte)value));
- value >>= 8;
- }
- return S_OK;
-}
-
HRESULT COutArchive::WriteSignature()
{
- RINOK(WriteDirect(kSignature, kSignatureSize));
- RINOK(WriteDirectByte(kMajorVersion));
- return WriteDirectByte(2);
+ Byte buf[8];
+ memcpy(buf, kSignature, kSignatureSize);
+ buf[kSignatureSize] = kMajorVersion;
+ buf[kSignatureSize + 1] = 3;
+ return WriteDirect(buf, 8);
}
#ifdef _7Z_VOL
@@ -88,16 +56,26 @@ HRESULT COutArchive::WriteFinishSignature()
}
#endif
+static void SetUInt32(Byte *p, UInt32 d)
+{
+ for (int i = 0; i < 4; i++, d >>= 8)
+ p[i] = (Byte)d;
+}
+
+static void SetUInt64(Byte *p, UInt64 d)
+{
+ for (int i = 0; i < 8; i++, d >>= 8)
+ p[i] = (Byte)d;
+}
+
HRESULT COutArchive::WriteStartHeader(const CStartHeader &h)
{
- UInt32 crc = CRC_INIT_VAL;
- crc = CrcUpdateUInt64(crc, h.NextHeaderOffset);
- crc = CrcUpdateUInt64(crc, h.NextHeaderSize);
- crc = CrcUpdateUInt32(crc, h.NextHeaderCRC);
- RINOK(WriteDirectUInt32(CRC_GET_DIGEST(crc)));
- RINOK(WriteDirectUInt64(h.NextHeaderOffset));
- RINOK(WriteDirectUInt64(h.NextHeaderSize));
- return WriteDirectUInt32(h.NextHeaderCRC);
+ Byte buf[24];
+ SetUInt64(buf + 4, h.NextHeaderOffset);
+ SetUInt64(buf + 12, h.NextHeaderSize);
+ SetUInt32(buf + 20, h.NextHeaderCRC);
+ SetUInt32(buf, CrcCalc(buf + 4, 20));
+ return WriteDirect(buf, 24);
}
#ifdef _7Z_VOL
@@ -172,47 +150,60 @@ HRESULT COutArchive::SkeepPrefixArchiveHeader()
return Stream->Seek(24, STREAM_SEEK_CUR, NULL);
}
-HRESULT COutArchive::WriteBytes(const void *data, size_t size)
+UInt64 COutArchive::GetPos() const
{
- if (_mainMode)
+ if (_countMode)
+ return _countSize;
+ if (_writeToStream)
+ return _outByte.GetProcessedSize();
+ return _outByte2.GetPos();
+}
+
+void COutArchive::WriteBytes(const void *data, size_t size)
+{
+ if (_countMode)
+ _countSize += size;
+ else if (_writeToStream)
{
- if (_dynamicMode)
- _dynamicBuffer.Write(data, size);
- else
- _outByte.WriteBytes(data, size);
+ _outByte.WriteBytes(data, size);
_crc = CrcUpdate(_crc, data, size);
}
else
- {
- if (_countMode)
- _countSize += size;
- else
- RINOK(_outByte2.Write(data, size));
- }
- return S_OK;
+ _outByte2.WriteBytes(data, size);
}
-HRESULT COutArchive::WriteBytes(const CByteBuffer &data)
+void COutArchive::WriteByte(Byte b)
{
- return WriteBytes(data, data.GetCapacity());
+ if (_countMode)
+ _countSize++;
+ else if (_writeToStream)
+ {
+ _outByte.WriteByte(b);
+ _crc = CRC_UPDATE_BYTE(_crc, b);
+ }
+ else
+ _outByte2.WriteByte(b);
}
-HRESULT COutArchive::WriteByte(Byte b)
+void COutArchive::WriteUInt32(UInt32 value)
{
- return WriteBytes(&b, 1);
+ for (int i = 0; i < 4; i++)
+ {
+ WriteByte((Byte)value);
+ value >>= 8;
+ }
}
-HRESULT COutArchive::WriteUInt32(UInt32 value)
+void COutArchive::WriteUInt64(UInt64 value)
{
- for (int i = 0; i < 4; i++)
+ for (int i = 0; i < 8; i++)
{
- RINOK(WriteByte((Byte)value));
+ WriteByte((Byte)value);
value >>= 8;
}
- return S_OK;
}
-HRESULT COutArchive::WriteNumber(UInt64 value)
+void COutArchive::WriteNumber(UInt64 value)
{
Byte firstByte = 0;
Byte mask = 0x80;
@@ -227,25 +218,24 @@ HRESULT COutArchive::WriteNumber(UInt64 value)
firstByte |= mask;
mask >>= 1;
}
- RINOK(WriteByte(firstByte));
+ WriteByte(firstByte);
for (;i > 0; i--)
{
- RINOK(WriteByte((Byte)value));
+ WriteByte((Byte)value);
value >>= 8;
}
- return S_OK;
}
-#ifdef _7Z_VOL
static UInt32 GetBigNumberSize(UInt64 value)
{
int i;
- for (i = 0; i < 8; i++)
- if (value < ((UInt64(1) << ( 7 * (i + 1)))))
+ for (i = 1; i < 9; i++)
+ if (value < (((UInt64)1 << (i * 7))))
break;
- return 1 + i;
+ return i;
}
+#ifdef _7Z_VOL
UInt32 COutArchive::GetVolHeadersSize(UInt64 dataSize, int nameLength, bool props)
{
UInt32 result = GetBigNumberSize(dataSize) * 2 + 41;
@@ -280,9 +270,9 @@ UInt64 COutArchive::GetVolPureSize(UInt64 volSize, int nameLength, bool props)
}
#endif
-HRESULT COutArchive::WriteFolder(const CFolder &folder)
+void COutArchive::WriteFolder(const CFolder &folder)
{
- RINOK(WriteNumber(folder.Coders.Size()));
+ WriteNumber(folder.Coders.Size());
int i;
for (i = 0; i < folder.Coders.Size(); i++)
{
@@ -290,7 +280,7 @@ HRESULT COutArchive::WriteFolder(const CFolder &folder)
{
size_t propertiesSize = coder.Properties.GetCapacity();
- UInt64 id = coder.MethodID;
+ UInt64 id = coder.MethodID;
int idSize;
for (idSize = 1; idSize < sizeof(id); idSize++)
if ((id >> (8 * idSize)) == 0)
@@ -303,161 +293,152 @@ HRESULT COutArchive::WriteFolder(const CFolder &folder)
bool isComplex = !coder.IsSimpleCoder();
b |= (isComplex ? 0x10 : 0);
b |= ((propertiesSize != 0) ? 0x20 : 0 );
- RINOK(WriteByte(b));
- RINOK(WriteBytes(longID, idSize));
+ WriteByte(b);
+ WriteBytes(longID, idSize);
if (isComplex)
{
- RINOK(WriteNumber(coder.NumInStreams));
- RINOK(WriteNumber(coder.NumOutStreams));
+ WriteNumber(coder.NumInStreams);
+ WriteNumber(coder.NumOutStreams);
}
if (propertiesSize == 0)
continue;
- RINOK(WriteNumber(propertiesSize));
- RINOK(WriteBytes(coder.Properties, propertiesSize));
+ WriteNumber(propertiesSize);
+ WriteBytes(coder.Properties, propertiesSize);
}
}
for (i = 0; i < folder.BindPairs.Size(); i++)
{
const CBindPair &bindPair = folder.BindPairs[i];
- RINOK(WriteNumber(bindPair.InIndex));
- RINOK(WriteNumber(bindPair.OutIndex));
+ WriteNumber(bindPair.InIndex);
+ WriteNumber(bindPair.OutIndex);
}
if (folder.PackStreams.Size() > 1)
for (i = 0; i < folder.PackStreams.Size(); i++)
{
- RINOK(WriteNumber(folder.PackStreams[i]));
+ WriteNumber(folder.PackStreams[i]);
}
- return S_OK;
}
-HRESULT COutArchive::WriteBoolVector(const CBoolVector &boolVector)
+void COutArchive::WriteBoolVector(const CBoolVector &boolVector)
{
Byte b = 0;
Byte mask = 0x80;
- for(int i = 0; i < boolVector.Size(); i++)
+ for (int i = 0; i < boolVector.Size(); i++)
{
if (boolVector[i])
b |= mask;
mask >>= 1;
if (mask == 0)
{
- RINOK(WriteByte(b));
+ WriteByte(b);
mask = 0x80;
b = 0;
}
}
if (mask != 0x80)
- {
- RINOK(WriteByte(b));
- }
- return S_OK;
+ WriteByte(b);
}
-HRESULT COutArchive::WriteHashDigests(
+void COutArchive::WriteHashDigests(
const CRecordVector<bool> &digestsDefined,
const CRecordVector<UInt32> &digests)
{
int numDefined = 0;
int i;
- for(i = 0; i < digestsDefined.Size(); i++)
+ for (i = 0; i < digestsDefined.Size(); i++)
if (digestsDefined[i])
numDefined++;
if (numDefined == 0)
- return S_OK;
+ return;
- RINOK(WriteByte(NID::kCRC));
+ WriteByte(NID::kCRC);
if (numDefined == digestsDefined.Size())
- {
- RINOK(WriteByte(1));
- }
+ WriteByte(1);
else
{
- RINOK(WriteByte(0));
- RINOK(WriteBoolVector(digestsDefined));
- }
- for(i = 0; i < digests.Size(); i++)
- {
- if(digestsDefined[i])
- RINOK(WriteUInt32(digests[i]));
+ WriteByte(0);
+ WriteBoolVector(digestsDefined);
}
- return S_OK;
+ for (i = 0; i < digests.Size(); i++)
+ if (digestsDefined[i])
+ WriteUInt32(digests[i]);
}
-HRESULT COutArchive::WritePackInfo(
+void COutArchive::WritePackInfo(
UInt64 dataOffset,
const CRecordVector<UInt64> &packSizes,
const CRecordVector<bool> &packCRCsDefined,
const CRecordVector<UInt32> &packCRCs)
{
if (packSizes.IsEmpty())
- return S_OK;
- RINOK(WriteByte(NID::kPackInfo));
- RINOK(WriteNumber(dataOffset));
- RINOK(WriteNumber(packSizes.Size()));
- RINOK(WriteByte(NID::kSize));
- for(int i = 0; i < packSizes.Size(); i++)
- RINOK(WriteNumber(packSizes[i]));
-
- RINOK(WriteHashDigests(packCRCsDefined, packCRCs));
+ return;
+ WriteByte(NID::kPackInfo);
+ WriteNumber(dataOffset);
+ WriteNumber(packSizes.Size());
+ WriteByte(NID::kSize);
+ for (int i = 0; i < packSizes.Size(); i++)
+ WriteNumber(packSizes[i]);
+
+ WriteHashDigests(packCRCsDefined, packCRCs);
- return WriteByte(NID::kEnd);
+ WriteByte(NID::kEnd);
}
-HRESULT COutArchive::WriteUnPackInfo(const CObjectVector<CFolder> &folders)
+void COutArchive::WriteUnpackInfo(const CObjectVector<CFolder> &folders)
{
if (folders.IsEmpty())
- return S_OK;
+ return;
- RINOK(WriteByte(NID::kUnPackInfo));
+ WriteByte(NID::kUnpackInfo);
- RINOK(WriteByte(NID::kFolder));
- RINOK(WriteNumber(folders.Size()));
+ WriteByte(NID::kFolder);
+ WriteNumber(folders.Size());
{
- RINOK(WriteByte(0));
- for(int i = 0; i < folders.Size(); i++)
- RINOK(WriteFolder(folders[i]));
+ WriteByte(0);
+ for (int i = 0; i < folders.Size(); i++)
+ WriteFolder(folders[i]);
}
- RINOK(WriteByte(NID::kCodersUnPackSize));
+ WriteByte(NID::kCodersUnpackSize);
int i;
- for(i = 0; i < folders.Size(); i++)
+ for (i = 0; i < folders.Size(); i++)
{
const CFolder &folder = folders[i];
- for (int j = 0; j < folder.UnPackSizes.Size(); j++)
- RINOK(WriteNumber(folder.UnPackSizes[j]));
+ for (int j = 0; j < folder.UnpackSizes.Size(); j++)
+ WriteNumber(folder.UnpackSizes[j]);
}
- CRecordVector<bool> unPackCRCsDefined;
- CRecordVector<UInt32> unPackCRCs;
- for(i = 0; i < folders.Size(); i++)
+ CRecordVector<bool> unpackCRCsDefined;
+ CRecordVector<UInt32> unpackCRCs;
+ for (i = 0; i < folders.Size(); i++)
{
const CFolder &folder = folders[i];
- unPackCRCsDefined.Add(folder.UnPackCRCDefined);
- unPackCRCs.Add(folder.UnPackCRC);
+ unpackCRCsDefined.Add(folder.UnpackCRCDefined);
+ unpackCRCs.Add(folder.UnpackCRC);
}
- RINOK(WriteHashDigests(unPackCRCsDefined, unPackCRCs));
+ WriteHashDigests(unpackCRCsDefined, unpackCRCs);
- return WriteByte(NID::kEnd);
+ WriteByte(NID::kEnd);
}
-HRESULT COutArchive::WriteSubStreamsInfo(
+void COutArchive::WriteSubStreamsInfo(
const CObjectVector<CFolder> &folders,
- const CRecordVector<CNum> &numUnPackStreamsInFolders,
- const CRecordVector<UInt64> &unPackSizes,
+ const CRecordVector<CNum> &numUnpackStreamsInFolders,
+ const CRecordVector<UInt64> &unpackSizes,
const CRecordVector<bool> &digestsDefined,
const CRecordVector<UInt32> &digests)
{
- RINOK(WriteByte(NID::kSubStreamsInfo));
+ WriteByte(NID::kSubStreamsInfo);
int i;
- for(i = 0; i < numUnPackStreamsInFolders.Size(); i++)
+ for (i = 0; i < numUnpackStreamsInFolders.Size(); i++)
{
- if (numUnPackStreamsInFolders[i] != 1)
+ if (numUnpackStreamsInFolders[i] != 1)
{
- RINOK(WriteByte(NID::kNumUnPackStream));
- for(i = 0; i < numUnPackStreamsInFolders.Size(); i++)
- RINOK(WriteNumber(numUnPackStreamsInFolders[i]));
+ WriteByte(NID::kNumUnpackStream);
+ for (i = 0; i < numUnpackStreamsInFolders.Size(); i++)
+ WriteNumber(numUnpackStreamsInFolders[i]);
break;
}
}
@@ -465,15 +446,15 @@ HRESULT COutArchive::WriteSubStreamsInfo(
bool needFlag = true;
CNum index = 0;
- for(i = 0; i < numUnPackStreamsInFolders.Size(); i++)
- for (CNum j = 0; j < numUnPackStreamsInFolders[i]; j++)
+ for (i = 0; i < numUnpackStreamsInFolders.Size(); i++)
+ for (CNum j = 0; j < numUnpackStreamsInFolders[i]; j++)
{
- if (j + 1 != numUnPackStreamsInFolders[i])
+ if (j + 1 != numUnpackStreamsInFolders[i])
{
if (needFlag)
- RINOK(WriteByte(NID::kSize));
+ WriteByte(NID::kSize);
needFlag = false;
- RINOK(WriteNumber(unPackSizes[index]));
+ WriteNumber(unpackSizes[index]);
}
index++;
}
@@ -484,8 +465,8 @@ HRESULT COutArchive::WriteSubStreamsInfo(
int digestIndex = 0;
for (i = 0; i < folders.Size(); i++)
{
- int numSubStreams = (int)numUnPackStreamsInFolders[i];
- if (numSubStreams == 1 && folders[i].UnPackCRCDefined)
+ int numSubStreams = (int)numUnpackStreamsInFolders[i];
+ if (numSubStreams == 1 && folders[i].UnpackCRCDefined)
digestIndex++;
else
for (int j = 0; j < numSubStreams; j++, digestIndex++)
@@ -494,84 +475,70 @@ HRESULT COutArchive::WriteSubStreamsInfo(
digests2.Add(digests[digestIndex]);
}
}
- RINOK(WriteHashDigests(digestsDefined2, digests2));
- return WriteByte(NID::kEnd);
+ WriteHashDigests(digestsDefined2, digests2);
+ WriteByte(NID::kEnd);
}
-HRESULT COutArchive::WriteTime(
- const CObjectVector<CFileItem> &files, Byte type)
+void COutArchive::SkipAlign(unsigned /* pos */, unsigned /* alignSize */)
{
- /////////////////////////////////////////////////
- // CreationTime
- CBoolVector boolVector;
- boolVector.Reserve(files.Size());
- bool thereAreDefined = false;
- bool allDefined = true;
- int i;
- for(i = 0; i < files.Size(); i++)
- {
- const CFileItem &item = files[i];
- bool defined;
- switch(type)
- {
- case NID::kCreationTime:
- defined = item.IsCreationTimeDefined;
- break;
- case NID::kLastWriteTime:
- defined = item.IsLastWriteTimeDefined;
- break;
- case NID::kLastAccessTime:
- defined = item.IsLastAccessTimeDefined;
- break;
- default:
- throw 1;
- }
- boolVector.Add(defined);
- thereAreDefined = (thereAreDefined || defined);
- allDefined = (allDefined && defined);
- }
- if (!thereAreDefined)
- return S_OK;
- RINOK(WriteByte(type));
- size_t dataSize = 1 + 1;
- dataSize += files.Size() * 8;
- if (allDefined)
- {
- RINOK(WriteNumber(dataSize));
+ return;
+}
+
+/*
+7-Zip 4.50 - 4.58 contain BUG, so they do not support .7z archives with Unknown field.
+
+void COutArchive::SkipAlign(unsigned pos, unsigned alignSize)
+{
+ pos += (unsigned)GetPos();
+ pos &= (alignSize - 1);
+ if (pos == 0)
+ return;
+ unsigned skip = alignSize - pos;
+ if (skip < 2)
+ skip += alignSize;
+ skip -= 2;
+ WriteByte(NID::kDummy);
+ WriteByte((Byte)skip);
+ for (unsigned i = 0; i < skip; i++)
+ WriteByte(0);
+}
+*/
+
+void COutArchive::WriteAlignedBoolHeader(const CBoolVector &v, int numDefined, Byte type, unsigned itemSize)
+{
+ const UInt64 bvSize = (numDefined == v.Size()) ? 0 : (v.Size() + 7) / 8;
+ const UInt64 dataSize = (UInt64)numDefined * itemSize + bvSize + 2;
+ SkipAlign(3 + (unsigned)bvSize + (unsigned)GetBigNumberSize(dataSize), itemSize);
+
+ WriteByte(type);
+ WriteNumber(dataSize);
+ if (numDefined == v.Size())
WriteByte(1);
- }
else
{
- RINOK(WriteNumber(1 + (boolVector.Size() + 7) / 8 + dataSize));
WriteByte(0);
- RINOK(WriteBoolVector(boolVector));
- }
- RINOK(WriteByte(0));
- for(i = 0; i < files.Size(); i++)
- {
- if (boolVector[i])
- {
- const CFileItem &item = files[i];
- CArchiveFileTime timeValue;
- timeValue.dwLowDateTime = 0;
- timeValue.dwHighDateTime = 0;
- switch(type)
- {
- case NID::kCreationTime:
- timeValue = item.CreationTime;
- break;
- case NID::kLastWriteTime:
- timeValue = item.LastWriteTime;
- break;
- case NID::kLastAccessTime:
- timeValue = item.LastAccessTime;
- break;
- }
- RINOK(WriteUInt32(timeValue.dwLowDateTime));
- RINOK(WriteUInt32(timeValue.dwHighDateTime));
- }
+ WriteBoolVector(v);
}
- return S_OK;
+ WriteByte(0);
+}
+
+void COutArchive::WriteUInt64DefVector(const CUInt64DefVector &v, Byte type)
+{
+ int numDefined = 0;
+
+ int i;
+ for (i = 0; i < v.Defined.Size(); i++)
+ if (v.Defined[i])
+ numDefined++;
+
+ if (numDefined == 0)
+ return;
+
+ WriteAlignedBoolHeader(v.Defined, numDefined, type, 8);
+
+ for (i = 0; i < v.Defined.Size(); i++)
+ if (v.Defined[i])
+ WriteUInt64(v.Values[i]);
}
HRESULT COutArchive::EncodeStream(
@@ -583,8 +550,8 @@ HRESULT COutArchive::EncodeStream(
CMyComPtr<ISequentialInStream> stream = streamSpec;
streamSpec->Init(data, dataSize);
CFolder folderItem;
- folderItem.UnPackCRCDefined = true;
- folderItem.UnPackCRC = CrcCalc(data, dataSize);
+ folderItem.UnpackCRCDefined = true;
+ folderItem.UnpackCRC = CrcCalc(data, dataSize);
UInt64 dataSize64 = dataSize;
RINOK(encoder.Encode(
EXTERNAL_CODECS_LOC_VARS
@@ -595,7 +562,7 @@ HRESULT COutArchive::EncodeStream(
HRESULT COutArchive::EncodeStream(
DECL_EXTERNAL_CODECS_LOC_VARS
- CEncoder &encoder, const CByteBuffer &data,
+ CEncoder &encoder, const CByteBuffer &data,
CRecordVector<UInt64> &packSizes, CObjectVector<CFolder> &folders)
{
return EncodeStream(
@@ -603,212 +570,70 @@ HRESULT COutArchive::EncodeStream(
encoder, data, data.GetCapacity(), packSizes, folders);
}
-static void WriteUInt32ToBuffer(Byte *data, UInt32 value)
-{
- for (int i = 0; i < 4; i++)
- {
- *data++ = (Byte)value;
- value >>= 8;
- }
-}
-
-static void WriteUInt64ToBuffer(Byte *data, UInt64 value)
-{
- for (int i = 0; i < 8; i++)
- {
- *data++ = (Byte)value;
- value >>= 8;
- }
-}
-
-
-HRESULT COutArchive::WriteHeader(
- const CArchiveDatabase &database,
+void COutArchive::WriteHeader(
+ const CArchiveDatabase &db,
const CHeaderOptions &headerOptions,
UInt64 &headerOffset)
{
int i;
- /////////////////////////////////
- // Names
-
- CNum numDefinedNames = 0;
- size_t namesDataSize = 0;
- for(i = 0; i < database.Files.Size(); i++)
- {
- const UString &name = database.Files[i].Name;
- if (!name.IsEmpty())
- numDefinedNames++;
- namesDataSize += (name.Length() + 1) * 2;
- }
-
- CByteBuffer namesData;
- if (numDefinedNames > 0)
- {
- namesData.SetCapacity((size_t)namesDataSize);
- size_t pos = 0;
- for(int i = 0; i < database.Files.Size(); i++)
- {
- const UString &name = database.Files[i].Name;
- for (int t = 0; t < name.Length(); t++)
- {
- wchar_t c = name[t];
- namesData[pos++] = Byte(c);
- namesData[pos++] = Byte(c >> 8);
- }
- namesData[pos++] = 0;
- namesData[pos++] = 0;
- }
- }
-
- /////////////////////////////////
- // Write Attributes
- CBoolVector attributesBoolVector;
- attributesBoolVector.Reserve(database.Files.Size());
- int numDefinedAttributes = 0;
- for(i = 0; i < database.Files.Size(); i++)
- {
- bool defined = database.Files[i].AreAttributesDefined;
- attributesBoolVector.Add(defined);
- if (defined)
- numDefinedAttributes++;
- }
-
- CByteBuffer attributesData;
- if (numDefinedAttributes > 0)
- {
- attributesData.SetCapacity(numDefinedAttributes * 4);
- size_t pos = 0;
- for(i = 0; i < database.Files.Size(); i++)
- {
- const CFileItem &file = database.Files[i];
- if (file.AreAttributesDefined)
- {
- WriteUInt32ToBuffer(attributesData + pos, file.Attributes);
- pos += 4;
- }
- }
- }
-
- /////////////////////////////////
- // Write StartPos
- CBoolVector startsBoolVector;
- startsBoolVector.Reserve(database.Files.Size());
- int numDefinedStarts = 0;
- for(i = 0; i < database.Files.Size(); i++)
- {
- bool defined = database.Files[i].IsStartPosDefined;
- startsBoolVector.Add(defined);
- if (defined)
- numDefinedStarts++;
- }
-
- CByteBuffer startsData;
- if (numDefinedStarts > 0)
- {
- startsData.SetCapacity(numDefinedStarts * 8);
- size_t pos = 0;
- for(i = 0; i < database.Files.Size(); i++)
- {
- const CFileItem &file = database.Files[i];
- if (file.IsStartPosDefined)
- {
- WriteUInt64ToBuffer(startsData + pos, file.StartPos);
- pos += 8;
- }
- }
- }
-
- /////////////////////////////////
- // Write Last Write Time
- // /*
- CNum numDefinedLastWriteTimes = 0;
- for(i = 0; i < database.Files.Size(); i++)
- if (database.Files[i].IsLastWriteTimeDefined)
- numDefinedLastWriteTimes++;
-
- if (numDefinedLastWriteTimes > 0)
- {
- CByteBuffer lastWriteTimeData;
- lastWriteTimeData.SetCapacity(numDefinedLastWriteTimes * 8);
- size_t pos = 0;
- for(i = 0; i < database.Files.Size(); i++)
- {
- const CFileItem &file = database.Files[i];
- if (file.IsLastWriteTimeDefined)
- {
- WriteUInt32ToBuffer(lastWriteTimeData + pos, file.LastWriteTime.dwLowDateTime);
- pos += 4;
- WriteUInt32ToBuffer(lastWriteTimeData + pos, file.LastWriteTime.dwHighDateTime);
- pos += 4;
- }
- }
- }
- // */
-
-
UInt64 packedSize = 0;
- for(i = 0; i < database.PackSizes.Size(); i++)
- packedSize += database.PackSizes[i];
+ for (i = 0; i < db.PackSizes.Size(); i++)
+ packedSize += db.PackSizes[i];
headerOffset = packedSize;
- _mainMode = true;
-
- _outByte.SetStream(SeqStream);
- _outByte.Init();
- _crc = CRC_INIT_VAL;
-
-
- RINOK(WriteByte(NID::kHeader));
+ WriteByte(NID::kHeader);
// Archive Properties
- if (database.Folders.Size() > 0)
+ if (db.Folders.Size() > 0)
{
- RINOK(WriteByte(NID::kMainStreamsInfo));
- RINOK(WritePackInfo(0, database.PackSizes,
- database.PackCRCsDefined,
- database.PackCRCs));
+ WriteByte(NID::kMainStreamsInfo);
+ WritePackInfo(0, db.PackSizes,
+ db.PackCRCsDefined,
+ db.PackCRCs);
- RINOK(WriteUnPackInfo(database.Folders));
+ WriteUnpackInfo(db.Folders);
- CRecordVector<UInt64> unPackSizes;
+ CRecordVector<UInt64> unpackSizes;
CRecordVector<bool> digestsDefined;
CRecordVector<UInt32> digests;
- for (i = 0; i < database.Files.Size(); i++)
+ for (i = 0; i < db.Files.Size(); i++)
{
- const CFileItem &file = database.Files[i];
+ const CFileItem &file = db.Files[i];
if (!file.HasStream)
continue;
- unPackSizes.Add(file.UnPackSize);
- digestsDefined.Add(file.IsFileCRCDefined);
- digests.Add(file.FileCRC);
+ unpackSizes.Add(file.Size);
+ digestsDefined.Add(file.CrcDefined);
+ digests.Add(file.Crc);
}
- RINOK(WriteSubStreamsInfo(
- database.Folders,
- database.NumUnPackStreamsVector,
- unPackSizes,
+ WriteSubStreamsInfo(
+ db.Folders,
+ db.NumUnpackStreamsVector,
+ unpackSizes,
digestsDefined,
- digests));
- RINOK(WriteByte(NID::kEnd));
+ digests);
+ WriteByte(NID::kEnd);
}
- if (database.Files.IsEmpty())
+ if (db.Files.IsEmpty())
{
- RINOK(WriteByte(NID::kEnd));
- return _outByte.Flush();
+ WriteByte(NID::kEnd);
+ return;
}
- RINOK(WriteByte(NID::kFilesInfo));
- RINOK(WriteNumber(database.Files.Size()));
+ WriteByte(NID::kFilesInfo);
+ WriteNumber(db.Files.Size());
+ {
+ /* ---------- Empty Streams ---------- */
CBoolVector emptyStreamVector;
- emptyStreamVector.Reserve(database.Files.Size());
+ emptyStreamVector.Reserve(db.Files.Size());
int numEmptyStreams = 0;
- for(i = 0; i < database.Files.Size(); i++)
- if (database.Files[i].HasStream)
+ for (i = 0; i < db.Files.Size(); i++)
+ if (db.Files[i].HasStream)
emptyStreamVector.Add(false);
else
{
@@ -817,134 +642,126 @@ HRESULT COutArchive::WriteHeader(
}
if (numEmptyStreams > 0)
{
- RINOK(WriteByte(NID::kEmptyStream));
- RINOK(WriteNumber((emptyStreamVector.Size() + 7) / 8));
- RINOK(WriteBoolVector(emptyStreamVector));
+ WriteByte(NID::kEmptyStream);
+ WriteNumber((emptyStreamVector.Size() + 7) / 8);
+ WriteBoolVector(emptyStreamVector);
CBoolVector emptyFileVector, antiVector;
emptyFileVector.Reserve(numEmptyStreams);
antiVector.Reserve(numEmptyStreams);
CNum numEmptyFiles = 0, numAntiItems = 0;
- for(i = 0; i < database.Files.Size(); i++)
+ for (i = 0; i < db.Files.Size(); i++)
{
- const CFileItem &file = database.Files[i];
+ const CFileItem &file = db.Files[i];
if (!file.HasStream)
{
- emptyFileVector.Add(!file.IsDirectory);
- if (!file.IsDirectory)
+ emptyFileVector.Add(!file.IsDir);
+ if (!file.IsDir)
numEmptyFiles++;
- antiVector.Add(file.IsAnti);
- if (file.IsAnti)
+ bool isAnti = db.IsItemAnti(i);
+ antiVector.Add(isAnti);
+ if (isAnti)
numAntiItems++;
}
}
if (numEmptyFiles > 0)
{
- RINOK(WriteByte(NID::kEmptyFile));
- RINOK(WriteNumber((emptyFileVector.Size() + 7) / 8));
- RINOK(WriteBoolVector(emptyFileVector));
+ WriteByte(NID::kEmptyFile);
+ WriteNumber((emptyFileVector.Size() + 7) / 8);
+ WriteBoolVector(emptyFileVector);
}
if (numAntiItems > 0)
{
- RINOK(WriteByte(NID::kAnti));
- RINOK(WriteNumber((antiVector.Size() + 7) / 8));
- RINOK(WriteBoolVector(antiVector));
+ WriteByte(NID::kAnti);
+ WriteNumber((antiVector.Size() + 7) / 8);
+ WriteBoolVector(antiVector);
}
}
-
- if (numDefinedNames > 0)
- {
- /////////////////////////////////////////////////
- RINOK(WriteByte(NID::kName));
- {
- RINOK(WriteNumber(1 + namesData.GetCapacity()));
- RINOK(WriteByte(0));
- RINOK(WriteBytes(namesData));
- }
-
}
- if (headerOptions.WriteCreated)
- {
- RINOK(WriteTime(database.Files, NID::kCreationTime));
- }
- if (headerOptions.WriteModified)
- {
- RINOK(WriteTime(database.Files, NID::kLastWriteTime));
- }
- if (headerOptions.WriteAccessed)
- {
- RINOK(WriteTime(database.Files, NID::kLastAccessTime));
- }
- if (numDefinedAttributes > 0)
{
- RINOK(WriteByte(NID::kWinAttributes));
- size_t size = 2;
- if (numDefinedAttributes != database.Files.Size())
- size += (attributesBoolVector.Size() + 7) / 8 + 1;
- size += attributesData.GetCapacity();
-
- RINOK(WriteNumber(size));
- if (numDefinedAttributes == database.Files.Size())
+ /* ---------- Names ---------- */
+
+ int numDefined = 0;
+ size_t namesDataSize = 0;
+ for (int i = 0; i < db.Files.Size(); i++)
{
- RINOK(WriteByte(1));
+ const UString &name = db.Files[i].Name;
+ if (!name.IsEmpty())
+ numDefined++;
+ namesDataSize += (name.Length() + 1) * 2;
}
- else
+
+ if (numDefined > 0)
{
- RINOK(WriteByte(0));
- RINOK(WriteBoolVector(attributesBoolVector));
- }
+ namesDataSize++;
+ SkipAlign(2 + GetBigNumberSize(namesDataSize), 2);
- {
- RINOK(WriteByte(0));
- RINOK(WriteBytes(attributesData));
+ WriteByte(NID::kName);
+ WriteNumber(namesDataSize);
+ WriteByte(0);
+ for (int i = 0; i < db.Files.Size(); i++)
+ {
+ const UString &name = db.Files[i].Name;
+ for (int t = 0; t <= name.Length(); t++)
+ {
+ wchar_t c = name[t];
+ WriteByte((Byte)c);
+ WriteByte((Byte)(c >> 8));
+ }
+ }
}
}
- if (numDefinedStarts > 0)
+ if (headerOptions.WriteCTime) WriteUInt64DefVector(db.CTime, NID::kCTime);
+ if (headerOptions.WriteATime) WriteUInt64DefVector(db.ATime, NID::kATime);
+ if (headerOptions.WriteMTime) WriteUInt64DefVector(db.MTime, NID::kMTime);
+ WriteUInt64DefVector(db.StartPos, NID::kStartPos);
+
{
- RINOK(WriteByte(NID::kStartPos));
- size_t size = 2;
- if (numDefinedStarts != database.Files.Size())
- size += (startsBoolVector.Size() + 7) / 8 + 1;
- size += startsData.GetCapacity();
-
- RINOK(WriteNumber(size));
- if (numDefinedStarts == database.Files.Size())
+ /* ---------- Write Attrib ---------- */
+ CBoolVector boolVector;
+ boolVector.Reserve(db.Files.Size());
+ int numDefined = 0;
+ for (i = 0; i < db.Files.Size(); i++)
{
- RINOK(WriteByte(1));
+ bool defined = db.Files[i].AttribDefined;
+ boolVector.Add(defined);
+ if (defined)
+ numDefined++;
}
- else
+ if (numDefined > 0)
{
- RINOK(WriteByte(0));
- RINOK(WriteBoolVector(startsBoolVector));
- }
-
- {
- RINOK(WriteByte(0));
- RINOK(WriteBytes(startsData));
+ WriteAlignedBoolHeader(boolVector, numDefined, NID::kWinAttributes, 4);
+ for (i = 0; i < db.Files.Size(); i++)
+ {
+ const CFileItem &file = db.Files[i];
+ if (file.AttribDefined)
+ WriteUInt32(file.Attrib);
+ }
}
}
- RINOK(WriteByte(NID::kEnd)); // for files
- RINOK(WriteByte(NID::kEnd)); // for headers
-
- return _outByte.Flush();
+ WriteByte(NID::kEnd); // for files
+ WriteByte(NID::kEnd); // for headers
}
HRESULT COutArchive::WriteDatabase(
DECL_EXTERNAL_CODECS_LOC_VARS
- const CArchiveDatabase &database,
- const CCompressionMethodMode *options,
+ const CArchiveDatabase &db,
+ const CCompressionMethodMode *options,
const CHeaderOptions &headerOptions)
{
+ if (!db.CheckNumFiles())
+ return E_FAIL;
+
UInt64 headerOffset;
UInt32 headerCRC;
UInt64 headerSize;
- if (database.IsEmpty())
+ if (db.IsEmpty())
{
headerSize = 0;
headerOffset = 0;
@@ -952,19 +769,35 @@ HRESULT COutArchive::WriteDatabase(
}
else
{
- _dynamicBuffer.Init();
- _dynamicMode = false;
-
+ bool encodeHeaders = false;
if (options != 0)
if (options->IsEmpty())
options = 0;
if (options != 0)
if (options->PasswordIsDefined || headerOptions.CompressMainHeader)
- _dynamicMode = true;
- RINOK(WriteHeader(database, headerOptions, headerOffset));
+ encodeHeaders = true;
+
+ _outByte.SetStream(SeqStream);
+ _outByte.Init();
+ _crc = CRC_INIT_VAL;
+ _countMode = encodeHeaders;
+ _writeToStream = true;
+ _countSize = 0;
+ WriteHeader(db, headerOptions, headerOffset);
- if (_dynamicMode)
+ if (encodeHeaders)
{
+ CByteBuffer buf;
+ buf.SetCapacity(_countSize);
+ _outByte2.Init((Byte *)buf, _countSize);
+
+ _countMode = false;
+ _writeToStream = false;
+ WriteHeader(db, headerOptions, headerOffset);
+
+ if (_countSize != _outByte2.GetPos())
+ return E_FAIL;
+
CCompressionMethodMode encryptOptions;
encryptOptions.PasswordIsDefined = options->PasswordIsDefined;
encryptOptions.Password = options->Password;
@@ -973,27 +806,23 @@ HRESULT COutArchive::WriteDatabase(
CObjectVector<CFolder> folders;
RINOK(EncodeStream(
EXTERNAL_CODECS_LOC_VARS
- encoder, _dynamicBuffer,
- _dynamicBuffer.GetSize(), packSizes, folders));
- _dynamicMode = false;
- _mainMode = true;
-
- _outByte.SetStream(SeqStream);
- _outByte.Init();
- _crc = CRC_INIT_VAL;
+ encoder, (const Byte *)buf,
+ _countSize, packSizes, folders));
+
+ _writeToStream = true;
if (folders.Size() == 0)
throw 1;
- RINOK(WriteID(NID::kEncodedHeader));
- RINOK(WritePackInfo(headerOffset, packSizes,
- CRecordVector<bool>(), CRecordVector<UInt32>()));
- RINOK(WriteUnPackInfo(folders));
- RINOK(WriteByte(NID::kEnd));
+ WriteID(NID::kEncodedHeader);
+ WritePackInfo(headerOffset, packSizes,
+ CRecordVector<bool>(), CRecordVector<UInt32>());
+ WriteUnpackInfo(folders);
+ WriteByte(NID::kEnd);
for (int i = 0; i < packSizes.Size(); i++)
headerOffset += packSizes[i];
- RINOK(_outByte.Flush());
}
+ RINOK(_outByte.Flush());
headerCRC = CRC_GET_DIGEST(_crc);
headerSize = _outByte.GetProcessedSize();
}
@@ -1003,8 +832,8 @@ HRESULT COutArchive::WriteDatabase(
CFinishHeader h;
h.NextHeaderSize = headerSize;
h.NextHeaderCRC = headerCRC;
- h.NextHeaderOffset =
- UInt64(0) - (headerSize +
+ h.NextHeaderOffset =
+ UInt64(0) - (headerSize +
4 + kFinishHeaderSize);
h.ArchiveStartOffset = h.NextHeaderOffset - headerOffset;
h.AdditionalStartBlockSize = 0;
@@ -1023,4 +852,25 @@ HRESULT COutArchive::WriteDatabase(
}
}
+void CArchiveDatabase::GetFile(int index, CFileItem &file, CFileItem2 &file2) const
+{
+ file = Files[index];
+ file2.CTimeDefined = CTime.GetItem(index, file2.CTime);
+ file2.ATimeDefined = ATime.GetItem(index, file2.ATime);
+ file2.MTimeDefined = MTime.GetItem(index, file2.MTime);
+ file2.StartPosDefined = StartPos.GetItem(index, file2.StartPos);
+ file2.IsAnti = IsItemAnti(index);
+}
+
+void CArchiveDatabase::AddFile(const CFileItem &file, const CFileItem2 &file2)
+{
+ int index = Files.Size();
+ CTime.SetItem(index, file2.CTimeDefined, file2.CTime);
+ ATime.SetItem(index, file2.ATimeDefined, file2.ATime);
+ MTime.SetItem(index, file2.MTimeDefined, file2.MTime);
+ StartPos.SetItem(index, file2.StartPosDefined, file2.StartPos);
+ SetItemAnti(index, file2.IsAnti);
+ Files.Add(file);
+}
+
}}
diff --git a/CPP/7zip/Archive/7z/7zOut.h b/CPP/7zip/Archive/7z/7zOut.h
index fd798184..bdd84abc 100755
--- a/CPP/7zip/Archive/7z/7zOut.h
+++ b/CPP/7zip/Archive/7z/7zOut.h
@@ -9,7 +9,6 @@
#include "7zEncode.h"
#include "../../Common/OutBuffer.h"
-#include "../../../Common/DynamicBuffer.h"
namespace NArchive {
namespace N7z {
@@ -21,58 +20,41 @@ class CWriteBufferLoc
size_t _pos;
public:
CWriteBufferLoc(): _size(0), _pos(0) {}
- void Init(Byte *data, size_t size)
- {
- _pos = 0;
+ void Init(Byte *data, size_t size)
+ {
_data = data;
- _size = size;
+ _size = size;
+ _pos = 0;
}
- HRESULT Write(const void *data, size_t size)
+ void WriteBytes(const void *data, size_t size)
{
- if (_pos + size > _size)
- return E_FAIL;
- memmove(_data + _pos, data, size);
+ if (size > _size - _pos)
+ throw 1;
+ memcpy(_data + _pos, data, size);
_pos += size;
- return S_OK;
- }
-};
-
-class CWriteDynamicBuffer
-{
- CByteDynamicBuffer _buffer;
- size_t _pos;
-public:
- CWriteDynamicBuffer(): _pos(0) {}
- void Init()
- {
- _pos = 0;
}
- void Write(const void *data, size_t size)
+ void WriteByte(Byte b)
{
- if (_pos + size > _buffer.GetCapacity())
- _buffer.EnsureCapacity(_pos + size);
- memmove(((Byte *)_buffer) +_pos, data, size);
- _pos += size;
+ if (_size == _pos)
+ throw 1;
+ _data[_pos++] = b;
}
- operator Byte *() { return (Byte *)_buffer; };
- operator const Byte *() const { return (const Byte *)_buffer; };
- size_t GetSize() const { return _pos; }
+ size_t GetPos() const { return _pos; }
};
struct CHeaderOptions
{
- // bool UseAdditionalHeaderStreams;
bool CompressMainHeader;
- bool WriteModified;
- bool WriteCreated;
- bool WriteAccessed;
+ bool WriteCTime;
+ bool WriteATime;
+ bool WriteMTime;
- CHeaderOptions():
- // UseAdditionalHeaderStreams(false),
+ CHeaderOptions():
CompressMainHeader(true),
- WriteModified(true),
- WriteCreated(false),
- WriteAccessed(false) {}
+ WriteCTime(false),
+ WriteATime(false),
+ WriteMTime(true)
+ {}
};
class COutArchive
@@ -80,56 +62,41 @@ class COutArchive
UInt64 _prefixHeaderPos;
HRESULT WriteDirect(const void *data, UInt32 size);
- HRESULT WriteDirectByte(Byte b) { return WriteDirect(&b, 1); }
- HRESULT WriteDirectUInt32(UInt32 value);
- HRESULT WriteDirectUInt64(UInt64 value);
- HRESULT WriteBytes(const void *data, size_t size);
- HRESULT WriteBytes(const CByteBuffer &data);
- HRESULT WriteByte(Byte b);
- HRESULT WriteUInt32(UInt32 value);
- HRESULT WriteNumber(UInt64 value);
- HRESULT WriteID(UInt64 value) { return WriteNumber(value); }
-
- HRESULT WriteFolder(const CFolder &folder);
+ UInt64 GetPos() const;
+ void WriteBytes(const void *data, size_t size);
+ void WriteBytes(const CByteBuffer &data) { WriteBytes(data, data.GetCapacity()); }
+ void WriteByte(Byte b);
+ void WriteUInt32(UInt32 value);
+ void WriteUInt64(UInt64 value);
+ void WriteNumber(UInt64 value);
+ void WriteID(UInt64 value) { WriteNumber(value); }
+
+ void WriteFolder(const CFolder &folder);
HRESULT WriteFileHeader(const CFileItem &itemInfo);
- HRESULT WriteBoolVector(const CBoolVector &boolVector);
- HRESULT WriteHashDigests(
+ void WriteBoolVector(const CBoolVector &boolVector);
+ void WriteHashDigests(
const CRecordVector<bool> &digestsDefined,
const CRecordVector<UInt32> &hashDigests);
- HRESULT WritePackInfo(
+ void WritePackInfo(
UInt64 dataOffset,
const CRecordVector<UInt64> &packSizes,
const CRecordVector<bool> &packCRCsDefined,
const CRecordVector<UInt32> &packCRCs);
- HRESULT WriteUnPackInfo(const CObjectVector<CFolder> &folders);
+ void WriteUnpackInfo(const CObjectVector<CFolder> &folders);
- HRESULT WriteSubStreamsInfo(
+ void WriteSubStreamsInfo(
const CObjectVector<CFolder> &folders,
- const CRecordVector<CNum> &numUnPackStreamsInFolders,
- const CRecordVector<UInt64> &unPackSizes,
+ const CRecordVector<CNum> &numUnpackStreamsInFolders,
+ const CRecordVector<UInt64> &unpackSizes,
const CRecordVector<bool> &digestsDefined,
const CRecordVector<UInt32> &hashDigests);
- /*
- HRESULT WriteStreamsInfo(
- UInt64 dataOffset,
- const CRecordVector<UInt64> &packSizes,
- const CRecordVector<bool> &packCRCsDefined,
- const CRecordVector<UInt32> &packCRCs,
- bool externalFolders,
- UInt64 externalFoldersStreamIndex,
- const CObjectVector<CFolder> &folders,
- const CRecordVector<CNum> &numUnPackStreamsInFolders,
- const CRecordVector<UInt64> &unPackSizes,
- const CRecordVector<bool> &digestsDefined,
- const CRecordVector<UInt32> &hashDigests);
- */
-
-
- HRESULT WriteTime(const CObjectVector<CFileItem> &files, Byte type);
+ void SkipAlign(unsigned pos, unsigned alignSize);
+ void WriteAlignedBoolHeader(const CBoolVector &v, int numDefined, Byte type, unsigned itemSize);
+ void WriteUInt64DefVector(const CUInt64DefVector &v, Byte type);
HRESULT EncodeStream(
DECL_EXTERNAL_CODECS_LOC_VARS
@@ -137,23 +104,19 @@ class COutArchive
CRecordVector<UInt64> &packSizes, CObjectVector<CFolder> &folders);
HRESULT EncodeStream(
DECL_EXTERNAL_CODECS_LOC_VARS
- CEncoder &encoder, const CByteBuffer &data,
+ CEncoder &encoder, const CByteBuffer &data,
CRecordVector<UInt64> &packSizes, CObjectVector<CFolder> &folders);
- HRESULT WriteHeader(
- const CArchiveDatabase &database,
+ void WriteHeader(
+ const CArchiveDatabase &db,
const CHeaderOptions &headerOptions,
UInt64 &headerOffset);
- bool _mainMode;
-
- bool _dynamicMode;
-
bool _countMode;
+ bool _writeToStream;
size_t _countSize;
+ UInt32 _crc;
COutBuffer _outByte;
CWriteBufferLoc _outByte2;
- CWriteDynamicBuffer _dynamicBuffer;
- UInt32 _crc;
#ifdef _7Z_VOL
bool _endMarker;
@@ -177,8 +140,8 @@ public:
HRESULT SkeepPrefixArchiveHeader();
HRESULT WriteDatabase(
DECL_EXTERNAL_CODECS_LOC_VARS
- const CArchiveDatabase &database,
- const CCompressionMethodMode *options,
+ const CArchiveDatabase &db,
+ const CCompressionMethodMode *options,
const CHeaderOptions &headerOptions);
#ifdef _7Z_VOL
diff --git a/CPP/7zip/Archive/7z/7zProperties.cpp b/CPP/7zip/Archive/7z/7zProperties.cpp
index f5b5ba98..66d90785 100755
--- a/CPP/7zip/Archive/7z/7zProperties.cpp
+++ b/CPP/7zip/Archive/7z/7zProperties.cpp
@@ -17,11 +17,11 @@ struct CPropMap
STATPROPSTG StatPROPSTG;
};
-CPropMap kPropMap[] =
+CPropMap kPropMap[] =
{
{ NID::kName, NULL, kpidPath, VT_BSTR},
{ NID::kSize, NULL, kpidSize, VT_UI8},
- { NID::kPackInfo, NULL, kpidPackedSize, VT_UI8},
+ { NID::kPackInfo, NULL, kpidPackSize, VT_UI8},
#ifdef _MULTI_PACK
{ 100, L"Pack0", kpidPackedSize0, VT_UI8},
@@ -31,10 +31,10 @@ CPropMap kPropMap[] =
{ 104, L"Pack4", kpidPackedSize4, VT_UI8},
#endif
- { NID::kCreationTime, NULL, kpidCreationTime, VT_FILETIME},
- { NID::kLastWriteTime, NULL, kpidLastWriteTime, VT_FILETIME},
- { NID::kLastAccessTime, NULL, kpidLastAccessTime, VT_FILETIME},
- { NID::kWinAttributes, NULL, kpidAttributes, VT_UI4},
+ { NID::kCTime, NULL, kpidCTime, VT_FILETIME},
+ { NID::kMTime, NULL, kpidMTime, VT_FILETIME},
+ { NID::kATime, NULL, kpidATime, VT_FILETIME},
+ { NID::kWinAttributes, NULL, kpidAttrib, VT_UI4},
{ NID::kStartPos, NULL, kpidPosition, VT_UI4},
{ NID::kCRC, NULL, kpidCRC, VT_UI4},
@@ -58,7 +58,7 @@ static int FindPropInMap(UInt64 filePropID)
return -1;
}
-static void CopyOneItem(CRecordVector<UInt64> &src,
+static void CopyOneItem(CRecordVector<UInt64> &src,
CRecordVector<UInt64> &dest, UInt32 item)
{
for (int i = 0; i < src.Size(); i++)
@@ -92,17 +92,17 @@ static void InsertToHead(CRecordVector<UInt64> &dest, UInt32 item)
}
void CHandler::FillPopIDs()
-{
+{
_fileInfoPopIDs.Clear();
#ifdef _7Z_VOL
if(_volumes.Size() < 1)
return;
const CVolume &volume = _volumes.Front();
- const CArchiveDatabaseEx &_database = volume.Database;
+ const CArchiveDatabaseEx &_db = volume.Database;
#endif
- CRecordVector<UInt64> fileInfoPopIDs = _database.ArchiveInfo.FileInfoPopIDs;
+ CRecordVector<UInt64> fileInfoPopIDs = _db.ArchiveInfo.FileInfoPopIDs;
RemoveOneItem(fileInfoPopIDs, NID::kEmptyStream);
RemoveOneItem(fileInfoPopIDs, NID::kEmptyFile);
@@ -111,13 +111,13 @@ void CHandler::FillPopIDs()
CopyOneItem(fileInfoPopIDs, _fileInfoPopIDs, NID::kAnti);
CopyOneItem(fileInfoPopIDs, _fileInfoPopIDs, NID::kSize);
CopyOneItem(fileInfoPopIDs, _fileInfoPopIDs, NID::kPackInfo);
- CopyOneItem(fileInfoPopIDs, _fileInfoPopIDs, NID::kCreationTime);
- CopyOneItem(fileInfoPopIDs, _fileInfoPopIDs, NID::kLastWriteTime);
- CopyOneItem(fileInfoPopIDs, _fileInfoPopIDs, NID::kLastAccessTime);
+ CopyOneItem(fileInfoPopIDs, _fileInfoPopIDs, NID::kCTime);
+ CopyOneItem(fileInfoPopIDs, _fileInfoPopIDs, NID::kMTime);
+ CopyOneItem(fileInfoPopIDs, _fileInfoPopIDs, NID::kATime);
CopyOneItem(fileInfoPopIDs, _fileInfoPopIDs, NID::kWinAttributes);
CopyOneItem(fileInfoPopIDs, _fileInfoPopIDs, NID::kCRC);
CopyOneItem(fileInfoPopIDs, _fileInfoPopIDs, NID::kComment);
- _fileInfoPopIDs += fileInfoPopIDs;
+ _fileInfoPopIDs += fileInfoPopIDs;
#ifndef _SFX
_fileInfoPopIDs.Add(97);
@@ -133,7 +133,7 @@ void CHandler::FillPopIDs()
#endif
#ifndef _SFX
- InsertToHead(_fileInfoPopIDs, NID::kLastWriteTime);
+ InsertToHead(_fileInfoPopIDs, NID::kMTime);
InsertToHead(_fileInfoPopIDs, NID::kPackInfo);
InsertToHead(_fileInfoPopIDs, NID::kSize);
InsertToHead(_fileInfoPopIDs, NID::kName);
diff --git a/CPP/7zip/Archive/7z/7zProperties.h b/CPP/7zip/Archive/7z/7zProperties.h
index 4da85f04..66181795 100755
--- a/CPP/7zip/Archive/7z/7zProperties.h
+++ b/CPP/7zip/Archive/7z/7zProperties.h
@@ -11,7 +11,7 @@ namespace N7z {
enum
{
kpidPackedSize0 = kpidUserDefined,
- kpidPackedSize1,
+ kpidPackedSize1,
kpidPackedSize2,
kpidPackedSize3,
kpidPackedSize4
diff --git a/CPP/7zip/Archive/7z/7zSpecStream.cpp b/CPP/7zip/Archive/7z/7zSpecStream.cpp
index 80d303a4..06969636 100755
--- a/CPP/7zip/Archive/7z/7zSpecStream.cpp
+++ b/CPP/7zip/Archive/7z/7zSpecStream.cpp
@@ -11,7 +11,7 @@ STDMETHODIMP CSequentialInStreamSizeCount2::Read(void *data, UInt32 size, UInt32
_size += realProcessedSize;
if (processedSize != 0)
*processedSize = realProcessedSize;
- return result;
+ return result;
}
STDMETHODIMP CSequentialInStreamSizeCount2::GetSubStreamSize(
diff --git a/CPP/7zip/Archive/7z/7zSpecStream.h b/CPP/7zip/Archive/7z/7zSpecStream.h
index 0253c421..2e26efd5 100755
--- a/CPP/7zip/Archive/7z/7zSpecStream.h
+++ b/CPP/7zip/Archive/7z/7zSpecStream.h
@@ -7,7 +7,7 @@
#include "../../ICoder.h"
#include "../../../Common/MyCom.h"
-class CSequentialInStreamSizeCount2:
+class CSequentialInStreamSizeCount2:
public ISequentialInStream,
public ICompressGetSubStreamSize,
public CMyUnknownImp
diff --git a/CPP/7zip/Archive/7z/7zUpdate.cpp b/CPP/7zip/Archive/7z/7zUpdate.cpp
index 68f4604d..d3039d49 100755
--- a/CPP/7zip/Archive/7z/7zUpdate.cpp
+++ b/CPP/7zip/Archive/7z/7zUpdate.cpp
@@ -22,7 +22,7 @@ static const UInt32 kDictionaryForBCJ2_LZMA = 1 << 20;
static const UInt32 kAlgorithmForBCJ2_LZMA = 1;
static const UInt32 kNumFastBytesForBCJ2_LZMA = 64;
-static HRESULT WriteRange(IInStream *inStream, ISequentialOutStream *outStream,
+static HRESULT WriteRange(IInStream *inStream, ISequentialOutStream *outStream,
UInt64 position, UInt64 size, ICompressProgressInfo *progress)
{
RINOK(inStream->Seek(position, STREAM_SEEK_SET, 0));
@@ -117,9 +117,9 @@ static int CompareFolderRefs(const int *p1, const int *p2, void *param)
db.Folders[i1],
db.Folders[i2]));
RINOZ(MyCompare(
- db.NumUnPackStreamsVector[i1],
- db.NumUnPackStreamsVector[i2]));
- if (db.NumUnPackStreamsVector[i1] == 0)
+ db.NumUnpackStreamsVector[i1],
+ db.NumUnpackStreamsVector[i2]));
+ if (db.NumUnpackStreamsVector[i1] == 0)
return 0;
return CompareFiles(
db.Files[db.FolderStartFileIndex[i1]],
@@ -133,9 +133,9 @@ static int CompareEmptyItems(const int *p1, const int *p2, void *param)
const CObjectVector<CUpdateItem> &updateItems = *(const CObjectVector<CUpdateItem> *)param;
const CUpdateItem &u1 = updateItems[*p1];
const CUpdateItem &u2 = updateItems[*p2];
- if (u1.IsDirectory != u2.IsDirectory)
- return (u1.IsDirectory) ? 1 : -1;
- if (u1.IsDirectory)
+ if (u1.IsDir != u2.IsDir)
+ return (u1.IsDir) ? 1 : -1;
+ if (u1.IsDir)
{
if (u1.IsAnti != u2.IsAnti)
return (u1.IsAnti ? 1 : -1);
@@ -147,8 +147,8 @@ static int CompareEmptyItems(const int *p1, const int *p2, void *param)
return MyStringCompareNoCase(u1.Name, u2.Name);
}
-static const char *g_Exts =
- " lzma 7z ace arc arj bz bz2 deb lzo lzx gz pak rpm sit tgz tbz tbz2 tgz cab ha lha lzh rar zoo"
+static const char *g_Exts =
+ " lzma 7z ace arc arj bz bz2 deb lzo lzx gz pak rpm sit tgz tbz tbz2 tgz cab ha lha lzh rar zoo"
" zip jar ear war msi"
" 3gp avi mov mpeg mpg mpe wmv"
" aac ape fla flac la mp3 m4a mp4 ofr ogg pac ra rm rka shn swa tta wv wma wav"
@@ -161,7 +161,7 @@ static const char *g_Exts =
" iso bin nrg mdf img pdi tar cpio xpi"
" vfd vhd vud vmc vsv"
" vmdk dsk nvram vmem vmsd vmsn vmss vmtm"
- " inl inc idl acf asa h hpp hxx c cpp cxx rc java cs pas bas vb cls ctl frm dlg def"
+ " inl inc idl acf asa h hpp hxx c cpp cxx rc java cs pas bas vb cls ctl frm dlg def"
" f77 f f90 f95"
" asm sql manifest dep "
" mak clw csproj vcproj sln dsp dsw "
@@ -212,29 +212,29 @@ int GetExtIndex(const char *ext)
struct CRefItem
{
- UInt32 Index;
const CUpdateItem *UpdateItem;
+ UInt32 Index;
UInt32 ExtensionPos;
UInt32 NamePos;
int ExtensionIndex;
- CRefItem(UInt32 index, const CUpdateItem &updateItem, bool sortByType):
+ CRefItem(UInt32 index, const CUpdateItem &ui, bool sortByType):
+ UpdateItem(&ui),
Index(index),
- UpdateItem(&updateItem),
ExtensionPos(0),
NamePos(0),
ExtensionIndex(0)
{
if (sortByType)
{
- int slashPos = GetReverseSlashPos(updateItem.Name);
+ int slashPos = GetReverseSlashPos(ui.Name);
NamePos = ((slashPos >= 0) ? (slashPos + 1) : 0);
- int dotPos = updateItem.Name.ReverseFind(L'.');
+ int dotPos = ui.Name.ReverseFind(L'.');
if (dotPos < 0 || (dotPos < slashPos && slashPos >= 0))
- ExtensionPos = updateItem.Name.Length();
- else
+ ExtensionPos = ui.Name.Length();
+ else
{
ExtensionPos = dotPos + 1;
- UString us = updateItem.Name.Mid(ExtensionPos);
+ UString us = ui.Name.Mid(ExtensionPos);
if (!us.IsEmpty())
{
us.MakeLower();
@@ -264,9 +264,9 @@ static int CompareUpdateItems(const CRefItem *p1, const CRefItem *p2, void *para
const CUpdateItem &u1 = *a1.UpdateItem;
const CUpdateItem &u2 = *a2.UpdateItem;
int n;
- if (u1.IsDirectory != u2.IsDirectory)
- return (u1.IsDirectory) ? 1 : -1;
- if (u1.IsDirectory)
+ if (u1.IsDir != u2.IsDir)
+ return (u1.IsDir) ? 1 : -1;
+ if (u1.IsDir)
{
if (u1.IsAnti != u2.IsAnti)
return (u1.IsAnti ? 1 : -1);
@@ -279,8 +279,9 @@ static int CompareUpdateItems(const CRefItem *p1, const CRefItem *p2, void *para
RINOZ(MyCompare(a1.ExtensionIndex, a2.ExtensionIndex))
RINOZ(MyStringCompareNoCase(u1.Name + a1.ExtensionPos, u2.Name + a2.ExtensionPos));
RINOZ(MyStringCompareNoCase(u1.Name + a1.NamePos, u2.Name + a2.NamePos));
- if (u1.IsLastWriteTimeDefined && u2.IsLastWriteTimeDefined)
- RINOZ(CompareFileTime(&u1.LastWriteTime, &u2.LastWriteTime));
+ if (!u1.MTimeDefined && u2.MTimeDefined) return 1;
+ if (u1.MTimeDefined && !u2.MTimeDefined) return -1;
+ if (u1.MTimeDefined && u2.MTimeDefined) RINOZ(MyCompare(u1.MTime, u2.MTime));
RINOZ(MyCompare(u1.Size, u2.Size))
}
return MyStringCompareNoCase(u1.Name, u2.Name);
@@ -313,7 +314,7 @@ static const UInt64 k_LZMA = 0x030101;
static const UInt64 k_BCJ = 0x03030103;
static const UInt64 k_BCJ2 = 0x0303011B;
-static bool GetMethodFull(UInt64 methodID,
+static bool GetMethodFull(UInt64 methodID,
UInt32 numInStreams, CMethodFull &methodResult)
{
methodResult.Id = methodID;
@@ -322,7 +323,7 @@ static bool GetMethodFull(UInt64 methodID,
return true;
}
-static bool MakeExeMethod(const CCompressionMethodMode &method,
+static bool MakeExeMethod(const CCompressionMethodMode &method,
bool bcj2Filter, CCompressionMethodMode &exeMethod)
{
exeMethod = method;
@@ -392,10 +393,10 @@ static bool MakeExeMethod(const CCompressionMethodMode &method,
exeMethod.Binds.Add(bind);
}
return true;
-}
+}
static void SplitFilesToGroups(
- const CCompressionMethodMode &method,
+ const CCompressionMethodMode &method,
bool useFilters, bool maxFilter,
const CObjectVector<CUpdateItem> &updateItems,
CObjectVector<CSolidGroup> &groups)
@@ -411,14 +412,14 @@ static void SplitFilesToGroups(
int i;
for (i = 0; i < updateItems.Size(); i++)
{
- const CUpdateItem &updateItem = updateItems[i];
- if (!updateItem.NewData)
+ const CUpdateItem &ui = updateItems[i];
+ if (!ui.NewData)
continue;
- if (!updateItem.HasStream())
+ if (!ui.HasStream())
continue;
if (useFilters)
{
- const UString name = updateItem.Name;
+ const UString name = ui.Name;
int dotPos = name.ReverseFind(L'.');
if (dotPos >= 0)
{
@@ -442,31 +443,31 @@ static void SplitFilesToGroups(
i++;
}
-static void FromUpdateItemToFileItem(const CUpdateItem &updateItem,
- CFileItem &file)
+static void FromUpdateItemToFileItem(const CUpdateItem &ui,
+ CFileItem &file, CFileItem2 &file2)
{
- file.Name = NItemName::MakeLegalName(updateItem.Name);
- if (updateItem.AttributesAreDefined)
- file.SetAttributes(updateItem.Attributes);
-
- if (updateItem.IsCreationTimeDefined)
- file.SetCreationTime(updateItem.CreationTime);
- if (updateItem.IsLastWriteTimeDefined)
- file.SetLastWriteTime(updateItem.LastWriteTime);
- if (updateItem.IsLastAccessTimeDefined)
- file.SetLastAccessTime(updateItem.LastAccessTime);
+ file.Name = NItemName::MakeLegalName(ui.Name);
+ if (ui.AttribDefined)
+ file.SetAttrib(ui.Attrib);
- file.UnPackSize = updateItem.Size;
- file.IsDirectory = updateItem.IsDirectory;
- file.IsAnti = updateItem.IsAnti;
- file.HasStream = updateItem.HasStream();
+ file2.CTime = ui.CTime; file2.CTimeDefined = ui.CTimeDefined;
+ file2.ATime = ui.ATime; file2.ATimeDefined = ui.ATimeDefined;
+ file2.MTime = ui.MTime; file2.MTimeDefined = ui.MTimeDefined;
+ file2.IsAnti = ui.IsAnti;
+ file2.StartPosDefined = false;
+
+ file.Size = ui.Size;
+ file.IsDir = ui.IsDir;
+ file.HasStream = ui.HasStream();
}
static HRESULT Update2(
DECL_EXTERNAL_CODECS_LOC_VARS
IInStream *inStream,
- const CArchiveDatabaseEx *database,
+ const CArchiveDatabaseEx *db,
const CObjectVector<CUpdateItem> &updateItems,
+ COutArchive &archive,
+ CArchiveDatabase &newDatabase,
ISequentialOutStream *seqOutStream,
IArchiveUpdateCallback *updateCallback,
const CUpdateOptions &options)
@@ -481,17 +482,17 @@ static HRESULT Update2(
return E_NOTIMPL;
*/
- UInt64 startBlockSize = database != 0 ? database->ArchiveInfo.StartPosition: 0;
+ UInt64 startBlockSize = db != 0 ? db->ArchiveInfo.StartPosition: 0;
if (startBlockSize > 0 && !options.RemoveSfxBlock)
{
RINOK(WriteRange(inStream, seqOutStream, 0, startBlockSize, NULL));
}
CRecordVector<int> fileIndexToUpdateIndexMap;
- if (database != 0)
+ if (db != 0)
{
- fileIndexToUpdateIndexMap.Reserve(database->Files.Size());
- for (int i = 0; i < database->Files.Size(); i++)
+ fileIndexToUpdateIndexMap.Reserve(db->Files.Size());
+ for (int i = 0; i < db->Files.Size(); i++)
fileIndexToUpdateIndexMap.Add(-1);
}
int i;
@@ -503,17 +504,17 @@ static HRESULT Update2(
}
CRecordVector<int> folderRefs;
- if (database != 0)
+ if (db != 0)
{
- for(i = 0; i < database->Folders.Size(); i++)
+ for(i = 0; i < db->Folders.Size(); i++)
{
CNum indexInFolder = 0;
CNum numCopyItems = 0;
- CNum numUnPackStreams = database->NumUnPackStreamsVector[i];
- for (CNum fileIndex = database->FolderStartFileIndex[i];
- indexInFolder < numUnPackStreams; fileIndex++)
+ CNum numUnpackStreams = db->NumUnpackStreamsVector[i];
+ for (CNum fileIndex = db->FolderStartFileIndex[i];
+ indexInFolder < numUnpackStreams; fileIndex++)
{
- if (database->Files[fileIndex].HasStream)
+ if (db->Files[fileIndex].HasStream)
{
indexInFolder++;
int updateIndex = fileIndexToUpdateIndexMap[fileIndex];
@@ -522,38 +523,35 @@ static HRESULT Update2(
numCopyItems++;
}
}
- if (numCopyItems != numUnPackStreams && numCopyItems != 0)
+ if (numCopyItems != numUnpackStreams && numCopyItems != 0)
return E_NOTIMPL; // It needs repacking !!!
if (numCopyItems > 0)
folderRefs.Add(i);
}
- folderRefs.Sort(CompareFolderRefs, (void *)database);
+ folderRefs.Sort(CompareFolderRefs, (void *)db);
}
- CArchiveDatabase newDatabase;
-
////////////////////////////
- COutArchive archive;
RINOK(archive.Create(seqOutStream, false));
RINOK(archive.SkeepPrefixArchiveHeader());
UInt64 complexity = 0;
for(i = 0; i < folderRefs.Size(); i++)
- complexity += database->GetFolderFullPackSize(folderRefs[i]);
+ complexity += db->GetFolderFullPackSize(folderRefs[i]);
UInt64 inSizeForReduce = 0;
for(i = 0; i < updateItems.Size(); i++)
{
- const CUpdateItem &updateItem = updateItems[i];
- if (updateItem.NewData)
+ const CUpdateItem &ui = updateItems[i];
+ if (ui.NewData)
{
- complexity += updateItem.Size;
+ complexity += ui.Size;
if (numSolidFiles == 1)
{
- if (updateItem.Size > inSizeForReduce)
- inSizeForReduce = updateItem.Size;
+ if (ui.Size > inSizeForReduce)
+ inSizeForReduce = ui.Size;
}
else
- inSizeForReduce += updateItem.Size;
+ inSizeForReduce += ui.Size;
}
}
RINOK(updateCallback->SetTotal(complexity));
@@ -573,57 +571,62 @@ static HRESULT Update2(
int folderIndex = folderRefs[i];
lps->ProgressOffset = complexity;
- UInt64 packSize = database->GetFolderFullPackSize(folderIndex);
+ UInt64 packSize = db->GetFolderFullPackSize(folderIndex);
RINOK(WriteRange(inStream, archive.SeqStream,
- database->GetFolderStreamPos(folderIndex, 0), packSize, progress));
+ db->GetFolderStreamPos(folderIndex, 0), packSize, progress));
complexity += packSize;
- const CFolder &folder = database->Folders[folderIndex];
- CNum startIndex = database->FolderStartPackStreamIndex[folderIndex];
+ const CFolder &folder = db->Folders[folderIndex];
+ CNum startIndex = db->FolderStartPackStreamIndex[folderIndex];
for (int j = 0; j < folder.PackStreams.Size(); j++)
{
- newDatabase.PackSizes.Add(database->PackSizes[startIndex + j]);
- // newDatabase.PackCRCsDefined.Add(database.PackCRCsDefined[startIndex + j]);
- // newDatabase.PackCRCs.Add(database.PackCRCs[startIndex + j]);
+ newDatabase.PackSizes.Add(db->PackSizes[startIndex + j]);
+ // newDatabase.PackCRCsDefined.Add(db.PackCRCsDefined[startIndex + j]);
+ // newDatabase.PackCRCs.Add(db.PackCRCs[startIndex + j]);
}
newDatabase.Folders.Add(folder);
- CNum numUnPackStreams = database->NumUnPackStreamsVector[folderIndex];
- newDatabase.NumUnPackStreamsVector.Add(numUnPackStreams);
+ CNum numUnpackStreams = db->NumUnpackStreamsVector[folderIndex];
+ newDatabase.NumUnpackStreamsVector.Add(numUnpackStreams);
CNum indexInFolder = 0;
- for (CNum fi = database->FolderStartFileIndex[folderIndex];
- indexInFolder < numUnPackStreams; fi++)
+ for (CNum fi = db->FolderStartFileIndex[folderIndex];
+ indexInFolder < numUnpackStreams; fi++)
{
- CFileItem file = database->Files[fi];
+ CFileItem file;
+ CFileItem2 file2;
+ db->GetFile(fi, file, file2);
if (file.HasStream)
{
indexInFolder++;
int updateIndex = fileIndexToUpdateIndexMap[fi];
if (updateIndex >= 0)
{
- const CUpdateItem &updateItem = updateItems[updateIndex];
- if (updateItem.NewProperties)
+ const CUpdateItem &ui = updateItems[updateIndex];
+ if (ui.NewProperties)
{
- CFileItem file2;
- FromUpdateItemToFileItem(updateItem, file2);
- file2.UnPackSize = file.UnPackSize;
- file2.FileCRC = file.FileCRC;
- file2.IsFileCRCDefined = file.IsFileCRCDefined;
- file2.HasStream = file.HasStream;
- file = file2;
+ CFileItem uf;
+ FromUpdateItemToFileItem(ui, uf, file2);
+ uf.Size = file.Size;
+ uf.Crc = file.Crc;
+ uf.CrcDefined = file.CrcDefined;
+ uf.HasStream = file.HasStream;
+ file = uf;
}
}
- newDatabase.Files.Add(file);
+ newDatabase.AddFile(file, file2);
}
}
}
+ folderRefs.ClearAndFree();
+ fileIndexToUpdateIndexMap.ClearAndFree();
+
/////////////////////////////////////////
// Compress New Files
CObjectVector<CSolidGroup> groups;
- SplitFilesToGroups(*options.Method, options.UseFilters, options.MaxFilter,
+ SplitFilesToGroups(*options.Method, options.UseFilters, options.MaxFilter,
updateItems, groups);
const UInt32 kMinReduceSize = (1 << 16);
@@ -651,13 +654,13 @@ static HRESULT Update2(
UInt32 index = refItems[i].Index;
indices.Add(index);
/*
- const CUpdateItem &updateItem = updateItems[index];
+ const CUpdateItem &ui = updateItems[index];
CFileItem file;
- if (updateItem.NewProperties)
- FromUpdateItemToFileItem(updateItem, file);
+ if (ui.NewProperties)
+ FromUpdateItemToFileItem(ui, file);
else
- file = database.Files[updateItem.IndexInArchive];
- if (file.IsAnti || file.IsDirectory)
+ file = db.Files[ui.IndexInArchive];
+ if (file.IsAnti || file.IsDir)
return E_FAIL;
newDatabase.Files.Add(file);
*/
@@ -670,16 +673,16 @@ static HRESULT Update2(
UInt64 totalSize = 0;
int numSubFiles;
UString prevExtension;
- for (numSubFiles = 0; i + numSubFiles < numFiles &&
+ for (numSubFiles = 0; i + numSubFiles < numFiles &&
numSubFiles < numSolidFiles; numSubFiles++)
{
- const CUpdateItem &updateItem = updateItems[indices[i + numSubFiles]];
- totalSize += updateItem.Size;
+ const CUpdateItem &ui = updateItems[indices[i + numSubFiles]];
+ totalSize += ui.Size;
if (totalSize > options.NumSolidBytes)
break;
if (options.SolidExtension)
{
- UString ext = updateItem.GetExtension();
+ UString ext = ui.GetExtension();
if (numSubFiles == 0)
prevExtension = ext;
else
@@ -699,29 +702,30 @@ static HRESULT Update2(
int startPackIndex = newDatabase.PackSizes.Size();
RINOK(encoder.Encode(
EXTERNAL_CODECS_LOC_VARS
- solidInStream, NULL, &inSizeForReduce, folderItem,
+ solidInStream, NULL, &inSizeForReduce, folderItem,
archive.SeqStream, newDatabase.PackSizes, progress));
for (; startPackIndex < newDatabase.PackSizes.Size(); startPackIndex++)
lps->OutSize += newDatabase.PackSizes[startPackIndex];
- lps->InSize += folderItem.GetUnPackSize();
+ lps->InSize += folderItem.GetUnpackSize();
// for()
// newDatabase.PackCRCsDefined.Add(false);
// newDatabase.PackCRCs.Add(0);
newDatabase.Folders.Add(folderItem);
- CNum numUnPackStreams = 0;
+ CNum numUnpackStreams = 0;
for (int subIndex = 0; subIndex < numSubFiles; subIndex++)
{
- const CUpdateItem &updateItem = updateItems[indices[i + subIndex]];
+ const CUpdateItem &ui = updateItems[indices[i + subIndex]];
CFileItem file;
- if (updateItem.NewProperties)
- FromUpdateItemToFileItem(updateItem, file);
+ CFileItem2 file2;
+ if (ui.NewProperties)
+ FromUpdateItemToFileItem(ui, file, file2);
else
- file = database->Files[updateItem.IndexInArchive];
- if (file.IsAnti || file.IsDirectory)
+ db->GetFile(ui.IndexInArchive, file, file2);
+ if (file2.IsAnti || file.IsDir)
return E_FAIL;
/*
@@ -734,28 +738,30 @@ static HRESULT Update2(
// file.Name += L".locked";
}
- file.FileCRC = inStreamSpec->CRCs[subIndex];
- file.UnPackSize = inStreamSpec->Sizes[subIndex];
- if (file.UnPackSize != 0)
+ file.Crc = inStreamSpec->CRCs[subIndex];
+ file.Size = inStreamSpec->Sizes[subIndex];
+ if (file.Size != 0)
{
- file.IsFileCRCDefined = true;
+ file.CrcDefined = true;
file.HasStream = true;
- numUnPackStreams++;
+ numUnpackStreams++;
}
else
{
- file.IsFileCRCDefined = false;
+ file.CrcDefined = false;
file.HasStream = false;
}
- newDatabase.Files.Add(file);
+ newDatabase.AddFile(file, file2);
}
- // numUnPackStreams = 0 is very bad case for locked files
+ // numUnpackStreams = 0 is very bad case for locked files
// v3.13 doesn't understand it.
- newDatabase.NumUnPackStreamsVector.Add(numUnPackStreams);
+ newDatabase.NumUnpackStreamsVector.Add(numUnpackStreams);
i += numSubFiles;
}
}
+ groups.ClearAndFree();
+
{
/////////////////////////////////////////
// Write Empty Files & Folders
@@ -763,267 +769,51 @@ static HRESULT Update2(
CRecordVector<int> emptyRefs;
for(i = 0; i < updateItems.Size(); i++)
{
- const CUpdateItem &updateItem = updateItems[i];
- if (updateItem.NewData)
+ const CUpdateItem &ui = updateItems[i];
+ if (ui.NewData)
{
- if (updateItem.HasStream())
+ if (ui.HasStream())
continue;
}
else
- if (updateItem.IndexInArchive != -1)
- if (database->Files[updateItem.IndexInArchive].HasStream)
+ if (ui.IndexInArchive != -1)
+ if (db->Files[ui.IndexInArchive].HasStream)
continue;
emptyRefs.Add(i);
}
emptyRefs.Sort(CompareEmptyItems, (void *)&updateItems);
- for(i = 0; i < emptyRefs.Size(); i++)
+ for (i = 0; i < emptyRefs.Size(); i++)
{
- const CUpdateItem &updateItem = updateItems[emptyRefs[i]];
+ const CUpdateItem &ui = updateItems[emptyRefs[i]];
CFileItem file;
- if (updateItem.NewProperties)
- FromUpdateItemToFileItem(updateItem, file);
+ CFileItem2 file2;
+ if (ui.NewProperties)
+ FromUpdateItemToFileItem(ui, file, file2);
else
- file = database->Files[updateItem.IndexInArchive];
- newDatabase.Files.Add(file);
+ db->GetFile(ui.IndexInArchive, file, file2);
+ newDatabase.AddFile(file, file2);
}
}
- /*
- if (newDatabase.Files.Size() != updateItems.Size())
- return E_FAIL;
- */
-
- return archive.WriteDatabase(EXTERNAL_CODECS_LOC_VARS
- newDatabase, options.HeaderMethod, options.HeaderOptions);
-}
-
-#ifdef _7Z_VOL
-
-static const UInt64 k_Copy = 0x0;
-
-static HRESULT WriteVolumeHeader(COutArchive &archive, CFileItem &file, const CUpdateOptions &options)
-{
- CCoderInfo coder;
- coder.NumInStreams = coder.NumOutStreams = 1;
- coder.MethodID = k_Copy;
-
- CFolder folder;
- folder.Coders.Add(coder);
- folder.PackStreams.Add(0);
-
- CNum numUnPackStreams = 0;
- if (file.UnPackSize != 0)
- {
- file.IsFileCRCDefined = true;
- file.HasStream = true;
- numUnPackStreams++;
- }
- else
- {
- throw 1;
- file.IsFileCRCDefined = false;
- file.HasStream = false;
- }
- folder.UnPackSizes.Add(file.UnPackSize);
-
- CArchiveDatabase newDatabase;
- newDatabase.Files.Add(file);
- newDatabase.Folders.Add(folder);
- newDatabase.NumUnPackStreamsVector.Add(numUnPackStreams);
- newDatabase.PackSizes.Add(file.UnPackSize);
- newDatabase.PackCRCsDefined.Add(false);
- newDatabase.PackCRCs.Add(file.FileCRC);
-
- return archive.WriteDatabase(newDatabase,
- options.HeaderMethod,
- false,
- false);
-}
-
-HRESULT UpdateVolume(
- IInStream *inStream,
- const CArchiveDatabaseEx *database,
- CObjectVector<CUpdateItem> &updateItems,
- ISequentialOutStream *seqOutStream,
- IArchiveUpdateCallback *updateCallback,
- const CUpdateOptions &options)
-{
- if (updateItems.Size() != 1)
- return E_NOTIMPL;
-
- CMyComPtr<IArchiveUpdateCallback2> volumeCallback;
- RINOK(updateCallback->QueryInterface(IID_IArchiveUpdateCallback2, (void **)&volumeCallback));
- if (!volumeCallback)
- return E_NOTIMPL;
-
- CMyComPtr<ISequentialInStream> fileStream;
- HRESULT result = updateCallback->GetStream(0, &fileStream);
- if (result != S_OK && result != S_FALSE)
- return result;
- if (result == S_FALSE)
- return E_FAIL;
-
- CFileItem file;
-
- const CUpdateItem &updateItem = updateItems[0];
- if (updateItem.NewProperties)
- FromUpdateItemToFileItem(updateItem, file);
- else
- file = database->Files[updateItem.IndexInArchive];
- if (file.IsAnti || file.IsDirectory)
- return E_FAIL;
-
- UInt64 complexity = 0;
- file.IsStartPosDefined = true;
- file.StartPos = 0;
- for (UInt64 volumeIndex = 0; true; volumeIndex++)
- {
- UInt64 volSize;
- RINOK(volumeCallback->GetVolumeSize(volumeIndex, &volSize));
- UInt64 pureSize = COutArchive::GetVolPureSize(volSize, file.Name.Length(), true);
- CMyComPtr<ISequentialOutStream> volumeStream;
- RINOK(volumeCallback->GetVolumeStream(volumeIndex, &volumeStream));
-
- COutArchive archive;
- RINOK(archive.Create(volumeStream, true));
- RINOK(archive.SkeepPrefixArchiveHeader());
-
- CSequentialInStreamWithCRC *inCrcStreamSpec = new CSequentialInStreamWithCRC;
- CMyComPtr<ISequentialInStream> inCrcStream = inCrcStreamSpec;
- inCrcStreamSpec->Init(fileStream);
-
- RINOK(WriteRange(inCrcStream, volumeStream, pureSize, updateCallback, complexity));
- file.UnPackSize = inCrcStreamSpec->GetSize();
- if (file.UnPackSize == 0)
- break;
- file.FileCRC = inCrcStreamSpec->GetCRC();
- RINOK(WriteVolumeHeader(archive, file, options));
- file.StartPos += file.UnPackSize;
- if (file.UnPackSize < pureSize)
- break;
- }
- return S_OK;
-}
-
-class COutVolumeStream:
- public ISequentialOutStream,
- public CMyUnknownImp
-{
- int _volIndex;
- UInt64 _volSize;
- UInt64 _curPos;
- CMyComPtr<ISequentialOutStream> _volumeStream;
- COutArchive _archive;
- CCRC _crc;
-
-public:
- MY_UNKNOWN_IMP
-
- CFileItem _file;
- CUpdateOptions _options;
- CMyComPtr<IArchiveUpdateCallback2> VolumeCallback;
- void Init(IArchiveUpdateCallback2 *volumeCallback,
- const UString &name)
- {
- _file.Name = name;
- _file.IsStartPosDefined = true;
- _file.StartPos = 0;
-
- VolumeCallback = volumeCallback;
- _volIndex = 0;
- _volSize = 0;
- }
-
- HRESULT Flush();
- STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
-};
-
-HRESULT COutVolumeStream::Flush()
-{
- if (_volumeStream)
- {
- _file.UnPackSize = _curPos;
- _file.FileCRC = _crc.GetDigest();
- RINOK(WriteVolumeHeader(_archive, _file, _options));
- _archive.Close();
- _volumeStream.Release();
- _file.StartPos += _file.UnPackSize;
- }
- return S_OK;
-}
-
-STDMETHODIMP COutVolumeStream::Write(const void *data, UInt32 size, UInt32 *processedSize)
-{
- if(processedSize != NULL)
- *processedSize = 0;
- while(size > 0)
- {
- if (!_volumeStream)
- {
- RINOK(VolumeCallback->GetVolumeSize(_volIndex, &_volSize));
- RINOK(VolumeCallback->GetVolumeStream(_volIndex, &_volumeStream));
- _volIndex++;
- _curPos = 0;
- RINOK(_archive.Create(_volumeStream, true));
- RINOK(_archive.SkeepPrefixArchiveHeader());
- _crc.Init();
- continue;
- }
- UInt64 pureSize = COutArchive::GetVolPureSize(_volSize, _file.Name.Length());
- UInt32 curSize = (UInt32)MyMin(UInt64(size), pureSize - _curPos);
-
- _crc.Update(data, curSize);
- UInt32 realProcessed;
- RINOK(_volumeStream->Write(data, curSize, &realProcessed))
- data = (void *)((Byte *)data + realProcessed);
- size -= realProcessed;
- if(processedSize != NULL)
- *processedSize += realProcessed;
- _curPos += realProcessed;
- if (realProcessed != curSize && realProcessed == 0)
- return E_FAIL;
- if (_curPos == pureSize)
- {
- RINOK(Flush());
- }
- }
+ newDatabase.ReserveDown();
return S_OK;
}
-#endif
-
HRESULT Update(
DECL_EXTERNAL_CODECS_LOC_VARS
IInStream *inStream,
- const CArchiveDatabaseEx *database,
+ const CArchiveDatabaseEx *db,
const CObjectVector<CUpdateItem> &updateItems,
+ COutArchive &archive,
+ CArchiveDatabase &newDatabase,
ISequentialOutStream *seqOutStream,
IArchiveUpdateCallback *updateCallback,
const CUpdateOptions &options)
{
- #ifdef _7Z_VOL
- if (seqOutStream)
- #endif
- return Update2(
+ return Update2(
EXTERNAL_CODECS_LOC_VARS
- inStream, database, updateItems,
- seqOutStream, updateCallback, options);
- #ifdef _7Z_VOL
- if (options.VolumeMode)
- return UpdateVolume(inStream, database, updateItems,
- seqOutStream, updateCallback, options);
- COutVolumeStream *volStreamSpec = new COutVolumeStream;
- CMyComPtr<ISequentialOutStream> volStream = volStreamSpec;
- CMyComPtr<IArchiveUpdateCallback2> volumeCallback;
- RINOK(updateCallback->QueryInterface(IID_IArchiveUpdateCallback2, (void **)&volumeCallback));
- if (!volumeCallback)
- return E_NOTIMPL;
- volStreamSpec->Init(volumeCallback, L"a.7z");
- volStreamSpec->_options = options;
- RINOK(Update2(inStream, database, updateItems,
- volStream, updateCallback, options));
- return volStreamSpec->Flush();
- #endif
+ inStream, db, updateItems,
+ archive, newDatabase, seqOutStream, updateCallback, options);
}
}}
diff --git a/CPP/7zip/Archive/7z/7zUpdate.h b/CPP/7zip/Archive/7z/7zUpdate.h
index ac1b5b65..bcc7cef7 100755
--- a/CPP/7zip/Archive/7z/7zUpdate.h
+++ b/CPP/7zip/Archive/7z/7zUpdate.h
@@ -14,38 +14,40 @@ namespace N7z {
struct CUpdateItem
{
- bool NewData;
- bool NewProperties;
int IndexInArchive;
int IndexInClient;
- UInt32 Attributes;
- FILETIME CreationTime;
- FILETIME LastWriteTime;
- FILETIME LastAccessTime;
+ UInt64 CTime;
+ UInt64 ATime;
+ UInt64 MTime;
UInt64 Size;
UString Name;
+
+ UInt32 Attrib;
+ bool NewData;
+ bool NewProperties;
+
bool IsAnti;
- bool IsDirectory;
-
- bool IsCreationTimeDefined;
- bool IsLastWriteTimeDefined;
- bool IsLastAccessTimeDefined;
- bool AttributesAreDefined;
-
- bool HasStream() const
- { return !IsDirectory && !IsAnti && Size != 0; }
- CUpdateItem():
- IsAnti(false),
- AttributesAreDefined(false),
- IsCreationTimeDefined(false),
- IsLastWriteTimeDefined(false),
- IsLastAccessTimeDefined(false)
+ bool IsDir;
+
+ bool AttribDefined;
+ bool CTimeDefined;
+ bool ATimeDefined;
+ bool MTimeDefined;
+
+ bool HasStream() const { return !IsDir && !IsAnti && Size != 0; }
+
+ CUpdateItem():
+ IsAnti(false),
+ IsDir(false),
+ AttribDefined(false),
+ CTimeDefined(false),
+ ATimeDefined(false),
+ MTimeDefined(false)
{}
- void SetDirectoryStatusFromAttributes()
- { IsDirectory = ((Attributes & FILE_ATTRIBUTE_DIRECTORY) != 0); };
+ void SetDirStatusFromAttrib() { IsDir = ((Attrib & FILE_ATTRIBUTE_DIRECTORY) != 0); };
int GetExtensionPos() const;
UString GetExtension() const;
@@ -70,8 +72,10 @@ struct CUpdateOptions
HRESULT Update(
DECL_EXTERNAL_CODECS_LOC_VARS
IInStream *inStream,
- const CArchiveDatabaseEx *database,
+ const CArchiveDatabaseEx *db,
const CObjectVector<CUpdateItem> &updateItems,
+ COutArchive &archive,
+ CArchiveDatabase &newDatabase,
ISequentialOutStream *seqOutStream,
IArchiveUpdateCallback *updateCallback,
const CUpdateOptions &options);
diff --git a/CPP/7zip/Archive/7z/makefile b/CPP/7zip/Archive/7z/makefile
new file mode 100755
index 00000000..1a72da0e
--- /dev/null
+++ b/CPP/7zip/Archive/7z/makefile
@@ -0,0 +1,111 @@
+PROG = 7z.dll
+DEF_FILE = ../Archive.def
+CFLAGS = $(CFLAGS) -I ../../../ \
+ -DCOMPRESS_MT \
+ -DEXTERNAL_CODECS \
+
+LIBS = $(LIBS) oleaut32.lib user32.lib
+
+AR_OBJS = \
+ $O\ArchiveExports.obj \
+ $O\DllExports.obj \
+
+7Z_OBJS = \
+ $O\7zCompressionMode.obj \
+ $O\7zDecode.obj \
+ $O\7zEncode.obj \
+ $O\7zExtract.obj \
+ $O\7zFolderInStream.obj \
+ $O\7zFolderOutStream.obj \
+ $O\7zHandler.obj \
+ $O\7zHandlerOut.obj \
+ $O\7zHeader.obj \
+ $O\7zIn.obj \
+ $O\7zOut.obj \
+ $O\7zProperties.obj \
+ $O\7zSpecStream.obj \
+ $O\7zUpdate.obj \
+ $O\7zRegister.obj \
+
+COMMON_OBJS = \
+ $O\CRC.obj \
+ $O\IntToString.obj \
+ $O\NewHandler.obj \
+ $O\MyString.obj \
+ $O\StringConvert.obj \
+ $O\StringToInt.obj \
+ $O\MyVector.obj \
+
+WIN_OBJS = \
+ $O\DLL.obj \
+ $O\FileDir.obj \
+ $O\FileFind.obj \
+ $O\FileIO.obj \
+ $O\PropVariant.obj \
+ $O\Synchronization.obj \
+ $O\System.obj \
+
+7ZIP_COMMON_OBJS = \
+ $O\CreateCoder.obj \
+ $O\InOutTempBuffer.obj \
+ $O\FilterCoder.obj \
+ $O\LimitedStreams.obj \
+ $O\LockedStream.obj \
+ $O\MethodId.obj \
+ $O\MethodProps.obj \
+ $O\OutBuffer.obj \
+ $O\ProgressUtils.obj \
+ $O\StreamBinder.obj \
+ $O\StreamObjects.obj \
+ $O\StreamUtils.obj \
+ $O\VirtThread.obj \
+
+AR_COMMON_OBJS = \
+ $O\CoderMixer2.obj \
+ $O\CoderMixer2MT.obj \
+ $O\CrossThreadProgress.obj \
+ $O\HandlerOut.obj \
+ $O\InStreamWithCRC.obj \
+ $O\ItemNameUtils.obj \
+ $O\MultiStream.obj \
+ $O\OutStreamWithCRC.obj \
+ $O\ParseProperties.obj \
+
+C_OBJS = \
+ $O\Alloc.obj \
+ $O\Threads.obj \
+
+!include "../../Crc2.mak"
+
+OBJS = \
+ $O\StdAfx.obj \
+ $(AR_OBJS) \
+ $(7Z_OBJS) \
+ $(COMMON_OBJS) \
+ $(WIN_OBJS) \
+ $(7ZIP_COMMON_OBJS) \
+ $(AR_COMMON_OBJS) \
+ $O\CopyCoder.obj \
+ $(C_OBJS) \
+ $(CRC_OBJS) \
+ $O\resource.res
+
+!include "../../../Build.mak"
+
+$(AR_OBJS): ../$(*B).cpp
+ $(COMPL)
+$(7Z_OBJS): $(*B).cpp
+ $(COMPL)
+$(COMMON_OBJS): ../../../Common/$(*B).cpp
+ $(COMPL)
+$(WIN_OBJS): ../../../Windows/$(*B).cpp
+ $(COMPL)
+$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp
+ $(COMPL)
+$(AR_COMMON_OBJS): ../Common/$(*B).cpp
+ $(COMPL)
+$O\CopyCoder.obj: ../../Compress/Copy/$(*B).cpp
+ $(COMPL)
+$(C_OBJS): ../../../../C/$(*B).c
+ $(COMPL_O2)
+!include "../../Crc.mak"
diff --git a/CPP/7zip/Archive/7z/resource.rc b/CPP/7zip/Archive/7z/resource.rc
new file mode 100755
index 00000000..f79dac08
--- /dev/null
+++ b/CPP/7zip/Archive/7z/resource.rc
@@ -0,0 +1,11 @@
+#include "../../MyVersionInfo.rc"
+
+MY_VERSION_INFO_DLL("7z Plugin", "7z")
+
+0 ICON "../Icons/7z.ico"
+
+STRINGTABLE
+BEGIN
+ 100 "7z:0"
+END
+
diff --git a/CPP/7zip/Archive/ArchiveExports.cpp b/CPP/7zip/Archive/ArchiveExports.cpp
index 3c51a3f5..ae388d67 100755
--- a/CPP/7zip/Archive/ArchiveExports.cpp
+++ b/CPP/7zip/Archive/ArchiveExports.cpp
@@ -13,14 +13,14 @@
static const unsigned int kNumArcsMax = 32;
static unsigned int g_NumArcs = 0;
-static const CArcInfo *g_Arcs[kNumArcsMax];
-void RegisterArc(const CArcInfo *arcInfo)
-{
+static const CArcInfo *g_Arcs[kNumArcsMax];
+void RegisterArc(const CArcInfo *arcInfo)
+{
if (g_NumArcs < kNumArcsMax)
- g_Arcs[g_NumArcs++] = arcInfo;
+ g_Arcs[g_NumArcs++] = arcInfo;
}
-DEFINE_GUID(CLSID_CArchiveHandler,
+DEFINE_GUID(CLSID_CArchiveHandler,
0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00);
#define CLS_ARC_ID_ITEM(cls) ((cls).Data4[5])
diff --git a/CPP/7zip/Archive/Arj/ArjHandler.cpp b/CPP/7zip/Archive/Arj/ArjHandler.cpp
deleted file mode 100755
index d154fd76..00000000
--- a/CPP/7zip/Archive/Arj/ArjHandler.cpp
+++ /dev/null
@@ -1,311 +0,0 @@
-// ArjHandler.cpp
-
-#include "StdAfx.h"
-
-#include "Common/Defs.h"
-#include "Common/StringConvert.h"
-#include "Common/ComTry.h"
-
-#include "Windows/Time.h"
-#include "Windows/PropVariant.h"
-
-#include "ArjHandler.h"
-
-#include "../../ICoder.h"
-
-#include "../../Common/StreamObjects.h"
-#include "../../Common/ProgressUtils.h"
-#include "../../Common/LimitedStreams.h"
-
-#include "../../Compress/Copy/CopyCoder.h"
-#include "../../Compress/Arj/ArjDecoder1.h"
-#include "../../Compress/Arj/ArjDecoder2.h"
-
-#include "../Common/ItemNameUtils.h"
-#include "../Common/OutStreamWithCRC.h"
-
-using namespace NWindows;
-using namespace NTime;
-
-namespace NArchive {
-namespace NArj{
-
-const wchar_t *kHostOS[] =
-{
- L"MSDOS",
- L"PRIMOS",
- L"Unix",
- L"AMIGA",
- L"Mac",
- L"OS/2",
- L"APPLE GS",
- L"Atari ST",
- L"Next",
- L"VAX VMS",
- L"WIN95"
-};
-
-
-const int kNumHostOSes = sizeof(kHostOS) / sizeof(kHostOS[0]);
-
-const wchar_t *kUnknownOS = L"Unknown";
-
-
-STATPROPSTG kProps[] =
-{
- { NULL, kpidPath, VT_BSTR},
- { NULL, kpidIsFolder, VT_BOOL},
- { NULL, kpidSize, VT_UI8},
- { NULL, kpidPackedSize, VT_UI8},
- { NULL, kpidLastWriteTime, VT_FILETIME},
- { NULL, kpidAttributes, VT_UI4},
- { NULL, kpidEncrypted, VT_BOOL},
- { NULL, kpidCRC, VT_UI4},
- { NULL, kpidMethod, VT_UI1},
- // { NULL, kpidUnpackVer, VT_UI1},
- { NULL, kpidHostOS, VT_BSTR}
-};
-
-IMP_IInArchive_Props
-IMP_IInArchive_ArcProps_NO
-
-STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
-{
- *numItems = _items.Size();
- return S_OK;
-}
-
-STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
-{
- COM_TRY_BEGIN
- NWindows::NCOM::CPropVariant prop;
- const CItemEx &item = _items[index];
- switch(propID)
- {
- case kpidPath: prop = NItemName::GetOSName(MultiByteToUnicodeString(item.Name, CP_OEMCP)); break;
- case kpidIsFolder: prop = item.IsDirectory(); break;
- case kpidSize: prop = item.Size; break;
- case kpidPackedSize: prop = item.PackSize; break;
- case kpidAttributes: prop = item.GetWinAttributes(); break;
- case kpidEncrypted: prop = item.IsEncrypted(); break;
- case kpidCRC: prop = item.FileCRC; break;
- case kpidMethod: prop = item.Method; break;
- case kpidHostOS: prop = (item.HostOS < kNumHostOSes) ? (kHostOS[item.HostOS]) : kUnknownOS; break;
- case kpidLastWriteTime:
- {
- FILETIME localFileTime, utcFileTime;
- if (DosTimeToFileTime(item.ModifiedTime, localFileTime))
- {
- if (!LocalFileTimeToFileTime(&localFileTime, &utcFileTime))
- utcFileTime.dwHighDateTime = utcFileTime.dwLowDateTime = 0;
- }
- else
- utcFileTime.dwHighDateTime = utcFileTime.dwLowDateTime = 0;
- prop = utcFileTime;
- break;
- }
- }
- prop.Detach(value);
- return S_OK;
- COM_TRY_END
-}
-
-STDMETHODIMP CHandler::Open(IInStream *inStream,
- const UInt64 *maxCheckStartPosition, IArchiveOpenCallback *callback)
-{
- COM_TRY_BEGIN
- try
- {
- _items.Clear();
- CInArchive archive;
- if(!archive.Open(inStream, maxCheckStartPosition))
- return S_FALSE;
- if (callback != NULL)
- {
- RINOK(callback->SetTotal(NULL, NULL));
- UInt64 numFiles = _items.Size();
- RINOK(callback->SetCompleted(&numFiles, NULL));
- }
- for (;;)
- {
- CItemEx item;
- bool filled;
- HRESULT result = archive.GetNextItem(filled, item);
- if (result == S_FALSE)
- return S_FALSE;
- if (result != S_OK)
- return S_FALSE;
- if (!filled)
- break;
- _items.Add(item);
- archive.IncreaseRealPosition(item.PackSize);
- if (callback != NULL)
- {
- UInt64 numFiles = _items.Size();
- RINOK(callback->SetCompleted(&numFiles, NULL));
- }
- }
- _stream = inStream;
- }
- catch(...)
- {
- return S_FALSE;
- }
- COM_TRY_END
- return S_OK;
-}
-
-STDMETHODIMP CHandler::Close()
-{
- _items.Clear();
- _stream.Release();
- return S_OK;
-}
-
-
-
-//////////////////////////////////////
-// CHandler::DecompressItems
-
-STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
- Int32 testModeSpec, IArchiveExtractCallback *extractCallback)
-{
- COM_TRY_BEGIN
- bool testMode = (testModeSpec != 0);
- UInt64 totalUnPacked = 0, totalPacked = 0;
- bool allFilesMode = (numItems == UInt32(-1));
- if (allFilesMode)
- numItems = _items.Size();
- if(numItems == 0)
- return S_OK;
- UInt32 i;
- for(i = 0; i < numItems; i++)
- {
- const CItemEx &item = _items[allFilesMode ? i : indices[i]];
- totalUnPacked += item.Size;
- totalPacked += item.PackSize;
- }
- extractCallback->SetTotal(totalUnPacked);
-
- UInt64 currentTotalUnPacked = 0, currentTotalPacked = 0;
- UInt64 currentItemUnPacked, currentItemPacked;
-
- CMyComPtr<ICompressCoder> arj1Decoder;
- CMyComPtr<ICompressCoder> arj2Decoder;
- NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder();
- CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;
-
- CLocalProgress *lps = new CLocalProgress;
- CMyComPtr<ICompressProgressInfo> progress = lps;
- lps->Init(extractCallback, false);
-
- CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
- CMyComPtr<ISequentialInStream> inStream(streamSpec);
- streamSpec->SetStream(_stream);
-
- for(i = 0; i < numItems; i++, currentTotalUnPacked += currentItemUnPacked,
- currentTotalPacked += currentItemPacked)
- {
- lps->InSize = currentTotalPacked;
- lps->OutSize = currentTotalUnPacked;
- RINOK(lps->SetCur());
-
- currentItemUnPacked = currentItemPacked = 0;
-
- CMyComPtr<ISequentialOutStream> realOutStream;
- Int32 askMode = testMode ?
- NExtract::NAskMode::kTest :
- NExtract::NAskMode::kExtract;
- Int32 index = allFilesMode ? i : indices[i];
- const CItemEx &item = _items[index];
- RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
-
- if(item.IsDirectory())
- {
- // if (!testMode)
- {
- RINOK(extractCallback->PrepareOperation(askMode));
- RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kOK));
- }
- continue;
- }
-
- if (!testMode && (!realOutStream))
- continue;
-
- RINOK(extractCallback->PrepareOperation(askMode));
- currentItemUnPacked = item.Size;
- currentItemPacked = item.PackSize;
-
- {
- COutStreamWithCRC *outStreamSpec = new COutStreamWithCRC;
- CMyComPtr<ISequentialOutStream> outStream(outStreamSpec);
- outStreamSpec->SetStream(realOutStream);
- outStreamSpec->Init();
- realOutStream.Release();
-
- streamSpec->Init(item.PackSize);
-
- UInt64 pos;
- _stream->Seek(item.DataPosition, STREAM_SEEK_SET, &pos);
-
- HRESULT result = S_OK;
- Int32 opRes = NExtract::NOperationResult::kOK;
-
- if (item.IsEncrypted())
- {
- opRes = NExtract::NOperationResult::kUnSupportedMethod;
- }
- else
- {
- switch(item.Method)
- {
- case NFileHeader::NCompressionMethod::kStored:
- {
- result = copyCoder->Code(inStream, outStream, NULL, NULL, progress);
- if (result == S_OK && copyCoderSpec->TotalSize != item.PackSize)
- result = S_FALSE;
- break;
- }
- case NFileHeader::NCompressionMethod::kCompressed1a:
- case NFileHeader::NCompressionMethod::kCompressed1b:
- case NFileHeader::NCompressionMethod::kCompressed1c:
- {
- if (!arj1Decoder)
- arj1Decoder = new NCompress::NArj::NDecoder1::CCoder;
- result = arj1Decoder->Code(inStream, outStream, NULL, &currentItemUnPacked, progress);
- break;
- }
- case NFileHeader::NCompressionMethod::kCompressed2:
- {
- if (!arj2Decoder)
- arj2Decoder = new NCompress::NArj::NDecoder2::CCoder;
- result = arj2Decoder->Code(inStream, outStream, NULL, &currentItemUnPacked, progress);
- break;
- }
- default:
- opRes = NExtract::NOperationResult::kUnSupportedMethod;
- }
- }
- if (opRes == NExtract::NOperationResult::kOK)
- {
- if (result == S_FALSE)
- opRes = NExtract::NOperationResult::kDataError;
- else
- {
- RINOK(result);
- opRes = (outStreamSpec->GetCRC() == item.FileCRC) ?
- NExtract::NOperationResult::kOK:
- NExtract::NOperationResult::kCRCError;
- }
- }
- outStream.Release();
- RINOK(extractCallback->SetOperationResult(opRes));
- }
- }
- return S_OK;
- COM_TRY_END
-}
-
-
-}}
diff --git a/CPP/7zip/Archive/Arj/ArjHeader.h b/CPP/7zip/Archive/Arj/ArjHeader.h
deleted file mode 100755
index 7aca1b98..00000000
--- a/CPP/7zip/Archive/Arj/ArjHeader.h
+++ /dev/null
@@ -1,121 +0,0 @@
-// Archive/Arj/Header.h
-
-#ifndef __ARCHIVE_ARJ_HEADER_H
-#define __ARCHIVE_ARJ_HEADER_H
-
-#include "Common/Types.h"
-
-namespace NArchive {
-namespace NArj {
-
-const int kMaxBlockSize = 2600;
-
-namespace NSignature
-{
- const Byte kSig0 = 0x60;
- const Byte kSig1 = 0xEA;
-}
-
-/*
-struct CArchiveHeader
-{
- // UInt16 BasicHeaderSize;
- Byte FirstHeaderSize;
- Byte Version;
- Byte ExtractVersion;
- Byte HostOS;
- Byte Flags;
- Byte SecuryVersion;
- Byte FileType;
- Byte Reserved;
- UInt32 CreatedTime;
- UInt32 ModifiedTime;
- UInt32 ArchiveSize;
- UInt32 SecurityEnvelopeFilePosition;
- UInt16 FilespecPositionInFilename;
- UInt16 LengthOfSecurityEnvelopeSata;
- Byte EncryptionVersion;
- Byte LastChapter;
-};
-*/
-
-namespace NFileHeader
-{
- namespace NCompressionMethod
- {
- enum EType
- {
- kStored = 0,
- kCompressed1a = 1,
- kCompressed1b = 2,
- kCompressed1c = 3,
- kCompressed2 = 4,
- kNoDataNoCRC = 8,
- kNoData = 9
- };
- }
- namespace NFileType
- {
- enum EType
- {
- kBinary = 0,
- k7BitText = 1,
- kDirectory = 3,
- kVolumeLablel = 4,
- kChapterLabel = 5
- };
- }
- namespace NFlags
- {
- const Byte kGarbled = 1;
- const Byte kVolume = 4;
- const Byte kExtFile = 8;
- const Byte kPathSym = 0x10;
- const Byte kBackup= 0x20;
- }
-
- /*
- struct CHeader
- {
- Byte FirstHeaderSize;
- Byte Version;
- Byte ExtractVersion;
- Byte HostOS;
- Byte Flags;
- Byte Method;
- Byte FileType;
- Byte Reserved;
- UInt32 ModifiedTime;
- UInt32 PackSize;
- UInt32 Size;
- UInt32 FileCRC;
- UInt16 FilespecPositionInFilename;
- UInt16 FileAccessMode;
- Byte FirstChapter;
- Byte LastChapter;
- };
- */
-
- namespace NHostOS
- {
- enum EEnum
- {
- kMSDOS = 0, // filesystem used by MS-DOS, OS/2, Win32
- // pkarj 2.50 (FAT / VFAT / FAT32 file systems)
- kPRIMOS = 1,
- kUnix = 2, // VAX/VMS
- kAMIGA = 3,
- kMac = 4,
- kOS_2 = 5, // what if it's a minix filesystem? [cjh]
- kAPPLE_GS = 6, // filesystem used by OS/2 (and NT 3.x)
- kAtari_ST = 7,
- kNext = 8,
- kVAX_VMS = 9,
- kWIN95 = 10
- };
- }
-}
-
-}}
-
-#endif
diff --git a/CPP/7zip/Archive/Arj/ArjIn.cpp b/CPP/7zip/Archive/Arj/ArjIn.cpp
deleted file mode 100755
index cc7cde49..00000000
--- a/CPP/7zip/Archive/Arj/ArjIn.cpp
+++ /dev/null
@@ -1,287 +0,0 @@
-// Archive/arj/InEngine.cpp
-
-#include "StdAfx.h"
-
-#include "Common/StringConvert.h"
-#include "Common/Buffer.h"
-
-#include "../../Common/StreamUtils.h"
-
-#include "ArjIn.h"
-
-extern "C"
-{
- #include "../../../../C/7zCrc.h"
-}
-
-namespace NArchive {
-namespace NArj {
-
-HRESULT CInArchive::ReadBytes(void *data, UInt32 size, UInt32 *processedSize)
-{
- size_t realProcessedSize = size;
- HRESULT result = ReadStream(_stream, data, &realProcessedSize);
- if (processedSize != NULL)
- *processedSize = (UInt32)realProcessedSize;
- IncreasePositionValue(realProcessedSize);
- return result;
-}
-
-static inline UInt16 GetUInt16FromMemLE(const Byte *p)
-{
- return (UInt16)(p[0] | (((UInt16)p[1]) << 8));
-}
-
-static inline UInt32 GetUInt32FromMemLE(const Byte *p)
-{
- return p[0] | (((UInt32)p[1]) << 8) | (((UInt32)p[2]) << 16) | (((UInt32)p[3]) << 24);
-}
-
-inline bool TestMarkerCandidate(const void *testBytes, UInt32 maxSize)
-{
- if (maxSize < 2 + 2 + 4)
- return false;
- const Byte *block = ((const Byte *)(testBytes));
- if (block[0] != NSignature::kSig0 || block[1] != NSignature::kSig1)
- return false;
- UInt32 blockSize = GetUInt16FromMemLE(block + 2);
- if (maxSize < 2 + 2 + blockSize + 4)
- return false;
- block += 4;
- if (blockSize == 0 || blockSize > 2600)
- return false;
- UInt32 crcFromFile = GetUInt32FromMemLE(block + blockSize);
- return (crcFromFile == CrcCalc(block, blockSize));
-}
-
-bool CInArchive::FindAndReadMarker(const UInt64 *searchHeaderSizeLimit)
-{
- // _archiveInfo.StartPosition = 0;
- _position = _streamStartPosition;
- if(_stream->Seek(_streamStartPosition, STREAM_SEEK_SET, NULL) != S_OK)
- return false;
-
- const int kMarkerSizeMax = 2 + 2 + kMaxBlockSize + 4;
-
- CByteBuffer byteBuffer;
- static const UInt32 kSearchMarkerBufferSize = 0x10000;
- byteBuffer.SetCapacity(kSearchMarkerBufferSize);
- Byte *buffer = byteBuffer;
-
- UInt32 processedSize;
- ReadBytes(buffer, kMarkerSizeMax, &processedSize);
- if (processedSize == 0)
- return false;
- if (TestMarkerCandidate(buffer, processedSize))
- {
- _position = _streamStartPosition;
- if(_stream->Seek(_position, STREAM_SEEK_SET, NULL) != S_OK)
- return false;
- return true;
- }
-
- UInt32 numBytesPrev = processedSize - 1;
- memmove(buffer, buffer + 1, numBytesPrev);
- UInt64 curTestPos = _streamStartPosition + 1;
- for (;;)
- {
- if (searchHeaderSizeLimit != NULL)
- if (curTestPos - _streamStartPosition > *searchHeaderSizeLimit)
- return false;
- UInt32 numReadBytes = kSearchMarkerBufferSize - numBytesPrev;
- ReadBytes(buffer + numBytesPrev, numReadBytes, &processedSize);
- UInt32 numBytesInBuffer = numBytesPrev + processedSize;
- if (numBytesInBuffer < 1)
- return false;
- UInt32 numTests = numBytesInBuffer;
- for(UInt32 pos = 0; pos < numTests; pos++, curTestPos++)
- {
- if (TestMarkerCandidate(buffer + pos, numBytesInBuffer - pos))
- {
- // _archiveInfo.StartPosition = curTestPos;
- _position = curTestPos;
- if(_stream->Seek(_position, STREAM_SEEK_SET, NULL) != S_OK)
- return false;
- return true;
- }
- }
- numBytesPrev = numBytesInBuffer - numTests;
- memmove(buffer, buffer + numTests, numBytesPrev);
- }
-}
-
-void CInArchive::IncreasePositionValue(UInt64 addValue)
-{
- _position += addValue;
-}
-
-void CInArchive::IncreaseRealPosition(UInt64 addValue)
-{
- if(_stream->Seek(addValue, STREAM_SEEK_CUR, &_position) != S_OK)
- throw CInArchiveException(CInArchiveException::kSeekStreamError);
-}
-
-bool CInArchive::ReadBytesAndTestSize(void *data, UInt32 size)
-{
- UInt32 realProcessedSize;
- if(ReadBytes(data, size, &realProcessedSize) != S_OK)
- throw CInArchiveException(CInArchiveException::kReadStreamError);
- return (realProcessedSize == size);
-}
-
-void CInArchive::SafeReadBytes(void *data, UInt32 size)
-{
- if(!ReadBytesAndTestSize(data, size))
- throw CInArchiveException(CInArchiveException::kUnexpectedEndOfArchive);
-}
-
-Byte CInArchive::SafeReadByte()
-{
- Byte b;
- SafeReadBytes(&b, 1);
- return b;
-}
-
-UInt16 CInArchive::SafeReadUInt16()
-{
- UInt16 value = 0;
- for (int i = 0; i < 2; i++)
- {
- Byte b = SafeReadByte();
- value |= (UInt16(b) << (8 * i));
- }
- return value;
-}
-
-UInt32 CInArchive::SafeReadUInt32()
-{
- UInt32 value = 0;
- for (int i = 0; i < 4; i++)
- {
- Byte b = SafeReadByte();
- value |= (UInt32(b) << (8 * i));
- }
- return value;
-}
-
-bool CInArchive::ReadBlock()
-{
- _blockPos = 0;
- _blockSize = SafeReadUInt16();
- if (_blockSize == 0 || _blockSize > kMaxBlockSize)
- return false;
- SafeReadBytes(_block, _blockSize);
- UInt32 crcFromFile = SafeReadUInt32();
- if (crcFromFile != CrcCalc(_block, _blockSize))
- throw CInArchiveException(CInArchiveException::kCRCError);
- return true;
-}
-
-bool CInArchive::ReadBlock2()
-{
- Byte id[2];
- ReadBytesAndTestSize(id, 2);
- if (id[0] != NSignature::kSig0 || id[1] != NSignature::kSig1)
- throw CInArchiveException(CInArchiveException::kIncorrectArchive);
- return ReadBlock();
-}
-
-bool CInArchive::Open(IInStream *inStream, const UInt64 *searchHeaderSizeLimit)
-{
- _stream = inStream;
- if(_stream->Seek(0, STREAM_SEEK_CUR, &_streamStartPosition) != S_OK)
- return false;
- _position = _streamStartPosition;
- if (!FindAndReadMarker(searchHeaderSizeLimit))
- return false;
- if (!ReadBlock2())
- return false;
- for (;;)
- if (!ReadBlock())
- break;
- return true;
-}
-
-void CInArchive::Close()
-{
- _stream.Release();
-}
-
-void CInArchive::ThrowIncorrectArchiveException()
-{
- throw CInArchiveException(CInArchiveException::kIncorrectArchive);
-}
-
-Byte CInArchive::ReadByte()
-{
- if (_blockPos >= _blockSize)
- ThrowIncorrectArchiveException();
- return _block[_blockPos++];
-}
-
-UInt16 CInArchive::ReadUInt16()
-{
- UInt16 value = 0;
- for (int i = 0; i < 2; i++)
- {
- Byte b = ReadByte();
- value |= (UInt16(b) << (8 * i));
- }
- return value;
-}
-
-UInt32 CInArchive::ReadUInt32()
-{
- UInt32 value = 0;
- for (int i = 0; i < 4; i++)
- {
- Byte b = ReadByte();
- value |= (UInt32(b) << (8 * i));
- }
- return value;
-}
-
-HRESULT CInArchive::GetNextItem(bool &filled, CItemEx &item)
-{
- filled = false;
- if (!ReadBlock2())
- return S_OK;
-
- Byte firstHeaderSize = ReadByte();
- item.Version = ReadByte();
- item.ExtractVersion = ReadByte();
- item.HostOS = ReadByte();
- item.Flags = ReadByte();
- item.Method = ReadByte();
- item.FileType = ReadByte();
- ReadByte(); // Reserved
- item.ModifiedTime = ReadUInt32();
- item.PackSize = ReadUInt32();
- item.Size = ReadUInt32();
- item.FileCRC = ReadUInt32();
- ReadUInt16(); // FilespecPositionInFilename
- item.FileAccessMode = ReadUInt16();
- ReadByte(); // FirstChapter
- ReadByte(); // LastChapter
-
- /*
- UInt32 extraData;
- if ((header.Flags & NFileHeader::NFlags::kExtFile) != 0)
- extraData = GetUInt32FromMemLE(_block + pos);
- */
- _blockPos = firstHeaderSize;
-
- for (; _blockPos < _blockSize;)
- item.Name += (char)ReadByte();
-
- for (;;)
- if (!ReadBlock())
- break;
-
- item.DataPosition = _position;
-
- filled = true;
- return S_OK;
-}
-
-}}
diff --git a/CPP/7zip/Archive/Arj/ArjIn.h b/CPP/7zip/Archive/Arj/ArjIn.h
deleted file mode 100755
index b73d7dba..00000000
--- a/CPP/7zip/Archive/Arj/ArjIn.h
+++ /dev/null
@@ -1,75 +0,0 @@
-// Archive/ArjIn.h
-
-#ifndef __ARCHIVE_ARJIN_H
-#define __ARCHIVE_ARJIN_H
-
-#include "Common/MyCom.h"
-#include "../../IStream.h"
-
-#include "ArjItem.h"
-
-namespace NArchive {
-namespace NArj {
-
-class CInArchiveException
-{
-public:
- enum CCauseType
- {
- kUnexpectedEndOfArchive = 0,
- kCRCError,
- kIncorrectArchive,
- kReadStreamError,
- kSeekStreamError
- }
- Cause;
- CInArchiveException(CCauseType cause): Cause(cause) {};
-};
-
-class CProgressVirt
-{
-public:
- STDMETHOD(SetCompleted)(const UInt64 *numFiles) PURE;
-};
-
-class CInArchive
-{
- CMyComPtr<IInStream> _stream;
- UInt64 _streamStartPosition;
- UInt64 _position;
- UInt16 _blockSize;
- Byte _block[kMaxBlockSize];
- UInt32 _blockPos;
-
-
- bool FindAndReadMarker(const UInt64 *searchHeaderSizeLimit);
-
- bool ReadBlock();
- bool ReadBlock2();
-
- Byte ReadByte();
- UInt16 ReadUInt16();
- UInt32 ReadUInt32();
-
- HRESULT ReadBytes(void *data, UInt32 size, UInt32 *processedSize);
- bool ReadBytesAndTestSize(void *data, UInt32 size);
- void SafeReadBytes(void *data, UInt32 size);
- Byte SafeReadByte();
- UInt16 SafeReadUInt16();
- UInt32 SafeReadUInt32();
-
- void IncreasePositionValue(UInt64 addValue);
- void ThrowIncorrectArchiveException();
-
-public:
- HRESULT GetNextItem(bool &filled, CItemEx &item);
-
- bool Open(IInStream *inStream, const UInt64 *searchHeaderSizeLimit);
- void Close();
-
- void IncreaseRealPosition(UInt64 addValue);
-};
-
-}}
-
-#endif
diff --git a/CPP/7zip/Archive/Arj/ArjItem.h b/CPP/7zip/Archive/Arj/ArjItem.h
deleted file mode 100755
index a0112107..00000000
--- a/CPP/7zip/Archive/Arj/ArjItem.h
+++ /dev/null
@@ -1,75 +0,0 @@
-// Archive/ArjItem.h
-
-#ifndef __ARCHIVE_ARJ_ITEM_H
-#define __ARCHIVE_ARJ_ITEM_H
-
-#include "Common/Types.h"
-#include "Common/MyString.h"
-#include "ArjHeader.h"
-
-namespace NArchive {
-namespace NArj {
-
-struct CVersion
-{
- Byte Version;
- Byte HostOS;
-};
-
-inline bool operator==(const CVersion &v1, const CVersion &v2)
- { return (v1.Version == v2.Version) && (v1.HostOS == v2.HostOS); }
-inline bool operator!=(const CVersion &v1, const CVersion &v2)
- { return !(v1 == v2); }
-
-class CItem
-{
-public:
- Byte Version;
- Byte ExtractVersion;
- Byte HostOS;
- Byte Flags;
- Byte Method;
- Byte FileType;
- UInt32 ModifiedTime;
- UInt32 PackSize;
- UInt32 Size;
- UInt32 FileCRC;
-
- // UInt16 FilespecPositionInFilename;
- UInt16 FileAccessMode;
- // Byte FirstChapter;
- // Byte LastChapter;
-
- AString Name;
-
- bool IsEncrypted() const { return (Flags & NFileHeader::NFlags::kGarbled) != 0; }
- bool IsDirectory() const { return (FileType == NFileHeader::NFileType::kDirectory); }
- UInt32 GetWinAttributes() const
- {
- UInt32 winAtrributes;
- switch(HostOS)
- {
- case NFileHeader::NHostOS::kMSDOS:
- case NFileHeader::NHostOS::kWIN95:
- winAtrributes = FileAccessMode;
- break;
- default:
- winAtrributes = 0;
- }
- if (IsDirectory())
- winAtrributes |= FILE_ATTRIBUTE_DIRECTORY;
- return winAtrributes;
- }
-};
-
-class CItemEx: public CItem
-{
-public:
- UInt64 DataPosition;
-};
-
-}}
-
-#endif
-
-
diff --git a/CPP/7zip/Archive/Arj/ArjRegister.cpp b/CPP/7zip/Archive/Arj/ArjRegister.cpp
deleted file mode 100755
index 8fb6c9ee..00000000
--- a/CPP/7zip/Archive/Arj/ArjRegister.cpp
+++ /dev/null
@@ -1,13 +0,0 @@
-// ArjRegister.cpp
-
-#include "StdAfx.h"
-
-#include "../../Common/RegisterArc.h"
-
-#include "ArjHandler.h"
-static IInArchive *CreateArc() { return new NArchive::NArj::CHandler; }
-
-static CArcInfo g_ArcInfo =
- { L"Arj", L"arj", 0, 4, { 0x60, 0xEA }, 2, false, CreateArc, 0 };
-
-REGISTER_ARC(Arj)
diff --git a/CPP/7zip/Archive/Arj/StdAfx.cpp b/CPP/7zip/Archive/Arj/StdAfx.cpp
deleted file mode 100755
index d0feea85..00000000
--- a/CPP/7zip/Archive/Arj/StdAfx.cpp
+++ /dev/null
@@ -1,3 +0,0 @@
-// StdAfx.cpp
-
-#include "StdAfx.h"
diff --git a/CPP/7zip/Archive/ArjHandler.cpp b/CPP/7zip/Archive/ArjHandler.cpp
new file mode 100755
index 00000000..9b12ed31
--- /dev/null
+++ b/CPP/7zip/Archive/ArjHandler.cpp
@@ -0,0 +1,792 @@
+// ArjHandler.cpp
+
+#include "StdAfx.h"
+
+#include "Common/ComTry.h"
+#include "Common/StringConvert.h"
+
+#include "Windows/PropVariant.h"
+#include "Windows/Time.h"
+
+#include "../../../C/CpuArch.h"
+
+#include "../Common/LimitedStreams.h"
+#include "../Common/ProgressUtils.h"
+#include "../Common/RegisterArc.h"
+#include "../Common/StreamObjects.h"
+#include "../Common/StreamUtils.h"
+
+#include "../Compress/Arj/ArjDecoder1.h"
+#include "../Compress/Arj/ArjDecoder2.h"
+#include "../Compress/Copy/CopyCoder.h"
+
+#include "IArchive.h"
+
+#include "Common/ItemNameUtils.h"
+#include "Common/OutStreamWithCRC.h"
+
+using namespace NWindows;
+
+#define Get16(p) GetUi16(p)
+#define Get32(p) GetUi32(p)
+
+namespace NArchive {
+namespace NArj {
+
+const int kBlockSizeMin = 30;
+const int kBlockSizeMax = 2600;
+
+namespace NSignature
+{
+ const Byte kSig0 = 0x60;
+ const Byte kSig1 = 0xEA;
+}
+
+namespace NFileHeader
+{
+ namespace NCompressionMethod
+ {
+ enum
+ {
+ kStored = 0,
+ kCompressed1a = 1,
+ kCompressed1b = 2,
+ kCompressed1c = 3,
+ kCompressed2 = 4,
+ kNoDataNoCRC = 8,
+ kNoData = 9
+ };
+ }
+
+ namespace NFileType
+ {
+ enum
+ {
+ kBinary = 0,
+ k7BitText = 1,
+ kArchiveHeader = 2,
+ kDirectory = 3,
+ kVolumeLablel = 4,
+ kChapterLabel = 5
+ };
+ }
+
+ namespace NFlags
+ {
+ const Byte kGarbled = 1;
+ const Byte kVolume = 4;
+ const Byte kExtFile = 8;
+ const Byte kPathSym = 0x10;
+ const Byte kBackup = 0x20;
+ }
+
+ namespace NHostOS
+ {
+ enum EEnum
+ {
+ kMSDOS = 0, // filesystem used by MS-DOS, OS/2, Win32
+ // pkarj 2.50 (FAT / VFAT / FAT32 file systems)
+ kPRIMOS,
+ kUnix,
+ kAMIGA,
+ kMac,
+ kOS_2,
+ kAPPLE_GS,
+ kAtari_ST,
+ kNext,
+ kVAX_VMS,
+ kWIN95
+ };
+ }
+}
+
+struct CArchiveHeader
+{
+ // Byte ArchiverVersion;
+ // Byte ExtractVersion;
+ Byte HostOS;
+ // Byte Flags;
+ // Byte SecuryVersion;
+ // Byte FileType;
+ // Byte Reserved;
+ UInt32 CTime;
+ UInt32 MTime;
+ UInt32 ArchiveSize;
+ // UInt32 SecurityEnvelopeFilePosition;
+ // UInt16 FilespecPositionInFilename;
+ // UInt16 LengthOfSecurityEnvelopeSata;
+ // Byte EncryptionVersion;
+ // Byte LastChapter;
+ AString Name;
+ AString Comment;
+
+ HRESULT Parse(const Byte *p, unsigned size);
+};
+
+static HRESULT ReadString(const Byte *p, unsigned &size, AString &res)
+{
+ AString s;
+ for (unsigned i = 0; i < size;)
+ {
+ char c = (char)p[i++];
+ if (c == 0)
+ {
+ size = i;
+ res = s;
+ return S_OK;
+ }
+ s += c;
+ }
+ return S_FALSE;
+}
+
+HRESULT CArchiveHeader::Parse(const Byte *p, unsigned size)
+{
+ if (size < kBlockSizeMin)
+ return S_FALSE;
+ Byte firstHeaderSize = p[0];
+ if (firstHeaderSize > size)
+ return S_FALSE;
+ // ArchiverVersion = p[1];
+ // ExtractVersion = p[2];
+ HostOS = p[3];
+ // Flags = p[4];
+ // SecuryVersion = p[5];
+ if (p[6] != NFileHeader::NFileType::kArchiveHeader)
+ return S_FALSE;
+ // Reserved = p[7];
+ CTime = Get32(p + 8);
+ MTime = Get32(p + 12);
+ ArchiveSize = Get32(p + 16);
+ // SecurityEnvelopeFilePosition = Get32(p + 20);
+ // UInt16 filespecPositionInFilename = Get16(p + 24);
+ // LengthOfSecurityEnvelopeSata = Get16(p + 26);
+ // EncryptionVersion = p[28];
+ // LastChapter = p[29];
+ unsigned pos = firstHeaderSize;
+ unsigned size1 = size - pos;
+ RINOK(ReadString(p + pos, size1, Name));
+ pos += size1;
+ size1 = size - pos;
+ RINOK(ReadString(p + pos, size1, Comment));
+ pos += size1;
+ return S_OK;
+}
+
+struct CItem
+{
+ AString Name;
+ AString Comment;
+
+ UInt32 MTime;
+ UInt32 PackSize;
+ UInt32 Size;
+ UInt32 FileCRC;
+
+ Byte Version;
+ Byte ExtractVersion;
+ Byte HostOS;
+ Byte Flags;
+ Byte Method;
+ Byte FileType;
+
+ // UInt16 FilespecPositionInFilename;
+ UInt16 FileAccessMode;
+ // Byte FirstChapter;
+ // Byte LastChapter;
+
+ UInt64 DataPosition;
+
+ bool IsEncrypted() const { return (Flags & NFileHeader::NFlags::kGarbled) != 0; }
+ bool IsDir() const { return (FileType == NFileHeader::NFileType::kDirectory); }
+ UInt32 GetWinAttributes() const
+ {
+ UInt32 winAtrributes;
+ switch(HostOS)
+ {
+ case NFileHeader::NHostOS::kMSDOS:
+ case NFileHeader::NHostOS::kWIN95:
+ winAtrributes = FileAccessMode;
+ break;
+ default:
+ winAtrributes = 0;
+ }
+ if (IsDir())
+ winAtrributes |= FILE_ATTRIBUTE_DIRECTORY;
+ return winAtrributes;
+ }
+
+ HRESULT Parse(const Byte *p, unsigned size);
+};
+
+HRESULT CItem::Parse(const Byte *p, unsigned size)
+{
+ if (size < kBlockSizeMin)
+ return S_FALSE;
+
+ Byte firstHeaderSize = p[0];
+
+ Version = p[1];
+ ExtractVersion = p[2];
+ HostOS = p[3];
+ Flags = p[4];
+ Method = p[5];
+ FileType = p[6];
+ // Reserved = p[7];
+ MTime = Get32(p + 8);
+ PackSize = Get32(p + 12);
+ Size = Get32(p + 16);
+ FileCRC = Get32(p + 20);
+ // FilespecPositionInFilename = Get16(p + 24);
+ FileAccessMode = Get16(p + 26);
+ // FirstChapter = p[28];
+ // FirstChapter = p[29];
+
+ unsigned pos = firstHeaderSize;
+ unsigned size1 = size - pos;
+ RINOK(ReadString(p + pos, size1, Name));
+ pos += size1;
+ size1 = size - pos;
+ RINOK(ReadString(p + pos, size1, Comment));
+ pos += size1;
+
+ return S_OK;
+}
+
+struct CInArchiveException
+{
+ enum CCauseType
+ {
+ kUnexpectedEndOfArchive = 0,
+ kCRCError,
+ kIncorrectArchive,
+ }
+ Cause;
+ CInArchiveException(CCauseType cause): Cause(cause) {};
+};
+
+class CInArchive
+{
+ UInt32 _blockSize;
+ Byte _block[kBlockSizeMax + 4];
+
+ HRESULT ReadBlock(bool &filled);
+ HRESULT ReadSignatureAndBlock(bool &filled);
+ HRESULT SkeepExtendedHeaders();
+
+ HRESULT SafeReadBytes(void *data, UInt32 size);
+
+public:
+ CArchiveHeader Header;
+
+ IInStream *Stream;
+ IArchiveOpenCallback *Callback;
+ UInt64 NumFiles;
+ UInt64 NumBytes;
+
+ HRESULT Open(const UInt64 *searchHeaderSizeLimit);
+ HRESULT GetNextItem(bool &filled, CItem &item);
+};
+
+static inline bool TestMarkerCandidate(const Byte *p, unsigned maxSize)
+{
+ if (p[0] != NSignature::kSig0 || p[1] != NSignature::kSig1)
+ return false;
+ UInt32 blockSize = Get16(p + 2);
+ p += 4;
+ if (p[6] != NFileHeader::NFileType::kArchiveHeader ||
+ p[0] > blockSize ||
+ maxSize < 2 + 2 + blockSize + 4 ||
+ blockSize < kBlockSizeMin || blockSize > kBlockSizeMax ||
+ p[28] > 8) // EncryptionVersion
+ return false;
+ // return (Get32(p + blockSize) == CrcCalc(p, blockSize));
+ return true;
+}
+
+static HRESULT FindAndReadMarker(ISequentialInStream *stream, const UInt64 *searchHeaderSizeLimit, UInt64 &position)
+{
+ position = 0;
+
+ const int kMarkerSizeMin = 2 + 2 + kBlockSizeMin + 4;
+ const int kMarkerSizeMax = 2 + 2 + kBlockSizeMax + 4;
+
+ CByteBuffer byteBuffer;
+ const UInt32 kBufSize = 1 << 16;
+ byteBuffer.SetCapacity(kBufSize);
+ Byte *buf = byteBuffer;
+
+ size_t processedSize = kMarkerSizeMax;
+ RINOK(ReadStream(stream, buf, &processedSize));
+ if (processedSize < kMarkerSizeMin)
+ return S_FALSE;
+ if (TestMarkerCandidate(buf, (unsigned)processedSize))
+ return S_OK;
+
+ UInt32 numBytesPrev = (UInt32)processedSize - 1;
+ memmove(buf, buf + 1, numBytesPrev);
+ UInt64 curTestPos = 1;
+ for (;;)
+ {
+ if (searchHeaderSizeLimit != NULL)
+ if (curTestPos > *searchHeaderSizeLimit)
+ return S_FALSE;
+ processedSize = kBufSize - numBytesPrev;
+ RINOK(ReadStream(stream, buf + numBytesPrev, &processedSize));
+ UInt32 numBytesInBuffer = numBytesPrev + (UInt32)processedSize;
+ if (numBytesInBuffer < kMarkerSizeMin)
+ return S_FALSE;
+ UInt32 numTests = numBytesInBuffer - kMarkerSizeMin + 1;
+ UInt32 pos;
+ for (pos = 0; pos < numTests; pos++)
+ {
+ for (; buf[pos] != NSignature::kSig0 && pos < numTests; pos++);
+ if (pos == numTests)
+ break;
+ if (TestMarkerCandidate(buf + pos, numBytesInBuffer - pos))
+ {
+ position = curTestPos + pos;
+ return S_OK;
+ }
+ }
+ curTestPos += pos;
+ numBytesPrev = numBytesInBuffer - numTests;
+ memmove(buf, buf + numTests, numBytesPrev);
+ }
+}
+
+HRESULT CInArchive::SafeReadBytes(void *data, UInt32 size)
+{
+ size_t processed = size;
+ RINOK(ReadStream(Stream, data, &processed));
+ if (processed != size)
+ throw CInArchiveException(CInArchiveException::kUnexpectedEndOfArchive);
+ return S_OK;
+}
+
+HRESULT CInArchive::ReadBlock(bool &filled)
+{
+ filled = false;
+ Byte buf[2];
+ RINOK(SafeReadBytes(buf, 2));
+ _blockSize = Get16(buf);
+ if (_blockSize == 0)
+ return S_OK;
+ if (_blockSize > kBlockSizeMax)
+ throw CInArchiveException(CInArchiveException::kIncorrectArchive);
+ RINOK(SafeReadBytes(_block, _blockSize + 4));
+ NumBytes += _blockSize + 6;
+ if (Get32(_block + _blockSize) != CrcCalc(_block, _blockSize))
+ throw CInArchiveException(CInArchiveException::kCRCError);
+ filled = true;
+ return S_OK;
+}
+
+HRESULT CInArchive::ReadSignatureAndBlock(bool &filled)
+{
+ Byte id[2];
+ RINOK(SafeReadBytes(id, 2));
+ if (id[0] != NSignature::kSig0 || id[1] != NSignature::kSig1)
+ throw CInArchiveException(CInArchiveException::kIncorrectArchive);
+ return ReadBlock(filled);
+}
+
+HRESULT CInArchive::SkeepExtendedHeaders()
+{
+ for (UInt32 i = 0;; i++)
+ {
+ bool filled;
+ RINOK(ReadBlock(filled));
+ if (!filled)
+ return S_OK;
+ if (Callback && (i & 0xFF) == 0)
+ RINOK(Callback->SetCompleted(&NumFiles, &NumBytes));
+ }
+}
+
+HRESULT CInArchive::Open(const UInt64 *searchHeaderSizeLimit)
+{
+ UInt64 position = 0;
+ RINOK(FindAndReadMarker(Stream, searchHeaderSizeLimit, position));
+ RINOK(Stream->Seek(position, STREAM_SEEK_SET, NULL));
+ bool filled;
+ RINOK(ReadSignatureAndBlock(filled));
+ if (!filled)
+ return S_FALSE;
+ RINOK(Header.Parse(_block, _blockSize));
+ return SkeepExtendedHeaders();
+}
+
+HRESULT CInArchive::GetNextItem(bool &filled, CItem &item)
+{
+ RINOK(ReadSignatureAndBlock(filled));
+ if (!filled)
+ return S_OK;
+ filled = false;
+ RINOK(item.Parse(_block, _blockSize));
+ /*
+ UInt32 extraData;
+ if ((header.Flags & NFileHeader::NFlags::kExtFile) != 0)
+ extraData = GetUInt32FromMemLE(_block + pos);
+ */
+
+ RINOK(SkeepExtendedHeaders());
+ filled = true;
+ return S_OK;
+}
+
+class CHandler:
+ public IInArchive,
+ public CMyUnknownImp
+{
+public:
+ MY_UNKNOWN_IMP1(IInArchive)
+
+ INTERFACE_IInArchive(;)
+
+ HRESULT Open2(IInStream *inStream, const UInt64 *maxCheckStartPosition,
+ IArchiveOpenCallback *callback);
+private:
+ CInArchive _archive;
+ CObjectVector<CItem> _items;
+ CMyComPtr<IInStream> _stream;
+};
+
+const wchar_t *kHostOS[] =
+{
+ L"MSDOS",
+ L"PRIMOS",
+ L"UNIX",
+ L"AMIGA",
+ L"MAC",
+ L"OS/2",
+ L"APPLE GS",
+ L"ATARI ST",
+ L"NEXT",
+ L"VAX VMS",
+ L"WIN95"
+};
+
+const wchar_t *kUnknownOS = L"Unknown";
+
+const int kNumHostOSes = sizeof(kHostOS) / sizeof(kHostOS[0]);
+
+STATPROPSTG kArcProps[] =
+{
+ { NULL, kpidName, VT_BSTR},
+ { NULL, kpidCTime, VT_BSTR},
+ { NULL, kpidMTime, VT_BSTR},
+ { NULL, kpidHostOS, VT_BSTR},
+ { NULL, kpidComment, VT_BSTR}
+};
+
+STATPROPSTG kProps[] =
+{
+ { NULL, kpidPath, VT_BSTR},
+ { NULL, kpidIsDir, VT_BOOL},
+ { NULL, kpidSize, VT_UI8},
+ { NULL, kpidPackSize, VT_UI8},
+ { NULL, kpidMTime, VT_FILETIME},
+ { NULL, kpidAttrib, VT_UI4},
+ { NULL, kpidEncrypted, VT_BOOL},
+ { NULL, kpidCRC, VT_UI4},
+ { NULL, kpidMethod, VT_UI1},
+ { NULL, kpidHostOS, VT_BSTR},
+ { NULL, kpidComment, VT_BSTR}
+};
+
+IMP_IInArchive_Props
+IMP_IInArchive_ArcProps
+
+static void SetTime(UInt32 dosTime, NWindows::NCOM::CPropVariant &prop)
+{
+ if (dosTime == 0)
+ return;
+ FILETIME localFileTime, utc;
+ if (NTime::DosTimeToFileTime(dosTime, localFileTime))
+ {
+ if (!LocalFileTimeToFileTime(&localFileTime, &utc))
+ utc.dwHighDateTime = utc.dwLowDateTime = 0;
+ }
+ else
+ utc.dwHighDateTime = utc.dwLowDateTime = 0;
+ prop = utc;
+}
+
+static void SetHostOS(Byte hostOS, NWindows::NCOM::CPropVariant &prop)
+{
+ prop = hostOS < kNumHostOSes ? kHostOS[hostOS] : kUnknownOS;
+}
+
+static void SetUnicodeString(const AString &s, NWindows::NCOM::CPropVariant &prop)
+{
+ if (!s.IsEmpty())
+ prop = MultiByteToUnicodeString(s, CP_OEMCP);
+}
+
+STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NWindows::NCOM::CPropVariant prop;
+ switch(propID)
+ {
+ case kpidName: SetUnicodeString(_archive.Header.Name, prop); break;
+ case kpidCTime: SetTime(_archive.Header.CTime, prop); break;
+ case kpidMTime: SetTime(_archive.Header.MTime, prop); break;
+ case kpidHostOS: SetHostOS(_archive.Header.HostOS, prop); break;
+ case kpidComment: SetUnicodeString(_archive.Header.Comment, prop); break;
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
+{
+ *numItems = _items.Size();
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NWindows::NCOM::CPropVariant prop;
+ const CItem &item = _items[index];
+ switch(propID)
+ {
+ case kpidPath: prop = NItemName::GetOSName(MultiByteToUnicodeString(item.Name, CP_OEMCP)); break;
+ case kpidIsDir: prop = item.IsDir(); break;
+ case kpidSize: prop = item.Size; break;
+ case kpidPackSize: prop = item.PackSize; break;
+ case kpidAttrib: prop = item.GetWinAttributes(); break;
+ case kpidEncrypted: prop = item.IsEncrypted(); break;
+ case kpidCRC: prop = item.FileCRC; break;
+ case kpidMethod: prop = item.Method; break;
+ case kpidHostOS: SetHostOS(item.HostOS, prop); break;
+ case kpidMTime: SetTime(item.MTime, prop); break;
+ case kpidComment: SetUnicodeString(item.Comment, prop); break;
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+HRESULT CHandler::Open2(IInStream *inStream, const UInt64 *maxCheckStartPosition,
+ IArchiveOpenCallback *callback)
+{
+ Close();
+
+ UInt64 endPos = 0;
+ if (callback != NULL)
+ {
+ RINOK(inStream->Seek(0, STREAM_SEEK_END, &endPos));
+ RINOK(inStream->Seek(0, STREAM_SEEK_SET, NULL));
+ }
+
+ _archive.Stream = inStream;
+ _archive.Callback = callback;
+ _archive.NumFiles = _archive.NumBytes = 0;
+
+ RINOK(_archive.Open(maxCheckStartPosition));
+ if (callback != NULL)
+ RINOK(callback->SetTotal(NULL, &endPos));
+ for (;;)
+ {
+ CItem item;
+ bool filled;
+
+
+ RINOK(_archive.GetNextItem(filled, item));
+
+ RINOK(inStream->Seek(0, STREAM_SEEK_CUR, &item.DataPosition));
+
+ if (!filled)
+ break;
+ _items.Add(item);
+
+ if (inStream->Seek(item.PackSize, STREAM_SEEK_CUR, NULL) != S_OK)
+ throw CInArchiveException(CInArchiveException::kUnexpectedEndOfArchive);
+
+ _archive.NumFiles = _items.Size();
+ _archive.NumBytes = item.DataPosition;
+
+ if (callback != NULL && _items.Size() % 100 == 0)
+ {
+ RINOK(callback->SetCompleted(&_archive.NumFiles, &_archive.NumBytes));
+ }
+ }
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Open(IInStream *inStream,
+ const UInt64 *maxCheckStartPosition, IArchiveOpenCallback *callback)
+{
+ COM_TRY_BEGIN
+ HRESULT res;
+ try
+ {
+ res = Open2(inStream, maxCheckStartPosition, callback);
+ if (res == S_OK)
+ {
+ _stream = inStream;
+ return S_OK;
+ }
+ }
+ catch(const CInArchiveException &) { res = S_FALSE; }
+ Close();
+ return res;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Close()
+{
+ _items.Clear();
+ _stream.Release();
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
+ Int32 testModeSpec, IArchiveExtractCallback *extractCallback)
+{
+ COM_TRY_BEGIN
+ bool testMode = (testModeSpec != 0);
+ UInt64 totalUnpacked = 0, totalPacked = 0;
+ bool allFilesMode = (numItems == UInt32(-1));
+ if (allFilesMode)
+ numItems = _items.Size();
+ if (numItems == 0)
+ return S_OK;
+ UInt32 i;
+ for (i = 0; i < numItems; i++)
+ {
+ const CItem &item = _items[allFilesMode ? i : indices[i]];
+ totalUnpacked += item.Size;
+ totalPacked += item.PackSize;
+ }
+ extractCallback->SetTotal(totalUnpacked);
+
+ totalUnpacked = totalPacked = 0;
+ UInt64 curUnpacked, curPacked;
+
+ CMyComPtr<ICompressCoder> arj1Decoder;
+ CMyComPtr<ICompressCoder> arj2Decoder;
+ NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder();
+ CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;
+
+ CLocalProgress *lps = new CLocalProgress;
+ CMyComPtr<ICompressProgressInfo> progress = lps;
+ lps->Init(extractCallback, false);
+
+ CLimitedSequentialInStream *inStreamSpec = new CLimitedSequentialInStream;
+ CMyComPtr<ISequentialInStream> inStream(inStreamSpec);
+ inStreamSpec->SetStream(_stream);
+
+ for (i = 0; i < numItems; i++, totalUnpacked += curUnpacked, totalPacked += curPacked)
+ {
+ lps->InSize = totalPacked;
+ lps->OutSize = totalUnpacked;
+ RINOK(lps->SetCur());
+
+ curUnpacked = curPacked = 0;
+
+ CMyComPtr<ISequentialOutStream> realOutStream;
+ Int32 askMode = testMode ?
+ NExtract::NAskMode::kTest :
+ NExtract::NAskMode::kExtract;
+ Int32 index = allFilesMode ? i : indices[i];
+ const CItem &item = _items[index];
+ RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
+
+ if (item.IsDir())
+ {
+ // if (!testMode)
+ {
+ RINOK(extractCallback->PrepareOperation(askMode));
+ RINOK(extractCallback->SetOperationResult(NExtract::NOperationResult::kOK));
+ }
+ continue;
+ }
+
+ if (!testMode && (!realOutStream))
+ continue;
+
+ RINOK(extractCallback->PrepareOperation(askMode));
+ curUnpacked = item.Size;
+ curPacked = item.PackSize;
+
+ {
+ COutStreamWithCRC *outStreamSpec = new COutStreamWithCRC;
+ CMyComPtr<ISequentialOutStream> outStream(outStreamSpec);
+ outStreamSpec->SetStream(realOutStream);
+ realOutStream.Release();
+ outStreamSpec->Init();
+
+ inStreamSpec->Init(item.PackSize);
+
+ UInt64 pos;
+ _stream->Seek(item.DataPosition, STREAM_SEEK_SET, &pos);
+
+ HRESULT result = S_OK;
+ Int32 opRes = NExtract::NOperationResult::kOK;
+
+ if (item.IsEncrypted())
+ opRes = NExtract::NOperationResult::kUnSupportedMethod;
+ else
+ {
+ switch(item.Method)
+ {
+ case NFileHeader::NCompressionMethod::kStored:
+ {
+ result = copyCoder->Code(inStream, outStream, NULL, NULL, progress);
+ if (result == S_OK && copyCoderSpec->TotalSize != item.PackSize)
+ result = S_FALSE;
+ break;
+ }
+ case NFileHeader::NCompressionMethod::kCompressed1a:
+ case NFileHeader::NCompressionMethod::kCompressed1b:
+ case NFileHeader::NCompressionMethod::kCompressed1c:
+ {
+ if (!arj1Decoder)
+ arj1Decoder = new NCompress::NArj::NDecoder1::CCoder;
+ result = arj1Decoder->Code(inStream, outStream, NULL, &curUnpacked, progress);
+ break;
+ }
+ case NFileHeader::NCompressionMethod::kCompressed2:
+ {
+ if (!arj2Decoder)
+ arj2Decoder = new NCompress::NArj::NDecoder2::CCoder;
+ result = arj2Decoder->Code(inStream, outStream, NULL, &curUnpacked, progress);
+ break;
+ }
+ default:
+ opRes = NExtract::NOperationResult::kUnSupportedMethod;
+ }
+ }
+ if (opRes == NExtract::NOperationResult::kOK)
+ {
+ if (result == S_FALSE)
+ opRes = NExtract::NOperationResult::kDataError;
+ else
+ {
+ RINOK(result);
+ opRes = (outStreamSpec->GetCRC() == item.FileCRC) ?
+ NExtract::NOperationResult::kOK:
+ NExtract::NOperationResult::kCRCError;
+ }
+ }
+ outStream.Release();
+ RINOK(extractCallback->SetOperationResult(opRes));
+ }
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+static IInArchive *CreateArc() { return new CHandler; }
+
+static CArcInfo g_ArcInfo =
+ { L"Arj", L"arj", 0, 4, { 0x60, 0xEA }, 2, false, CreateArc, 0 };
+
+REGISTER_ARC(Arj)
+
+}}
diff --git a/CPP/7zip/Archive/BZip2/BZip2Handler.cpp b/CPP/7zip/Archive/BZip2/BZip2Handler.cpp
index c88c883f..30b75444 100755
--- a/CPP/7zip/Archive/BZip2/BZip2Handler.cpp
+++ b/CPP/7zip/Archive/BZip2/BZip2Handler.cpp
@@ -21,9 +21,9 @@ namespace NBZip2 {
static const CMethodId kMethodId_BZip2 = 0x040202;
-STATPROPSTG kProps[] =
+STATPROPSTG kProps[] =
{
- { NULL, kpidPackedSize, VT_UI8}
+ { NULL, kpidPackSize, VT_UI8}
};
IMP_IInArchive_Props
@@ -40,13 +40,13 @@ STDMETHODIMP CHandler::GetProperty(UInt32 /* index */, PROPID propID, PROPVARIA
NWindows::NCOM::CPropVariant prop;
switch(propID)
{
- case kpidPackedSize: prop = _item.PackSize; break;
+ case kpidPackSize: prop = _item.PackSize; break;
}
prop.Detach(value);
return S_OK;
}
-STDMETHODIMP CHandler::Open(IInStream *stream,
+STDMETHODIMP CHandler::Open(IInStream *stream,
const UInt64 * /* maxCheckStartPosition */,
IArchiveOpenCallback * /* openArchiveCallback */)
{
diff --git a/CPP/7zip/Archive/BZip2/BZip2Handler.h b/CPP/7zip/Archive/BZip2/BZip2Handler.h
index 4a45e52f..5bb3360a 100755
--- a/CPP/7zip/Archive/BZip2/BZip2Handler.h
+++ b/CPP/7zip/Archive/BZip2/BZip2Handler.h
@@ -15,7 +15,7 @@
namespace NArchive {
namespace NBZip2 {
-class CHandler:
+class CHandler:
public IInArchive,
public IOutArchive,
public ISetProperties,
@@ -35,11 +35,11 @@ class CHandler:
DECL_EXTERNAL_CODECS_VARS
- void InitMethodProperties()
- {
+ void InitMethodProperties()
+ {
_level = 5;
- _dicSize =
- _numPasses = 0xFFFFFFFF;
+ _dicSize =
+ _numPasses = 0xFFFFFFFF;
#ifdef COMPRESS_MT
_numThreads = NWindows::NSystem::GetNumberOfProcessors();;
#endif
diff --git a/CPP/7zip/Archive/BZip2/BZip2HandlerOut.cpp b/CPP/7zip/Archive/BZip2/BZip2HandlerOut.cpp
index 33c9d0bf..fd93f179 100755
--- a/CPP/7zip/Archive/BZip2/BZip2HandlerOut.cpp
+++ b/CPP/7zip/Archive/BZip2/BZip2HandlerOut.cpp
@@ -55,7 +55,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
{
{
NCOM::CPropVariant prop;
- RINOK(updateCallback->GetProperty(0, kpidIsFolder, &prop));
+ RINOK(updateCallback->GetProperty(0, kpidIsDir, &prop));
if (prop.vt == VT_BOOL)
{
if (prop.boolVal != VARIANT_FALSE)
@@ -79,21 +79,21 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
UInt32 dicSize = _dicSize;
if (dicSize == 0xFFFFFFFF)
- dicSize = (_level >= 5 ? kDicSizeX5 :
- (_level >= 3 ? kDicSizeX3 :
+ dicSize = (_level >= 5 ? kDicSizeX5 :
+ (_level >= 3 ? kDicSizeX3 :
kDicSizeX1));
UInt32 numPasses = _numPasses;
if (numPasses == 0xFFFFFFFF)
- numPasses = (_level >= 9 ? kNumPassesX9 :
- (_level >= 7 ? kNumPassesX7 :
+ numPasses = (_level >= 9 ? kNumPassesX9 :
+ (_level >= 7 ? kNumPassesX7 :
kNumPassesX1));
return UpdateArchive(
EXTERNAL_CODECS_VARS
- size, outStream, 0, dicSize, numPasses,
+ size, outStream, 0, dicSize, numPasses,
#ifdef COMPRESS_MT
- _numThreads,
+ _numThreads,
#endif
updateCallback);
}
@@ -151,6 +151,6 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *v
return E_INVALIDARG;
}
return S_OK;
-}
+}
}}
diff --git a/CPP/7zip/Archive/BZip2/BZip2Update.cpp b/CPP/7zip/Archive/BZip2/BZip2Update.cpp
index d5eecc17..300d8844 100755
--- a/CPP/7zip/Archive/BZip2/BZip2Update.cpp
+++ b/CPP/7zip/Archive/BZip2/BZip2Update.cpp
@@ -47,15 +47,15 @@ HRESULT UpdateArchive(
encoder.QueryInterface(IID_ICompressSetCoderProperties, &setCoderProperties);
if (setCoderProperties)
{
- NWindows::NCOM::CPropVariant properties[] =
+ NWindows::NCOM::CPropVariant properties[] =
{
- dictionary,
+ dictionary,
numPasses
#ifdef COMPRESS_MT
, numThreads
#endif
};
- PROPID propIDs[] =
+ PROPID propIDs[] =
{
NCoderPropID::kDictionarySize,
NCoderPropID::kNumPasses
diff --git a/CPP/7zip/Archive/BZip2/StdAfx.cpp b/CPP/7zip/Archive/BZip2/StdAfx.cpp
deleted file mode 100755
index d0feea85..00000000
--- a/CPP/7zip/Archive/BZip2/StdAfx.cpp
+++ /dev/null
@@ -1,3 +0,0 @@
-// StdAfx.cpp
-
-#include "StdAfx.h"
diff --git a/CPP/7zip/Archive/Cab/CabBlockInStream.cpp b/CPP/7zip/Archive/Cab/CabBlockInStream.cpp
index 343ef821..308616b8 100755
--- a/CPP/7zip/Archive/Cab/CabBlockInStream.cpp
+++ b/CPP/7zip/Archive/Cab/CabBlockInStream.cpp
@@ -2,8 +2,8 @@
#include "StdAfx.h"
-extern "C"
-{
+extern "C"
+{
#include "../../../../C/Alloc.h"
}
@@ -45,7 +45,7 @@ public:
m_Value ^= ((UInt32)(m_Hist[i])) << (8 * (m_Pos - i - 1));
}
void UpdateUInt32(UInt32 v) { m_Value ^= v; }
- UInt32 GetResult() const { return m_Value; }
+ UInt32 GetResult() const { return m_Value; }
};
void CCheckSum2::Update(const void *data, UInt32 size)
@@ -65,7 +65,7 @@ void CCheckSum2::Update(const void *data, UInt32 size)
int numWords = size / 4;
- while (numWords-- != 0)
+ while (numWords-- != 0)
{
UInt32 temp = *dataPointer++;
temp |= ((UInt32)(*dataPointer++)) << 8;
diff --git a/CPP/7zip/Archive/Cab/CabBlockInStream.h b/CPP/7zip/Archive/Cab/CabBlockInStream.h
index b8b5d8b9..1db3835b 100755
--- a/CPP/7zip/Archive/Cab/CabBlockInStream.h
+++ b/CPP/7zip/Archive/Cab/CabBlockInStream.h
@@ -9,7 +9,7 @@
namespace NArchive {
namespace NCab {
-class CCabBlockInStream:
+class CCabBlockInStream:
public ISequentialInStream,
public CMyUnknownImp
{
diff --git a/CPP/7zip/Archive/Cab/CabHandler.cpp b/CPP/7zip/Archive/Cab/CabHandler.cpp
index b3e65d90..f4a11afb 100755
--- a/CPP/7zip/Archive/Cab/CabHandler.cpp
+++ b/CPP/7zip/Archive/Cab/CabHandler.cpp
@@ -31,19 +31,18 @@ namespace NCab {
// #define _CAB_DETAILS
#ifdef _CAB_DETAILS
-enum
+enum
{
kpidBlockReal = kpidUserDefined
};
#endif
-STATPROPSTG kProps[] =
+STATPROPSTG kProps[] =
{
{ NULL, kpidPath, VT_BSTR},
- // { NULL, kpidIsFolder, VT_BOOL},
{ NULL, kpidSize, VT_UI8},
- { NULL, kpidLastWriteTime, VT_FILETIME},
- { NULL, kpidAttributes, VT_UI4},
+ { NULL, kpidMTime, VT_FILETIME},
+ { NULL, kpidAttrib, VT_UI4},
{ NULL, kpidMethod, VT_BSTR},
{ NULL, kpidBlock, VT_I4}
#ifdef _CAB_DETAILS
@@ -54,7 +53,7 @@ STATPROPSTG kProps[] =
#endif
};
-static const wchar_t *kMethods[] =
+static const wchar_t *kMethods[] =
{
L"None",
L"MSZip",
@@ -65,7 +64,7 @@ static const wchar_t *kMethods[] =
static const int kNumMethods = sizeof(kMethods) / sizeof(kMethods[0]);
static const wchar_t *kUnknownMethod = L"Unknown";
-STATPROPSTG kArcProps[] =
+STATPROPSTG kArcProps[] =
{
{ NULL, kpidMethod, VT_BSTR},
// { NULL, kpidSolid, VT_BOOL},
@@ -101,7 +100,7 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
resString += L' ';
resString += method;
}
- prop = resString;
+ prop = resString;
break;
}
// case kpidSolid: prop = _database.IsSolid(); break;
@@ -145,13 +144,11 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *va
prop = (const wchar_t *)NItemName::WinNameToOSName(unicodeName);
break;
}
- case kpidIsFolder:
- prop = item.IsDirectory();
- break;
- case kpidSize:
- prop = item.Size;
- break;
- case kpidLastWriteTime:
+ case kpidIsDir: prop = item.IsDir(); break;
+ case kpidSize: prop = item.Size; break;
+ case kpidAttrib: prop = item.GetWinAttributes(); break;
+
+ case kpidMTime:
{
FILETIME localFileTime, utcFileTime;
if (NTime::DosTimeToFileTime(item.Time, localFileTime))
@@ -164,9 +161,6 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *va
prop = utcFileTime;
break;
}
- case kpidAttributes:
- prop = item.GetWinAttributes();
- break;
case kpidMethod:
{
@@ -174,7 +168,7 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *va
const CFolder &folder = db.Folders[realFolderIndex];
int methodIndex = folder.GetCompressionMethod();
UString method = (methodIndex < kNumMethods) ? kMethods[methodIndex] : kUnknownMethod;
- if (methodIndex == NHeader::NCompressionMethodMajor::kLZX ||
+ if (methodIndex == NHeader::NCompressionMethodMajor::kLZX ||
methodIndex == NHeader::NCompressionMethodMajor::kQuantum)
{
method += L":";
@@ -185,21 +179,13 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *va
prop = method;
break;
}
- case kpidBlock:
- prop = (Int32)m_Database.GetFolderIndex(&mvItem);
- break;
+ case kpidBlock: prop = (Int32)m_Database.GetFolderIndex(&mvItem); break;
#ifdef _CAB_DETAILS
- case kpidBlockReal:
- prop = UInt32(item.FolderIndex);
- break;
- case kpidOffset:
- prop = (UInt32)item.Offset;
- break;
- case kpidVolume:
- prop = (UInt32)mvItem.VolumeIndex;
- break;
+ case kpidBlockReal: prop = (UInt32)item.FolderIndex; break;
+ case kpidOffset: prop = (UInt32)item.Offset; break;
+ case kpidVolume: prop = (UInt32)mvItem.VolumeIndex; break;
#endif
}
@@ -209,7 +195,7 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *va
}
/*
-class CPropgressImp: public CProgressVirt
+class CProgressImp: public CProgressVirt
{
CMyComPtr<IArchiveOpenCallback> m_OpenArchiveCallback;
public:
@@ -219,14 +205,14 @@ public:
{ m_OpenArchiveCallback = openArchiveCallback; }
};
-STDMETHODIMP CPropgressImp::SetTotal(const UInt64 *numFiles)
+STDMETHODIMP CProgressImp::SetTotal(const UInt64 *numFiles)
{
if (m_OpenArchiveCallback)
return m_OpenArchiveCallback->SetCompleted(numFiles, NULL);
return S_OK;
}
-STDMETHODIMP CPropgressImp::SetCompleted(const UInt64 *numFiles)
+STDMETHODIMP CProgressImp::SetCompleted(const UInt64 *numFiles)
{
if (m_OpenArchiveCallback)
return m_OpenArchiveCallback->SetCompleted(numFiles, NULL);
@@ -234,9 +220,9 @@ STDMETHODIMP CPropgressImp::SetCompleted(const UInt64 *numFiles)
}
*/
-STDMETHODIMP CHandler::Open(IInStream *inStream,
+STDMETHODIMP CHandler::Open(IInStream *inStream,
const UInt64 *maxCheckStartPosition,
- IArchiveOpenCallback *openArchiveCallback)
+ IArchiveOpenCallback *callback)
{
COM_TRY_BEGIN
Close();
@@ -244,7 +230,7 @@ STDMETHODIMP CHandler::Open(IInStream *inStream,
CInArchive archive;
CMyComPtr<IArchiveOpenVolumeCallback> openVolumeCallback;
{
- CMyComPtr<IArchiveOpenCallback> openArchiveCallbackWrap = openArchiveCallback;
+ CMyComPtr<IArchiveOpenCallback> openArchiveCallbackWrap = callback;
openArchiveCallbackWrap.QueryInterface(IID_IArchiveOpenVolumeCallback, &openVolumeCallback);
}
@@ -264,7 +250,7 @@ STDMETHODIMP CHandler::Open(IInStream *inStream,
{
const CDatabaseEx &dbPrev = m_Database.Volumes[prevChecked ? m_Database.Volumes.Size() - 1 : 0];
if (dbPrev.ArchiveInfo.SetID != db.ArchiveInfo.SetID ||
- dbPrev.ArchiveInfo.CabinetNumber + (prevChecked ? 1: - 1) !=
+ dbPrev.ArchiveInfo.CabinetNumber + (prevChecked ? 1: - 1) !=
db.ArchiveInfo.CabinetNumber)
res = S_FALSE;
}
@@ -273,7 +259,7 @@ STDMETHODIMP CHandler::Open(IInStream *inStream,
m_Database.Volumes.Insert(prevChecked ? m_Database.Volumes.Size() : 0, db);
else if (res != S_FALSE)
return res;
- else
+ else
{
if (m_Database.Volumes.IsEmpty())
return S_FALSE;
@@ -283,7 +269,7 @@ STDMETHODIMP CHandler::Open(IInStream *inStream,
}
numItems += db.Items.Size();
- RINOK(openArchiveCallback->SetCompleted(&numItems, NULL));
+ RINOK(callback->SetCompleted(&numItems, NULL));
nextStream = 0;
for (;;)
@@ -342,7 +328,7 @@ STDMETHODIMP CHandler::Close()
return S_OK;
}
-class CCabFolderOutStream:
+class CCabFolderOutStream:
public ISequentialOutStream,
public CMyUnknownImp
{
@@ -373,8 +359,8 @@ public:
void Init(
const CMvDatabaseEx *database,
- const CRecordVector<bool> *extractStatuses,
- int startIndex,
+ const CRecordVector<bool> *extractStatuses,
+ int startIndex,
UInt64 folderSize,
IArchiveExtractCallback *extractCallback,
bool testMode);
@@ -387,8 +373,8 @@ public:
void CCabFolderOutStream::Init(
const CMvDatabaseEx *database,
- const CRecordVector<bool> *extractStatuses,
- int startIndex,
+ const CRecordVector<bool> *extractStatuses,
+ int startIndex,
UInt64 folderSize,
IArchiveExtractCallback *extractCallback,
bool testMode)
@@ -409,7 +395,7 @@ void CCabFolderOutStream::Init(
HRESULT CCabFolderOutStream::OpenFile()
{
- Int32 askMode = (*m_ExtractStatuses)[m_CurrentIndex] ? (m_TestMode ?
+ Int32 askMode = (*m_ExtractStatuses)[m_CurrentIndex] ? (m_TestMode ?
NExtract::NAskMode::kTest :
NExtract::NAskMode::kExtract) :
NExtract::NAskMode::kSkip;
@@ -474,7 +460,7 @@ HRESULT CCabFolderOutStream::Write2(const void *data, UInt32 size, UInt32 *proce
{
m_RealOutStream.Release();
RINOK(m_ExtractCallback->SetOperationResult(
- m_IsOk ?
+ m_IsOk ?
NArchive::NExtract::NOperationResult::kOK:
NArchive::NExtract::NOperationResult::kDataError));
m_FileIsOpen = false;
@@ -574,7 +560,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
int index = allFilesMode ? i : indices[i];
const CMvItem &mvItem = m_Database.Items[index];
const CItem &item = m_Database.Volumes[mvItem.VolumeIndex].Items[mvItem.ItemIndex];
- if (item.IsDirectory())
+ if (item.IsDir())
continue;
int folderIndex = m_Database.GetFolderIndex(&mvItem);
if (folderIndex != lastFolder)
@@ -622,9 +608,9 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
const CItem &item = db.Items[itemIndex];
i++;
- if (item.IsDirectory())
+ if (item.IsDir())
{
- Int32 askMode= testMode ?
+ Int32 askMode= testMode ?
NArchive::NExtract::NAskMode::kTest :
NArchive::NExtract::NAskMode::kExtract;
CMyComPtr<ISequentialOutStream> realOutStream;
@@ -638,7 +624,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
if (folderIndex < 0)
{
// If we need previous archive
- Int32 askMode= testMode ?
+ Int32 askMode= testMode ?
NArchive::NExtract::NAskMode::kTest :
NArchive::NExtract::NAskMode::kExtract;
CMyComPtr<ISequentialOutStream> realOutStream;
@@ -661,7 +647,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
int indexNext = allFilesMode ? i : indices[i];
const CMvItem &mvItem = m_Database.Items[indexNext];
const CItem &item = m_Database.Volumes[mvItem.VolumeIndex].Items[mvItem.ItemIndex];
- if (item.IsDirectory())
+ if (item.IsDir())
continue;
int newFolderIndex = m_Database.GetFolderIndex(&mvItem);
@@ -683,7 +669,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
const CFolder &folder = db.Folders[item.GetFolderIndex(db.Folders.Size())];
- cabFolderOutStream->Init(&m_Database, &extractStatuses, startIndex2,
+ cabFolderOutStream->Init(&m_Database, &extractStatuses, startIndex2,
curUnpack, extractCallback, testMode);
cabBlockInStreamSpec->MsZip = false;
diff --git a/CPP/7zip/Archive/Cab/CabHandler.h b/CPP/7zip/Archive/Cab/CabHandler.h
index e17c3a7d..1edcd11e 100755
--- a/CPP/7zip/Archive/Cab/CabHandler.h
+++ b/CPP/7zip/Archive/Cab/CabHandler.h
@@ -10,7 +10,7 @@
namespace NArchive {
namespace NCab {
-class CHandler:
+class CHandler:
public IInArchive,
public CMyUnknownImp
{
diff --git a/CPP/7zip/Archive/Cab/CabHeader.cpp b/CPP/7zip/Archive/Cab/CabHeader.cpp
index 37533dff..d1f71df3 100755
--- a/CPP/7zip/Archive/Cab/CabHeader.cpp
+++ b/CPP/7zip/Archive/Cab/CabHeader.cpp
@@ -8,12 +8,8 @@ namespace NArchive{
namespace NCab{
namespace NHeader{
-namespace NArchive {
+Byte kMarker[kMarkerSize] = {'M' + 1, 'S', 'C', 'F', 0, 0, 0, 0 };
-UInt32 kSignature = 0x4643534d + 1;
-static class CSignatureInitializer
-{ public: CSignatureInitializer() { kSignature--; }} g_SignatureInitializer;
-
-}
+struct SignatureInitializer { SignatureInitializer() { kMarker[0]--; }; } g_SignatureInitializer;
}}}
diff --git a/CPP/7zip/Archive/Cab/CabHeader.h b/CPP/7zip/Archive/Cab/CabHeader.h
index 5c122743..0f0d2af3 100755
--- a/CPP/7zip/Archive/Cab/CabHeader.h
+++ b/CPP/7zip/Archive/Cab/CabHeader.h
@@ -7,11 +7,13 @@
namespace NArchive {
namespace NCab {
-namespace NHeader{
+namespace NHeader {
-namespace NArchive
+const unsigned kMarkerSize = 8;
+extern Byte kMarker[kMarkerSize];
+
+namespace NArchive
{
- extern UInt32 kSignature;
namespace NFlags
{
const int kPrevCabinet = 0x0001;
diff --git a/CPP/7zip/Archive/Cab/CabIn.cpp b/CPP/7zip/Archive/Cab/CabIn.cpp
index ae774f19..072e4076 100755
--- a/CPP/7zip/Archive/Cab/CabIn.cpp
+++ b/CPP/7zip/Archive/Cab/CabIn.cpp
@@ -2,15 +2,12 @@
#include "StdAfx.h"
-#include "Common/StringConvert.h"
-#include "Common/MyCom.h"
#include "CabIn.h"
-#include "Windows/Defs.h"
-#include "../../Common/StreamUtils.h"
+#include "../Common/FindSignature.h"
-namespace NArchive{
-namespace NCab{
+namespace NArchive {
+namespace NCab {
/*
static HRESULT ReadBytes(IInStream *inStream, void *data, UInt32 size)
@@ -94,39 +91,21 @@ void CInArchive::Skeep(size_t size)
ReadByte();
}
-HRESULT CInArchive::Open2(IInStream *inStream,
+HRESULT CInArchive::Open2(IInStream *stream,
const UInt64 *searchHeaderSizeLimit,
CDatabase &database)
{
database.Clear();
- RINOK(inStream->Seek(0, STREAM_SEEK_CUR, &database.StartPosition));
+ RINOK(stream->Seek(0, STREAM_SEEK_SET, &database.StartPosition));
- {
- if (!inBuffer.Create(1 << 17))
- return E_OUTOFMEMORY;
- inBuffer.SetStream(inStream);
- inBuffer.Init();
- UInt64 value = 0;
- const int kSignatureSize = 8;
- UInt64 kSignature64 = NHeader::NArchive::kSignature;
- for (;;)
- {
- Byte b;
- if (!inBuffer.ReadByte(b))
- return S_FALSE;
- value >>= 8;
- value |= ((UInt64)b) << ((kSignatureSize - 1) * 8);
- if (inBuffer.GetProcessedSize() >= kSignatureSize)
- {
- if (value == kSignature64)
- break;
- if (searchHeaderSizeLimit != NULL)
- if (inBuffer.GetProcessedSize() > (*searchHeaderSizeLimit))
- return S_FALSE;
- }
- }
- database.StartPosition += inBuffer.GetProcessedSize() - kSignatureSize;
- }
+ RINOK(FindSignatureInStream(stream, NHeader::kMarker, NHeader::kMarkerSize,
+ searchHeaderSizeLimit, database.StartPosition));
+
+ RINOK(stream->Seek(database.StartPosition + NHeader::kMarkerSize, STREAM_SEEK_SET, NULL));
+ if (!inBuffer.Create(1 << 17))
+ return E_OUTOFMEMORY;
+ inBuffer.SetStream(stream);
+ inBuffer.Init();
CInArchiveInfo &archiveInfo = database.ArchiveInfo;
@@ -141,7 +120,9 @@ HRESULT CInArchive::Open2(IInStream *inStream,
archiveInfo.VersionMajor = ReadByte(); // cabinet file format version, major
archiveInfo.NumFolders = ReadUInt16(); // number of CFFOLDER entries in this cabinet
archiveInfo.NumFiles = ReadUInt16(); // number of CFFILE entries in this cabinet
- archiveInfo.Flags = ReadUInt16(); // number of CFFILE entries in this cabinet
+ archiveInfo.Flags = ReadUInt16();
+ if (archiveInfo.Flags > 7)
+ return S_FALSE;
archiveInfo.SetID = ReadUInt16(); // must be the same for all cabinets in a set
archiveInfo.CabinetNumber = ReadUInt16(); // number of this cabinet file in a set
@@ -175,9 +156,9 @@ HRESULT CInArchive::Open2(IInStream *inStream,
database.Folders.Add(folder);
}
- RINOK(inStream->Seek(database.StartPosition + archiveInfo.FileHeadersOffset, STREAM_SEEK_SET, NULL));
+ RINOK(stream->Seek(database.StartPosition + archiveInfo.FileHeadersOffset, STREAM_SEEK_SET, NULL));
- inBuffer.SetStream(inStream);
+ inBuffer.SetStream(stream);
inBuffer.Init();
for(i = 0; i < archiveInfo.NumFiles; i++)
{
@@ -221,8 +202,8 @@ static int CompareMvItems(const CMvItem *p1, const CMvItem *p2, void *param)
const CDatabaseEx &db2 = mvDb.Volumes[p2->VolumeIndex];
const CItem &item1 = db1.Items[p1->ItemIndex];
const CItem &item2 = db2.Items[p2->ItemIndex];;
- bool isDir1 = item1.IsDirectory();
- bool isDir2 = item2.IsDirectory();
+ bool isDir1 = item1.IsDir();
+ bool isDir2 = item2.IsDir();
if (isDir1 && !isDir2)
return -1;
if (isDir2 && !isDir1)
@@ -322,7 +303,7 @@ bool CMvDatabaseEx::Check()
if (fIndex >= FolderStartFileIndex.Size())
return false;
const CItem &item = Volumes[mvItem.VolumeIndex].Items[mvItem.ItemIndex];
- if (item.IsDirectory())
+ if (item.IsDir())
continue;
int folderIndex = GetFolderIndex(&mvItem);
if (folderIndex != prevFolder)
diff --git a/CPP/7zip/Archive/Cab/CabIn.h b/CPP/7zip/Archive/Cab/CabIn.h
index ebeead87..4975095f 100755
--- a/CPP/7zip/Archive/Cab/CabIn.h
+++ b/CPP/7zip/Archive/Cab/CabIn.h
@@ -93,7 +93,7 @@ public:
return true;
return false;
}
- int GetNumberOfNewFolders() const
+ int GetNumberOfNewFolders() const
{
int res = Folders.Size();
if (IsTherePrevFolder())
@@ -124,10 +124,10 @@ public:
CRecordVector<CMvItem> Items;
CRecordVector<int> StartFolderOfVol;
CRecordVector<int> FolderStartFileIndex;
- int GetFolderIndex(const CMvItem *mvi) const
+ int GetFolderIndex(const CMvItem *mvi) const
{
const CDatabaseEx &db = Volumes[mvi->VolumeIndex];
- return StartFolderOfVol[mvi->VolumeIndex] +
+ return StartFolderOfVol[mvi->VolumeIndex] +
db.Items[mvi->ItemIndex].GetFolderIndex(db.Folders.Size());
}
void Clear()
@@ -152,7 +152,7 @@ class CInArchive
void Skeep(size_t size);
void ReadOtherArchive(COtherArchive &oa);
- HRESULT Open2(IInStream *inStream,
+ HRESULT Open2(IInStream *inStream,
const UInt64 *searchHeaderSizeLimit,
CDatabase &database);
public:
diff --git a/CPP/7zip/Archive/Cab/CabItem.h b/CPP/7zip/Archive/Cab/CabItem.h
index 8b41fe69..63a1e856 100755
--- a/CPP/7zip/Archive/Cab/CabItem.h
+++ b/CPP/7zip/Archive/Cab/CabItem.h
@@ -19,9 +19,8 @@ struct CFolder
Byte GetCompressionMethod() const { return (Byte)(CompressionTypeMajor & 0xF); }
};
-class CItem
+struct CItem
{
-public:
AString Name;
UInt32 Offset;
UInt32 Size;
@@ -29,26 +28,28 @@ public:
UInt16 FolderIndex;
UInt16 Flags;
UInt16 Attributes;
+
UInt64 GetEndOffset() const { return (UInt64)Offset + Size; }
UInt32 GetWinAttributes() const { return (Attributes & ~NHeader::kFileNameIsUTFAttributeMask); }
bool IsNameUTF() const { return (Attributes & NHeader::kFileNameIsUTFAttributeMask) != 0; }
- bool IsDirectory() const { return (Attributes & FILE_ATTRIBUTE_DIRECTORY) != 0; }
+ bool IsDir() const { return (Attributes & FILE_ATTRIBUTE_DIRECTORY) != 0; }
- bool ContinuedFromPrev() const
- {
- return
+ bool ContinuedFromPrev() const
+ {
+ return
(FolderIndex == NHeader::NFolderIndex::kContinuedFromPrev) ||
(FolderIndex == NHeader::NFolderIndex::kContinuedPrevAndNext);
}
- bool ContinuedToNext() const
- {
- return
+
+ bool ContinuedToNext() const
+ {
+ return
(FolderIndex == NHeader::NFolderIndex::kContinuedToNext) ||
(FolderIndex == NHeader::NFolderIndex::kContinuedPrevAndNext);
}
- int GetFolderIndex(int numFolders) const
- {
+ int GetFolderIndex(int numFolders) const
+ {
if (ContinuedFromPrev())
return 0;
if (ContinuedToNext())
diff --git a/CPP/7zip/Archive/Cab/StdAfx.cpp b/CPP/7zip/Archive/Cab/StdAfx.cpp
deleted file mode 100755
index d0feea85..00000000
--- a/CPP/7zip/Archive/Cab/StdAfx.cpp
+++ /dev/null
@@ -1,3 +0,0 @@
-// StdAfx.cpp
-
-#include "StdAfx.h"
diff --git a/CPP/7zip/Archive/Chm/ChmHandler.cpp b/CPP/7zip/Archive/Chm/ChmHandler.cpp
index 7f3b1837..9da64bce 100755
--- a/CPP/7zip/Archive/Chm/ChmHandler.cpp
+++ b/CPP/7zip/Archive/Chm/ChmHandler.cpp
@@ -32,17 +32,16 @@ namespace NChm {
#ifdef _CHM_DETAILS
-enum
+enum
{
kpidSection = kpidUserDefined
};
#endif
-STATPROPSTG kProps[] =
+STATPROPSTG kProps[] =
{
{ NULL, kpidPath, VT_BSTR},
- // { NULL, kpidIsFolder, VT_BOOL},
{ NULL, kpidSize, VT_UI8},
{ NULL, kpidMethod, VT_BSTR},
{ NULL, kpidBlock, VT_UI4}
@@ -54,7 +53,7 @@ STATPROPSTG kProps[] =
#endif
};
-STATPROPSTG kArcProps[] =
+STATPROPSTG kArcProps[] =
{
{ NULL, kpidNumBlocks, VT_UI8}
};
@@ -71,7 +70,7 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
NWindows::NCOM::CPropVariant prop;
switch(propID)
{
- case kpidNumBlocks:
+ case kpidNumBlocks:
{
UInt64 numBlocks = 0;
for (int i = 0; i < m_Database.Sections.Size(); i++)
@@ -84,7 +83,7 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
numBlocks += m.LzxInfo.ResetTable.GetNumBlocks();
}
}
- prop = numBlocks;
+ prop = numBlocks;
break;
}
}
@@ -132,15 +131,11 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *va
}
break;
}
- case kpidIsFolder:
- prop = item.IsDirectory();
- break;
- case kpidSize:
- prop = item.Size;
- break;
+ case kpidIsDir: prop = item.IsDir(); break;
+ case kpidSize: prop = item.Size; break;
case kpidMethod:
{
- if (!item.IsDirectory())
+ if (!item.IsDir())
if (item.Section == 0)
prop = L"Copy";
else if (item.Section < m_Database.Sections.Size())
@@ -156,12 +151,8 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *va
#ifdef _CHM_DETAILS
- case kpidSection:
- prop = (UInt32)item.Section;
- break;
- case kpidOffset:
- prop = (UInt32)item.Offset;
- break;
+ case kpidSection: prop = (UInt32)item.Section; break;
+ case kpidOffset: prop = (UInt32)item.Offset; break;
#endif
}
@@ -170,41 +161,39 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *va
COM_TRY_END
}
-class CPropgressImp: public CProgressVirt
+class CProgressImp: public CProgressVirt
{
- CMyComPtr<IArchiveOpenCallback> m_OpenArchiveCallback;
+ CMyComPtr<IArchiveOpenCallback> _callback;
public:
STDMETHOD(SetTotal)(const UInt64 *numFiles);
STDMETHOD(SetCompleted)(const UInt64 *numFiles);
- void Init(IArchiveOpenCallback *openArchiveCallback)
- { m_OpenArchiveCallback = openArchiveCallback; }
+ CProgressImp(IArchiveOpenCallback *callback): _callback(callback) {};
};
-STDMETHODIMP CPropgressImp::SetTotal(const UInt64 *numFiles)
+STDMETHODIMP CProgressImp::SetTotal(const UInt64 *numFiles)
{
- if (m_OpenArchiveCallback)
- return m_OpenArchiveCallback->SetCompleted(numFiles, NULL);
+ if (_callback)
+ return _callback->SetCompleted(numFiles, NULL);
return S_OK;
}
-STDMETHODIMP CPropgressImp::SetCompleted(const UInt64 *numFiles)
+STDMETHODIMP CProgressImp::SetCompleted(const UInt64 *numFiles)
{
- if (m_OpenArchiveCallback)
- return m_OpenArchiveCallback->SetCompleted(numFiles, NULL);
+ if (_callback)
+ return _callback->SetCompleted(numFiles, NULL);
return S_OK;
}
-STDMETHODIMP CHandler::Open(IInStream *inStream,
+STDMETHODIMP CHandler::Open(IInStream *inStream,
const UInt64 *maxCheckStartPosition,
- IArchiveOpenCallback *openArchiveCallback)
+ IArchiveOpenCallback * /* openArchiveCallback */)
{
COM_TRY_BEGIN
m_Stream.Release();
try
{
CInArchive archive;
- CPropgressImp progressImp;
- progressImp.Init(openArchiveCallback);
+ // CProgressImp progressImp(openArchiveCallback);
RINOK(archive.Open(inStream, maxCheckStartPosition, m_Database));
/*
if (m_Database.LowLevel)
@@ -227,7 +216,7 @@ STDMETHODIMP CHandler::Close()
return S_OK;
}
-class CChmFolderOutStream:
+class CChmFolderOutStream:
public ISequentialOutStream,
public CMyUnknownImp
{
@@ -280,7 +269,7 @@ void CChmFolderOutStream::Init(
HRESULT CChmFolderOutStream::OpenFile()
{
- Int32 askMode = (*m_ExtractStatuses)[m_CurrentIndex] ? (m_TestMode ?
+ Int32 askMode = (*m_ExtractStatuses)[m_CurrentIndex] ? (m_TestMode ?
NExtract::NAskMode::kTest :
NExtract::NAskMode::kExtract) :
NExtract::NAskMode::kSkip;
@@ -345,7 +334,7 @@ HRESULT CChmFolderOutStream::Write2(const void *data, UInt32 size, UInt32 *proce
{
m_RealOutStream.Release();
RINOK(m_ExtractCallback->SetOperationResult(
- m_IsOk ?
+ m_IsOk ?
NArchive::NExtract::NOperationResult::kOK:
NArchive::NExtract::NOperationResult::kDataError));
m_FileIsOpen = false;
@@ -356,7 +345,7 @@ HRESULT CChmFolderOutStream::Write2(const void *data, UInt32 size, UInt32 *proce
else
{
if (m_CurrentIndex >= m_NumFiles)
- return E_FAIL;
+ return E_FAIL;
int fullIndex = m_StartIndex + m_CurrentIndex;
m_RemainFileSize = m_Database->GetFileSize(fullIndex);
UInt64 fileOffset = m_Database->GetFileOffset(fullIndex);
@@ -458,7 +447,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
RINOK(lps->SetCur());
CMyComPtr<ISequentialOutStream> realOutStream;
- Int32 askMode= testMode ?
+ Int32 askMode= testMode ?
NArchive::NExtract::NAskMode::kTest :
NArchive::NExtract::NAskMode::kExtract;
Int32 index = allFilesMode ? i : indices[i];
@@ -502,7 +491,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
RINOK(copyCoder->Code(inStream, realOutStream, NULL, NULL, progress));
realOutStream.Release();
- RINOK(extractCallback->SetOperationResult((copyCoderSpec->TotalSize == item.Size) ?
+ RINOK(extractCallback->SetOperationResult((copyCoderSpec->TotalSize == item.Size) ?
NArchive::NExtract::NOperationResult::kOK:
NArchive::NExtract::NOperationResult::kDataError));
}
@@ -516,7 +505,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
int entryIndex = m_Database.Indices[index];
const CItem &item = m_Database.Items[entryIndex];
UInt64 sectionIndex = item.Section;
- if (item.IsDirectory() || item.Size == 0)
+ if (item.IsDir() || item.Size == 0)
continue;
if (sectionIndex == 0)
{
@@ -554,10 +543,10 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
int entryIndex = m_Database.Indices[index];
const CItem &item = m_Database.Items[entryIndex];
UInt64 sectionIndex = item.Section;
- Int32 askMode= testMode ?
+ Int32 askMode= testMode ?
NArchive::NExtract::NAskMode::kTest :
NArchive::NExtract::NAskMode::kExtract;
- if (item.IsDirectory())
+ if (item.IsDir())
{
CMyComPtr<ISequentialOutStream> realOutStream;
RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
diff --git a/CPP/7zip/Archive/Chm/ChmHandler.h b/CPP/7zip/Archive/Chm/ChmHandler.h
index 09113b8f..440c50f1 100755
--- a/CPP/7zip/Archive/Chm/ChmHandler.h
+++ b/CPP/7zip/Archive/Chm/ChmHandler.h
@@ -10,7 +10,7 @@
namespace NArchive {
namespace NChm {
-class CHandler:
+class CHandler:
public IInArchive,
public CMyUnknownImp
{
diff --git a/CPP/7zip/Archive/Chm/ChmHeader.cpp b/CPP/7zip/Archive/Chm/ChmHeader.cpp
index 4d485b6c..e8dc9f3e 100755
--- a/CPP/7zip/Archive/Chm/ChmHeader.cpp
+++ b/CPP/7zip/Archive/Chm/ChmHeader.cpp
@@ -11,11 +11,11 @@ namespace NHeader{
UInt32 kItsfSignature = 0x46535449 + 1;
UInt32 kItolSignature = 0x4C4F5449 + 1;
static class CSignatureInitializer
-{
-public:
+{
+public:
CSignatureInitializer()
- {
- kItsfSignature--;
+ {
+ kItsfSignature--;
kItolSignature--;
}
}g_SignatureInitializer;
diff --git a/CPP/7zip/Archive/Chm/ChmIn.cpp b/CPP/7zip/Archive/Chm/ChmIn.cpp
index 5e13f54b..1379b1fd 100755
--- a/CPP/7zip/Archive/Chm/ChmIn.cpp
+++ b/CPP/7zip/Archive/Chm/ChmIn.cpp
@@ -17,16 +17,16 @@ namespace NChm{
// define CHM_LOW, if you want to see low level items
// #define CHM_LOW
-static const GUID kChmLzxGuid =
+static const GUID kChmLzxGuid =
{ 0x7FC28940, 0x9D31, 0x11D0, 0x9B, 0x27, 0x00, 0xA0, 0xC9, 0x1E, 0x9C, 0x7C };
-static const GUID kHelp2LzxGuid =
+static const GUID kHelp2LzxGuid =
{ 0x0A9007C6, 0x4076, 0x11D3, 0x87, 0x89, 0x00, 0x00, 0xF8, 0x10, 0x57, 0x54 };
-static const GUID kDesGuid =
+static const GUID kDesGuid =
{ 0x67F6E4A2, 0x60BF, 0x11D3, 0x85, 0x40, 0x00, 0xC0, 0x4F, 0x58, 0xC3, 0xCF };
static bool AreGuidsEqual(REFGUID g1, REFGUID g2)
-{
- if (g1.Data1 != g2.Data1 ||
+{
+ if (g1.Data1 != g2.Data1 ||
g1.Data2 != g2.Data2 ||
g1.Data3 != g2.Data3)
return false;
@@ -60,7 +60,7 @@ static void PrintUInt32(UInt32 v, AString &s)
}
AString CMethodInfo::GetGuidString() const
-{
+{
AString s;
s += '{';
PrintUInt32(Guid.Data1, s);
@@ -278,9 +278,9 @@ HRESULT CInArchive::OpenChm(IInStream *inStream, CDatabase &database)
if (unknown1 != 0 && unknown1 != 1) // it's 0 in one .sll file
return S_FALSE;
/* UInt32 timeStamp = */ ReadUInt32();
- // Considered as a big-endian DWORD, it appears to contain seconds (MSB) and
- // fractional seconds (second byte).
- // The third and fourth bytes may contain even more fractional bits.
+ // Considered as a big-endian DWORD, it appears to contain seconds (MSB) and
+ // fractional seconds (second byte).
+ // The third and fourth bytes may contain even more fractional bits.
// The 4 least significant bits in the last byte are constant.
/* UInt32 lang = */ ReadUInt32();
GUID g;
@@ -326,12 +326,12 @@ HRESULT CInArchive::OpenChm(IInStream *inStream, CDatabase &database)
if (dirChunkSize < 32)
return S_FALSE;
/* UInt32 density = */ ReadUInt32(); // "Density" of quickref section, usually 2.
- /* UInt32 depth = */ ReadUInt32(); // Depth of the index tree: 1 there is no index,
+ /* UInt32 depth = */ ReadUInt32(); // Depth of the index tree: 1 there is no index,
// 2 if there is one level of PMGI chunks.
/* UInt32 chunkNumber = */ ReadUInt32(); // Chunk number of root index chunk, -1 if there is none
- // (though at least one file has 0 despite there being no
- // index chunk, probably a bug.)
+ // (though at least one file has 0 despite there being no
+ // index chunk, probably a bug.)
/* UInt32 firstPmglChunkNumber = */ ReadUInt32(); // Chunk number of first PMGL (listing) chunk
/* UInt32 lastPmglChunkNumber = */ ReadUInt32(); // Chunk number of last PMGL (listing) chunk
ReadUInt32(); // -1 (unknown)
@@ -348,11 +348,11 @@ HRESULT CInArchive::OpenChm(IInStream *inStream, CDatabase &database)
UInt64 chunkPos = _inBuffer.GetProcessedSize();
if (ReadUInt32() == NHeader::kPmglSignature)
{
- // The quickref area is written backwards from the end of the chunk.
- // One quickref entry exists for every n entries in the file, where n
- // is calculated as 1 + (1 << quickref density). So for density = 2, n = 5.
+ // The quickref area is written backwards from the end of the chunk.
+ // One quickref entry exists for every n entries in the file, where n
+ // is calculated as 1 + (1 << quickref density). So for density = 2, n = 5.
- UInt32 quickrefLength = ReadUInt32(); // Length of free space and/or quickref area at end of directory chunk
+ UInt32 quickrefLength = ReadUInt32(); // Length of free space and/or quickref area at end of directory chunk
if (quickrefLength > dirChunkSize || quickrefLength < 2)
return S_FALSE;
ReadUInt32(); // Always 0
@@ -393,10 +393,10 @@ HRESULT CInArchive::OpenHelp2(IInStream *inStream, CDatabase &database)
if (numHeaderSections != kNumHeaderSectionsMax)
return S_FALSE;
ReadUInt32(); // Length of post-header table
- GUID g;
+ GUID g;
ReadGUID(g); // {0A9007C1-4076-11D3-8789-0000F8105754}
- // header section table
+ // header section table
UInt64 sectionOffsets[kNumHeaderSectionsMax];
UInt64 sectionSizes[kNumHeaderSectionsMax];
UInt32 i;
@@ -434,9 +434,9 @@ HRESULT CInArchive::OpenHelp2(IInStream *inStream, CDatabase &database)
ReadUInt64(); // Number of directory index entries (same as number of AOLL
// chunks in main directory)
- // (The obvious guess for the following two fields, which recur in a number
- // of places, is they are maximum sizes for the directory and directory index.
- // However, I have seen no direct evidence that this is the case.)
+ // (The obvious guess for the following two fields, which recur in a number
+ // of places, is they are maximum sizes for the directory and directory index.
+ // However, I have seen no direct evidence that this is the case.)
ReadUInt32(); // $100000 (Same as field following chunk size in directory)
ReadUInt32(); // $20000 (Same as field following chunk size in directory index)
@@ -480,8 +480,8 @@ HRESULT CInArchive::OpenHelp2(IInStream *inStream, CDatabase &database)
if (unknown != 0 && unknown != 1) // = 0 for some HxW files, 1 in other cases;
return S_FALSE;
database.ContentOffset = _startPosition + ReadUInt64();
- /* UInt32 timeStamp = */ ReadUInt32();
- // A timestamp of some sort.
+ /* UInt32 timeStamp = */ ReadUInt32();
+ // A timestamp of some sort.
// Considered as a big-endian DWORD, it appears to contain
// seconds (MSB) and fractional seconds (second byte).
// The third and fourth bytes may contain even more fractional
@@ -527,7 +527,7 @@ HRESULT CInArchive::OpenHelp2(IInStream *inStream, CDatabase &database)
UInt32 quickrefLength = ReadUInt32(); // Length of quickref area at end of directory chunk
if (quickrefLength > dirChunkSize || quickrefLength < 2)
return S_FALSE;
- ReadUInt64(); // Directory chunk number
+ ReadUInt64(); // Directory chunk number
// This must match physical position in file, that is
// the chunk size times the chunk number must be the
// offset from the end of the directory header.
@@ -625,8 +625,8 @@ static int CompareFiles(const int *p1, const int *p2, void *param)
const CObjectVector<CItem> &items = *(const CObjectVector<CItem> *)param;
const CItem &item1 = items[*p1];
const CItem &item2 = items[*p2];
- bool isDir1 = item1.IsDirectory();
- bool isDir2 = item2.IsDirectory();
+ bool isDir1 = item1.IsDir();
+ bool isDir2 = item2.IsDir();
if (isDir1 && !isDir2)
return -1;
if (isDir2)
@@ -663,7 +663,7 @@ bool CFilesDatabase::Check()
for(int i = 0; i < Indices.Size(); i++)
{
const CItem &item = Items[Indices[i]];
- if (item.Section == 0 || item.IsDirectory())
+ if (item.Section == 0 || item.IsDir())
continue;
if (item.Section != prevSection)
{
@@ -718,7 +718,7 @@ HRESULT CInArchive::OpenHighLevel(IInStream *inStream, CFilesDatabase &database)
AString transformPrefix = sectionPrefix + kTransform;
if (database.Help2Format)
{
- // Transform List
+ // Transform List
RINOK(DecompressStream(inStream, database, transformPrefix + kTransformList));
if ((_chunkSize & 0xF) != 0)
return S_FALSE;
@@ -760,21 +760,21 @@ HRESULT CInArchive::OpenHighLevel(IInStream *inStream, CFilesDatabase &database)
li.WindowSize = ReadUInt32();
li.CacheSize = ReadUInt32();
if (
- li.ResetInterval != 1 &&
- li.ResetInterval != 2 &&
- li.ResetInterval != 4 &&
- li.ResetInterval != 8 &&
- li.ResetInterval != 16 &&
- li.ResetInterval != 32 &&
+ li.ResetInterval != 1 &&
+ li.ResetInterval != 2 &&
+ li.ResetInterval != 4 &&
+ li.ResetInterval != 8 &&
+ li.ResetInterval != 16 &&
+ li.ResetInterval != 32 &&
li.ResetInterval != 64)
return S_FALSE;
if (
- li.WindowSize != 1 &&
- li.WindowSize != 2 &&
- li.WindowSize != 4 &&
- li.WindowSize != 8 &&
- li.WindowSize != 16 &&
- li.WindowSize != 32 &&
+ li.WindowSize != 1 &&
+ li.WindowSize != 2 &&
+ li.WindowSize != 4 &&
+ li.WindowSize != 8 &&
+ li.WindowSize != 16 &&
+ li.WindowSize != 32 &&
li.WindowSize != 64)
return S_FALSE;
numDWORDS -= 5;
@@ -803,7 +803,7 @@ HRESULT CInArchive::OpenHighLevel(IInStream *inStream, CFilesDatabase &database)
if (method.IsLzx())
{
// ResetTable;
- RINOK(DecompressStream(inStream, database, transformPrefix +
+ RINOK(DecompressStream(inStream, database, transformPrefix +
method.GetGuidString() + kResetTable));
CResetTable &rt = method.LzxInfo.ResetTable;
if (_chunkSize < 4)
@@ -845,7 +845,7 @@ HRESULT CInArchive::OpenHighLevel(IInStream *inStream, CFilesDatabase &database)
return database.Check() ? S_OK : S_FALSE;
}
-HRESULT CInArchive::Open2(IInStream *inStream,
+HRESULT CInArchive::Open2(IInStream *inStream,
const UInt64 *searchHeaderSizeLimit,
CFilesDatabase &database)
{
@@ -864,6 +864,11 @@ HRESULT CInArchive::Open2(IInStream *inStream,
const int kSignatureSize = 8;
UInt64 hxsSignature = NHeader::GetHxsSignature();
UInt64 chmSignature = ((UInt64)chmVersion << 32)| NHeader::kItsfSignature;
+ UInt64 limit = 1 << 18;
+ if (searchHeaderSizeLimit)
+ if (limit > *searchHeaderSizeLimit)
+ limit = *searchHeaderSizeLimit;
+
for (;;)
{
Byte b;
@@ -880,9 +885,8 @@ HRESULT CInArchive::Open2(IInStream *inStream,
database.Help2Format = true;
break;
}
- if (searchHeaderSizeLimit != NULL)
- if (_inBuffer.GetProcessedSize() > (*searchHeaderSizeLimit))
- return S_FALSE;
+ if (_inBuffer.GetProcessedSize() > limit)
+ return S_FALSE;
}
}
_startPosition += _inBuffer.GetProcessedSize() - kSignatureSize;
@@ -919,7 +923,7 @@ HRESULT CInArchive::Open2(IInStream *inStream,
return S_OK;
}
-HRESULT CInArchive::Open(IInStream *inStream,
+HRESULT CInArchive::Open(IInStream *inStream,
const UInt64 *searchHeaderSizeLimit,
CFilesDatabase &database)
{
diff --git a/CPP/7zip/Archive/Chm/ChmIn.h b/CPP/7zip/Archive/Chm/ChmIn.h
index e677c618..943336cb 100755
--- a/CPP/7zip/Archive/Chm/ChmIn.h
+++ b/CPP/7zip/Archive/Chm/ChmIn.h
@@ -19,21 +19,21 @@ struct CItem
UInt64 Size;
AString Name;
- bool IsFormatRelatedItem() const
+ bool IsFormatRelatedItem() const
{
if (Name.Length() < 2)
return false;
return Name[0] == ':' && Name[1] == ':';
}
- bool IsUserItem() const
+ bool IsUserItem() const
{
if (Name.Length() < 2)
return false;
return Name[0] == '/';
}
- bool IsDirectory() const
+ bool IsDir() const
{
if (Name.Length() == 0)
return false;
@@ -57,12 +57,12 @@ struct CDatabase
return -1;
}
- void Clear()
- {
+ void Clear()
+ {
NewFormat = false;
NewFormatString.Empty();
Help2Format = false;
- Items.Clear();
+ Items.Clear();
}
};
@@ -72,7 +72,7 @@ struct CResetTable
UInt64 CompressedSize;
UInt64 BlockSize;
CRecordVector<UInt64> ResetOffsets;
- bool GetCompressedSizeOfBlocks(UInt64 blockIndex, UInt32 numBlocks, UInt64 &size) const
+ bool GetCompressedSizeOfBlocks(UInt64 blockIndex, UInt32 numBlocks, UInt64 &size) const
{
if (blockIndex >= ResetOffsets.Size())
return false;
@@ -83,11 +83,11 @@ struct CResetTable
size = ResetOffsets[(int)(blockIndex + numBlocks)] - startPos;
return true;
}
- bool GetCompressedSizeOfBlock(UInt64 blockIndex, UInt64 &size) const
+ bool GetCompressedSizeOfBlock(UInt64 blockIndex, UInt64 &size) const
{
return GetCompressedSizeOfBlocks(blockIndex, 1, size);
}
- UInt64 GetNumBlocks(UInt64 size) const
+ UInt64 GetNumBlocks(UInt64 size) const
{
return (size + BlockSize - 1) / BlockSize;
}
@@ -116,16 +116,16 @@ struct CLzxInfo
UInt64 GetFolder(UInt64 offset) const { return offset / GetFolderSize(); };
UInt64 GetFolderPos(UInt64 folderIndex) const { return folderIndex * GetFolderSize(); };
UInt64 GetBlockIndexFromFolderIndex(UInt64 folderIndex) const { return folderIndex * ResetInterval; };
- bool GetOffsetOfFolder(UInt64 folderIndex, UInt64 &offset) const
- {
+ bool GetOffsetOfFolder(UInt64 folderIndex, UInt64 &offset) const
+ {
UInt64 blockIndex = GetBlockIndexFromFolderIndex(folderIndex);
if (blockIndex >= ResetTable.ResetOffsets.Size())
return false;
offset = ResetTable.ResetOffsets[(int)blockIndex];
return true;
}
- bool GetCompressedSizeOfFolder(UInt64 folderIndex, UInt64 &size) const
- {
+ bool GetCompressedSizeOfFolder(UInt64 folderIndex, UInt64 &size) const
+ {
UInt64 blockIndex = GetBlockIndexFromFolderIndex(folderIndex);
return ResetTable.GetCompressedSizeOfBlocks(blockIndex, ResetInterval, size);
}
@@ -165,8 +165,8 @@ public:
UInt64 GetFileSize(int fileIndex) const { return Items[Indices[fileIndex]].Size; }
UInt64 GetFileOffset(int fileIndex) const { return Items[Indices[fileIndex]].Offset; }
- UInt64 GetFolder(int fileIndex) const
- {
+ UInt64 GetFolder(int fileIndex) const
+ {
const CItem &item = Items[Indices[fileIndex]];
const CSectionInfo &section = Sections[(int)item.Section];
if (section.IsLzx())
@@ -174,8 +174,8 @@ public:
return 0;
}
- UInt64 GetLastFolder(int fileIndex) const
- {
+ UInt64 GetLastFolder(int fileIndex) const
+ {
const CItem &item = Items[Indices[fileIndex]];
const CSectionInfo &section = Sections[(int)item.Section];
if (section.IsLzx())
@@ -183,16 +183,16 @@ public:
return 0;
}
- void HighLevelClear()
- {
+ void HighLevelClear()
+ {
LowLevel = true;
- Indices.Clear();
- Sections.Clear();
+ Indices.Clear();
+ Sections.Clear();
}
- void Clear()
- {
- CDatabase::Clear();
+ void Clear()
+ {
+ CDatabase::Clear();
HighLevelClear();
}
void SetIndices();
diff --git a/CPP/7zip/Archive/Chm/StdAfx.cpp b/CPP/7zip/Archive/Chm/StdAfx.cpp
deleted file mode 100755
index d0feea85..00000000
--- a/CPP/7zip/Archive/Chm/StdAfx.cpp
+++ /dev/null
@@ -1,3 +0,0 @@
-// StdAfx.cpp
-
-#include "StdAfx.h"
diff --git a/CPP/7zip/Archive/Com/ComHandler.cpp b/CPP/7zip/Archive/Com/ComHandler.cpp
index 2255c021..8b46976c 100755
--- a/CPP/7zip/Archive/Com/ComHandler.cpp
+++ b/CPP/7zip/Archive/Com/ComHandler.cpp
@@ -10,19 +10,19 @@
namespace NArchive {
namespace NCom {
-STATPROPSTG kProps[] =
+STATPROPSTG kProps[] =
{
{ NULL, kpidPath, VT_BSTR},
- { NULL, kpidIsFolder, VT_BOOL},
+ { NULL, kpidIsDir, VT_BOOL},
{ NULL, kpidSize, VT_UI8},
// { NULL, kpidAttributes, VT_UI4},
- { NULL, kpidPackedSize, VT_UI8},
- { NULL, kpidCreationTime, VT_FILETIME},
- { NULL, kpidLastWriteTime, VT_FILETIME}
+ { NULL, kpidPackSize, VT_UI8},
+ { NULL, kpidCTime, VT_FILETIME},
+ { NULL, kpidMTime, VT_FILETIME}
};
-STATPROPSTG kArcProps[] =
+STATPROPSTG kArcProps[] =
{
{ NULL, kpidClusterSize, VT_UI4}
};
@@ -58,25 +58,19 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
prop = name;
break;
}
- case kpidIsFolder:
- prop = item.IsDir();
- break;
- case kpidCreationTime:
- prop = item.CreationTime;
- break;
- case kpidLastWriteTime:
- prop = item.LastWriteTime;
- break;
+ case kpidIsDir: prop = item.IsDir(); break;
+ case kpidCTime: prop = item.CTime; break;
+ case kpidMTime: prop = item.MTime; break;
/*
case kpidAttributes:
prop = item.Falgs;
break;
*/
- case kpidPackedSize:
+ case kpidPackSize:
if (!item.IsDir())
{
- int numBits = _db.IsLargeStream(item.Size) ?
- _db.SectorSizeBits :
+ int numBits = _db.IsLargeStream(item.Size) ?
+ _db.SectorSizeBits :
_db.MiniSectorSizeBits;
prop = (item.Size + ((UInt64)1 << numBits) - 1) >> numBits << numBits;
break;
@@ -91,7 +85,7 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
COM_TRY_END
}
-STDMETHODIMP CHandler::Open(IInStream *inStream,
+STDMETHODIMP CHandler::Open(IInStream *inStream,
const UInt64 * /* maxCheckStartPosition */,
IArchiveOpenCallback * /* openArchiveCallback */)
{
@@ -150,7 +144,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
currentItemSize = item.Size;
CMyComPtr<ISequentialOutStream> realOutStream;
- Int32 askMode = testMode ?
+ Int32 askMode = testMode ?
NArchive::NExtract::NAskMode::kTest :
NArchive::NExtract::NAskMode::kExtract;
RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
@@ -204,7 +198,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
if (fid >= _db.NumSectorsInMiniStream)
break;
size = 1 << _db.MiniSectorSizeBits;
- offset = (((UInt64)_db.MiniSids[fid] + 1) << _db.SectorSizeBits) +
+ offset = (((UInt64)_db.MiniSids[fid] + 1) << _db.SectorSizeBits) +
((sid & ((1 << subBits) - 1)) << _db.MiniSectorSizeBits);
if (sid >= _db.MatSize)
break;
diff --git a/CPP/7zip/Archive/Com/ComHandler.h b/CPP/7zip/Archive/Com/ComHandler.h
index f8b2b135..89bc98d0 100755
--- a/CPP/7zip/Archive/Com/ComHandler.h
+++ b/CPP/7zip/Archive/Com/ComHandler.h
@@ -10,7 +10,7 @@
namespace NArchive {
namespace NCom {
-class CHandler:
+class CHandler:
public IInArchive,
public CMyUnknownImp
{
diff --git a/CPP/7zip/Archive/Com/ComIn.cpp b/CPP/7zip/Archive/Com/ComIn.cpp
index b8dfdb81..74e601c1 100755
--- a/CPP/7zip/Archive/Com/ComIn.cpp
+++ b/CPP/7zip/Archive/Com/ComIn.cpp
@@ -2,8 +2,8 @@
#include "StdAfx.h"
-extern "C"
-{
+extern "C"
+{
#include "../../../../C/Alloc.h"
}
@@ -69,8 +69,8 @@ static void ReadItem(Byte *p, CItem &item, bool mode64bit)
item.RightDid = GetUi32(p + 72);
item.SonDid = GetUi32(p + 76);
// item.Flags = GetUi32(p + 96);
- GetFileTimeFromMem(p + 100, &item.CreationTime);
- GetFileTimeFromMem(p + 108, &item.LastWriteTime);
+ GetFileTimeFromMem(p + 100, &item.CTime);
+ GetFileTimeFromMem(p + 108, &item.MTime);
item.Sid = GetUi32(p + 116);
item.Size = GetUi32(p + 120);
if (mode64bit)
@@ -127,7 +127,7 @@ static UString CompoundNameToFileName(const UString &s)
}
else
res += c;
- }
+ }
return res;
}
@@ -219,7 +219,7 @@ HRESULT OpenArchive(IInStream *inStream, CDatabase &db)
db.SectorSizeBits = sectorSizeBits;
db.MiniSectorSizeBits = miniSectorSizeBits;
- if (sectorSizeBits > 28 || miniSectorSizeBits > 28 ||
+ if (sectorSizeBits > 28 || miniSectorSizeBits > 28 ||
sectorSizeBits < 7 || miniSectorSizeBits < 2 || miniSectorSizeBits > sectorSizeBits)
return S_FALSE;
UInt32 numSectorsForFAT = GetUi32(p + 0x2C);
diff --git a/CPP/7zip/Archive/Com/ComIn.h b/CPP/7zip/Archive/Com/ComIn.h
index 683e61dc..081c6aaa 100755
--- a/CPP/7zip/Archive/Com/ComIn.h
+++ b/CPP/7zip/Archive/Com/ComIn.h
@@ -46,8 +46,8 @@ struct CItem
Byte Name[kNameSizeMax];
// UInt16 NameSize;
// UInt32 Flags;
- FILETIME CreationTime;
- FILETIME LastWriteTime;
+ FILETIME CTime;
+ FILETIME MTime;
UInt64 Size;
UInt32 LeftDid;
UInt32 RightDid;
diff --git a/CPP/7zip/Archive/Common/CoderMixer.cpp b/CPP/7zip/Archive/Common/CoderMixer.cpp
index db626fe1..a19f0457 100755
--- a/CPP/7zip/Archive/Common/CoderMixer.cpp
+++ b/CPP/7zip/Archive/Common/CoderMixer.cpp
@@ -16,4 +16,4 @@ void CCoderInfo::SetCoderInfo(const UInt64 *inSize, const UInt64 *outSize)
OutSizeValue = *outSize;
}
-}
+}
diff --git a/CPP/7zip/Archive/Common/CoderMixer2.cpp b/CPP/7zip/Archive/Common/CoderMixer2.cpp
index d11e9e60..aed94f9c 100755
--- a/CPP/7zip/Archive/Common/CoderMixer2.cpp
+++ b/CPP/7zip/Archive/Common/CoderMixer2.cpp
@@ -81,7 +81,7 @@ void CBindReverseConverter::CreateReverseBindInfo(CBindInfo &destBindInfo)
destBindInfo.InStreams.Add(_srcOutToDestInMap[_srcBindInfo.OutStreams[i]]);
}
-CCoderInfo2::CCoderInfo2(UInt32 numInStreams, UInt32 numOutStreams):
+CCoderInfo2::CCoderInfo2(UInt32 numInStreams, UInt32 numOutStreams):
NumInStreams(numInStreams),
NumOutStreams(numOutStreams)
{
@@ -91,7 +91,7 @@ CCoderInfo2::CCoderInfo2(UInt32 numInStreams, UInt32 numOutStreams):
OutSizePointers.Reserve(NumOutStreams);
}
-static void SetSizes(const UInt64 **srcSizes, CRecordVector<UInt64> &sizes,
+static void SetSizes(const UInt64 **srcSizes, CRecordVector<UInt64> &sizes,
CRecordVector<const UInt64 *> &sizePointers, UInt32 numItems)
{
sizes.Clear();
@@ -118,4 +118,4 @@ void CCoderInfo2::SetCoderInfo(const UInt64 **inSizes,
SetSizes(outSizes, OutSizes, OutSizePointers, NumOutStreams);
}
-}
+}
diff --git a/CPP/7zip/Archive/Common/CoderMixer2.h b/CPP/7zip/Archive/Common/CoderMixer2.h
index be68c680..a03722d6 100755
--- a/CPP/7zip/Archive/Common/CoderMixer2.h
+++ b/CPP/7zip/Archive/Common/CoderMixer2.h
@@ -92,7 +92,7 @@ struct CBindInfo
}
- void FindInStream(UInt32 streamIndex, UInt32 &coderIndex,
+ void FindInStream(UInt32 streamIndex, UInt32 &coderIndex,
UInt32 &coderStreamIndex) const
{
for (coderIndex = 0; coderIndex < (UInt32)Coders.Size(); coderIndex++)
@@ -107,7 +107,7 @@ struct CBindInfo
}
throw 1;
}
- void FindOutStream(UInt32 streamIndex, UInt32 &coderIndex,
+ void FindOutStream(UInt32 streamIndex, UInt32 &coderIndex,
UInt32 &coderStreamIndex) const
{
for (coderIndex = 0; coderIndex < (UInt32)Coders.Size(); coderIndex++)
diff --git a/CPP/7zip/Archive/Common/CoderMixer2MT.cpp b/CPP/7zip/Archive/Common/CoderMixer2MT.cpp
index e1030976..1265dfcd 100755
--- a/CPP/7zip/Archive/Common/CoderMixer2MT.cpp
+++ b/CPP/7zip/Archive/Common/CoderMixer2MT.cpp
@@ -6,7 +6,7 @@
namespace NCoderMixer {
-CCoder2::CCoder2(UInt32 numInStreams, UInt32 numOutStreams):
+CCoder2::CCoder2(UInt32 numInStreams, UInt32 numOutStreams):
CCoderInfo2(numInStreams, numOutStreams)
{
InStreams.Reserve(NumInStreams);
@@ -35,7 +35,7 @@ void CCoder2::Code(ICompressProgressInfo *progress)
OutStreamPointers.Add((ISequentialOutStream *)OutStreams[i]);
}
if (Coder)
- Result = Coder->Code(InStreamPointers[0], OutStreamPointers[0],
+ Result = Coder->Code(InStreamPointers[0], OutStreamPointers[0],
InSizePointers[0], OutSizePointers[0], progress);
else
Result = Coder2->Code(&InStreamPointers.Front(), &InSizePointers.Front(), NumInStreams,
@@ -49,7 +49,7 @@ void CCoder2::Code(ICompressProgressInfo *progress)
}
}
-static void SetSizes(const UInt64 **srcSizes, CRecordVector<UInt64> &sizes,
+static void SetSizes(const UInt64 **srcSizes, CRecordVector<UInt64> &sizes,
CRecordVector<const UInt64 *> &sizePointers, UInt32 numItems)
{
sizes.Clear();
@@ -80,8 +80,8 @@ void CCoder2::SetCoderInfo(const UInt64 **inSizes, const UInt64 **outSizes)
// CCoderMixer2MT
HRESULT CCoderMixer2MT::SetBindInfo(const CBindInfo &bindInfo)
-{
- _bindInfo = bindInfo;
+{
+ _bindInfo = bindInfo;
_streamBinders.Clear();
for(int i = 0; i < _bindInfo.BindPairs.Size(); i++)
{
@@ -118,7 +118,7 @@ void CCoderMixer2MT::ReInit()
}
-HRESULT CCoderMixer2MT::Init(ISequentialInStream **inStreams, ISequentialOutStream **outStreams)
+HRESULT CCoderMixer2MT::Init(ISequentialInStream **inStreams, ISequentialOutStream **outStreams)
{
/*
if (_coders.Size() != _bindInfo.Coders.Size())
@@ -176,9 +176,9 @@ HRESULT CCoderMixer2MT::ReturnIfError(HRESULT code)
}
STDMETHODIMP CCoderMixer2MT::Code(ISequentialInStream **inStreams,
- const UInt64 ** /* inSizes */,
+ const UInt64 ** /* inSizes */,
UInt32 numInStreams,
- ISequentialOutStream **outStreams,
+ ISequentialOutStream **outStreams,
const UInt64 ** /* outSizes */,
UInt32 numOutStreams,
ICompressProgressInfo *progress)
@@ -227,4 +227,4 @@ STDMETHODIMP CCoderMixer2MT::Code(ISequentialInStream **inStreams,
return S_OK;
}
-}
+}
diff --git a/CPP/7zip/Archive/Common/CoderMixer2MT.h b/CPP/7zip/Archive/Common/CoderMixer2MT.h
index 505f1a88..d1c7f4d0 100755
--- a/CPP/7zip/Archive/Common/CoderMixer2MT.h
+++ b/CPP/7zip/Archive/Common/CoderMixer2MT.h
@@ -35,7 +35,7 @@ struct CCoder2: public CCoderInfo2, public CVirtThread
{
ReInit()
for each coder
- SetCoderInfo
+ SetCoderInfo
Code
}
*/
@@ -57,9 +57,9 @@ public:
MY_UNKNOWN_IMP
STDMETHOD(Code)(ISequentialInStream **inStreams,
- const UInt64 **inSizes,
+ const UInt64 **inSizes,
UInt32 numInStreams,
- ISequentialOutStream **outStreams,
+ ISequentialOutStream **outStreams,
const UInt64 **outSizes,
UInt32 numOutStreams,
ICompressProgressInfo *progress);
diff --git a/CPP/7zip/Archive/Common/CoderMixer2ST.cpp b/CPP/7zip/Archive/Common/CoderMixer2ST.cpp
index 6bcab0dd..a59ce5fc 100755
--- a/CPP/7zip/Archive/Common/CoderMixer2ST.cpp
+++ b/CPP/7zip/Archive/Common/CoderMixer2ST.cpp
@@ -11,9 +11,9 @@ CCoderMixer2ST::CCoderMixer2ST() {}
CCoderMixer2ST::~CCoderMixer2ST(){ }
HRESULT CCoderMixer2ST::SetBindInfo(const CBindInfo &bindInfo)
-{
- _bindInfo = bindInfo;
- return S_OK;
+{
+ _bindInfo = bindInfo;
+ return S_OK;
}
void CCoderMixer2ST::AddCoderCommon(bool isMain)
@@ -37,7 +37,7 @@ void CCoderMixer2ST::AddCoder2(ICompressCoder2 *coder, bool isMain)
void CCoderMixer2ST::ReInit() { }
HRESULT CCoderMixer2ST::GetInStream(
- ISequentialInStream **inStreams, const UInt64 **inSizes,
+ ISequentialInStream **inStreams, const UInt64 **inSizes,
UInt32 streamIndex, ISequentialInStream **inStreamRes)
{
CMyComPtr<ISequentialInStream> seqInStream;
@@ -54,7 +54,7 @@ HRESULT CCoderMixer2ST::GetInStream(
return E_INVALIDARG;
UInt32 coderIndex, coderStreamIndex;
- _bindInfo.FindOutStream(_bindInfo.BindPairs[binderIndex].OutIndex,
+ _bindInfo.FindOutStream(_bindInfo.BindPairs[binderIndex].OutIndex,
coderIndex, coderStreamIndex);
CCoderInfo &coder = _coders[coderIndex];
@@ -86,7 +86,7 @@ HRESULT CCoderMixer2ST::GetInStream(
}
HRESULT CCoderMixer2ST::GetOutStream(
- ISequentialOutStream **outStreams, const UInt64 **outSizes,
+ ISequentialOutStream **outStreams, const UInt64 **outSizes,
UInt32 streamIndex, ISequentialOutStream **outStreamRes)
{
CMyComPtr<ISequentialOutStream> seqOutStream;
@@ -103,7 +103,7 @@ HRESULT CCoderMixer2ST::GetOutStream(
return E_INVALIDARG;
UInt32 coderIndex, coderStreamIndex;
- _bindInfo.FindInStream(_bindInfo.BindPairs[binderIndex].InIndex,
+ _bindInfo.FindInStream(_bindInfo.BindPairs[binderIndex].InIndex,
coderIndex, coderStreamIndex);
CCoderInfo &coder = _coders[coderIndex];
@@ -136,9 +136,9 @@ HRESULT CCoderMixer2ST::GetOutStream(
STDMETHODIMP CCoderMixer2ST::Code(ISequentialInStream **inStreams,
- const UInt64 **inSizes,
+ const UInt64 **inSizes,
UInt32 numInStreams,
- ISequentialOutStream **outStreams,
+ ISequentialOutStream **outStreams,
const UInt64 **outSizes,
UInt32 numOutStreams,
ICompressProgressInfo *progress)
@@ -216,9 +216,9 @@ STDMETHODIMP CCoderMixer2ST::Code(ISequentialInStream **inStreams,
else
{
RINOK(mainCoder.Coder2->Code(
- &seqInStreamsSpec.Front(),
+ &seqInStreamsSpec.Front(),
&mainCoder.InSizePointers.Front(), mainCoder.NumInStreams,
- &seqOutStreamsSpec.Front(),
+ &seqOutStreamsSpec.Front(),
&mainCoder.OutSizePointers.Front(), mainCoder.NumOutStreams,
progress));
}
@@ -236,4 +236,4 @@ UInt64 CCoderMixer2ST::GetWriteProcessedSize(UInt32 binderIndex) const
}
*/
-}
+}
diff --git a/CPP/7zip/Archive/Common/CoderMixer2ST.h b/CPP/7zip/Archive/Common/CoderMixer2ST.h
index ea5a53e3..a4ea7e80 100755
--- a/CPP/7zip/Archive/Common/CoderMixer2ST.h
+++ b/CPP/7zip/Archive/Common/CoderMixer2ST.h
@@ -14,13 +14,13 @@ namespace NCoderMixer2 {
// {
// AddCoder[2]()
// }
-//
+//
// for each file
// {
// ReInit()
// for each coder
// {
-// SetCoderInfo
+// SetCoderInfo
// }
// SetProgressIndex(UInt32 coderIndex);
// Code
@@ -41,16 +41,16 @@ class CCoderMixer2ST:
MY_UNKNOWN_IMP
HRESULT GetInStream(
- ISequentialInStream **inStreams, const UInt64 **inSizes,
+ ISequentialInStream **inStreams, const UInt64 **inSizes,
UInt32 streamIndex, ISequentialInStream **inStreamRes);
HRESULT GetOutStream(
- ISequentialOutStream **outStreams, const UInt64 **outSizes,
+ ISequentialOutStream **outStreams, const UInt64 **outSizes,
UInt32 streamIndex, ISequentialOutStream **outStreamRes);
public:
STDMETHOD(Code)(ISequentialInStream **inStreams,
- const UInt64 **inSizes,
+ const UInt64 **inSizes,
UInt32 numInStreams,
- ISequentialOutStream **outStreams,
+ ISequentialOutStream **outStreams,
const UInt64 **outSizes,
UInt32 numOutStreams,
ICompressProgressInfo *progress);
@@ -63,13 +63,13 @@ public:
void ReInit();
void SetCoderInfo(UInt32 coderIndex, const UInt64 **inSizes, const UInt64 **outSizes)
- {
+ {
{ _coders[coderIndex].SetCoderInfo(inSizes, outSizes); }
}
void SetProgressCoderIndex(UInt32 /*coderIndex*/)
- {
- // _progressCoderIndex = coderIndex;
+ {
+ // _progressCoderIndex = coderIndex;
}
// UInt64 GetWriteProcessedSize(UInt32 binderIndex) const;
diff --git a/CPP/7zip/Archive/Common/CoderMixerMT.cpp b/CPP/7zip/Archive/Common/CoderMixerMT.cpp
index 85cf0a52..f43d1612 100755
--- a/CPP/7zip/Archive/Common/CoderMixerMT.cpp
+++ b/CPP/7zip/Archive/Common/CoderMixerMT.cpp
@@ -10,9 +10,9 @@ void CCoder::Execute() { Code(NULL); }
void CCoder::Code(ICompressProgressInfo *progress)
{
- Result = Coder->Code(InStream, OutStream,
- InSizeAssigned ? &InSizeValue : NULL,
- OutSizeAssigned ? &OutSizeValue : NULL,
+ Result = Coder->Code(InStream, OutStream,
+ InSizeAssigned ? &InSizeValue : NULL,
+ OutSizeAssigned ? &OutSizeValue : NULL,
progress);
InStream.Release();
OutStream.Release();
@@ -39,7 +39,7 @@ HRESULT CCoderMixerMT::ReturnIfError(HRESULT code)
}
STDMETHODIMP CCoderMixerMT::Code(ISequentialInStream *inStream,
- ISequentialOutStream *outStream,
+ ISequentialOutStream *outStream,
const UInt64 * /* inSize */, const UInt64 * /* outSize */,
ICompressProgressInfo *progress)
{
@@ -96,4 +96,4 @@ STDMETHODIMP CCoderMixerMT::Code(ISequentialInStream *inStream,
return S_OK;
}
-}
+}
diff --git a/CPP/7zip/Archive/Common/CoderMixerMT.h b/CPP/7zip/Archive/Common/CoderMixerMT.h
index 6fd1ba44..c70e1829 100755
--- a/CPP/7zip/Archive/Common/CoderMixerMT.h
+++ b/CPP/7zip/Archive/Common/CoderMixerMT.h
@@ -29,7 +29,7 @@ struct CCoder: public CCoderInfo, public CVirtThread
{
ReInit()
for each coder
- SetCoderInfo
+ SetCoderInfo
Code
}
*/
@@ -48,7 +48,7 @@ public:
MY_UNKNOWN_IMP
STDMETHOD(Code)(ISequentialInStream *inStream,
- ISequentialOutStream *outStream,
+ ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress);
diff --git a/CPP/7zip/Archive/Common/CrossThreadProgress.h b/CPP/7zip/Archive/Common/CrossThreadProgress.h
index b5422a31..7e0b1053 100755
--- a/CPP/7zip/Archive/Common/CrossThreadProgress.h
+++ b/CPP/7zip/Archive/Common/CrossThreadProgress.h
@@ -7,7 +7,7 @@
#include "../../../Windows/Synchronization.h"
#include "../../../Common/MyCom.h"
-class CCrossThreadProgress:
+class CCrossThreadProgress:
public ICompressProgressInfo,
public CMyUnknownImp
{
diff --git a/CPP/7zip/Archive/Common/DummyOutStream.h b/CPP/7zip/Archive/Common/DummyOutStream.h
index d19b3111..13d5b62c 100755
--- a/CPP/7zip/Archive/Common/DummyOutStream.h
+++ b/CPP/7zip/Archive/Common/DummyOutStream.h
@@ -6,7 +6,7 @@
#include "../../IStream.h"
#include "Common/MyCom.h"
-class CDummyOutStream:
+class CDummyOutStream:
public ISequentialOutStream,
public CMyUnknownImp
{
@@ -14,6 +14,7 @@ class CDummyOutStream:
UInt64 _size;
public:
void SetStream(ISequentialOutStream *outStream) { _stream = outStream; }
+ void ReleaseStream() { _stream.Release(); }
void Init() { _size = 0; }
MY_UNKNOWN_IMP
STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
diff --git a/CPP/7zip/Archive/Common/FindSignature.cpp b/CPP/7zip/Archive/Common/FindSignature.cpp
new file mode 100755
index 00000000..15aa6cea
--- /dev/null
+++ b/CPP/7zip/Archive/Common/FindSignature.cpp
@@ -0,0 +1,62 @@
+// FindSignature.cpp
+
+#include "StdAfx.h"
+
+#include "Common/Buffer.h"
+
+#include "FindSignature.h"
+
+#include "../../Common/StreamUtils.h"
+
+HRESULT FindSignatureInStream(ISequentialInStream *stream,
+ const Byte *signature, unsigned signatureSize,
+ const UInt64 *limit, UInt64 &resPos)
+{
+ resPos = 0;
+ CByteBuffer byteBuffer2;
+ byteBuffer2.SetCapacity(signatureSize);
+ RINOK(ReadStream_FALSE(stream, byteBuffer2, signatureSize));
+
+ if (memcmp(byteBuffer2, signature, signatureSize) == 0)
+ return S_OK;
+
+ const UInt32 kBufferSize = (1 << 16);
+ CByteBuffer byteBuffer;
+ byteBuffer.SetCapacity(kBufferSize);
+ Byte *buffer = byteBuffer;
+ UInt32 numPrevBytes = signatureSize - 1;
+ memcpy(buffer, (const Byte *)byteBuffer2 + 1, numPrevBytes);
+ resPos = 1;
+ for (;;)
+ {
+ if (limit != NULL)
+ if (resPos > *limit)
+ return S_FALSE;
+ do
+ {
+ UInt32 numReadBytes = kBufferSize - numPrevBytes;
+ UInt32 processedSize;
+ RINOK(stream->Read(buffer + numPrevBytes, numReadBytes, &processedSize));
+ numPrevBytes += processedSize;
+ if (processedSize == 0)
+ return S_FALSE;
+ }
+ while (numPrevBytes < signatureSize);
+ UInt32 numTests = numPrevBytes - signatureSize + 1;
+ for (UInt32 pos = 0; pos < numTests; pos++)
+ {
+ Byte b = signature[0];
+ for (; buffer[pos] != b && pos < numTests; pos++);
+ if (pos == numTests)
+ break;
+ if (memcmp(buffer + pos, signature, signatureSize) == 0)
+ {
+ resPos += pos;
+ return S_OK;
+ }
+ }
+ resPos += numTests;
+ numPrevBytes -= numTests;
+ memmove(buffer, buffer + numTests, numPrevBytes);
+ }
+}
diff --git a/CPP/7zip/Archive/Common/FindSignature.h b/CPP/7zip/Archive/Common/FindSignature.h
new file mode 100755
index 00000000..e15af573
--- /dev/null
+++ b/CPP/7zip/Archive/Common/FindSignature.h
@@ -0,0 +1,12 @@
+// FindSignature.h
+
+#ifndef __FINDSIGNATURE_H
+#define __FINDSIGNATURE_H
+
+#include "../../IStream.h"
+
+HRESULT FindSignatureInStream(ISequentialInStream *stream,
+ const Byte *signature, unsigned signatureSize,
+ const UInt64 *limit, UInt64 &resPos);
+
+#endif
diff --git a/CPP/7zip/Archive/Common/HandlerOut.cpp b/CPP/7zip/Archive/Common/HandlerOut.cpp
index 082a484d..63899fe4 100755
--- a/CPP/7zip/Archive/Common/HandlerOut.cpp
+++ b/CPP/7zip/Archive/Common/HandlerOut.cpp
@@ -79,10 +79,10 @@ static bool AreEqual(const UString &methodName, const wchar_t *s)
{ return (methodName.CompareNoCase(s) == 0); }
static inline bool IsLZMAMethod(const UString &methodName)
-{
- return
- AreEqual(methodName, kLZMAMethodName) ||
- AreEqual(methodName, kLZMA2MethodName);
+{
+ return
+ AreEqual(methodName, kLZMAMethodName) ||
+ AreEqual(methodName, kLZMA2MethodName);
}
static inline bool IsBZip2Method(const UString &methodName)
@@ -92,10 +92,10 @@ static inline bool IsPpmdMethod(const UString &methodName)
{ return AreEqual(methodName, kPpmdMethodName); }
static inline bool IsDeflateMethod(const UString &methodName)
-{
- return
- AreEqual(methodName, kDeflateMethodName) ||
- AreEqual(methodName, kDeflate64MethodName);
+{
+ return
+ AreEqual(methodName, kDeflateMethodName) ||
+ AreEqual(methodName, kDeflate64MethodName);
}
struct CNameToPropID
@@ -105,7 +105,7 @@ struct CNameToPropID
const wchar_t *Name;
};
-CNameToPropID g_NameToPropID[] =
+CNameToPropID g_NameToPropID[] =
{
{ NCoderPropID::kOrder, VT_UI4, L"O" },
{ NCoderPropID::kPosStateBits, VT_UI4, L"PB" },
@@ -158,7 +158,7 @@ static int FindPropIdFromStringName(const UString &name)
return -1;
}
-static void SetOneMethodProp(COneMethodInfo &oneMethodInfo, PROPID propID,
+static void SetOneMethodProp(COneMethodInfo &oneMethodInfo, PROPID propID,
const NWindows::NCOM::CPropVariant &value)
{
for (int j = 0; j < oneMethodInfo.Properties.Size(); j++)
@@ -182,24 +182,24 @@ void COutHandler::SetCompressionMethod2(COneMethodInfo &oneMethodInfo
if (IsLZMAMethod(oneMethodInfo.MethodName))
{
- UInt32 dicSize =
- (level >= 9 ? kLzmaDicSizeX9 :
- (level >= 7 ? kLzmaDicSizeX7 :
- (level >= 5 ? kLzmaDicSizeX5 :
- (level >= 3 ? kLzmaDicSizeX3 :
- kLzmaDicSizeX1))));
+ UInt32 dicSize =
+ (level >= 9 ? kLzmaDicSizeX9 :
+ (level >= 7 ? kLzmaDicSizeX7 :
+ (level >= 5 ? kLzmaDicSizeX5 :
+ (level >= 3 ? kLzmaDicSizeX3 :
+ kLzmaDicSizeX1))));
- UInt32 algo =
- (level >= 5 ? kLzmaAlgoX5 :
- kLzmaAlgoX1);
+ UInt32 algo =
+ (level >= 5 ? kLzmaAlgoX5 :
+ kLzmaAlgoX1);
- UInt32 fastBytes =
- (level >= 7 ? kLzmaFastBytesX7 :
- kLzmaFastBytesX1);
+ UInt32 fastBytes =
+ (level >= 7 ? kLzmaFastBytesX7 :
+ kLzmaFastBytesX1);
- const wchar_t *matchFinder =
- (level >= 5 ? kLzmaMatchFinderX5 :
- kLzmaMatchFinderX1);
+ const wchar_t *matchFinder =
+ (level >= 5 ? kLzmaMatchFinderX5 :
+ kLzmaMatchFinderX1);
SetOneMethodProp(oneMethodInfo, NCoderPropID::kDictionarySize, dicSize);
SetOneMethodProp(oneMethodInfo, NCoderPropID::kAlgorithm, algo);
@@ -211,19 +211,19 @@ void COutHandler::SetCompressionMethod2(COneMethodInfo &oneMethodInfo
}
else if (IsDeflateMethod(oneMethodInfo.MethodName))
{
- UInt32 fastBytes =
- (level >= 9 ? kDeflateFastBytesX9 :
- (level >= 7 ? kDeflateFastBytesX7 :
+ UInt32 fastBytes =
+ (level >= 9 ? kDeflateFastBytesX9 :
+ (level >= 7 ? kDeflateFastBytesX7 :
kDeflateFastBytesX1));
- UInt32 numPasses =
- (level >= 9 ? kDeflatePassesX9 :
- (level >= 7 ? kDeflatePassesX7 :
+ UInt32 numPasses =
+ (level >= 9 ? kDeflatePassesX9 :
+ (level >= 7 ? kDeflatePassesX7 :
kDeflatePassesX1));
- UInt32 algo =
- (level >= 5 ? kDeflateAlgoX5 :
- kDeflateAlgoX1);
+ UInt32 algo =
+ (level >= 5 ? kDeflateAlgoX5 :
+ kDeflateAlgoX1);
SetOneMethodProp(oneMethodInfo, NCoderPropID::kAlgorithm, algo);
SetOneMethodProp(oneMethodInfo, NCoderPropID::kNumFastBytes, fastBytes);
@@ -231,14 +231,14 @@ void COutHandler::SetCompressionMethod2(COneMethodInfo &oneMethodInfo
}
else if (IsBZip2Method(oneMethodInfo.MethodName))
{
- UInt32 numPasses =
- (level >= 9 ? kBZip2NumPassesX9 :
- (level >= 7 ? kBZip2NumPassesX7 :
+ UInt32 numPasses =
+ (level >= 9 ? kBZip2NumPassesX9 :
+ (level >= 7 ? kBZip2NumPassesX7 :
kBZip2NumPassesX1));
- UInt32 dicSize =
- (level >= 5 ? kBZip2DicSizeX5 :
- (level >= 3 ? kBZip2DicSizeX3 :
+ UInt32 dicSize =
+ (level >= 5 ? kBZip2DicSizeX5 :
+ (level >= 3 ? kBZip2DicSizeX3 :
kBZip2DicSizeX1));
SetOneMethodProp(oneMethodInfo, NCoderPropID::kNumPasses, numPasses);
@@ -249,16 +249,16 @@ void COutHandler::SetCompressionMethod2(COneMethodInfo &oneMethodInfo
}
else if (IsPpmdMethod(oneMethodInfo.MethodName))
{
- UInt32 useMemSize =
- (level >= 9 ? kPpmdMemSizeX9 :
- (level >= 7 ? kPpmdMemSizeX7 :
- (level >= 5 ? kPpmdMemSizeX5 :
+ UInt32 useMemSize =
+ (level >= 9 ? kPpmdMemSizeX9 :
+ (level >= 7 ? kPpmdMemSizeX7 :
+ (level >= 5 ? kPpmdMemSizeX5 :
kPpmdMemSizeX1)));
- UInt32 order =
- (level >= 9 ? kPpmdOrderX9 :
- (level >= 7 ? kPpmdOrderX7 :
- (level >= 5 ? kPpmdOrderX5 :
+ UInt32 order =
+ (level >= 9 ? kPpmdOrderX9 :
+ (level >= 7 ? kPpmdOrderX7 :
+ (level >= 5 ? kPpmdOrderX5 :
kPpmdOrderX1)));
SetOneMethodProp(oneMethodInfo, NCoderPropID::kUsedMemorySize, useMemSize);
@@ -313,7 +313,7 @@ HRESULT COutHandler::SetParam(COneMethodInfo &oneMethodInfo, const UString &name
{
CProp property;
if (
- name.CompareNoCase(L"D") == 0 ||
+ name.CompareNoCase(L"D") == 0 ||
name.CompareNoCase(L"MEM") == 0)
{
UInt32 dicSize;
@@ -457,11 +457,12 @@ void COutHandler::Init()
{
_removeSfxBlock = false;
_compressHeaders = true;
+ _encryptHeadersSpecified = false;
_encryptHeaders = false;
- WriteModified = true;
- WriteCreated = false;
- WriteAccessed = false;
+ WriteCTime = false;
+ WriteATime = false;
+ WriteMTime = true;
#ifdef COMPRESS_MT
_numThreads = NWindows::NSystem::GetNumberOfProcessors();
@@ -530,12 +531,9 @@ HRESULT COutHandler::SetProperty(const wchar_t *nameSpec, const PROPVARIANT &val
#endif
return S_OK;
}
- if (name.CompareNoCase(L"RSFX") == 0)
- return SetBoolProperty(_removeSfxBlock, value);
- if (name.CompareNoCase(L"F") == 0)
- return SetBoolProperty(_autoFilter, value);
- if (name.CompareNoCase(L"HC") == 0)
- return SetBoolProperty(_compressHeaders, value);
+ if (name.CompareNoCase(L"RSFX") == 0) return SetBoolProperty(_removeSfxBlock, value);
+ if (name.CompareNoCase(L"F") == 0) return SetBoolProperty(_autoFilter, value);
+ if (name.CompareNoCase(L"HC") == 0) return SetBoolProperty(_compressHeaders, value);
if (name.CompareNoCase(L"HCF") == 0)
{
bool compressHeadersFull = true;
@@ -545,15 +543,15 @@ HRESULT COutHandler::SetProperty(const wchar_t *nameSpec, const PROPVARIANT &val
return S_OK;
}
if (name.CompareNoCase(L"HE") == 0)
- return SetBoolProperty(_encryptHeaders, value);
- if (name.CompareNoCase(L"TM") == 0)
- return SetBoolProperty(WriteModified, value);
- if (name.CompareNoCase(L"TC") == 0)
- return SetBoolProperty(WriteCreated, value);
- if (name.CompareNoCase(L"TA") == 0)
- return SetBoolProperty(WriteAccessed, value);
- if (name.CompareNoCase(L"V") == 0)
- return SetBoolProperty(_volumeMode, value);
+ {
+ RINOK(SetBoolProperty(_encryptHeaders, value));
+ _encryptHeadersSpecified = true;
+ return S_OK;
+ }
+ if (name.CompareNoCase(L"TC") == 0) return SetBoolProperty(WriteCTime, value);
+ if (name.CompareNoCase(L"TA") == 0) return SetBoolProperty(WriteATime, value);
+ if (name.CompareNoCase(L"TM") == 0) return SetBoolProperty(WriteMTime, value);
+ if (name.CompareNoCase(L"V") == 0) return SetBoolProperty(_volumeMode, value);
number = 0;
}
if (number > 10000)
@@ -623,6 +621,6 @@ HRESULT COutHandler::SetProperty(const wchar_t *nameSpec, const PROPVARIANT &val
}
}
return S_OK;
-}
+}
}
diff --git a/CPP/7zip/Archive/Common/HandlerOut.h b/CPP/7zip/Archive/Common/HandlerOut.h
index ab925cc3..b6095a6b 100755
--- a/CPP/7zip/Archive/Common/HandlerOut.h
+++ b/CPP/7zip/Archive/Common/HandlerOut.h
@@ -4,7 +4,7 @@
#define __HANDLER_OUT_H
#include "../../Common/MethodProps.h"
-#include "../../Common/CreateCoder.h"
+#include "../../../Common/MyString.h"
namespace NArchive {
@@ -31,17 +31,18 @@ public:
CObjectVector<COneMethodInfo> _methods;
bool _removeSfxBlock;
- UInt64 _numSolidFiles;
+ UInt64 _numSolidFiles;
UInt64 _numSolidBytes;
bool _numSolidBytesDefined;
bool _solidExtension;
bool _compressHeaders;
+ bool _encryptHeadersSpecified;
bool _encryptHeaders;
- bool WriteModified;
- bool WriteCreated;
- bool WriteAccessed;
+ bool WriteCTime;
+ bool WriteATime;
+ bool WriteMTime;
bool _autoFilter;
UInt32 _level;
@@ -77,8 +78,6 @@ public:
UInt32 numProcessors;
UInt32 mainDicSize;
UInt32 mainDicMethodIndex;
-
- DECL_EXTERNAL_CODECS_VARS
};
}
diff --git a/CPP/7zip/Archive/Common/InStreamWithCRC.h b/CPP/7zip/Archive/Common/InStreamWithCRC.h
index 96bea9b2..c5ada6fe 100755
--- a/CPP/7zip/Archive/Common/InStreamWithCRC.h
+++ b/CPP/7zip/Archive/Common/InStreamWithCRC.h
@@ -6,12 +6,12 @@
#include "../../../Common/MyCom.h"
#include "../../IStream.h"
-extern "C"
-{
+extern "C"
+{
#include "../../../../C/7zCrc.h"
}
-class CSequentialInStreamWithCRC:
+class CSequentialInStreamWithCRC:
public ISequentialInStream,
public CMyUnknownImp
{
@@ -38,7 +38,7 @@ public:
bool WasFinished() const { return _wasFinished; }
};
-class CInStreamWithCRC:
+class CInStreamWithCRC:
public IInStream,
public CMyUnknownImp
{
diff --git a/CPP/7zip/Archive/Common/ItemNameUtils.cpp b/CPP/7zip/Archive/Common/ItemNameUtils.cpp
index f7c3fcd9..6dfaf980 100755
--- a/CPP/7zip/Archive/Common/ItemNameUtils.cpp
+++ b/CPP/7zip/Archive/Common/ItemNameUtils.cpp
@@ -38,7 +38,7 @@ bool HasTailSlash(const AString &name, UINT codePage)
{
if (name.IsEmpty())
return false;
- LPCSTR prev =
+ LPCSTR prev =
#ifdef _WIN32
CharPrevExA((WORD)codePage, name, &name[name.Length()], 0);
#else
diff --git a/CPP/7zip/Archive/Common/MultiStream.cpp b/CPP/7zip/Archive/Common/MultiStream.cpp
index a8cb333e..cf7dc050 100755
--- a/CPP/7zip/Archive/Common/MultiStream.cpp
+++ b/CPP/7zip/Archive/Common/MultiStream.cpp
@@ -33,7 +33,7 @@ STDMETHODIMP CMultiStream::Read(void *data, UInt32 size, UInt32 *processedSize)
return S_OK;
}
-STDMETHODIMP CMultiStream::Seek(Int64 offset, UInt32 seekOrigin,
+STDMETHODIMP CMultiStream::Seek(Int64 offset, UInt32 seekOrigin,
UInt64 *newPosition)
{
UInt64 newPos;
@@ -76,7 +76,7 @@ STDMETHODIMP CMultiStream::Seek(Int64 offset, UInt32 seekOrigin,
/*
-class COutVolumeStream:
+class COutVolumeStream:
public ISequentialOutStream,
public CMyUnknownImp
{
@@ -93,9 +93,9 @@ public:
CFileItem _file;
CUpdateOptions _options;
CMyComPtr<IArchiveUpdateCallback2> VolumeCallback;
- void Init(IArchiveUpdateCallback2 *volumeCallback,
- const UString &name)
- {
+ void Init(IArchiveUpdateCallback2 *volumeCallback,
+ const UString &name)
+ {
_file.Name = name;
_file.IsStartPosDefined = true;
_file.StartPos = 0;
diff --git a/CPP/7zip/Archive/Common/MultiStream.h b/CPP/7zip/Archive/Common/MultiStream.h
index b0fe41d6..137c9400 100755
--- a/CPP/7zip/Archive/Common/MultiStream.h
+++ b/CPP/7zip/Archive/Common/MultiStream.h
@@ -7,7 +7,7 @@
#include "../../../Common/MyVector.h"
#include "../../Archive/IArchive.h"
-class CMultiStream:
+class CMultiStream:
public IInStream,
public CMyUnknownImp
{
@@ -40,7 +40,7 @@ public:
};
/*
-class COutMultiStream:
+class COutMultiStream:
public IOutStream,
public CMyUnknownImp
{
diff --git a/CPP/7zip/Archive/Common/OutStreamWithCRC.h b/CPP/7zip/Archive/Common/OutStreamWithCRC.h
index eaeecde7..32870235 100755
--- a/CPP/7zip/Archive/Common/OutStreamWithCRC.h
+++ b/CPP/7zip/Archive/Common/OutStreamWithCRC.h
@@ -6,12 +6,12 @@
#include "../../../Common/MyCom.h"
#include "../../IStream.h"
-extern "C"
-{
+extern "C"
+{
#include "../../../../C/7zCrc.h"
}
-class COutStreamWithCRC:
+class COutStreamWithCRC:
public ISequentialOutStream,
public CMyUnknownImp
{
diff --git a/CPP/7zip/Archive/Common/OutStreamWithSha1.h b/CPP/7zip/Archive/Common/OutStreamWithSha1.h
index 976b347c..6df23080 100755
--- a/CPP/7zip/Archive/Common/OutStreamWithSha1.h
+++ b/CPP/7zip/Archive/Common/OutStreamWithSha1.h
@@ -11,7 +11,7 @@
#include "../../Crypto/Hash/Sha1.h"
-class COutStreamWithSha1:
+class COutStreamWithSha1:
public ISequentialOutStream,
public CMyUnknownImp
{
diff --git a/CPP/7zip/Archive/Common/ParseProperties.cpp b/CPP/7zip/Archive/Common/ParseProperties.cpp
index 83d51241..5cd849e2 100755
--- a/CPP/7zip/Archive/Common/ParseProperties.cpp
+++ b/CPP/7zip/Archive/Common/ParseProperties.cpp
@@ -138,7 +138,7 @@ int ParseStringToUInt32(const UString &srcString, UInt32 &number)
const wchar_t *start = srcString;
const wchar_t *end;
UInt64 number64 = ConvertStringToUInt64(start, &end);
- if (number64 > 0xFFFFFFFF)
+ if (number64 > 0xFFFFFFFF)
{
number = 0;
return 0;
@@ -158,7 +158,7 @@ HRESULT ParseMtProp(const UString &name, const PROPVARIANT &prop, UInt32 default
break;
default:
{
- bool val;
+ bool val;
RINOK(SetBoolProperty(val, prop));
numThreads = (val ? defaultNumThreads : 1);
break;
diff --git a/CPP/7zip/Archive/Cpio/CpioHandler.cpp b/CPP/7zip/Archive/Cpio/CpioHandler.cpp
index e2392b86..e034c87b 100755
--- a/CPP/7zip/Archive/Cpio/CpioHandler.cpp
+++ b/CPP/7zip/Archive/Cpio/CpioHandler.cpp
@@ -27,20 +27,20 @@ namespace NArchive {
namespace NCpio {
/*
-enum // PropID
+enum
{
kpidinode = kpidUserDefined,
kpidiChkSum
};
*/
-STATPROPSTG kProps[] =
+STATPROPSTG kProps[] =
{
{ NULL, kpidPath, VT_BSTR},
- { NULL, kpidIsFolder, VT_BOOL},
+ { NULL, kpidIsDir, VT_BOOL},
{ NULL, kpidSize, VT_UI8},
- { NULL, kpidPackedSize, VT_UI8},
- { NULL, kpidLastWriteTime, VT_FILETIME},
+ { NULL, kpidPackSize, VT_UI8},
+ { NULL, kpidMTime, VT_FILETIME},
// { NULL, kpidUser, VT_BSTR},
// { NULL, kpidGroup, VT_BSTR},
// { L"inode", kpidinode, VT_UI4}
@@ -50,27 +50,28 @@ STATPROPSTG kProps[] =
IMP_IInArchive_Props
IMP_IInArchive_ArcProps_NO
-STDMETHODIMP CHandler::Open(IInStream *stream,
+STDMETHODIMP CHandler::Open(IInStream *stream,
const UInt64 * /* maxCheckStartPosition */,
- IArchiveOpenCallback *openArchiveCallback)
+ IArchiveOpenCallback *callback)
{
COM_TRY_BEGIN
// try
{
CInArchive archive;
- if (archive.Open(stream) != S_OK)
- return S_FALSE;
-
- _items.Clear();
+ UInt64 endPos = 0;
+ bool needSetTotal = true;
- if (openArchiveCallback != NULL)
+ if (callback != NULL)
{
- RINOK(openArchiveCallback->SetTotal(NULL, NULL));
- UInt64 numFiles = _items.Size();
- RINOK(openArchiveCallback->SetCompleted(&numFiles, NULL));
+ RINOK(stream->Seek(0, STREAM_SEEK_END, &endPos));
+ RINOK(stream->Seek(0, STREAM_SEEK_SET, NULL));
}
+ RINOK(archive.Open(stream));
+
+ _items.Clear();
+
for (;;)
{
CItemEx item;
@@ -84,10 +85,19 @@ STDMETHODIMP CHandler::Open(IInStream *stream,
break;
_items.Add(item);
archive.SkeepDataRecords(item.Size, item.Align);
- if (openArchiveCallback != NULL)
+ if (callback != NULL)
{
- UInt64 numFiles = _items.Size();
- RINOK(openArchiveCallback->SetCompleted(&numFiles, NULL));
+ if (needSetTotal)
+ {
+ RINOK(callback->SetTotal(NULL, &endPos));
+ needSetTotal = false;
+ }
+ if (_items.Size() % 100 == 0)
+ {
+ UInt64 numFiles = _items.Size();
+ UInt64 numBytes = item.HeaderPosition;
+ RINOK(callback->SetCompleted(&numFiles, &numBytes));
+ }
}
}
if (_items.Size() == 0)
@@ -127,17 +137,16 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
switch(propID)
{
case kpidPath:
- prop = (const wchar_t *)NItemName::GetOSName(
- MultiByteToUnicodeString(item.Name, CP_OEMCP));
+ prop = NItemName::GetOSName(MultiByteToUnicodeString(item.Name, CP_OEMCP));
break;
- case kpidIsFolder:
- prop = item.IsDirectory();
+ case kpidIsDir:
+ prop = item.IsDir();
break;
case kpidSize:
- case kpidPackedSize:
+ case kpidPackSize:
prop = (UInt64)item.Size;
break;
- case kpidLastWriteTime:
+ case kpidMTime:
{
FILETIME utcFileTime;
if (item.ModificationTime != 0)
@@ -151,12 +160,8 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
break;
}
/*
- case kpidinode:
- prop = item.inode;
- break;
- case kpidiChkSum:
- prop = item.ChkSum;
- break;
+ case kpidinode: prop = item.inode; break;
+ case kpidiChkSum: prop = item.ChkSum; break;
*/
}
prop.Detach(value);
@@ -199,14 +204,14 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
lps->InSize = lps->OutSize = currentTotalSize;
RINOK(lps->SetCur());
CMyComPtr<ISequentialOutStream> realOutStream;
- Int32 askMode = testMode ?
+ Int32 askMode = testMode ?
NArchive::NExtract::NAskMode::kTest :
NArchive::NExtract::NAskMode::kExtract;
Int32 index = allFilesMode ? i : indices[i];
const CItemEx &item = _items[index];
RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
currentItemSize = item.Size;
- if (item.IsDirectory())
+ if (item.IsDir())
{
RINOK(extractCallback->PrepareOperation(askMode));
RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK));
@@ -224,7 +229,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
streamSpec->Init(item.Size);
RINOK(copyCoder->Code(inStream, realOutStream, NULL, NULL, progress));
realOutStream.Release();
- RINOK(extractCallback->SetOperationResult((copyCoderSpec->TotalSize == item.Size) ?
+ RINOK(extractCallback->SetOperationResult((copyCoderSpec->TotalSize == item.Size) ?
NArchive::NExtract::NOperationResult::kOK:
NArchive::NExtract::NOperationResult::kDataError));
}
diff --git a/CPP/7zip/Archive/Cpio/CpioHandler.h b/CPP/7zip/Archive/Cpio/CpioHandler.h
index 3b4e7036..1993c37f 100755
--- a/CPP/7zip/Archive/Cpio/CpioHandler.h
+++ b/CPP/7zip/Archive/Cpio/CpioHandler.h
@@ -11,7 +11,7 @@
namespace NArchive {
namespace NCpio {
-class CHandler:
+class CHandler:
public IInArchive,
public CMyUnknownImp
{
diff --git a/CPP/7zip/Archive/Cpio/CpioHeader.cpp b/CPP/7zip/Archive/Cpio/CpioHeader.cpp
index 9e4d99cb..f7b5a414 100755
--- a/CPP/7zip/Archive/Cpio/CpioHeader.cpp
+++ b/CPP/7zip/Archive/Cpio/CpioHeader.cpp
@@ -8,7 +8,7 @@ namespace NArchive {
namespace NCpio {
namespace NFileHeader {
- namespace NMagic
+ namespace NMagic
{
extern const char *kMagic1 = "070701";
extern const char *kMagic2 = "070702";
diff --git a/CPP/7zip/Archive/Cpio/CpioHeader.h b/CPP/7zip/Archive/Cpio/CpioHeader.h
index 40a0014a..21afcc17 100755
--- a/CPP/7zip/Archive/Cpio/CpioHeader.h
+++ b/CPP/7zip/Archive/Cpio/CpioHeader.h
@@ -10,7 +10,7 @@ namespace NCpio {
namespace NFileHeader
{
- namespace NMagic
+ namespace NMagic
{
extern const char *kMagic1;
extern const char *kMagic2;
@@ -56,7 +56,7 @@ namespace NFileHeader
char NameSize[8]; // count includes terminating NUL in pathname
char ChkSum[8]; // 0 for "new" portable format; for CRC format the sum of all the bytes in the file
bool CheckMagic() const
- { return memcmp(Magic, NMagic::kMagic1, 6) == 0 ||
+ { return memcmp(Magic, NMagic::kMagic1, 6) == 0 ||
memcmp(Magic, NMagic::kMagic2, 6) == 0; };
};
*/
diff --git a/CPP/7zip/Archive/Cpio/CpioIn.cpp b/CPP/7zip/Archive/Cpio/CpioIn.cpp
index 4732a32e..d4d807e1 100755
--- a/CPP/7zip/Archive/Cpio/CpioIn.cpp
+++ b/CPP/7zip/Archive/Cpio/CpioIn.cpp
@@ -140,12 +140,12 @@ HRESULT CInArchive::GetNextItem(bool &filled, CItemEx &item)
UInt32 nameSize;
- bool oldBE =
+ bool oldBE =
_block[0] == NFileHeader::NMagic::kMagicForRecord2[1] &&
_block[1] == NFileHeader::NMagic::kMagicForRecord2[0];
bool binMode = (_block[0] == NFileHeader::NMagic::kMagicForRecord2[0] &&
- _block[1] == NFileHeader::NMagic::kMagicForRecord2[1]) ||
+ _block[1] == NFileHeader::NMagic::kMagicForRecord2[1]) ||
oldBE;
if (binMode)
@@ -175,7 +175,7 @@ HRESULT CInArchive::GetNextItem(bool &filled, CItemEx &item)
item.ChkSum = 0;
item.HeaderSize = GetAlignedSize(
nameSize + NFileHeader::kRecord2Size, item.Align);
- nameSize = item.HeaderSize - NFileHeader::kRecord2Size;
+ nameSize = item.HeaderSize - NFileHeader::kRecord2Size;
}
else
{
@@ -183,8 +183,8 @@ HRESULT CInArchive::GetNextItem(bool &filled, CItemEx &item)
if (processedSize != 4)
return S_FALSE;
- bool magicOK =
- memcmp(_block, NFileHeader::NMagic::kMagic1, 6) == 0 ||
+ bool magicOK =
+ memcmp(_block, NFileHeader::NMagic::kMagic1, 6) == 0 ||
memcmp(_block, NFileHeader::NMagic::kMagic2, 6) == 0;
_blockPos = 6;
if (magicOK)
@@ -211,7 +211,7 @@ HRESULT CInArchive::GetNextItem(bool &filled, CItemEx &item)
GetFromHex(item.ChkSum);
item.HeaderSize = GetAlignedSize(
nameSize + NFileHeader::kRecordSize, item.Align);
- nameSize = item.HeaderSize - NFileHeader::kRecordSize;
+ nameSize = item.HeaderSize - NFileHeader::kRecordSize;
}
else
{
@@ -237,7 +237,7 @@ HRESULT CInArchive::GetNextItem(bool &filled, CItemEx &item)
GetFromOct11(item.Size); // ?????
item.HeaderSize = GetAlignedSize(
nameSize + NFileHeader::kOctRecordSize, item.Align);
- nameSize = item.HeaderSize - NFileHeader::kOctRecordSize;
+ nameSize = item.HeaderSize - NFileHeader::kOctRecordSize;
}
}
if (nameSize == 0 || nameSize >= (1 << 27))
diff --git a/CPP/7zip/Archive/Cpio/CpioItem.h b/CPP/7zip/Archive/Cpio/CpioItem.h
index cee8b5b3..70aa384d 100755
--- a/CPP/7zip/Archive/Cpio/CpioItem.h
+++ b/CPP/7zip/Archive/Cpio/CpioItem.h
@@ -34,7 +34,7 @@ struct CItem
UInt32 Align;
- bool IsDirectory() const
+ bool IsDir() const
#ifdef _WIN32
{ return (Mode & _S_IFMT) == _S_IFDIR; }
#else
diff --git a/CPP/7zip/Archive/Cpio/StdAfx.cpp b/CPP/7zip/Archive/Cpio/StdAfx.cpp
deleted file mode 100755
index d0feea85..00000000
--- a/CPP/7zip/Archive/Cpio/StdAfx.cpp
+++ /dev/null
@@ -1,3 +0,0 @@
-// StdAfx.cpp
-
-#include "StdAfx.h"
diff --git a/CPP/7zip/Archive/Deb/DebHandler.cpp b/CPP/7zip/Archive/Deb/DebHandler.cpp
deleted file mode 100755
index 19cf310b..00000000
--- a/CPP/7zip/Archive/Deb/DebHandler.cpp
+++ /dev/null
@@ -1,202 +0,0 @@
-// DebHandler.cpp
-
-#include "StdAfx.h"
-
-#include "DebHandler.h"
-#include "DebIn.h"
-
-#include "Common/Defs.h"
-#include "Common/StringConvert.h"
-#include "Common/NewHandler.h"
-#include "Common/ComTry.h"
-
-#include "Windows/Time.h"
-#include "Windows/PropVariant.h"
-
-#include "../../Common/ProgressUtils.h"
-#include "../../Common/LimitedStreams.h"
-
-#include "../../Compress/Copy/CopyCoder.h"
-
-#include "../Common/ItemNameUtils.h"
-
-using namespace NWindows;
-using namespace NTime;
-
-namespace NArchive {
-namespace NDeb {
-
-STATPROPSTG kProps[] =
-{
- { NULL, kpidPath, VT_BSTR},
- { NULL, kpidSize, VT_UI8},
- { NULL, kpidPackedSize, VT_UI8},
- { NULL, kpidLastWriteTime, VT_FILETIME}
-};
-
-IMP_IInArchive_Props
-IMP_IInArchive_ArcProps_NO
-
-STDMETHODIMP CHandler::Open(IInStream *stream,
- const UInt64 * /* maxCheckStartPosition */,
- IArchiveOpenCallback *openArchiveCallback)
-{
- COM_TRY_BEGIN
- {
- CInArchive archive;
- if(archive.Open(stream) != S_OK)
- return S_FALSE;
- _items.Clear();
-
- if (openArchiveCallback != NULL)
- {
- RINOK(openArchiveCallback->SetTotal(NULL, NULL));
- UInt64 numFiles = _items.Size();
- RINOK(openArchiveCallback->SetCompleted(&numFiles, NULL));
- }
-
- for (;;)
- {
- CItemEx item;
- bool filled;
- HRESULT result = archive.GetNextItem(filled, item);
- if (result == S_FALSE)
- return S_FALSE;
- if (result != S_OK)
- return S_FALSE;
- if (!filled)
- break;
- _items.Add(item);
- archive.SkeepData(item.Size);
- if (openArchiveCallback != NULL)
- {
- UInt64 numFiles = _items.Size();
- RINOK(openArchiveCallback->SetCompleted(&numFiles, NULL));
- }
- }
- _inStream = stream;
- }
- return S_OK;
- COM_TRY_END
-}
-
-STDMETHODIMP CHandler::Close()
-{
- _inStream.Release();
- _items.Clear();
- return S_OK;
-}
-
-STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
-{
- *numItems = _items.Size();
- return S_OK;
-}
-
-STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
-{
- COM_TRY_BEGIN
- NWindows::NCOM::CPropVariant prop;
- const CItemEx &item = _items[index];
-
- switch(propID)
- {
- case kpidPath:
- prop = (const wchar_t *)NItemName::GetOSName2(
- MultiByteToUnicodeString(item.Name, CP_OEMCP));
- break;
- case kpidIsFolder:
- prop = false;
- break;
- case kpidSize:
- case kpidPackedSize:
- prop = item.Size;
- break;
- case kpidLastWriteTime:
- {
- FILETIME utcFileTime;
- if (item.ModificationTime != 0)
- NTime::UnixTimeToFileTime(item.ModificationTime, utcFileTime);
- else
- {
- utcFileTime.dwLowDateTime = 0;
- utcFileTime.dwHighDateTime = 0;
- }
- prop = utcFileTime;
- break;
- }
- }
- prop.Detach(value);
- return S_OK;
- COM_TRY_END
-}
-
-STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
- Int32 _aTestMode, IArchiveExtractCallback *extractCallback)
-{
- COM_TRY_BEGIN
- bool testMode = (_aTestMode != 0);
- bool allFilesMode = (numItems == UInt32(-1));
- if (allFilesMode)
- numItems = _items.Size();
- if (numItems == 0)
- return S_OK;
- UInt64 totalSize = 0;
- UInt32 i;
- for (i = 0; i < numItems; i++)
- totalSize += _items[allFilesMode ? i : indices[i]].Size;
- extractCallback->SetTotal(totalSize);
-
- UInt64 currentTotalSize = 0;
- UInt64 currentItemSize;
-
- NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder();
- CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;
-
- CLocalProgress *lps = new CLocalProgress;
- CMyComPtr<ICompressProgressInfo> progress = lps;
- lps->Init(extractCallback, false);
-
- CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
- CMyComPtr<ISequentialInStream> inStream(streamSpec);
- streamSpec->SetStream(_inStream);
-
- for (i = 0; i < numItems; i++, currentTotalSize += currentItemSize)
- {
- lps->InSize = lps->OutSize = currentTotalSize;
- RINOK(lps->SetCur());
- CMyComPtr<ISequentialOutStream> realOutStream;
- Int32 askMode = testMode ?
- NArchive::NExtract::NAskMode::kTest :
- NArchive::NExtract::NAskMode::kExtract;
- Int32 index = allFilesMode ? i : indices[i];
- const CItemEx &item = _items[index];
- RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
- currentItemSize = item.Size;
-
-
-
-
-
-
- if (!testMode && (!realOutStream))
- continue;
- RINOK(extractCallback->PrepareOperation(askMode));
- if (testMode)
- {
- RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK));
- continue;
- }
- RINOK(_inStream->Seek(item.GetDataPosition(), STREAM_SEEK_SET, NULL));
- streamSpec->Init(item.Size);
- RINOK(copyCoder->Code(inStream, realOutStream, NULL, NULL, progress));
- realOutStream.Release();
- RINOK(extractCallback->SetOperationResult((copyCoderSpec->TotalSize == item.Size) ?
- NArchive::NExtract::NOperationResult::kOK:
- NArchive::NExtract::NOperationResult::kDataError));
- }
- return S_OK;
- COM_TRY_END
-}
-
-}}
diff --git a/CPP/7zip/Archive/Deb/DebHeader.cpp b/CPP/7zip/Archive/Deb/DebHeader.cpp
deleted file mode 100755
index dce00e1b..00000000
--- a/CPP/7zip/Archive/Deb/DebHeader.cpp
+++ /dev/null
@@ -1,13 +0,0 @@
-// Archive/Deb/Header.h
-
-#include "StdAfx.h"
-
-#include "DebHeader.h"
-
-namespace NArchive {
-namespace NDeb {
-namespace NHeader {
-
-const char *kSignature = "!<arch>\n";
-
-}}}
diff --git a/CPP/7zip/Archive/Deb/DebHeader.h b/CPP/7zip/Archive/Deb/DebHeader.h
deleted file mode 100755
index c2884000..00000000
--- a/CPP/7zip/Archive/Deb/DebHeader.h
+++ /dev/null
@@ -1,38 +0,0 @@
-// Archive/Deb/Header.h
-
-#ifndef __ARCHIVE_DEB_HEADER_H
-#define __ARCHIVE_DEB_HEADER_H
-
-#include "Common/Types.h"
-
-namespace NArchive {
-namespace NDeb {
-
-namespace NHeader
-{
- const int kSignatureLen = 8;
- extern const char *kSignature;
- const int kNameSize = 16;
- const int kTimeSize = 12;
- const int kModeSize = 8;
- const int kSizeSize = 10;
-
- /*
- struct CHeader
- {
- char Name[kNameSize];
- char ModificationTime[kTimeSize];
- char Number0[6];
- char Number1[6];
- char Mode[kModeSize];
- char Size[kSizeSize];
- char Quote;
- char NewLine;
- };
- */
- const int kHeaderSize = kNameSize + kTimeSize + 6 + 6 + kModeSize + kSizeSize + 1 + 1;
-}
-
-}}
-
-#endif
diff --git a/CPP/7zip/Archive/Deb/DebIn.cpp b/CPP/7zip/Archive/Deb/DebIn.cpp
deleted file mode 100755
index 41aaeb8a..00000000
--- a/CPP/7zip/Archive/Deb/DebIn.cpp
+++ /dev/null
@@ -1,156 +0,0 @@
-// Archive/DebIn.cpp
-
-#include "StdAfx.h"
-
-#include "DebIn.h"
-#include "DebHeader.h"
-
-#include "Common/StringToInt.h"
-#include "Windows/Defs.h"
-
-#include "../../Common/StreamUtils.h"
-
-namespace NArchive {
-namespace NDeb {
-
-using namespace NHeader;
-
-HRESULT CInArchive::Open(IInStream *inStream)
-{
- RINOK(inStream->Seek(0, STREAM_SEEK_CUR, &m_Position));
- char signature[kSignatureLen];
- RINOK(ReadStream_FALSE(inStream, signature, kSignatureLen));
- m_Position += kSignatureLen;
- if (memcmp(signature, kSignature, kSignatureLen) != 0)
- return S_FALSE;
- m_Stream = inStream;
- return S_OK;
-}
-
-static void MyStrNCpy(char *dest, const char *src, int size)
-{
- for (int i = 0; i < size; i++)
- {
- char c = src[i];
- dest[i] = c;
- if (c == 0)
- break;
- }
-}
-
-static bool OctalToNumber(const char *s, int size, UInt64 &res)
-{
- char sz[32];
- MyStrNCpy(sz, s, size);
- sz[size] = 0;
- const char *end;
- int i;
- for (i = 0; sz[i] == ' '; i++);
- res = ConvertOctStringToUInt64(sz + i, &end);
- return (*end == ' ' || *end == 0);
-}
-
-static bool OctalToNumber32(const char *s, int size, UInt32 &res)
-{
- UInt64 res64;
- if (!OctalToNumber(s, size, res64))
- return false;
- res = (UInt32)res64;
- return (res64 <= 0xFFFFFFFF);
-}
-
-static bool DecimalToNumber(const char *s, int size, UInt64 &res)
-{
- char sz[32];
- MyStrNCpy(sz, s, size);
- sz[size] = 0;
- const char *end;
- int i;
- for (i = 0; sz[i] == ' '; i++);
- res = ConvertStringToUInt64(sz + i, &end);
- return (*end == ' ' || *end == 0);
-}
-
-static bool DecimalToNumber32(const char *s, int size, UInt32 &res)
-{
- UInt64 res64;
- if (!DecimalToNumber(s, size, res64))
- return false;
- res = (UInt32)res64;
- return (res64 <= 0xFFFFFFFF);
-}
-
-#define RIF(x) { if (!(x)) return S_FALSE; }
-
-
-HRESULT CInArchive::GetNextItemReal(bool &filled, CItemEx &item)
-{
- filled = false;
-
- char header[NHeader::kHeaderSize];
- const char *cur = header;
-
- size_t processedSize = sizeof(header);
- item.HeaderPosition = m_Position;
- RINOK(ReadStream(m_Stream, header, &processedSize));
- m_Position += processedSize;
- if (processedSize != sizeof(header))
- return S_OK;
-
- char tempString[kNameSize + 1];
- MyStrNCpy(tempString, cur, kNameSize);
- cur += kNameSize;
- tempString[kNameSize] = '\0';
- item.Name = tempString;
- item.Name.Trim();
-
- for (int i = 0; i < item.Name.Length(); i++)
- if (((Byte)item.Name[i]) < 0x20)
- return S_FALSE;
-
- RIF(DecimalToNumber32(cur, kTimeSize, item.ModificationTime));
- cur += kTimeSize;
-
- cur += 6 + 6;
-
- RIF(OctalToNumber32(cur, kModeSize, item.Mode));
- cur += kModeSize;
-
- RIF(DecimalToNumber(cur, kSizeSize, item.Size));
- cur += kSizeSize;
-
- filled = true;
- return S_OK;
-}
-
-HRESULT CInArchive::GetNextItem(bool &filled, CItemEx &item)
-{
- for (;;)
- {
- RINOK(GetNextItemReal(filled, item));
- if (!filled)
- return S_OK;
- if (item.Name.CompareNoCase("debian-binary") != 0)
- return S_OK;
- if (item.Size != 4)
- return S_OK;
- SkeepData(item.Size);
- }
-}
-
-HRESULT CInArchive::Skeep(UInt64 numBytes)
-{
- UInt64 newPostion;
- RINOK(m_Stream->Seek(numBytes, STREAM_SEEK_CUR, &newPostion));
- m_Position += numBytes;
- if (m_Position != newPostion)
- return E_FAIL;
- return S_OK;
-}
-
-HRESULT CInArchive::SkeepData(UInt64 dataSize)
-{
- return Skeep((dataSize + 1) & (~((UInt64)0x1)));
-}
-
-}}
diff --git a/CPP/7zip/Archive/Deb/DebIn.h b/CPP/7zip/Archive/Deb/DebIn.h
deleted file mode 100755
index 7d33fa59..00000000
--- a/CPP/7zip/Archive/Deb/DebIn.h
+++ /dev/null
@@ -1,28 +0,0 @@
-// Archive/DebIn.h
-
-#ifndef __ARCHIVE_DEB_IN_H
-#define __ARCHIVE_DEB_IN_H
-
-#include "Common/MyCom.h"
-#include "../../IStream.h"
-#include "DebItem.h"
-
-namespace NArchive {
-namespace NDeb {
-
-class CInArchive
-{
- CMyComPtr<IInStream> m_Stream;
- UInt64 m_Position;
-
- HRESULT GetNextItemReal(bool &filled, CItemEx &itemInfo);
- HRESULT Skeep(UInt64 numBytes);
-public:
- HRESULT Open(IInStream *inStream);
- HRESULT GetNextItem(bool &filled, CItemEx &itemInfo);
- HRESULT SkeepData(UInt64 dataSize);
-};
-
-}}
-
-#endif
diff --git a/CPP/7zip/Archive/Deb/DebItem.h b/CPP/7zip/Archive/Deb/DebItem.h
deleted file mode 100755
index 86e6740d..00000000
--- a/CPP/7zip/Archive/Deb/DebItem.h
+++ /dev/null
@@ -1,32 +0,0 @@
-// Archive/Deb/ItemInfo.h
-
-#ifndef __ARCHIVE_DEB_ITEMINFO_H
-#define __ARCHIVE_DEB_ITEMINFO_H
-
-#include "Common/Types.h"
-#include "Common/MyString.h"
-#include "DebHeader.h"
-
-namespace NArchive {
-namespace NDeb {
-
-class CItem
-{
-public:
- AString Name;
- UInt64 Size;
- UInt32 ModificationTime;
- UInt32 Mode;
-};
-
-class CItemEx: public CItem
-{
-public:
- UInt64 HeaderPosition;
- UInt64 GetDataPosition() const { return HeaderPosition + NHeader::kHeaderSize; };
- // UInt64 GetFullSize() const { return NFileHeader::kRecordSize + Size; };
-};
-
-}}
-
-#endif
diff --git a/CPP/7zip/Archive/Deb/DebRegister.cpp b/CPP/7zip/Archive/Deb/DebRegister.cpp
deleted file mode 100755
index 35c4965e..00000000
--- a/CPP/7zip/Archive/Deb/DebRegister.cpp
+++ /dev/null
@@ -1,13 +0,0 @@
-// DebRegister.cpp
-
-#include "StdAfx.h"
-
-#include "../../Common/RegisterArc.h"
-
-#include "DebHandler.h"
-static IInArchive *CreateArc() { return new NArchive::NDeb::CHandler; }
-
-static CArcInfo g_ArcInfo =
- { L"Deb", L"deb", 0, 0xEC, { '!', '<', 'a', 'r', 'c', 'h', '>', '\n' }, 8, false, CreateArc, 0 };
-
-REGISTER_ARC(Deb)
diff --git a/CPP/7zip/Archive/Deb/StdAfx.cpp b/CPP/7zip/Archive/Deb/StdAfx.cpp
deleted file mode 100755
index d0feea85..00000000
--- a/CPP/7zip/Archive/Deb/StdAfx.cpp
+++ /dev/null
@@ -1,3 +0,0 @@
-// StdAfx.cpp
-
-#include "StdAfx.h"
diff --git a/CPP/7zip/Archive/Deb/StdAfx.h b/CPP/7zip/Archive/Deb/StdAfx.h
deleted file mode 100755
index e7fb6986..00000000
--- a/CPP/7zip/Archive/Deb/StdAfx.h
+++ /dev/null
@@ -1,8 +0,0 @@
-// StdAfx.h
-
-#ifndef __STDAFX_H
-#define __STDAFX_H
-
-#include "../../../Common/MyWindows.h"
-
-#endif
diff --git a/CPP/7zip/Archive/DebHandler.cpp b/CPP/7zip/Archive/DebHandler.cpp
new file mode 100755
index 00000000..9bac2b7d
--- /dev/null
+++ b/CPP/7zip/Archive/DebHandler.cpp
@@ -0,0 +1,411 @@
+// DebHandler.cpp
+
+#include "StdAfx.h"
+
+#include "Common/ComTry.h"
+#include "Common/Defs.h"
+#include "Common/NewHandler.h"
+#include "Common/StringConvert.h"
+#include "Common/StringToInt.h"
+
+#include "Windows/PropVariant.h"
+#include "Windows/Time.h"
+
+#include "../Common/LimitedStreams.h"
+#include "../Common/ProgressUtils.h"
+#include "../Common/RegisterArc.h"
+#include "../Common/StreamUtils.h"
+
+#include "../Compress/Copy/CopyCoder.h"
+
+#include "Common/ItemNameUtils.h"
+
+using namespace NWindows;
+using namespace NTime;
+
+namespace NArchive {
+namespace NDeb {
+
+namespace NHeader
+{
+ const int kSignatureLen = 8;
+
+ const char *kSignature = "!<arch>\n";
+
+ const int kNameSize = 16;
+ const int kTimeSize = 12;
+ const int kModeSize = 8;
+ const int kSizeSize = 10;
+
+ /*
+ struct CHeader
+ {
+ char Name[kNameSize];
+ char MTime[kTimeSize];
+ char Number0[6];
+ char Number1[6];
+ char Mode[kModeSize];
+ char Size[kSizeSize];
+ char Quote;
+ char NewLine;
+ };
+ */
+ const int kHeaderSize = kNameSize + kTimeSize + 6 + 6 + kModeSize + kSizeSize + 1 + 1;
+}
+
+class CItem
+{
+public:
+ AString Name;
+ UInt64 Size;
+ UInt32 MTime;
+ UInt32 Mode;
+};
+
+class CItemEx: public CItem
+{
+public:
+ UInt64 HeaderPosition;
+ UInt64 GetDataPosition() const { return HeaderPosition + NHeader::kHeaderSize; };
+ // UInt64 GetFullSize() const { return NFileHeader::kRecordSize + Size; };
+};
+
+class CInArchive
+{
+ CMyComPtr<IInStream> m_Stream;
+ UInt64 m_Position;
+
+ HRESULT GetNextItemReal(bool &filled, CItemEx &itemInfo);
+ HRESULT Skeep(UInt64 numBytes);
+public:
+ HRESULT Open(IInStream *inStream);
+ HRESULT GetNextItem(bool &filled, CItemEx &itemInfo);
+ HRESULT SkeepData(UInt64 dataSize);
+};
+
+HRESULT CInArchive::Open(IInStream *inStream)
+{
+ RINOK(inStream->Seek(0, STREAM_SEEK_CUR, &m_Position));
+ char signature[NHeader::kSignatureLen];
+ RINOK(ReadStream_FALSE(inStream, signature, NHeader::kSignatureLen));
+ m_Position += NHeader::kSignatureLen;
+ if (memcmp(signature, NHeader::kSignature, NHeader::kSignatureLen) != 0)
+ return S_FALSE;
+ m_Stream = inStream;
+ return S_OK;
+}
+
+static void MyStrNCpy(char *dest, const char *src, int size)
+{
+ for (int i = 0; i < size; i++)
+ {
+ char c = src[i];
+ dest[i] = c;
+ if (c == 0)
+ break;
+ }
+}
+
+static bool OctalToNumber(const char *s, int size, UInt64 &res)
+{
+ char sz[32];
+ MyStrNCpy(sz, s, size);
+ sz[size] = 0;
+ const char *end;
+ int i;
+ for (i = 0; sz[i] == ' '; i++);
+ res = ConvertOctStringToUInt64(sz + i, &end);
+ return (*end == ' ' || *end == 0);
+}
+
+static bool OctalToNumber32(const char *s, int size, UInt32 &res)
+{
+ UInt64 res64;
+ if (!OctalToNumber(s, size, res64))
+ return false;
+ res = (UInt32)res64;
+ return (res64 <= 0xFFFFFFFF);
+}
+
+static bool DecimalToNumber(const char *s, int size, UInt64 &res)
+{
+ char sz[32];
+ MyStrNCpy(sz, s, size);
+ sz[size] = 0;
+ const char *end;
+ int i;
+ for (i = 0; sz[i] == ' '; i++);
+ res = ConvertStringToUInt64(sz + i, &end);
+ return (*end == ' ' || *end == 0);
+}
+
+static bool DecimalToNumber32(const char *s, int size, UInt32 &res)
+{
+ UInt64 res64;
+ if (!DecimalToNumber(s, size, res64))
+ return false;
+ res = (UInt32)res64;
+ return (res64 <= 0xFFFFFFFF);
+}
+
+#define RIF(x) { if (!(x)) return S_FALSE; }
+
+
+HRESULT CInArchive::GetNextItemReal(bool &filled, CItemEx &item)
+{
+ filled = false;
+
+ char header[NHeader::kHeaderSize];
+ const char *cur = header;
+
+ size_t processedSize = sizeof(header);
+ item.HeaderPosition = m_Position;
+ RINOK(ReadStream(m_Stream, header, &processedSize));
+ m_Position += processedSize;
+ if (processedSize != sizeof(header))
+ return S_OK;
+
+ char tempString[NHeader::kNameSize + 1];
+ MyStrNCpy(tempString, cur, NHeader::kNameSize);
+ cur += NHeader::kNameSize;
+ tempString[NHeader::kNameSize] = '\0';
+ item.Name = tempString;
+ item.Name.Trim();
+
+ for (int i = 0; i < item.Name.Length(); i++)
+ if (((Byte)item.Name[i]) < 0x20)
+ return S_FALSE;
+
+ RIF(DecimalToNumber32(cur, NHeader::kTimeSize, item.MTime));
+ cur += NHeader::kTimeSize;
+
+ cur += 6 + 6;
+
+ RIF(OctalToNumber32(cur, NHeader::kModeSize, item.Mode));
+ cur += NHeader::kModeSize;
+
+ RIF(DecimalToNumber(cur, NHeader::kSizeSize, item.Size));
+ cur += NHeader::kSizeSize;
+
+ filled = true;
+ return S_OK;
+}
+
+HRESULT CInArchive::GetNextItem(bool &filled, CItemEx &item)
+{
+ for (;;)
+ {
+ RINOK(GetNextItemReal(filled, item));
+ if (!filled)
+ return S_OK;
+ if (item.Name.CompareNoCase("debian-binary") != 0)
+ return S_OK;
+ if (item.Size != 4)
+ return S_OK;
+ SkeepData(item.Size);
+ }
+}
+
+HRESULT CInArchive::Skeep(UInt64 numBytes)
+{
+ UInt64 newPostion;
+ RINOK(m_Stream->Seek(numBytes, STREAM_SEEK_CUR, &newPostion));
+ m_Position += numBytes;
+ if (m_Position != newPostion)
+ return E_FAIL;
+ return S_OK;
+}
+
+HRESULT CInArchive::SkeepData(UInt64 dataSize)
+{
+ return Skeep((dataSize + 1) & (~((UInt64)0x1)));
+}
+
+
+class CHandler:
+ public IInArchive,
+ public CMyUnknownImp
+{
+public:
+ MY_UNKNOWN_IMP1(IInArchive)
+
+ INTERFACE_IInArchive(;)
+
+private:
+ CObjectVector<CItemEx> _items;
+ CMyComPtr<IInStream> _inStream;
+};
+
+
+STATPROPSTG kProps[] =
+{
+ { NULL, kpidPath, VT_BSTR},
+ { NULL, kpidSize, VT_UI8},
+ { NULL, kpidPackSize, VT_UI8},
+ { NULL, kpidMTime, VT_FILETIME}
+};
+
+IMP_IInArchive_Props
+IMP_IInArchive_ArcProps_NO
+
+STDMETHODIMP CHandler::Open(IInStream *stream,
+ const UInt64 * /* maxCheckStartPosition */,
+ IArchiveOpenCallback *openArchiveCallback)
+{
+ COM_TRY_BEGIN
+ {
+ CInArchive archive;
+ if(archive.Open(stream) != S_OK)
+ return S_FALSE;
+ _items.Clear();
+
+ if (openArchiveCallback != NULL)
+ {
+ RINOK(openArchiveCallback->SetTotal(NULL, NULL));
+ UInt64 numFiles = _items.Size();
+ RINOK(openArchiveCallback->SetCompleted(&numFiles, NULL));
+ }
+
+ for (;;)
+ {
+ CItemEx item;
+ bool filled;
+ HRESULT result = archive.GetNextItem(filled, item);
+ if (result == S_FALSE)
+ return S_FALSE;
+ if (result != S_OK)
+ return S_FALSE;
+ if (!filled)
+ break;
+ _items.Add(item);
+ archive.SkeepData(item.Size);
+ if (openArchiveCallback != NULL)
+ {
+ UInt64 numFiles = _items.Size();
+ RINOK(openArchiveCallback->SetCompleted(&numFiles, NULL));
+ }
+ }
+ _inStream = stream;
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Close()
+{
+ _inStream.Release();
+ _items.Clear();
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
+{
+ *numItems = _items.Size();
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NWindows::NCOM::CPropVariant prop;
+ const CItemEx &item = _items[index];
+
+ switch(propID)
+ {
+ case kpidPath: prop = (const wchar_t *)NItemName::GetOSName2(MultiByteToUnicodeString(item.Name, CP_OEMCP)); break;
+ case kpidSize:
+ case kpidPackSize:
+ prop = item.Size;
+ break;
+ case kpidMTime:
+ {
+ if (item.MTime != 0)
+ {
+ FILETIME fileTime;
+ NTime::UnixTimeToFileTime(item.MTime, fileTime);
+ prop = fileTime;
+ }
+ break;
+ }
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
+ Int32 _aTestMode, IArchiveExtractCallback *extractCallback)
+{
+ COM_TRY_BEGIN
+ bool testMode = (_aTestMode != 0);
+ bool allFilesMode = (numItems == UInt32(-1));
+ if (allFilesMode)
+ numItems = _items.Size();
+ if (numItems == 0)
+ return S_OK;
+ UInt64 totalSize = 0;
+ UInt32 i;
+ for (i = 0; i < numItems; i++)
+ totalSize += _items[allFilesMode ? i : indices[i]].Size;
+ extractCallback->SetTotal(totalSize);
+
+ UInt64 currentTotalSize = 0;
+ UInt64 currentItemSize;
+
+ NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder();
+ CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;
+
+ CLocalProgress *lps = new CLocalProgress;
+ CMyComPtr<ICompressProgressInfo> progress = lps;
+ lps->Init(extractCallback, false);
+
+ CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
+ CMyComPtr<ISequentialInStream> inStream(streamSpec);
+ streamSpec->SetStream(_inStream);
+
+ for (i = 0; i < numItems; i++, currentTotalSize += currentItemSize)
+ {
+ lps->InSize = lps->OutSize = currentTotalSize;
+ RINOK(lps->SetCur());
+ CMyComPtr<ISequentialOutStream> realOutStream;
+ Int32 askMode = testMode ?
+ NArchive::NExtract::NAskMode::kTest :
+ NArchive::NExtract::NAskMode::kExtract;
+ Int32 index = allFilesMode ? i : indices[i];
+ const CItemEx &item = _items[index];
+ RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
+ currentItemSize = item.Size;
+
+
+
+
+
+
+ if (!testMode && (!realOutStream))
+ continue;
+ RINOK(extractCallback->PrepareOperation(askMode));
+ if (testMode)
+ {
+ RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK));
+ continue;
+ }
+ RINOK(_inStream->Seek(item.GetDataPosition(), STREAM_SEEK_SET, NULL));
+ streamSpec->Init(item.Size);
+ RINOK(copyCoder->Code(inStream, realOutStream, NULL, NULL, progress));
+ realOutStream.Release();
+ RINOK(extractCallback->SetOperationResult((copyCoderSpec->TotalSize == item.Size) ?
+ NArchive::NExtract::NOperationResult::kOK:
+ NArchive::NExtract::NOperationResult::kDataError));
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+static IInArchive *CreateArc() { return new NArchive::NDeb::CHandler; }
+
+static CArcInfo g_ArcInfo =
+ { L"Deb", L"deb", 0, 0xEC, { '!', '<', 'a', 'r', 'c', 'h', '>', '\n' }, 8, false, CreateArc, 0 };
+
+REGISTER_ARC(Deb)
+
+}}
diff --git a/CPP/7zip/Archive/DllExports.cpp b/CPP/7zip/Archive/DllExports.cpp
index dae2698f..ccad2126 100755
--- a/CPP/7zip/Archive/DllExports.cpp
+++ b/CPP/7zip/Archive/DllExports.cpp
@@ -18,7 +18,7 @@ static bool IsItWindowsNT()
{
OSVERSIONINFO versionInfo;
versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
- if (!::GetVersionEx(&versionInfo))
+ if (!::GetVersionEx(&versionInfo))
return false;
return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
}
@@ -37,7 +37,7 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
return TRUE;
}
-DEFINE_GUID(CLSID_CArchiveHandler,
+DEFINE_GUID(CLSID_CArchiveHandler,
0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00);
STDAPI CreateArchiver(const GUID *classID, const GUID *iid, void **outObject);
diff --git a/CPP/7zip/Archive/DllExports2.cpp b/CPP/7zip/Archive/DllExports2.cpp
index d3b15f06..545fcbd3 100755
--- a/CPP/7zip/Archive/DllExports2.cpp
+++ b/CPP/7zip/Archive/DllExports2.cpp
@@ -7,8 +7,8 @@
#include "../../Common/Types.h"
#include "../../Windows/PropVariant.h"
#if defined(_WIN32) && defined(_7ZIP_LARGE_PAGES)
-extern "C"
-{
+extern "C"
+{
#include "../../../C/Alloc.h"
}
#endif
@@ -25,7 +25,7 @@ static bool IsItWindowsNT()
{
OSVERSIONINFO versionInfo;
versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
- if (!::GetVersionEx(&versionInfo))
+ if (!::GetVersionEx(&versionInfo))
return false;
return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
}
@@ -47,12 +47,12 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
return TRUE;
}
-DEFINE_GUID(CLSID_CArchiveHandler,
+DEFINE_GUID(CLSID_CArchiveHandler,
0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00);
static const UInt16 kDecodeId = 0x2790;
-DEFINE_GUID(CLSID_CCodec,
+DEFINE_GUID(CLSID_CCodec,
0x23170F69, 0x40C1, kDecodeId, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
STDAPI CreateCoder(const GUID *clsid, const GUID *iid, void **outObject);
diff --git a/CPP/7zip/Archive/DmgHandler.cpp b/CPP/7zip/Archive/DmgHandler.cpp
new file mode 100755
index 00000000..7d5201c0
--- /dev/null
+++ b/CPP/7zip/Archive/DmgHandler.cpp
@@ -0,0 +1,778 @@
+// DmgHandler.cpp
+
+#include "StdAfx.h"
+
+#include "../../../C/CpuArch.h"
+
+#include "Common/Buffer.h"
+#include "Common/ComTry.h"
+#include "Common/IntToString.h"
+#include "Common/MyXml.h"
+#include "Common/UTFConvert.h"
+
+#include "Windows/PropVariant.h"
+
+#include "../Common/LimitedStreams.h"
+#include "../Common/ProgressUtils.h"
+#include "../Common/RegisterArc.h"
+#include "../Common/StreamUtils.h"
+
+#include "../Compress/BZip2/BZip2Decoder.h"
+#include "../Compress/Copy/CopyCoder.h"
+#include "../Compress/Deflate/ZlibDecoder.h"
+
+// #define DMG_SHOW_RAW
+
+// #include <stdio.h>
+#define PRF(x) // x
+
+#define Get32(p) GetBe32(p)
+#define Get64(p) GetBe64(p)
+
+static int Base64ToByte(char c)
+{
+ if (c >= 'A' && c <= 'Z') return c - 'A';
+ if (c >= 'a' && c <= 'z') return c - 'a' + 26;
+ if (c >= '0' && c <= '9') return c - '0' + 52;
+ if (c == '+') return 62;
+ if (c == '/') return 63;
+ if (c == '=') return 0;
+ return -1;
+}
+
+static int Base64ToBin(Byte *dest, const char *src, int srcLen)
+{
+ int srcPos = 0;
+ int destPos = 0;
+ while (srcPos < srcLen)
+ {
+ Byte buf[4];
+ int filled = 0;
+ while (srcPos < srcLen)
+ {
+ int n = Base64ToByte(src[srcPos++]);
+ if (n >= 0)
+ {
+ buf[filled++] = (Byte)n;
+ if (filled == 4)
+ break;
+ }
+ }
+ if (filled >= 2) { if (dest) dest[destPos] = (buf[0] << 2) | (buf[1] >> 4); destPos++; }
+ if (filled >= 3) { if (dest) dest[destPos] = (buf[1] << 4) | (buf[2] >> 2); destPos++; }
+ if (filled >= 4) { if (dest) dest[destPos] = (buf[2] << 6) | (buf[3] ); destPos++; }
+ }
+ return destPos;
+}
+
+static UString GetSizeString(UInt64 value)
+{
+ wchar_t s[32];
+ wchar_t c;
+ if (value < (UInt64)20000) c = 0;
+ else if (value < ((UInt64)20000 << 10)) { value >>= 10; c = L'K'; }
+ else if (value < ((UInt64)20000 << 20)) { value >>= 20; c = L'M'; }
+ else { value >>= 30; c = L'G'; }
+ ConvertUInt64ToString(value, s);
+ int p = MyStringLen(s);
+ s[p++] = c;
+ s[p++] = L'\0';
+ return s;
+}
+
+namespace NArchive {
+namespace NDmg {
+
+struct CBlock
+{
+ UInt32 Type;
+ UInt64 UnpPos;
+ UInt64 UnpSize;
+ UInt64 PackPos;
+ UInt64 PackSize;
+};
+
+struct CFile
+{
+ CByteBuffer Raw;
+ // UInt64 StartPos;
+ CRecordVector<CBlock> Blocks;
+ UInt64 GetUnpackSize() const
+ {
+ UInt64 size = 0;
+ for (int i = 0; i < Blocks.Size(); i++)
+ size += Blocks[i].UnpSize;
+ return size;
+ };
+ UInt64 GetPackSize() const
+ {
+ UInt64 size = 0;
+ for (int i = 0; i < Blocks.Size(); i++)
+ size += Blocks[i].PackSize;
+ return size;
+ };
+
+ AString Name;
+};
+
+class CHandler:
+ public IInArchive,
+ public CMyUnknownImp
+{
+ CMyComPtr<IInStream> _inStream;
+
+ AString _xml;
+ CObjectVector<CFile> _files;
+ CRecordVector<int> _fileIndices;
+
+ HRESULT Open2(IInStream *stream);
+ HRESULT Extract(IInStream *stream);
+public:
+ MY_UNKNOWN_IMP1(IInArchive)
+ INTERFACE_IInArchive(;)
+};
+
+const UInt32 kXmlSizeMax = ((UInt32)1 << 31) - (1 << 14);
+
+enum
+{
+ METHOD_ZERO_0 = 0,
+ METHOD_COPY = 1,
+ METHOD_ZERO_2 = 2,
+ METHOD_ZLIB = 0x80000005,
+ METHOD_BZIP2 = 0x80000006,
+ METHOD_DUMMY = 0x7FFFFFFE,
+ METHOD_END = 0xFFFFFFFF
+};
+
+struct CMethodStat
+{
+ UInt32 NumBlocks;
+ UInt64 PackSize;
+ UInt64 UnpSize;
+ CMethodStat(): NumBlocks(0), PackSize(0), UnpSize(0) {}
+};
+
+struct CMethods
+{
+ CRecordVector<CMethodStat> Stats;
+ CRecordVector<UInt32> Types;
+ void Update(const CFile &file);
+ UString GetString() const;
+};
+
+void CMethods::Update(const CFile &file)
+{
+ for (int i = 0; i < file.Blocks.Size(); i++)
+ {
+ const CBlock &b = file.Blocks[i];
+ int index = Types.FindInSorted(b.Type);
+ if (index < 0)
+ {
+ index = Types.AddToUniqueSorted(b.Type);
+ Stats.Insert(index, CMethodStat());
+ }
+ CMethodStat &m = Stats[index];
+ m.PackSize += b.PackSize;
+ m.UnpSize += b.UnpSize;
+ m.NumBlocks++;
+ }
+}
+
+UString CMethods::GetString() const
+{
+ UString res;
+ for (int i = 0; i < Types.Size(); i++)
+ {
+ if (i != 0)
+ res += L' ';
+ wchar_t buf[32];
+ const wchar_t *s;
+ const CMethodStat &m = Stats[i];
+ bool showPack = true;
+ UInt32 type = Types[i];
+ switch(type)
+ {
+ case METHOD_ZERO_0: s = L"zero0"; showPack = (m.PackSize != 0); break;
+ case METHOD_ZERO_2: s = L"zero2"; showPack = (m.PackSize != 0); break;
+ case METHOD_COPY: s = L"copy"; showPack = (m.UnpSize != m.PackSize); break;
+ case METHOD_ZLIB: s = L"zlib"; break;
+ case METHOD_BZIP2: s = L"bzip2"; break;
+ default: ConvertUInt64ToString(type, buf); s = buf;
+ }
+ res += s;
+ if (m.NumBlocks != 1)
+ {
+ res += L'[';
+ ConvertUInt64ToString(m.NumBlocks, buf);
+ res += buf;
+ res += L']';
+ }
+ res += L'-';
+ res += GetSizeString(m.UnpSize);
+ if (showPack)
+ {
+ res += L'-';
+ res += GetSizeString(m.PackSize);
+ }
+ }
+ return res;
+}
+
+STATPROPSTG kProps[] =
+{
+ { NULL, kpidPath, VT_BSTR},
+ { NULL, kpidSize, VT_UI8},
+ { NULL, kpidPackSize, VT_UI8},
+ { NULL, kpidComment, VT_BSTR},
+ { NULL, kpidMethod, VT_BSTR}
+};
+
+IMP_IInArchive_Props
+
+STATPROPSTG kArcProps[] =
+{
+ { NULL, kpidMethod, VT_BSTR},
+ { NULL, kpidNumBlocks, VT_UI4}
+};
+
+STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NWindows::NCOM::CPropVariant prop;
+ switch(propID)
+ {
+ case kpidMethod:
+ {
+ CMethods m;
+ for (int i = 0; i < _files.Size(); i++)
+ m.Update(_files[i]);
+ prop = m.GetString();
+ break;
+ }
+ case kpidNumBlocks:
+ {
+ UInt64 numBlocks = 0;
+ for (int i = 0; i < _files.Size(); i++)
+ numBlocks += _files[i].Blocks.Size();
+ prop = numBlocks;
+ break;
+ }
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+IMP_IInArchive_ArcProps
+
+static int FindKeyPair(const CXmlItem &item, const AString &key, const AString &nextTag)
+{
+ for (int i = 0; i + 1 < item.SubItems.Size(); i++)
+ {
+ const CXmlItem &si = item.SubItems[i];
+ if (si.IsTagged("key") && si.GetSubString() == key && item.SubItems[i + 1].IsTagged(nextTag))
+ return i + 1;
+ }
+ return -1;
+}
+
+static AString GetStringFromKeyPair(const CXmlItem &item, const AString &key, const AString &nextTag)
+{
+ int index = FindKeyPair(item, key, nextTag);
+ if (index >= 0)
+ return item.SubItems[index].GetSubString();
+ return AString();
+}
+
+HRESULT CHandler::Open2(IInStream *stream)
+{
+ const int HEADER_SIZE = 0x1E0;
+
+ UInt64 headerPos;
+ RINOK(stream->Seek(-HEADER_SIZE, STREAM_SEEK_END, &headerPos));
+ Byte buf[HEADER_SIZE];
+ RINOK(ReadStream_FALSE(stream, buf, HEADER_SIZE));
+ UInt64 address1 = Get64(buf + 0);
+ UInt64 address2 = Get64(buf + 0xB8);
+ UInt64 size64 = Get64(buf + 0xC0);
+ if (address1 != address2 || size64 >= kXmlSizeMax || size64 == 0 ||
+ address1 >= headerPos || address1 + size64 > headerPos)
+ return S_FALSE;
+ RINOK(stream->Seek(address1, STREAM_SEEK_SET, NULL));
+ size_t size = (size_t)size64;
+
+ char *ss = _xml.GetBuffer((int)size + 1);
+ RINOK(ReadStream_FALSE(stream, ss, size));
+ ss[size] = 0;
+ _xml.ReleaseBuffer();
+
+ CXml xml;
+ if (!xml.Parse(_xml))
+ return S_FALSE;
+ if (xml.Root.Name != "plist")
+ return S_FALSE;
+
+ int dictIndex = xml.Root.FindSubTag("dict");
+ if (dictIndex < 0)
+ return S_FALSE;
+
+ const CXmlItem &dictItem = xml.Root.SubItems[dictIndex];
+ int rfDictIndex = FindKeyPair(dictItem, "resource-fork", "dict");
+ if (rfDictIndex < 0)
+ return S_FALSE;
+
+ const CXmlItem &rfDictItem = dictItem.SubItems[rfDictIndex];
+ int arrIndex = FindKeyPair(rfDictItem, "blkx", "array");
+ if (arrIndex < 0)
+ return S_FALSE;
+
+ const CXmlItem &arrItem = rfDictItem.SubItems[arrIndex];
+
+ /* some DMG file has BUG:
+ PackPos for each new file is 0.
+ So we use additional "StartPos" to fix that BUG */
+
+ /*
+ UInt64 startPos = 0;
+ bool startPosIsDefined = false;
+ */
+
+
+ for (int i = 0; i < arrItem.SubItems.Size(); i++)
+ {
+ const CXmlItem &item = arrItem.SubItems[i];
+ if (!item.IsTagged("dict"))
+ continue;
+
+ CFile file;
+ // file.StartPos = startPos;
+
+ int destLen;
+ {
+ AString dataString;
+ AString name = GetStringFromKeyPair(item, "Name", "string");
+ if (name.IsEmpty())
+ name = GetStringFromKeyPair(item, "CFName", "string");
+ file.Name = name;
+ dataString = GetStringFromKeyPair(item, "Data", "data");
+
+ destLen = Base64ToBin(NULL, dataString, dataString.Length());
+ file.Raw.SetCapacity(destLen);
+ Base64ToBin(file.Raw, dataString, dataString.Length());
+ }
+
+ if (destLen > 0xCC && Get32(file.Raw) == 0x6D697368)
+ {
+ PRF(printf("\n\n index = %d", _files.Size()));
+ const int kRecordSize = 40;
+ for (int offset = 0xCC; offset + kRecordSize <= destLen; offset += kRecordSize)
+ {
+ const Byte *p = (const Byte *)file.Raw + offset;
+ CBlock b;
+ b.Type = Get32(p);
+ if (b.Type == METHOD_END)
+ break;
+ if (b.Type == METHOD_DUMMY)
+ continue;
+
+ b.UnpPos = Get64(p + 0x08) << 9;
+ b.UnpSize = Get64(p + 0x10) << 9;
+ b.PackPos = Get64(p + 0x18);
+ b.PackSize = Get64(p + 0x20);
+
+ /*
+ if (startPosIsdefined)
+ {
+ }
+ else
+ {
+ startPosIsdefined = true;
+ startPos = b.PackPos;
+ }
+ startPos += b.PackSize;
+ */
+
+ file.Blocks.Add(b);
+
+ PRF(printf("\nType=%8x m[1]=%8x uPos=%8x uSize=%7x pPos=%8x pSize=%7x",
+ b.Type, Get32(p + 4), (UInt32)b.UnpPos, (UInt32)b.UnpSize, (UInt32)b.PackPos, (UInt32)b.PackSize));
+ }
+ }
+ int itemIndex = _files.Add(file);
+ if (file.Blocks.Size() > 0)
+ {
+ // if (file.Name.Find("HFS") >= 0)
+ _fileIndices.Add(itemIndex);
+ }
+ }
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Open(IInStream *stream,
+ const UInt64 * /* maxCheckStartPosition */,
+ IArchiveOpenCallback * /* openArchiveCallback */)
+{
+ COM_TRY_BEGIN
+ {
+ Close();
+ if (Open2(stream) != S_OK)
+ return S_FALSE;
+ _inStream = stream;
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Close()
+{
+ _inStream.Release();
+ _fileIndices.Clear();
+ _files.Clear();
+ _xml.Empty();
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
+{
+ *numItems = _fileIndices.Size()
+ #ifdef DMG_SHOW_RAW
+ + _files.Size() + 1;
+ #endif
+ ;
+ return S_OK;
+}
+
+#define RAW_PREFIX L"raw" WSTRING_PATH_SEPARATOR
+
+STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NWindows::NCOM::CPropVariant prop;
+
+ #ifdef DMG_SHOW_RAW
+ if ((int)index == _fileIndices.Size())
+ {
+ switch(propID)
+ {
+ case kpidPath:
+ prop = RAW_PREFIX L"a.xml";
+ break;
+ case kpidSize:
+ case kpidPackedSize:
+ prop = (UInt64)_xml.Length();
+ break;
+ }
+ }
+ else if ((int)index > _fileIndices.Size())
+ {
+ int rawIndex = (int)index - (_fileIndices.Size() + 1);
+ switch(propID)
+ {
+ case kpidPath:
+ {
+ wchar_t s[32] = RAW_PREFIX;
+ ConvertUInt64ToString(rawIndex, s + MyStringLen(s));
+ prop = s;
+ break;
+ }
+ case kpidSize:
+ case kpidPackedSize:
+ prop = (UInt64)_files[rawIndex].Raw.GetCapacity();
+ break;
+ }
+ }
+ else
+ #endif
+ {
+ int itemIndex = _fileIndices[index];
+ const CFile &item = _files[itemIndex];
+ switch(propID)
+ {
+ case kpidMethod:
+ {
+ CMethods m;
+ m.Update(item);
+ UString resString = m.GetString();
+ if (!resString.IsEmpty())
+ prop = resString;
+ break;
+ }
+
+ // case kpidExtension: prop = L"hfs"; break;
+
+ case kpidPath:
+ {
+ // break;
+ UString name;
+ wchar_t s[32];
+ ConvertUInt64ToString(index, s);
+ name = s;
+ int num = 10;
+ int numDigits;
+ for (numDigits = 1; num < _fileIndices.Size(); numDigits++)
+ num *= 10;
+ while (name.Length() < numDigits)
+ name = L'0' + name;
+
+ AString subName;
+ int pos1 = item.Name.Find('(');
+ if (pos1 >= 0)
+ {
+ pos1++;
+ int pos2 = item.Name.Find(')', pos1);
+ if (pos2 >= 0)
+ {
+ subName = item.Name.Mid(pos1, pos2 - pos1);
+ pos1 = subName.Find(':');
+ if (pos1 >= 0)
+ subName = subName.Left(pos1);
+ }
+ }
+ subName.Trim();
+ if (!subName.IsEmpty())
+ {
+ if (subName == "Apple_HFS")
+ subName = "hfs";
+ else if (subName == "Apple_HFSX")
+ subName = "hfsx";
+ else if (subName == "Apple_Free")
+ subName = "free";
+ else if (subName == "DDM")
+ subName = "ddm";
+ UString name2;
+ ConvertUTF8ToUnicode(subName, name2);
+ name += L'.';
+ name += name2;
+ }
+ else
+ {
+ UString name2;
+ ConvertUTF8ToUnicode(item.Name, name2);
+ if (!name2.IsEmpty())
+ name += L" - ";
+ name += name2;
+ }
+ prop = name;
+ break;
+ }
+ case kpidComment:
+ {
+ UString name;
+ ConvertUTF8ToUnicode(item.Name, name);
+ prop = name;
+ break;
+ }
+
+ case kpidSize: prop = item.GetUnpackSize(); break;
+ case kpidPackSize: prop = item.GetPackSize(); break;
+ }
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
+ Int32 _aTestMode, IArchiveExtractCallback *extractCallback)
+{
+ COM_TRY_BEGIN
+ bool testMode = (_aTestMode != 0);
+ bool allFilesMode = (numItems == UInt32(-1));
+ if (allFilesMode)
+ numItems = _files.Size();
+ if (numItems == 0)
+ return S_OK;
+ UInt64 totalSize = 0;
+ UInt32 i;
+ for (i = 0; i < numItems; i++)
+ {
+ int index = (int)(allFilesMode ? i : indices[i]);
+ #ifdef DMG_SHOW_RAW
+ if (index == _fileIndices.Size())
+ totalSize += _xml.Length();
+ else if (index > _fileIndices.Size())
+ totalSize += _files[index - (_fileIndices.Size() + 1)].Raw.GetCapacity();
+ else
+ #endif
+ totalSize += _files[_fileIndices[index]].GetUnpackSize();
+ }
+ extractCallback->SetTotal(totalSize);
+
+ UInt64 currentPackTotal = 0;
+ UInt64 currentUnpTotal = 0;
+ UInt64 currentPackSize = 0;
+ UInt64 currentUnpSize = 0;
+
+ const UInt32 kZeroBufSize = (1 << 14);
+ CByteBuffer zeroBuf;
+ zeroBuf.SetCapacity(kZeroBufSize);
+ memset(zeroBuf, 0, kZeroBufSize);
+
+ NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder();
+ CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;
+
+ NCompress::NBZip2::CDecoder *bzip2CoderSpec = new NCompress::NBZip2::CDecoder();
+ CMyComPtr<ICompressCoder> bzip2Coder = bzip2CoderSpec;
+
+ NCompress::NZlib::CDecoder *zlibCoderSpec = new NCompress::NZlib::CDecoder();
+ CMyComPtr<ICompressCoder> zlibCoder = zlibCoderSpec;
+
+ CLocalProgress *lps = new CLocalProgress;
+ CMyComPtr<ICompressProgressInfo> progress = lps;
+ lps->Init(extractCallback, false);
+
+ CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
+ CMyComPtr<ISequentialInStream> inStream(streamSpec);
+ streamSpec->SetStream(_inStream);
+
+ for (i = 0; i < numItems; i++, currentPackTotal += currentPackSize, currentUnpTotal += currentUnpSize)
+ {
+ lps->InSize = currentPackTotal;
+ lps->OutSize = currentUnpTotal;
+ currentPackSize = 0;
+ currentUnpSize = 0;
+ RINOK(lps->SetCur());
+ CMyComPtr<ISequentialOutStream> realOutStream;
+ Int32 askMode = testMode ?
+ NArchive::NExtract::NAskMode::kTest :
+ NArchive::NExtract::NAskMode::kExtract;
+ Int32 index = allFilesMode ? i : indices[i];
+ // const CItemEx &item = _files[index];
+ RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
+
+
+ if (!testMode && (!realOutStream))
+ continue;
+ RINOK(extractCallback->PrepareOperation(askMode));
+
+ CLimitedSequentialOutStream *outStreamSpec = new CLimitedSequentialOutStream;
+ CMyComPtr<ISequentialOutStream> outStream(outStreamSpec);
+ outStreamSpec->SetStream(realOutStream);
+
+ realOutStream.Release();
+
+ Int32 opRes = NArchive::NExtract::NOperationResult::kOK;
+ #ifdef DMG_SHOW_RAW
+ if (index > _fileIndices.Size())
+ {
+ const CByteBuffer &buf = _files[index - (_fileIndices.Size() + 1)].Raw;
+ outStreamSpec->Init(buf.GetCapacity());
+ RINOK(WriteStream(outStream, buf, buf.GetCapacity()));
+ currentPackSize = currentUnpSize = buf.GetCapacity();
+ }
+ else if (index == _fileIndices.Size())
+ {
+ outStreamSpec->Init(_xml.Length());
+ RINOK(WriteStream(outStream, (const char *)_xml, _xml.Length()));
+ currentPackSize = currentUnpSize = _xml.Length();
+ }
+ else
+ #endif
+ {
+ const CFile &item = _files[_fileIndices[index]];
+ currentPackSize = item.GetPackSize();
+ currentUnpSize = item.GetUnpackSize();
+
+ UInt64 unpPos = 0;
+ UInt64 packPos = 0;
+ {
+ for (int j = 0; j < item.Blocks.Size(); j++)
+ {
+ lps->InSize = currentPackTotal + packPos;
+ lps->OutSize = currentUnpTotal + unpPos;
+ RINOK(lps->SetCur());
+
+ const CBlock &block = item.Blocks[j];
+
+ packPos += block.PackSize;
+ if (block.UnpPos != unpPos)
+ {
+ opRes = NArchive::NExtract::NOperationResult::kDataError;
+ break;
+ }
+
+ RINOK(_inStream->Seek(block.PackPos, STREAM_SEEK_SET, NULL));
+ streamSpec->Init(block.PackSize);
+ // UInt64 startSize = outStreamSpec->GetSize();
+ bool realMethod = true;
+ outStreamSpec->Init(block.UnpSize);
+ HRESULT res = S_OK;
+
+ switch(block.Type)
+ {
+ case METHOD_ZERO_0:
+ case METHOD_ZERO_2:
+ realMethod = false;
+ if (block.PackSize != 0)
+ opRes = NArchive::NExtract::NOperationResult::kUnSupportedMethod;
+ break;
+
+ case METHOD_COPY:
+ if (block.UnpSize != block.PackSize)
+ {
+ opRes = NArchive::NExtract::NOperationResult::kUnSupportedMethod;
+ break;
+ }
+ res = copyCoder->Code(inStream, outStream, NULL, NULL, progress);
+ break;
+
+ case METHOD_ZLIB:
+ {
+ res = zlibCoder->Code(inStream, outStream, NULL, NULL, progress);
+ if (res != S_OK)
+ break;
+ break;
+ }
+
+ case METHOD_BZIP2:
+ {
+ res = bzip2Coder->Code(inStream, outStream, NULL, NULL, progress);
+ if (res == S_OK)
+ if (streamSpec->GetSize() != block.PackSize)
+ opRes = NArchive::NExtract::NOperationResult::kDataError;
+ break;
+ }
+
+ default:
+ opRes = NArchive::NExtract::NOperationResult::kUnSupportedMethod;
+ break;
+ }
+ if (res != S_OK)
+ {
+ if (res != S_FALSE)
+ return res;
+ if (opRes == NArchive::NExtract::NOperationResult::kOK)
+ opRes = NArchive::NExtract::NOperationResult::kDataError;
+ }
+ unpPos += block.UnpSize;
+ if (!outStreamSpec->IsFinishedOK())
+ {
+ if (realMethod && opRes == NArchive::NExtract::NOperationResult::kOK)
+ opRes = NArchive::NExtract::NOperationResult::kDataError;
+
+ while (outStreamSpec->GetRem() != 0)
+ {
+ UInt64 rem = outStreamSpec->GetRem();
+ UInt32 size = (UInt32)MyMin(rem, (UInt64)kZeroBufSize);
+ RINOK(WriteStream(outStream, zeroBuf, size));
+ }
+ }
+ }
+ }
+ }
+ outStream.Release();
+ RINOK(extractCallback->SetOperationResult(opRes));
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+static IInArchive *CreateArc() { return new CHandler; }
+
+static CArcInfo g_ArcInfo =
+ { L"Dmg", L"dmg", 0, 0xE4, { 0 }, 0, false, CreateArc, 0 };
+
+REGISTER_ARC(Dmg)
+
+}}
diff --git a/CPP/7zip/Archive/ElfHandler.cpp b/CPP/7zip/Archive/ElfHandler.cpp
new file mode 100755
index 00000000..952f2273
--- /dev/null
+++ b/CPP/7zip/Archive/ElfHandler.cpp
@@ -0,0 +1,543 @@
+4// ElfHandler.cpp
+
+#include "StdAfx.h"
+
+#include "../../../C/CpuArch.h"
+
+#include "Common/Buffer.h"
+#include "Common/ComTry.h"
+#include "Common/IntToString.h"
+
+#include "Windows/PropVariantUtils.h"
+
+#include "../Common/LimitedStreams.h"
+#include "../Common/ProgressUtils.h"
+#include "../Common/RegisterArc.h"
+#include "../Common/StreamUtils.h"
+
+#include "../Compress/Copy/CopyCoder.h"
+
+#include "Common/DummyOutStream.h"
+
+static UInt16 Get16(const Byte *p, int be) { if (be) return GetBe16(p); return GetUi16(p); }
+static UInt32 Get32(const Byte *p, int be) { if (be) return GetBe32(p); return GetUi32(p); }
+static UInt64 Get64(const Byte *p, int be) { if (be) return GetBe64(p); return GetUi64(p); }
+
+using namespace NWindows;
+
+namespace NArchive {
+namespace NElf {
+
+#define ELF_CLASS_32 1
+#define ELF_CLASS_64 2
+
+#define ELF_DATA_2LSB 1
+#define ELF_DATA_2MSB 2
+
+#define NUM_SCAN_SECTIONS_MAX (1 << 6)
+
+struct CHeader
+{
+ bool Mode64;
+ bool Be;
+ Byte Os;
+ Byte AbiVer;
+
+ UInt16 Type;
+ UInt16 Machine;
+ // UInt32 Version;
+
+ // UInt64 EntryVa;
+ UInt64 ProgOffset;
+ UInt64 SectOffset;
+ UInt32 Flags;
+ UInt16 ElfHeaderSize;
+ UInt16 SegmentEntrySize;
+ UInt16 NumSegments;
+ UInt16 SectEntrySize;
+ UInt16 NumSections;
+ // UInt16 SectNameStringTableIndex;
+
+ bool Parse(const Byte *buf);
+
+ bool CheckSegmentEntrySize() const
+ {
+ return (Mode64 && SegmentEntrySize == 0x38) || (!Mode64 && SegmentEntrySize == 0x20);
+ };
+
+ UInt64 GetHeadersSize() const
+ { return ElfHeaderSize +
+ (UInt64)SegmentEntrySize * NumSegments +
+ (UInt64)SectEntrySize * NumSections; }
+
+};
+
+bool CHeader::Parse(const Byte *p)
+{
+ switch(p[4])
+ {
+ case ELF_CLASS_32: Mode64 = false; break;
+ case ELF_CLASS_64: Mode64 = true; break;
+ default: return false;
+ }
+ bool be;
+ switch(p[5])
+ {
+ case ELF_DATA_2LSB: be = false; break;
+ case ELF_DATA_2MSB: be = true; break;
+ default: return false;
+ }
+ Be = be;
+ if (p[6] != 1) // Version
+ return false;
+ Os = p[7];
+ AbiVer = p[8];
+ for (int i = 9; i < 16; i++)
+ if (p[i] != 0)
+ return false;
+
+ Type = Get16(p + 0x10, be);
+ Machine = Get16(p + 0x12, be);
+ if (Get32(p + 0x14, be) != 1) // Version
+ return false;
+
+ if (Mode64)
+ {
+ // EntryVa = Get64(p + 0x18, be);
+ ProgOffset = Get64(p + 0x20, be);
+ SectOffset = Get64(p + 0x28, be);
+ p += 0x30;
+ }
+ else
+ {
+ // EntryVa = Get32(p + 0x18, be);
+ ProgOffset = Get32(p + 0x1C, be);
+ SectOffset = Get32(p + 0x20, be);
+ p += 0x24;
+ }
+
+ Flags = Get32(p + 0, be);
+ ElfHeaderSize = Get16(p + 4, be);
+ SegmentEntrySize = Get16(p + 6, be);
+ NumSegments = Get16(p + 8, be);
+ SectEntrySize = Get16(p + 10, be);
+ NumSections = Get16(p + 12, be);
+ // SectNameStringTableIndex = Get16(p + 14, be);
+ return CheckSegmentEntrySize();
+}
+
+struct CSegment
+{
+ UInt32 Type;
+ UInt32 Flags;
+ UInt64 Offset;
+ UInt64 Va;
+ // UInt64 Pa;
+ UInt64 PSize;
+ UInt64 VSize;
+ // UInt64 Align;
+
+ void UpdateTotalSize(UInt64 &totalSize)
+ {
+ UInt64 t = Offset + PSize;
+ if (t > totalSize)
+ totalSize = t;
+ }
+ void Parse(const Byte *p, bool mode64, bool be);
+};
+
+void CSegment::Parse(const Byte *p, bool mode64, bool be)
+{
+ Type = Get32(p, be);
+ if (mode64)
+ {
+ Flags = Get32(p + 4, be);
+ Offset = Get64(p + 8, be);
+ Va = Get64(p + 0x10, be);
+ // Pa = Get64(p + 0x18, be);
+ PSize = Get64(p + 0x20, be);
+ VSize = Get64(p + 0x28, be);
+ // Align = Get64(p + 0x30, be);
+ }
+ else
+ {
+ Offset = Get32(p + 4, be);
+ Va = Get32(p + 8, be);
+ // Pa = Get32(p + 12, be);
+ PSize = Get32(p + 16, be);
+ VSize = Get32(p + 20, be);
+ Flags = Get32(p + 24, be);
+ // Align = Get32(p + 28, be);
+ }
+}
+
+static const CUInt32PCharPair g_MachinePairs[] =
+{
+ { 0, "None" },
+ { 1, "AT&T WE 32100" },
+ { 2, "SPARC" },
+ { 3, "Intel 386" },
+ { 4, "Motorola 68000" },
+ { 5, "Motorola 88000" },
+ { 6, "Intel 486" },
+ { 7, "Intel i860" },
+ { 8, "MIPS" },
+ { 9, "IBM S/370" },
+ { 10, "MIPS RS3000 LE" },
+ { 11, "RS6000" },
+
+ { 15, "PA-RISC" },
+ { 16, "nCUBE" },
+ { 17, "Fujitsu VPP500" },
+ { 18, "SPARC 32+" },
+ { 19, "Intel i960" },
+ { 20, "PowerPC" },
+ { 21, "PowerPC 64-bit" },
+ { 22, "IBM S/390" },
+
+ { 36, "NEX v800" },
+ { 37, "Fujitsu FR20" },
+ { 38, "TRW RH-32" },
+ { 39, "Motorola RCE" },
+ { 40, "ARM" },
+ { 41, "Alpha" },
+ { 42, "Hitachi SH" },
+ { 43, "SPARC-V9" },
+ { 44, "Siemens Tricore" },
+ { 45, "ARC" },
+ { 46, "H8/300" },
+ { 47, "H8/300H" },
+ { 48, "H8S" },
+ { 49, "H8/500" },
+ { 50, "IA-64" },
+ { 51, "Stanford MIPS-X" },
+ { 52, "Motorola ColdFire" },
+ { 53, "M68HC12" },
+ { 54, "Fujitsu MMA" },
+ { 55, "Siemens PCP" },
+ { 56, "Sony nCPU" },
+ { 57, "Denso NDR1" },
+ { 58, "Motorola StarCore" },
+ { 59, "Toyota ME16" },
+ { 60, "ST100" },
+ { 61, "Advanced Logic TinyJ" },
+ { 62, "AMD64" },
+ { 63, "Sony DSP" },
+
+ { 66, "Siemens FX66" },
+ { 67, "ST9+" },
+ { 68, "ST7" },
+ { 69, "MC68HC16" },
+ { 70, "MC68HC11" },
+ { 71, "MC68HC08" },
+ { 72, "MC68HC05" },
+ { 73, "Silicon Graphics SVx" },
+ { 74, "ST19" },
+ { 75, "Digital VAX" },
+ { 76, "Axis CRIS" },
+ { 77, "Infineon JAVELIN" },
+ { 78, "Element 14 FirePath" },
+ { 79, "LSI ZSP" },
+ { 80, "MMIX" },
+ { 81, "HUANY" },
+ { 82, "SiTera Prism" },
+ { 83, "Atmel AVR" },
+ { 84, "Fujitsu FR30" },
+ { 85, "Mitsubishi D10V" },
+ { 86, "Mitsubishi D30V" },
+ { 87, "NEC v850" },
+ { 88, "Mitsubishi M32R" },
+ { 89, "Matsushita MN10300" },
+ { 90, "Matsushita MN10200" },
+ { 91, "picoJava" },
+ { 92, "OpenRISC" },
+ { 93, "ARC Tangent-A5" },
+ { 94, "Tensilica Xtensa" },
+ { 0x9026, "Alpha" }
+};
+
+static const CUInt32PCharPair g_AbiOS[] =
+{
+ { 0, "None" },
+ { 1, "HP-UX" },
+ { 2, "NetBSD" },
+ { 3, "Linux" },
+
+ { 6, "Solaris" },
+ { 7, "AIX" },
+ { 8, "IRIX" },
+ { 9, "FreeBSD" },
+ { 10, "TRU64" },
+ { 11, "Novell Modesto" },
+ { 12, "OpenBSD" },
+ { 13, "OpenVMS" },
+ { 14, "HP NSK" },
+ { 15, "AROS" },
+ { 97, "ARM" },
+ { 255, "Standalone" }
+};
+
+static const CUInt32PCharPair g_SegmentFlags[] =
+{
+ { 1 << 0, "Execute" },
+ { 1 << 1, "Write" },
+ { 1 << 2, "Read" }
+};
+
+static const char *g_Types[] =
+{
+ "None",
+ "Relocatable file",
+ "Executable file",
+ "Shared object file",
+ "Core file"
+};
+
+static const char *g_SegnmentTypes[] =
+{
+ "Unused",
+ "Loadable segment",
+ "Dynamic linking tables",
+ "Program interpreter path name",
+ "Note section",
+ "SHLIB",
+ "Program header table",
+ "TLS"
+};
+
+class CHandler:
+ public IInArchive,
+ public CMyUnknownImp
+{
+ CMyComPtr<IInStream> _inStream;
+ CObjectVector<CSegment> _sections;
+ UInt32 _peOffset;
+ CHeader _header;
+ UInt64 _totalSize;
+ HRESULT Open2(IInStream *stream);
+ bool Parse(const Byte *buf, UInt32 size);
+public:
+ MY_UNKNOWN_IMP1(IInArchive)
+ INTERFACE_IInArchive(;)
+};
+
+#define ELF_PT_PHDR 6
+
+bool CHandler::Parse(const Byte *buf, UInt32 size)
+{
+ if (size < 64)
+ return false;
+ if (!_header.Parse(buf))
+ return false;
+ if (_header.ProgOffset > size ||
+ _header.ProgOffset + (UInt64)_header.SegmentEntrySize * _header.NumSegments > size ||
+ _header.NumSegments > NUM_SCAN_SECTIONS_MAX)
+ return false;
+ const Byte *p = buf + _header.ProgOffset;
+ _totalSize = _header.ProgOffset;
+
+ for (int i = 0; i < _header.NumSegments; i++, p += _header.SegmentEntrySize)
+ {
+ CSegment sect;
+ sect.Parse(p, _header.Mode64, _header.Be);
+ sect.UpdateTotalSize(_totalSize);
+ if (sect.Type != ELF_PT_PHDR)
+ _sections.Add(sect);
+ }
+ UInt64 total2 = _header.SectOffset + (UInt64)_header.SectEntrySize * _header.NumSections;
+ if (total2 > _totalSize)
+ _totalSize = total2;
+ return true;
+}
+
+STATPROPSTG kArcProps[] =
+{
+ { NULL, kpidCpu, VT_BSTR},
+ { NULL, kpidBit64, VT_BOOL},
+ { NULL, kpidBigEndian, VT_BOOL},
+ { NULL, kpidHostOS, VT_BSTR},
+ { NULL, kpidCharacts, VT_BSTR},
+ { NULL, kpidPhySize, VT_UI8},
+ { NULL, kpidHeadersSize, VT_UI8}
+ };
+
+STATPROPSTG kProps[] =
+{
+ { NULL, kpidPath, VT_BSTR},
+ { NULL, kpidSize, VT_UI8},
+ { NULL, kpidPackSize, VT_UI8},
+ { NULL, kpidType, VT_BSTR},
+ { NULL, kpidCharacts, VT_BSTR},
+ { NULL, kpidOffset, VT_UI8},
+ { NULL, kpidVa, VT_UI8}
+};
+
+IMP_IInArchive_Props
+IMP_IInArchive_ArcProps
+
+STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NCOM::CPropVariant prop;
+ switch(propID)
+ {
+ case kpidPhySize: prop = _totalSize; break;
+ case kpidHeadersSize: prop = _header.GetHeadersSize(); break;
+ case kpidBit64: if (_header.Mode64) prop = _header.Mode64; break;
+ case kpidBigEndian: if (_header.Be) prop = _header.Be; break;
+ case kpidCpu: PAIR_TO_PROP(g_MachinePairs, _header.Machine, prop); break;
+ case kpidHostOS: PAIR_TO_PROP(g_AbiOS, _header.Os, prop); break;
+ case kpidCharacts: TYPE_TO_PROP(g_Types, _header.Type, prop); break;
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NCOM::CPropVariant prop;
+ const CSegment &item = _sections[index];
+ switch(propID)
+ {
+ case kpidPath:
+ {
+ wchar_t sz[32];
+ ConvertUInt64ToString(index, sz);
+ prop = sz;
+ break;
+ }
+ case kpidSize: prop = (UInt64)item.VSize; break;
+ case kpidPackSize: prop = (UInt64)item.PSize; break;
+ case kpidOffset: prop = item.Offset; break;
+ case kpidVa: prop = item.Va; break;
+ case kpidType: TYPE_TO_PROP(g_SegnmentTypes, item.Type, prop); break;
+ case kpidCharacts: FLAGS_TO_PROP(g_SegmentFlags, item.Flags, prop); break;
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+HRESULT CHandler::Open2(IInStream *stream)
+{
+ const UInt32 kBufSize = 1 << 18;
+ const UInt32 kSigSize = 4;
+
+ CByteBuffer buffer;
+ buffer.SetCapacity(kBufSize);
+ Byte *buf = buffer;
+
+ size_t processed = kSigSize;
+ RINOK(ReadStream_FALSE(stream, buf, processed));
+ if (buf[0] != 0x7F || buf[1] != 'E' || buf[2] != 'L' || buf[3] != 'F')
+ return S_FALSE;
+ processed = kBufSize - kSigSize;
+ RINOK(ReadStream(stream, buf + kSigSize, &processed));
+ processed += kSigSize;
+ if (!Parse(buf, (UInt32)processed))
+ return S_FALSE;
+ UInt64 fileSize;
+ RINOK(stream->Seek(0, STREAM_SEEK_END, &fileSize));
+ return (fileSize == _totalSize) ? S_OK : S_FALSE;
+}
+
+STDMETHODIMP CHandler::Open(IInStream *inStream,
+ const UInt64 * /* maxCheckStartPosition */,
+ IArchiveOpenCallback * /* openArchiveCallback */)
+{
+ COM_TRY_BEGIN
+ Close();
+ RINOK(Open2(inStream));
+ _inStream = inStream;
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Close()
+{
+ _inStream.Release();
+ _sections.Clear();
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
+{
+ *numItems = _sections.Size();
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
+ Int32 _aTestMode, IArchiveExtractCallback *extractCallback)
+{
+ COM_TRY_BEGIN
+ bool testMode = (_aTestMode != 0);
+ bool allFilesMode = (numItems == UInt32(-1));
+ if (allFilesMode)
+ numItems = _sections.Size();
+ if (numItems == 0)
+ return S_OK;
+ UInt64 totalSize = 0;
+ UInt32 i;
+ for (i = 0; i < numItems; i++)
+ totalSize += _sections[allFilesMode ? i : indices[i]].PSize;
+ extractCallback->SetTotal(totalSize);
+
+ UInt64 currentTotalSize = 0;
+ UInt64 currentItemSize;
+
+ NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder();
+ CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;
+
+ CLocalProgress *lps = new CLocalProgress;
+ CMyComPtr<ICompressProgressInfo> progress = lps;
+ lps->Init(extractCallback, false);
+
+ CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
+ CMyComPtr<ISequentialInStream> inStream(streamSpec);
+ streamSpec->SetStream(_inStream);
+
+ CDummyOutStream *outStreamSpec = new CDummyOutStream;
+ CMyComPtr<ISequentialOutStream> outStream(outStreamSpec);
+
+ for (i = 0; i < numItems; i++, currentTotalSize += currentItemSize)
+ {
+ lps->InSize = lps->OutSize = currentTotalSize;
+ RINOK(lps->SetCur());
+ Int32 askMode = testMode ?
+ NArchive::NExtract::NAskMode::kTest :
+ NArchive::NExtract::NAskMode::kExtract;
+ UInt32 index = allFilesMode ? i : indices[i];
+ const CSegment &item = _sections[index];
+ currentItemSize = item.PSize;
+ {
+ CMyComPtr<ISequentialOutStream> realOutStream;
+ RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
+ if (!testMode && (!realOutStream))
+ continue;
+ outStreamSpec->SetStream(realOutStream);
+ outStreamSpec->Init();
+ }
+
+ RINOK(extractCallback->PrepareOperation(askMode));
+ RINOK(_inStream->Seek(item.Offset, STREAM_SEEK_SET, NULL));
+ streamSpec->Init(currentItemSize);
+ RINOK(copyCoder->Code(inStream, outStream, NULL, NULL, progress));
+ outStreamSpec->ReleaseStream();
+ RINOK(extractCallback->SetOperationResult(copyCoderSpec->TotalSize == currentItemSize ?
+ NArchive::NExtract::NOperationResult::kOK:
+ NArchive::NExtract::NOperationResult::kDataError));
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+static IInArchive *CreateArc() { return new CHandler; }
+
+static CArcInfo g_ArcInfo =
+ { L"ELF", L"", 0, 0xDE, { 0 }, 0, false, CreateArc, 0 };
+
+REGISTER_ARC(Elf)
+
+}}
diff --git a/CPP/7zip/Archive/GZip/GZipHandler.cpp b/CPP/7zip/Archive/GZip/GZipHandler.cpp
index 48d85fa4..96ae85f1 100755
--- a/CPP/7zip/Archive/GZip/GZipHandler.cpp
+++ b/CPP/7zip/Archive/GZip/GZipHandler.cpp
@@ -22,7 +22,7 @@ namespace NGZip {
static const CMethodId kMethodId_Deflate = 0x040108;
-const wchar_t *kHostOS[] =
+const wchar_t *kHostOS[] =
{
L"FAT",
L"AMIGA",
@@ -34,14 +34,14 @@ const wchar_t *kHostOS[] =
L"Mac",
L"Z_System",
L"CPM",
- L"TOPS20", // pkzip 2.50 NTFS
- L"NTFS", // filesystem used by Windows NT
+ L"TOPS20", // pkzip 2.50 NTFS
+ L"NTFS", // filesystem used by Windows NT
L"QDOS ", // SMS/QDOS
L"Acorn", // Archimedes Acorn RISC OS
L"VFAT", // filesystem used by Windows 95, NT
L"MVS",
L"BeOS", // hybrid POSIX/database filesystem
- // BeBOX or PowerMac
+ // BeBOX or PowerMac
L"Tandem",
L"THEOS"
};
@@ -59,16 +59,14 @@ enum // PropID
};
*/
-STATPROPSTG kProps[] =
+STATPROPSTG kProps[] =
{
{ NULL, kpidPath, VT_BSTR},
{ NULL, kpidSize, VT_UI8},
- { NULL, kpidPackedSize, VT_UI8},
-
- { NULL, kpidLastWriteTime, VT_FILETIME},
+ { NULL, kpidPackSize, VT_UI8},
+ { NULL, kpidMTime, VT_FILETIME},
// { NULL, kpidMethod, VT_UI1},
{ NULL, kpidHostOS, VT_BSTR},
-
{ NULL, kpidCRC, VT_UI4}
// { L"Extra", kpidExtraIsPresent, VT_BOOL}
// { L"Extra flags", kpidExtraFlags, VT_UI1},
@@ -94,7 +92,7 @@ STDMETHODIMP CHandler::GetProperty(UInt32 /* index */, PROPID propID, PROPVARIA
if (m_Item.NameIsPresent())
prop = MultiByteToUnicodeString(m_Item.Name, CP_ACP);
break;
- case kpidLastWriteTime:
+ case kpidMTime:
{
FILETIME utcTime;
if (m_Item.Time != 0)
@@ -109,35 +107,19 @@ STDMETHODIMP CHandler::GetProperty(UInt32 /* index */, PROPID propID, PROPVARIA
}
break;
}
- case kpidSize:
- prop = UInt64(m_Item.UnPackSize32);
- break;
- case kpidPackedSize:
- prop = m_PackSize;
- break;
- case kpidCommented:
- prop = m_Item.CommentIsPresent();
- break;
+ case kpidSize: prop = UInt64(m_Item.UnPackSize32); break;
+ case kpidPackSize: prop = m_PackSize; break;
+ case kpidCommented: prop = m_Item.CommentIsPresent(); break;
case kpidHostOS:
prop = (m_Item.HostOS < kNumHostOSes) ?
kHostOS[m_Item.HostOS] : kUnknownOS;
break;
- case kpidMethod:
- prop = m_Item.CompressionMethod;
- break;
- case kpidCRC:
- prop = m_Item.FileCRC;
- break;
+ case kpidMethod: prop = m_Item.CompressionMethod; break;
+ case kpidCRC: prop = m_Item.FileCRC; break;
/*
- case kpidExtraFlags:
- prop = m_Item.ExtraFlags;
- break;
- case kpidIsText:
- prop = m_Item.IsText();
- break;
- case kpidExtraIsPresent:
- prop = m_Item.ExtraFieldIsPresent();
- break;
+ case kpidExtraFlags: prop = m_Item.ExtraFlags; break;
+ case kpidIsText: prop = m_Item.IsText(); break;
+ case kpidExtraIsPresent: prop = m_Item.ExtraFieldIsPresent(); break;
*/
}
prop.Detach(value);
@@ -145,7 +127,7 @@ STDMETHODIMP CHandler::GetProperty(UInt32 /* index */, PROPID propID, PROPVARIA
COM_TRY_END
}
-STDMETHODIMP CHandler::Open(IInStream *inStream,
+STDMETHODIMP CHandler::Open(IInStream *inStream,
const UInt64 * /* maxCheckStartPosition */,
IArchiveOpenCallback * /* openArchiveCallback */)
{
@@ -155,7 +137,7 @@ STDMETHODIMP CHandler::Open(IInStream *inStream,
CInArchive archive;
RINOK(inStream->Seek(0, STREAM_SEEK_CUR, &m_StreamStartPosition));
RINOK(archive.ReadHeader(inStream, m_Item));
- m_DataOffset = archive.GetOffset();
+ m_DataOffset = archive.GetOffset();
UInt64 newPosition;
RINOK(inStream->Seek(-8, STREAM_SEEK_END, &newPosition));
m_PackSize = newPosition - (m_StreamStartPosition + m_DataOffset);
@@ -274,7 +256,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
}
CMyComPtr<ICompressGetInStreamProcessedSize> getInStreamProcessedSize;
- RINOK(deflateDecoder.QueryInterface(IID_ICompressGetInStreamProcessedSize,
+ RINOK(deflateDecoder.QueryInterface(IID_ICompressGetInStreamProcessedSize,
&getInStreamProcessedSize));
UInt64 packSize;
RINOK(getInStreamProcessedSize->GetInStreamProcessedSize(&packSize));
diff --git a/CPP/7zip/Archive/GZip/GZipHandler.h b/CPP/7zip/Archive/GZip/GZipHandler.h
index 3f5a1acd..49a01a8d 100755
--- a/CPP/7zip/Archive/GZip/GZipHandler.h
+++ b/CPP/7zip/Archive/GZip/GZipHandler.h
@@ -15,7 +15,7 @@
namespace NArchive {
namespace NGZip {
-class CHandler:
+class CHandler:
public IInArchive,
public IOutArchive,
public ISetProperties,
@@ -53,7 +53,7 @@ private:
void InitMethodProperties()
{
m_Method.NumMatchFinderCyclesDefined = false;
- m_Level = m_Method.NumPasses = m_Method.NumFastBytes =
+ m_Level = m_Method.NumPasses = m_Method.NumFastBytes =
m_Method.NumMatchFinderCycles = m_Method.Algo = 0xFFFFFFFF;
}
};
diff --git a/CPP/7zip/Archive/GZip/GZipHandlerOut.cpp b/CPP/7zip/Archive/GZip/GZipHandlerOut.cpp
index f2776adb..1fb1547d 100755
--- a/CPP/7zip/Archive/GZip/GZipHandlerOut.cpp
+++ b/CPP/7zip/Archive/GZip/GZipHandlerOut.cpp
@@ -9,7 +9,6 @@
#include "Common/StringToInt.h"
#include "Windows/Time.h"
-#include "Windows/FileFind.h"
#include "Windows/PropVariant.h"
#include "../../Compress/Copy/CopyCoder.h"
@@ -65,23 +64,11 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
newItem.Flags = 0;
if (IntToBool(newProperties))
{
- UInt32 attributes;
FILETIME utcTime;
UString name;
- bool isDirectory;
{
NCOM::CPropVariant prop;
- RINOK(updateCallback->GetProperty(itemIndex, kpidAttributes, &prop));
- if (prop.vt == VT_EMPTY)
- attributes = 0;
- else if (prop.vt != VT_UI4)
- return E_INVALIDARG;
- else
- attributes = prop.ulVal;
- }
- {
- NCOM::CPropVariant prop;
- RINOK(updateCallback->GetProperty(itemIndex, kpidLastWriteTime, &prop));
+ RINOK(updateCallback->GetProperty(itemIndex, kpidMTime, &prop));
if (prop.vt != VT_FILETIME)
return E_INVALIDARG;
utcTime = prop.filetime;
@@ -98,16 +85,15 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
}
{
NCOM::CPropVariant prop;
- RINOK(updateCallback->GetProperty(itemIndex, kpidIsFolder, &prop));
- if (prop.vt == VT_EMPTY)
- isDirectory = false;
- else if (prop.vt != VT_BOOL)
+ RINOK(updateCallback->GetProperty(itemIndex, kpidIsDir, &prop));
+ if (prop.vt == VT_BOOL)
+ {
+ if (prop.boolVal != VARIANT_FALSE)
+ return E_INVALIDARG;
+ }
+ else if (prop.vt != VT_EMPTY)
return E_INVALIDARG;
- else
- isDirectory = (prop.boolVal != VARIANT_FALSE);
}
- if (isDirectory || NFile::NFind::NAttributes::IsDirectory(attributes))
- return E_INVALIDARG;
if(!FileTimeToUnixTime(utcTime, newItem.Time))
return E_INVALIDARG;
newItem.Name = UnicodeStringToMultiByte(name, CP_ACP);
@@ -133,17 +119,17 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
if (level == 0xFFFFFFFF)
level = 5;
if (m_Method.NumPasses == 0xFFFFFFFF)
- m_Method.NumPasses = (level >= 9 ? kNumPassesX9 :
- (level >= 7 ? kNumPassesX7 :
+ m_Method.NumPasses = (level >= 9 ? kNumPassesX9 :
+ (level >= 7 ? kNumPassesX7 :
kNumPassesX1));
if (m_Method.NumFastBytes == 0xFFFFFFFF)
- m_Method.NumFastBytes = (level >= 9 ? kNumFastBytesX9 :
- (level >= 7 ? kNumFastBytesX7 :
+ m_Method.NumFastBytes = (level >= 9 ? kNumFastBytesX9 :
+ (level >= 7 ? kNumFastBytesX7 :
kNumFastBytesX1));
if (m_Method.Algo == 0xFFFFFFFF)
- m_Method.Algo =
- (level >= 5 ? kAlgoX5 :
- kAlgoX1);
+ m_Method.Algo =
+ (level >= 5 ? kAlgoX5 :
+ kAlgoX1);
return UpdateArchive(
EXTERNAL_CODECS_VARS
@@ -210,6 +196,6 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *v
return E_INVALIDARG;
}
return S_OK;
-}
+}
}}
diff --git a/CPP/7zip/Archive/GZip/GZipHeader.cpp b/CPP/7zip/Archive/GZip/GZipHeader.cpp
index 5e697fa9..88b34e86 100755
--- a/CPP/7zip/Archive/GZip/GZipHeader.cpp
+++ b/CPP/7zip/Archive/GZip/GZipHeader.cpp
@@ -12,7 +12,7 @@ extern UInt16 kSignature = 0x8B1F + 1;
static class CMarkersInitializer
{
public:
- CMarkersInitializer()
+ CMarkersInitializer()
{ kSignature--; }
} g_MarkerInitializer;
diff --git a/CPP/7zip/Archive/GZip/GZipHeader.h b/CPP/7zip/Archive/GZip/GZipHeader.h
index e83548eb..010a60aa 100755
--- a/CPP/7zip/Archive/GZip/GZipHeader.h
+++ b/CPP/7zip/Archive/GZip/GZipHeader.h
@@ -25,7 +25,7 @@ namespace NFileHeader
};
*/
- namespace NFlags
+ namespace NFlags
{
const int kDataIsText = 1 << 0;
const int kHeaderCRCIsPresent = 1 << 1;
@@ -34,7 +34,7 @@ namespace NFileHeader
const int kComentIsPresent = 1 << 4;
}
- namespace NExtraFlags
+ namespace NExtraFlags
{
enum EEnum
{
@@ -52,7 +52,7 @@ namespace NFileHeader
{
enum EEnum
{
- kFAT = 0, // filesystem used by MS-DOS, OS/2, Win32
+ kFAT = 0, // filesystem used by MS-DOS, OS/2, Win32
// pkzip 2.50 (FAT / VFAT / FAT32 file systems)
kAMIGA = 1,
kVMS = 2, // VAX/VMS
@@ -63,14 +63,14 @@ namespace NFileHeader
kMac = 7,
kZ_System = 8,
kCPM = 9,
- kTOPS20 = 10, // pkzip 2.50 NTFS
- kNTFS = 11, // filesystem used by Windows NT
+ kTOPS20 = 10, // pkzip 2.50 NTFS
+ kNTFS = 11, // filesystem used by Windows NT
kQDOS = 12, // SMS/QDOS
kAcorn = 13, // Archimedes Acorn RISC OS
kVFAT = 14, // filesystem used by Windows 95, NT
kMVS = 15,
kBeOS = 16, // hybrid POSIX/database filesystem
- // BeBOX or PowerMac
+ // BeBOX or PowerMac
kTandem = 17,
kTHEOS = 18,
diff --git a/CPP/7zip/Archive/GZip/GZipIn.cpp b/CPP/7zip/Archive/GZip/GZipIn.cpp
index 33b0ac47..d754c045 100755
--- a/CPP/7zip/Archive/GZip/GZipIn.cpp
+++ b/CPP/7zip/Archive/GZip/GZipIn.cpp
@@ -10,9 +10,9 @@
#include "../../Common/StreamUtils.h"
-extern "C"
-{
- #include "../../../../C/7zCrc.h"
+extern "C"
+{
+ #include "../../../../C/7zCrc.h"
}
namespace NArchive {
diff --git a/CPP/7zip/Archive/GZip/GZipItem.h b/CPP/7zip/Archive/GZip/GZipItem.h
index cd5e59f0..678962a9 100755
--- a/CPP/7zip/Archive/GZip/GZipItem.h
+++ b/CPP/7zip/Archive/GZip/GZipItem.h
@@ -39,7 +39,7 @@ public:
{ return TestFlag(NFileHeader::NFlags::kComentIsPresent); }
void SetNameIsPresentFlag(bool nameIsPresent)
- {
+ {
if (nameIsPresent)
Flags |= NFileHeader::NFlags::kNameIsPresent;
else
diff --git a/CPP/7zip/Archive/GZip/GZipRegister.cpp b/CPP/7zip/Archive/GZip/GZipRegister.cpp
index e293cfc3..b4bc6ded 100755
--- a/CPP/7zip/Archive/GZip/GZipRegister.cpp
+++ b/CPP/7zip/Archive/GZip/GZipRegister.cpp
@@ -13,6 +13,6 @@ static IOutArchive *CreateArcOut() { return new NArchive::NGZip::CHandler; }
#endif
static CArcInfo g_ArcInfo =
- { L"GZip", L"gz gzip tgz tpz", L"* * .tar .tar", 0xEF, { 0x1F, 0x8B }, 2, true, CreateArc, CreateArcOut };
+ { L"GZip", L"gz gzip tgz tpz", L"* * .tar .tar", 0xEF, { 0x1F, 0x8B, 8 }, 3, true, CreateArc, CreateArcOut };
REGISTER_ARC(GZip)
diff --git a/CPP/7zip/Archive/GZip/GZipUpdate.cpp b/CPP/7zip/Archive/GZip/GZipUpdate.cpp
index 1f5ebd0e..8f8a2c4f 100755
--- a/CPP/7zip/Archive/GZip/GZipUpdate.cpp
+++ b/CPP/7zip/Archive/GZip/GZipUpdate.cpp
@@ -22,11 +22,16 @@ namespace NGZip {
static const CMethodId kMethodId_Deflate = 0x040108;
-static const Byte kHostOS = NFileHeader::NHostOS::kFAT;
+static const Byte kHostOS =
+ #ifdef _WIN32
+ NFileHeader::NHostOS::kFAT;
+ #else
+ NFileHeader::NHostOS::kUnix;
+ #endif
HRESULT UpdateArchive(
DECL_EXTERNAL_CODECS_LOC_VARS
- IInStream * /* inStream */,
+ IInStream * /* inStream */,
UInt64 unpackSize,
ISequentialOutStream *outStream,
const CItem &newItem,
@@ -73,17 +78,17 @@ HRESULT UpdateArchive(
if (!deflateEncoder)
return E_NOTIMPL;
- NWindows::NCOM::CPropVariant properties[] =
- {
- compressionMethod.Algo,
- compressionMethod.NumPasses,
+ NWindows::NCOM::CPropVariant properties[] =
+ {
+ compressionMethod.Algo,
+ compressionMethod.NumPasses,
compressionMethod.NumFastBytes,
compressionMethod.NumMatchFinderCycles
};
- PROPID propIDs[] =
- {
+ PROPID propIDs[] =
+ {
NCoderPropID::kAlgorithm,
- NCoderPropID::kNumPasses,
+ NCoderPropID::kNumPasses,
NCoderPropID::kNumFastBytes,
NCoderPropID::kMatchFinderCycles
};
diff --git a/CPP/7zip/Archive/GZip/GZipUpdate.h b/CPP/7zip/Archive/GZip/GZipUpdate.h
index 27a396bf..231d7972 100755
--- a/CPP/7zip/Archive/GZip/GZipUpdate.h
+++ b/CPP/7zip/Archive/GZip/GZipUpdate.h
@@ -24,7 +24,7 @@ struct CCompressionMethodMode
HRESULT UpdateArchive(
DECL_EXTERNAL_CODECS_LOC_VARS
- IInStream *inStream,
+ IInStream *inStream,
UInt64 unpackSize,
ISequentialOutStream *outStream,
const CItem &newItem,
diff --git a/CPP/7zip/Archive/GZip/StdAfx.cpp b/CPP/7zip/Archive/GZip/StdAfx.cpp
deleted file mode 100755
index d0feea85..00000000
--- a/CPP/7zip/Archive/GZip/StdAfx.cpp
+++ /dev/null
@@ -1,3 +0,0 @@
-// StdAfx.cpp
-
-#include "StdAfx.h"
diff --git a/CPP/7zip/Archive/Hfs/HfsHandler.cpp b/CPP/7zip/Archive/Hfs/HfsHandler.cpp
new file mode 100755
index 00000000..ade53877
--- /dev/null
+++ b/CPP/7zip/Archive/Hfs/HfsHandler.cpp
@@ -0,0 +1,244 @@
+// HfsHandler.cpp
+
+#include "StdAfx.h"
+
+#include "Common/ComTry.h"
+#include "Windows/PropVariant.h"
+#include "../../Common/StreamUtils.h"
+#include "HfsHandler.h"
+
+namespace NArchive {
+namespace NHfs {
+
+STATPROPSTG kProps[] =
+{
+ { NULL, kpidPath, VT_BSTR},
+ { NULL, kpidIsDir, VT_BOOL},
+ { NULL, kpidSize, VT_UI8},
+ { NULL, kpidPackSize, VT_UI8},
+ { NULL, kpidCTime, VT_FILETIME},
+ { NULL, kpidMTime, VT_FILETIME},
+ { NULL, kpidATime, VT_FILETIME}
+};
+
+STATPROPSTG kArcProps[] =
+{
+ { NULL, kpidMethod, VT_BSTR},
+ { NULL, kpidClusterSize, VT_UI4},
+ { NULL, kpidFreeSpace, VT_UI8},
+ { NULL, kpidCTime, VT_FILETIME},
+ { NULL, kpidMTime, VT_FILETIME}
+};
+
+IMP_IInArchive_Props
+IMP_IInArchive_ArcProps
+
+static void HfsTimeToProp(UInt32 hfsTime, NWindows::NCOM::CPropVariant &prop)
+{
+ FILETIME ft;
+ HfsTimeToFileTime(hfsTime, ft);
+ prop = ft;
+}
+
+STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NWindows::NCOM::CPropVariant prop;
+ switch(propID)
+ {
+ case kpidMethod: prop = _db.Header.IsHfsX() ? L"HFSX" : L"HFS+"; break;
+ case kpidClusterSize: prop = (UInt32)1 << _db.Header.BlockSizeLog; break;
+ case kpidFreeSpace: prop = (UInt64)_db.Header.NumFreeBlocks << _db.Header.BlockSizeLog; break;
+ case kpidMTime: HfsTimeToProp(_db.Header.MTime, prop); break;
+ case kpidCTime:
+ {
+ FILETIME localFt, ft;
+ HfsTimeToFileTime(_db.Header.CTime, localFt);
+ if (LocalFileTimeToFileTime(&localFt, &ft))
+ prop = ft;
+ break;
+ }
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NWindows::NCOM::CPropVariant prop;
+ const CItem &item = _db.Items[index];
+ switch(propID)
+ {
+ case kpidPath: prop = _db.GetItemPath(index); break;
+ case kpidIsDir: prop = item.IsDir(); break;
+
+ case kpidCTime: HfsTimeToProp(item.CTime, prop); break;
+ case kpidMTime: HfsTimeToProp(item.MTime, prop); break;
+ case kpidATime: HfsTimeToProp(item.ATime, prop); break;
+
+ case kpidPackSize: if (!item.IsDir()) prop = (UInt64)item.NumBlocks << _db.Header.BlockSizeLog; break;
+ case kpidSize: if (!item.IsDir()) prop = item.Size; break;
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+class CProgressImp: public CProgressVirt
+{
+ CMyComPtr<IArchiveOpenCallback> _callback;
+public:
+ HRESULT SetTotal(UInt64 numFiles);
+ HRESULT SetCompleted(UInt64 numFiles);
+ CProgressImp(IArchiveOpenCallback *callback): _callback(callback) {}
+};
+
+HRESULT CProgressImp::SetTotal(UInt64 numFiles)
+{
+ if (_callback)
+ return _callback->SetTotal(&numFiles, NULL);
+ return S_OK;
+}
+
+HRESULT CProgressImp::SetCompleted(UInt64 numFiles)
+{
+ if (_callback)
+ return _callback->SetCompleted(&numFiles, NULL);
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Open(IInStream *inStream,
+ const UInt64 * /* maxCheckStartPosition */,
+ IArchiveOpenCallback *callback)
+{
+ COM_TRY_BEGIN
+ Close();
+ try
+ {
+ CProgressImp progressImp(callback);
+ HRESULT res = _db.Open(inStream, &progressImp);
+ if (res == E_ABORT)
+ return res;
+ if (res != S_OK)
+ return S_FALSE;
+ _stream = inStream;
+ }
+ catch(...) { return S_FALSE; }
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Close()
+{
+ _stream.Release();
+ _db.Clear();
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
+ Int32 _aTestMode, IArchiveExtractCallback *extractCallback)
+{
+ COM_TRY_BEGIN
+ bool testMode = (_aTestMode != 0);
+ bool allFilesMode = (numItems == UInt32(-1));
+ if (allFilesMode)
+ numItems = _db.Items.Size();
+ if (numItems == 0)
+ return S_OK;
+ UInt32 i;
+ UInt64 totalSize = 0;
+ for (i = 0; i < numItems; i++)
+ {
+ const CItem &item = _db.Items[allFilesMode ? i : indices[i]];
+ if (!item.IsDir())
+ totalSize += item.Size;
+ }
+ RINOK(extractCallback->SetTotal(totalSize));
+
+ UInt64 currentTotalSize = 0, currentItemSize = 0;
+
+ CByteBuffer buf;
+ const UInt32 kBufSize = (1 << 16);
+ buf.SetCapacity(kBufSize);
+
+ for (i = 0; i < numItems; i++, currentTotalSize += currentItemSize)
+ {
+ RINOK(extractCallback->SetCompleted(&currentTotalSize));
+ Int32 index = allFilesMode ? i : indices[i];
+ const CItem &item = _db.Items[index];
+ currentItemSize = 0;
+ if (!item.IsDir())
+ currentItemSize = item.Size;
+
+ CMyComPtr<ISequentialOutStream> realOutStream;
+ Int32 askMode = testMode ?
+ NArchive::NExtract::NAskMode::kTest :
+ NArchive::NExtract::NAskMode::kExtract;
+ RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
+
+ if (item.IsDir())
+ {
+ RINOK(extractCallback->PrepareOperation(askMode));
+ RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK));
+ continue;
+ }
+ if (!testMode && (!realOutStream))
+ continue;
+ RINOK(extractCallback->PrepareOperation(askMode));
+ UInt64 pos = 0;
+ int res = NArchive::NExtract::NOperationResult::kOK;
+ int i;
+ for (i = 0; i < item.Extents.Size(); i++)
+ {
+ if (item.Size == pos)
+ break;
+ if (res != NArchive::NExtract::NOperationResult::kOK)
+ break;
+ const CExtent &e = item.Extents[i];
+ RINOK(_stream->Seek((UInt64)e.Pos << _db.Header.BlockSizeLog, STREAM_SEEK_SET, NULL));
+ UInt64 extentSize = (UInt64)e.NumBlocks << _db.Header.BlockSizeLog;
+ for (;;)
+ {
+ if (extentSize == 0)
+ break;
+ UInt64 rem = item.Size - pos;
+ if (rem == 0)
+ {
+ if (extentSize >= (UInt64)((UInt32)1 << _db.Header.BlockSizeLog))
+ res = NArchive::NExtract::NOperationResult::kDataError;
+ break;
+ }
+ UInt32 curSize = kBufSize;
+ if (curSize > rem)
+ curSize = (UInt32)rem;
+ if (curSize > extentSize)
+ curSize = (UInt32)extentSize;
+ RINOK(ReadStream_FALSE(_stream, buf, curSize));
+ if (realOutStream)
+ {
+ RINOK(WriteStream(realOutStream, buf, curSize));
+ }
+ pos += curSize;
+ extentSize -= curSize;
+ UInt64 processed = currentTotalSize + pos;
+ RINOK(extractCallback->SetCompleted(&processed));
+ }
+ }
+ if (i != item.Extents.Size() || item.Size != pos)
+ res = NArchive::NExtract::NOperationResult::kDataError;
+ realOutStream.Release();
+ RINOK(extractCallback->SetOperationResult(res));
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
+{
+ *numItems = _db.Items.Size();
+ return S_OK;
+}
+
+}}
diff --git a/CPP/7zip/Archive/Arj/ArjHandler.h b/CPP/7zip/Archive/Hfs/HfsHandler.h
index 4351b26f..269af218 100755
--- a/CPP/7zip/Archive/Arj/ArjHandler.h
+++ b/CPP/7zip/Archive/Hfs/HfsHandler.h
@@ -1,27 +1,24 @@
-// ArjHandler.h
+// HfsHandler.h
-#ifndef __ARJ_HANDLER_H
-#define __ARJ_HANDLER_H
+#ifndef __ARCHIVE_HFS_HANDLER_H
+#define __ARCHIVE_HFS_HANDLER_H
#include "Common/MyCom.h"
#include "../IArchive.h"
-#include "ArjIn.h"
+#include "HfsIn.h"
namespace NArchive {
-namespace NArj {
+namespace NHfs {
-class CHandler:
+class CHandler:
public IInArchive,
public CMyUnknownImp
{
+ CMyComPtr<IInStream> _stream;
+ CDatabase _db;
public:
MY_UNKNOWN_IMP1(IInArchive)
-
INTERFACE_IInArchive(;)
-
-private:
- CObjectVector<CItemEx> _items;
- CMyComPtr<IInStream> _stream;
};
}}
diff --git a/CPP/7zip/Archive/Hfs/HfsIn.cpp b/CPP/7zip/Archive/Hfs/HfsIn.cpp
new file mode 100755
index 00000000..8391dd93
--- /dev/null
+++ b/CPP/7zip/Archive/Hfs/HfsIn.cpp
@@ -0,0 +1,480 @@
+// HfsIn.cpp
+
+#include "StdAfx.h"
+
+#include "../../Common/StreamUtils.h"
+#include "Common/IntToString.h"
+
+#include "HfsIn.h"
+
+#include "../../../../C/CpuArch.h"
+
+#define Get16(p) GetBe16(p)
+#define Get32(p) GetBe32(p)
+#define Get64(p) GetBe64(p)
+
+namespace NArchive {
+namespace NHfs {
+
+#define RINOZ(x) { int __tt = (x); if (__tt != 0) return __tt; }
+
+static int CompareIdToIndex(const CIdIndexPair *p1, const CIdIndexPair *p2, void * /* param */)
+{
+ RINOZ(MyCompare(p1->ID, p2->ID));
+ return MyCompare(p1->Index, p2->Index);
+}
+
+bool operator< (const CIdIndexPair &a1, const CIdIndexPair &a2) { return (a1.ID < a2.ID); }
+bool operator> (const CIdIndexPair &a1, const CIdIndexPair &a2) { return (a1.ID > a2.ID); }
+bool operator==(const CIdIndexPair &a1, const CIdIndexPair &a2) { return (a1.ID == a2.ID); }
+bool operator!=(const CIdIndexPair &a1, const CIdIndexPair &a2) { return (a1.ID != a2.ID); }
+
+static UString GetSpecName(const UString &name, UInt32 /* id */)
+{
+ UString name2 = name;
+ name2.Trim();
+ if (name2.IsEmpty())
+ {
+ /*
+ wchar_t s[32];
+ ConvertUInt64ToString(id, s);
+ return L"[" + (UString)s + L"]";
+ */
+ return L"[]";
+ }
+ return name;
+}
+
+UString CDatabase::GetItemPath(int index) const
+{
+ const CItem *item = &Items[index];
+ UString name = GetSpecName(item->Name, item->ID);
+
+ for (int i = 0; i < 1000; i++)
+ {
+ if (item->ParentID < 16 && item->ParentID != 2)
+ {
+ if (item->ParentID != 1)
+ break;
+ return name;
+ }
+ CIdIndexPair pair;
+ pair.ID = item->ParentID;
+ pair.Index = 0;
+ int indexInMap = IdToIndexMap.FindInSorted(pair);
+ if (indexInMap < 0)
+ break;
+ item = &Items[IdToIndexMap[indexInMap].Index];
+ name = GetSpecName(item->Name, item->ID) + WCHAR_PATH_SEPARATOR + name;
+ }
+ return (UString)L"Unknown" + WCHAR_PATH_SEPARATOR + name;
+}
+
+void CFork::Parse(const Byte *p)
+{
+ Size = Get64(p);
+ // ClumpSize = Get32(p + 8);
+ NumBlocks = Get32(p + 0xC);
+ for (int i = 0; i < 8; i++)
+ {
+ CExtent &e = Extents[i];
+ e.Pos = Get32(p + 0x10 + i * 8);
+ e.NumBlocks = Get32(p + 0x10 + i * 8 + 4);
+ }
+}
+
+static HRESULT ReadExtent(int blockSizeLog, IInStream *inStream, Byte *buf, const CExtent &e)
+{
+ RINOK(inStream->Seek((UInt64)e.Pos << blockSizeLog, STREAM_SEEK_SET, NULL));
+ return ReadStream_FALSE(inStream, buf, (size_t)e.NumBlocks << blockSizeLog);
+}
+
+HRESULT CDatabase::ReadFile(const CFork &fork, CByteBuffer &buf, IInStream *inStream)
+{
+ if (fork.NumBlocks >= Header.NumBlocks)
+ return S_FALSE;
+ size_t totalSize = (size_t)fork.NumBlocks << Header.BlockSizeLog;
+ if ((totalSize >> Header.BlockSizeLog) != fork.NumBlocks)
+ return S_FALSE;
+ buf.SetCapacity(totalSize);
+ UInt32 curBlock = 0;
+ for (int i = 0; i < 8; i++)
+ {
+ if (curBlock >= fork.NumBlocks)
+ break;
+ const CExtent &e = fork.Extents[i];
+ if (fork.NumBlocks - curBlock < e.NumBlocks || e.Pos >= Header.NumBlocks)
+ return S_FALSE;
+ RINOK(ReadExtent(Header.BlockSizeLog, inStream,
+ (Byte *)buf + ((size_t)curBlock << Header.BlockSizeLog), e));
+ curBlock += e.NumBlocks;
+ }
+ return S_OK;
+}
+
+struct CNodeDescriptor
+{
+ UInt32 fLink;
+ UInt32 bLink;
+ Byte Kind;
+ Byte Height;
+ UInt16 NumRecords;
+ // UInt16 Reserved;
+ void Parse(const Byte *p);
+};
+
+void CNodeDescriptor::Parse(const Byte *p)
+{
+ fLink = Get32(p);
+ bLink = Get32(p + 4);
+ Kind = p[8];
+ Height = p[9];
+ NumRecords = Get16(p + 10);
+}
+
+struct CHeaderRec
+{
+ // UInt16 TreeDepth;
+ // UInt32 RootNode;
+ // UInt32 LeafRecords;
+ UInt32 FirstLeafNode;
+ // UInt32 LastLeafNode;
+ int NodeSizeLog;
+ // UInt16 MaxKeyLength;
+ UInt32 TotalNodes;
+ // UInt32 FreeNodes;
+ // UInt16 Reserved1;
+ // UInt32 ClumpSize;
+ // Byte BtreeType;
+ // Byte KeyCompareType;
+ // UInt32 Attributes;
+ // UInt32 Reserved3[16];
+
+ HRESULT Parse(const Byte *p);
+};
+
+HRESULT CHeaderRec::Parse(const Byte *p)
+{
+ // TreeDepth = Get16(p);
+ // RootNode = Get32(p + 2);
+ // LeafRecords = Get32(p + 6);
+ FirstLeafNode = Get32(p + 0xA);
+ // LastLeafNode = Get32(p + 0xE);
+ UInt32 nodeSize = Get16(p + 0x12);
+
+ int i;
+ for (i = 9; ((UInt32)1 << i) != nodeSize; i++)
+ if (i == 16)
+ return S_FALSE;
+ NodeSizeLog = i;
+
+ // MaxKeyLength = Get16(p + 0x14);
+ TotalNodes = Get32(p + 0x16);
+ // FreeNodes = Get32(p + 0x1A);
+ // Reserved1 = Get16(p + 0x1E);
+ // ClumpSize = Get32(p + 0x20);
+ // BtreeType = p[0x24];
+ // KeyCompareType = p[0x25];
+ // Attributes = Get32(p + 0x26);
+ /*
+ for (int i = 0; i < 16; i++)
+ Reserved3[i] = Get32(p + 0x2A + i * 4);
+ */
+ return S_OK;
+}
+
+
+enum ENodeType
+{
+ NODE_TYPE_LEAF = 0xFF,
+ NODE_TYPE_INDEX = 0,
+ NODE_TYPE_HEADER = 1,
+ NODE_TYPE_MODE = 2
+};
+
+HRESULT CDatabase::LoadExtentFile(IInStream *inStream)
+{
+ // FileExtents.Clear();
+ // ResExtents.Clear();
+
+ CByteBuffer extents;
+ RINOK(ReadFile(Header.ExtentsFile, extents, inStream));
+
+ const Byte *p = (const Byte *)extents;
+
+ // CNodeDescriptor nodeDesc;
+ // nodeDesc.Parse(p);
+ CHeaderRec hr;
+ RINOK(hr.Parse(p + 14));
+
+ UInt32 node = hr.FirstLeafNode;
+ if (node != 0)
+ return S_FALSE;
+ /*
+ while (node != 0)
+ {
+ size_t nodeOffset = node * hr.NodeSize;
+ if ((node + 1)* hr.NodeSize > CatalogBuf.GetCapacity())
+ return S_FALSE;
+ CNodeDescriptor desc;
+ desc.Parse(p + nodeOffset);
+ if (desc.Kind != NODE_TYPE_LEAF)
+ return S_FALSE;
+ UInt32 ptr = hr.NodeSize;
+ for (int i = 0; i < desc.NumRecords; i++)
+ {
+ UInt32 offs = Get16(p + nodeOffset + hr.NodeSize - (i + 1) * 2);
+ UInt32 offsNext = Get16(p + nodeOffset + hr.NodeSize - (i + 2) * 2);
+
+ const Byte *r = p + nodeOffset + offs;
+ int keyLength = Get16(r);
+ Byte forkType = r[2];
+ UInt32 id = Get16(r + 4);
+ UInt32 startBlock = Get16(r + 4);
+ CObjectVector<CIdExtents> *extents = (forkType == 0) ? &FileExtents : &ResExtents;
+ if (extents->Size() == 0)
+ extents->Add(CIdExtents());
+ else
+ {
+ CIdExtents &e = extents->Back();
+ if (e.ID != id)
+ {
+ if (e.ID > id)
+ return S_FALSE;
+ extents->Add(CIdExtents());
+ }
+ }
+ CIdExtents &e = extents->Back();
+ for (UInt32 k = offs + 10 + 2; k + 8 <= offsNext; k += 8)
+ {
+ CExtent ee;
+ ee.Pos = Get32(p + nodeOffset + k);
+ ee.NumBlocks = Get32(p + nodeOffset + k * 4);
+ e.Extents.Add(ee);
+ }
+ }
+ node = desc.fLink;
+ }
+ */
+ return S_OK;
+}
+
+
+HRESULT CDatabase::LoadCatalog(IInStream *inStream, CProgressVirt *progress)
+{
+ Items.Clear();
+ IdToIndexMap.ClearAndFree();
+
+ CByteBuffer catalogBuf;
+ RINOK(ReadFile(Header.CatalogFile, catalogBuf, inStream));
+ const Byte *p = (const Byte *)catalogBuf;
+
+ // CNodeDescriptor nodeDesc;
+ // nodeDesc.Parse(p);
+ CHeaderRec hr;
+ hr.Parse(p + 14);
+
+ // CaseSensetive = (Header.IsHfsX() && hr.KeyCompareType == 0xBC);
+
+ if ((catalogBuf.GetCapacity() >> hr.NodeSizeLog) < hr.TotalNodes)
+ return S_FALSE;
+
+ CByteBuffer usedBuf;
+ usedBuf.SetCapacity(hr.TotalNodes);
+ for (UInt32 i = 0; i < hr.TotalNodes; i++)
+ usedBuf[i] = 0;
+
+ UInt32 node = hr.FirstLeafNode;
+ while (node != 0)
+ {
+ if (node >= hr.TotalNodes)
+ return S_FALSE;
+ if (usedBuf[node])
+ return S_FALSE;
+ usedBuf[node] = 1;
+ size_t nodeOffset = (size_t)node << hr.NodeSizeLog;
+ CNodeDescriptor desc;
+ desc.Parse(p + nodeOffset);
+ if (desc.Kind != NODE_TYPE_LEAF)
+ return S_FALSE;
+ for (int i = 0; i < desc.NumRecords; i++)
+ {
+ UInt32 nodeSize = (1 << hr.NodeSizeLog);
+ UInt32 offs = Get16(p + nodeOffset + nodeSize - (i + 1) * 2);
+ UInt32 offsNext = Get16(p + nodeOffset + nodeSize - (i + 2) * 2);
+ UInt32 recSize = offsNext - offs;
+ if (offsNext >= nodeSize || offsNext < offs || recSize < 6)
+ return S_FALSE;
+
+ CItem item;
+
+ const Byte *r = p + nodeOffset + offs;
+ UInt32 keyLength = Get16(r);
+ item.ParentID = Get32(r + 2);
+ UString name;
+ if (keyLength < 6 || (keyLength & 1) != 0 || keyLength + 2 > recSize)
+ return S_FALSE;
+ r += 6;
+ recSize -= 6;
+ keyLength -= 6;
+
+ int nameLength = Get16(r);
+ if (nameLength * 2 != (int)keyLength)
+ return S_FALSE;
+ r += 2;
+ recSize -= 2;
+
+ wchar_t *pp = name.GetBuffer(nameLength + 1);
+
+ int j;
+ for (j = 0; j < nameLength; j++)
+ pp[j] = ((wchar_t)r[j * 2] << 8) | r[j * 2 + 1];
+ pp[j] = 0;
+ name.ReleaseBuffer();
+ r += j * 2;
+ recSize -= j * 2;
+
+ if (recSize < 2)
+ return S_FALSE;
+ item.Type = Get16(r);
+
+ if (item.Type != RECORD_TYPE_FOLDER && item.Type != RECORD_TYPE_FILE)
+ continue;
+ if (recSize < 0x58)
+ return S_FALSE;
+
+ // item.Flags = Get16(r + 2);
+ // item.Valence = Get32(r + 4);
+ item.ID = Get32(r + 8);
+ item.CTime = Get32(r + 0xC);
+ item.MTime = Get32(r + 0x10);
+ // item.AttrMTime = Get32(r + 0x14);
+ item.ATime = Get32(r + 0x18);
+ // item.BackupDate = Get32(r + 0x1C);
+
+ /*
+ item.OwnerID = Get32(r + 0x20);
+ item.GroupID = Get32(r + 0x24);
+ item.AdminFlags = r[0x28];
+ item.OwnerFlags = r[0x29];
+ item.FileMode = Get16(r + 0x2A);
+ item.special.iNodeNum = Get16(r + 0x2C);
+ */
+
+ item.Name = name;
+
+ if (item.IsDir())
+ {
+ CIdIndexPair pair;
+ pair.ID = item.ID;
+ pair.Index = Items.Size();
+ IdToIndexMap.Add(pair);
+ }
+ else
+ {
+ CFork fd;
+ recSize -= 0x58;
+ r += 0x58;
+ if (recSize < 0x50 * 2)
+ return S_FALSE;
+ fd.Parse(r);
+ item.Size = fd.Size;
+ item.NumBlocks = fd.NumBlocks;
+ UInt32 curBlock = 0;
+ for (int j = 0; j < 8; j++)
+ {
+ if (curBlock >= fd.NumBlocks)
+ break;
+ const CExtent &e = fd.Extents[j];
+ item.Extents.Add(e);
+ curBlock += e.NumBlocks;
+ }
+ }
+ Items.Add(item);
+ if (progress && Items.Size() % 100 == 0)
+ {
+ RINOK(progress->SetCompleted(Items.Size()));
+ }
+ }
+ node = desc.fLink;
+ }
+ IdToIndexMap.Sort(CompareIdToIndex, NULL);
+ return S_OK;
+}
+
+HRESULT CDatabase::Open(IInStream *inStream, CProgressVirt *progress)
+{
+ static const UInt32 kHeaderSize = 1024 + 512;
+ Byte buf[kHeaderSize];
+ RINOK(ReadStream_FALSE(inStream, buf, kHeaderSize));
+ int i;
+ for (i = 0; i < 1024; i++)
+ if (buf[i] != 0)
+ return S_FALSE;
+ const Byte *p = buf + 1024;
+ CVolHeader &h = Header;
+
+ h.Header[0] = p[0];
+ h.Header[1] = p[1];
+ if (p[0] != 'H' || (p[1] != '+' && p[1] != 'X'))
+ return S_FALSE;
+ h.Version = Get16(p + 2);
+ if (h.Version < 4 || h.Version > 5)
+ return S_FALSE;
+
+ // h.Attr = Get32(p + 4);
+ // h.LastMountedVersion = Get32(p + 8);
+ // h.JournalInfoBlock = Get32(p + 0xC);
+
+ h.CTime = Get32(p + 0x10);
+ h.MTime = Get32(p + 0x14);
+ // h.BackupTime = Get32(p + 0x18);
+ // h.CheckedTime = Get32(p + 0x1C);
+
+ // h.NumFiles = Get32(p + 0x20);
+ // h.NumFolders = Get32(p + 0x24);
+
+ UInt32 numFiles = Get32(p + 0x20);
+ UInt32 numFolders = Get32(p + 0x24);;
+ if (progress)
+ {
+ RINOK(progress->SetTotal(numFolders + numFiles));
+ }
+
+ UInt32 blockSize = Get32(p + 0x28);
+
+ for (i = 9; ((UInt32)1 << i) != blockSize; i++)
+ if (i == 31)
+ return S_FALSE;
+ h.BlockSizeLog = i;
+
+ h.NumBlocks = Get32(p + 0x2C);
+ h.NumFreeBlocks = Get32(p + 0x30);
+
+ /*
+ h.WriteCount = Get32(p + 0x44);
+ for (i = 0; i < 6; i++)
+ h.FinderInfo[i] = Get32(p + 0x50 + i * 4);
+ h.VolID = Get64(p + 0x68);
+ */
+
+ UInt64 endPos;
+ RINOK(inStream->Seek(0, STREAM_SEEK_END, &endPos));
+ if ((endPos >> h.BlockSizeLog) < h.NumBlocks)
+ return S_FALSE;
+
+ // h.AllocationFile.Parse(p + 0x70 + 0x50 * 0);
+ h.ExtentsFile.Parse( p + 0x70 + 0x50 * 1);
+ h.CatalogFile.Parse( p + 0x70 + 0x50 * 2);
+ // h.AttributesFile.Parse(p + 0x70 + 0x50 * 3);
+ // h.StartupFile.Parse( p + 0x70 + 0x50 * 4);
+
+ RINOK(LoadExtentFile(inStream));
+ RINOK(LoadCatalog(inStream, progress));
+
+ // if (Header.NumFiles + Header.NumFolders != (UInt32)Items.Size()) return S_OK;
+
+ return S_OK;
+}
+
+}}
diff --git a/CPP/7zip/Archive/Hfs/HfsIn.h b/CPP/7zip/Archive/Hfs/HfsIn.h
new file mode 100755
index 00000000..c1953905
--- /dev/null
+++ b/CPP/7zip/Archive/Hfs/HfsIn.h
@@ -0,0 +1,154 @@
+// HfsIn.h
+
+#ifndef __ARCHIVE_HFS_IN_H
+#define __ARCHIVE_HFS_IN_H
+
+#include "Common/MyString.h"
+#include "Common/Buffer.h"
+
+namespace NArchive {
+namespace NHfs {
+
+struct CExtent
+{
+ UInt32 Pos;
+ UInt32 NumBlocks;
+};
+
+struct CFork
+{
+ UInt64 Size;
+ // UInt32 ClumpSize;
+ UInt32 NumBlocks;
+ CExtent Extents[8];
+ void Parse(const Byte *p);
+};
+
+struct CVolHeader
+{
+ Byte Header[2];
+ UInt16 Version;
+ // UInt32 Attr;
+ // UInt32 LastMountedVersion;
+ // UInt32 JournalInfoBlock;
+
+ UInt32 CTime;
+ UInt32 MTime;
+ // UInt32 BackupTime;
+ // UInt32 CheckedTime;
+
+ // UInt32 NumFiles;
+ // UInt32 NumFolders;
+ int BlockSizeLog;
+ UInt32 NumBlocks;
+ UInt32 NumFreeBlocks;
+
+ // UInt32 WriteCount;
+ // UInt32 FinderInfo[8];
+ // UInt64 VolID;
+
+ // CFork AllocationFile;
+ CFork ExtentsFile;
+ CFork CatalogFile;
+ // CFork AttributesFile;
+ // CFork StartupFile;
+
+ bool IsHfsX() const { return Version > 4; }
+};
+
+inline void HfsTimeToFileTime(UInt32 hfsTime, FILETIME &ft)
+{
+ UInt64 v = ((UInt64)3600 * 24 * (365 * 303 + 24 * 3) + hfsTime) * 10000000;
+ ft.dwLowDateTime = (DWORD)v;
+ ft.dwHighDateTime = (DWORD)(v >> 32);
+}
+
+enum ERecordType
+{
+ RECORD_TYPE_FOLDER = 1,
+ RECORD_TYPE_FILE = 2,
+ RECORD_TYPE_FOLDER_THREAD = 3,
+ RECORD_TYPE_FILE_THREAD = 4
+};
+
+struct CItem
+{
+ UString Name;
+
+ UInt32 ParentID;
+
+ UInt16 Type;
+ // UInt16 Flags;
+ // UInt32 Valence;
+ UInt32 ID;
+ UInt32 CTime;
+ UInt32 MTime;
+ // UInt32 AttrMTime;
+ UInt32 ATime;
+ // UInt32 BackupDate;
+
+ /*
+ UInt32 OwnerID;
+ UInt32 GroupID;
+ Byte AdminFlags;
+ Byte OwnerFlags;
+ UInt16 FileMode;
+ union
+ {
+ UInt32 iNodeNum;
+ UInt32 LinkCount;
+ UInt32 RawDevice;
+ } special;
+ */
+
+ UInt64 Size;
+ UInt32 NumBlocks;
+ CRecordVector<CExtent> Extents;
+
+ bool IsDir() const { return Type == RECORD_TYPE_FOLDER; }
+ CItem(): Size(0), NumBlocks(0) {}
+};
+
+struct CIdIndexPair
+{
+ UInt32 ID;
+ int Index;
+};
+
+struct CProgressVirt
+{
+ virtual HRESULT SetTotal(UInt64 numFiles) PURE;
+ virtual HRESULT SetCompleted(UInt64 numFiles) PURE;
+};
+
+class CDatabase
+{
+ // CObjectVector<CIdExtents> FileExtents;
+ // CObjectVector<CIdExtents> ResExtents;
+ CRecordVector<CIdIndexPair> IdToIndexMap;
+
+ HRESULT LoadExtentFile(IInStream *inStream);
+ HRESULT LoadCatalog(IInStream *inStream, CProgressVirt *progress);
+
+ HRESULT ReadFile(const CFork &fork, CByteBuffer &buf, IInStream *inStream);
+public:
+ CVolHeader Header;
+ CObjectVector<CItem> Items;
+ // bool CaseSensetive;
+
+ void Clear()
+ {
+ // CaseSensetive = false;
+ Items.Clear();
+ // FileExtents.Clear();
+ // ResExtents.Clear();
+ IdToIndexMap.Clear();
+ }
+
+ UString GetItemPath(int index) const;
+ HRESULT Open(IInStream *inStream, CProgressVirt *progress);
+};
+
+}}
+
+#endif
diff --git a/CPP/7zip/Archive/Hfs/HfsRegister.cpp b/CPP/7zip/Archive/Hfs/HfsRegister.cpp
new file mode 100755
index 00000000..2d706900
--- /dev/null
+++ b/CPP/7zip/Archive/Hfs/HfsRegister.cpp
@@ -0,0 +1,13 @@
+// HfsRegister.cpp
+
+#include "StdAfx.h"
+
+#include "../../Common/RegisterArc.h"
+
+#include "HfsHandler.h"
+static IInArchive *CreateArc() { return new NArchive::NHfs::CHandler; }
+
+static CArcInfo g_ArcInfo =
+ { L"HFS", L"hfs", 0, 0xE3, { 'H', '+', 0, 4 }, 4, false, CreateArc, 0 };
+
+REGISTER_ARC(Hfs)
diff --git a/CPP/7zip/Archive/IArchive.h b/CPP/7zip/Archive/IArchive.h
index e0ae7aa1..88d6c408 100755
--- a/CPP/7zip/Archive/IArchive.h
+++ b/CPP/7zip/Archive/IArchive.h
@@ -22,7 +22,7 @@ namespace NFileTimeType
namespace NArchive
{
- enum
+ enum
{
kName = 0,
kClassID,
@@ -39,7 +39,7 @@ namespace NArchive
{
namespace NAskMode
{
- enum
+ enum
{
kExtract = 0,
kTest,
@@ -48,7 +48,7 @@ namespace NArchive
}
namespace NOperationResult
{
- enum
+ enum
{
kOK = 0,
kUnSupportedMethod,
@@ -61,7 +61,7 @@ namespace NArchive
{
namespace NOperationResult
{
- enum
+ enum
{
kOK = 0,
kError
@@ -70,33 +70,42 @@ namespace NArchive
}
}
+#define INTERFACE_IArchiveOpenCallback(x) \
+ STDMETHOD(SetTotal)(const UInt64 *files, const UInt64 *bytes) x; \
+ STDMETHOD(SetCompleted)(const UInt64 *files, const UInt64 *bytes) x; \
+
ARCHIVE_INTERFACE(IArchiveOpenCallback, 0x10)
{
- STDMETHOD(SetTotal)(const UInt64 *files, const UInt64 *bytes) PURE;
- STDMETHOD(SetCompleted)(const UInt64 *files, const UInt64 *bytes) PURE;
+ INTERFACE_IArchiveOpenCallback(PURE);
};
+#define INTERFACE_IArchiveExtractCallback(x) \
+ INTERFACE_IProgress(x) \
+ /* GetStream OUT: S_OK - OK, S_FALSE - skeep this file */ \
+ STDMETHOD(GetStream)(UInt32 index, ISequentialOutStream **outStream, Int32 askExtractMode) x; \
+ STDMETHOD(PrepareOperation)(Int32 askExtractMode) x; \
+ STDMETHOD(SetOperationResult)(Int32 resultEOperationResult) x; \
+
ARCHIVE_INTERFACE_SUB(IArchiveExtractCallback, IProgress, 0x20)
{
- STDMETHOD(GetStream)(UInt32 index, ISequentialOutStream **outStream,
- Int32 askExtractMode) PURE;
- // GetStream OUT: S_OK - OK, S_FALSE - skeep this file
- STDMETHOD(PrepareOperation)(Int32 askExtractMode) PURE;
- STDMETHOD(SetOperationResult)(Int32 resultEOperationResult) PURE;
+ INTERFACE_IArchiveExtractCallback(PURE)
};
+#define INTERFACE_IArchiveOpenVolumeCallback(x) \
+ STDMETHOD(GetProperty)(PROPID propID, PROPVARIANT *value) x; \
+ STDMETHOD(GetStream)(const wchar_t *name, IInStream **inStream) x; \
+
ARCHIVE_INTERFACE(IArchiveOpenVolumeCallback, 0x30)
{
- STDMETHOD(GetProperty)(PROPID propID, PROPVARIANT *value) PURE;
- STDMETHOD(GetStream)(const wchar_t *name, IInStream **inStream) PURE;
+ INTERFACE_IArchiveOpenVolumeCallback(PURE);
};
ARCHIVE_INTERFACE(IInArchiveGetStream, 0x40)
{
- STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **stream) PURE;
+ STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **stream) PURE;
};
@@ -108,7 +117,7 @@ ARCHIVE_INTERFACE(IArchiveOpenSetSubArchiveName, 0x50)
/*
IInArchive::Extract:
- indices must be sorted
+ indices must be sorted
numItems = 0xFFFFFFFF means "all files"
testMode != 0 means "test files without writing to outStream"
*/
@@ -131,23 +140,30 @@ ARCHIVE_INTERFACE(IInArchive, 0x60)
};
+#define INTERFACE_IArchiveUpdateCallback(x) \
+ INTERFACE_IProgress(x); \
+ STDMETHOD(GetUpdateItemInfo)(UInt32 index, \
+ Int32 *newData, /*1 - new data, 0 - old data */ \
+ Int32 *newProperties, /* 1 - new properties, 0 - old properties */ \
+ UInt32 *indexInArchive /* -1 if there is no in archive, or if doesn't matter */ \
+ ) x; \
+ STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value) x; \
+ STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **inStream) x; \
+ STDMETHOD(SetOperationResult)(Int32 operationResult) x; \
+
ARCHIVE_INTERFACE_SUB(IArchiveUpdateCallback, IProgress, 0x80)
{
- STDMETHOD(GetUpdateItemInfo)(UInt32 index,
- Int32 *newData, // 1 - new data, 0 - old data
- Int32 *newProperties, // 1 - new properties, 0 - old properties
- UInt32 *indexInArchive // -1 if there is no in archive, or if doesn't matter
- ) PURE;
- STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value) PURE;
- STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **inStream) PURE;
- STDMETHOD(SetOperationResult)(Int32 operationResult) PURE;
+ INTERFACE_IArchiveUpdateCallback(PURE);
};
+#define INTERFACE_IArchiveUpdateCallback2(x) \
+ INTERFACE_IArchiveUpdateCallback(x) \
+ STDMETHOD(GetVolumeSize)(UInt32 index, UInt64 *size) x; \
+ STDMETHOD(GetVolumeStream)(UInt32 index, ISequentialOutStream **volumeStream) x; \
ARCHIVE_INTERFACE_SUB(IArchiveUpdateCallback2, IArchiveUpdateCallback, 0x82)
{
- STDMETHOD(GetVolumeSize)(UInt32 index, UInt64 *size) PURE;
- STDMETHOD(GetVolumeStream)(UInt32 index, ISequentialOutStream **volumeStream) PURE;
+ INTERFACE_IArchiveUpdateCallback2(PURE);
};
@@ -196,12 +212,17 @@ ARCHIVE_INTERFACE(ISetProperties, 0x03)
{ *numProperties = sizeof(kArcProps) / sizeof(kArcProps[0]); return S_OK; } \
STDMETHODIMP CHandler::GetArchivePropertyInfo IMP_IInArchive_GetProp(kArcProps)
+#define IMP_IInArchive_ArcProps_WITH_NAME \
+ STDMETHODIMP CHandler::GetNumberOfArchiveProperties(UInt32 *numProperties) \
+ { *numProperties = sizeof(kArcProps) / sizeof(kArcProps[0]); return S_OK; } \
+ STDMETHODIMP CHandler::GetArchivePropertyInfo IMP_IInArchive_GetProp_WITH_NAME(kArcProps)
+
#define IMP_IInArchive_ArcProps_NO \
STDMETHODIMP CHandler::GetNumberOfArchiveProperties(UInt32 *numProperties) \
{ *numProperties = 0; return S_OK; } \
STDMETHODIMP CHandler::GetArchivePropertyInfo(UInt32, BSTR *, PROPID *, VARTYPE *) \
{ return E_NOTIMPL; } \
STDMETHODIMP CHandler::GetArchiveProperty(PROPID, PROPVARIANT *value) \
- { value->vt = VT_EMPTY; return S_OK; }
+ { value->vt = VT_EMPTY; return S_OK; }
#endif
diff --git a/CPP/7zip/Archive/7z/7z.ico b/CPP/7zip/Archive/Icons/7z.ico
index 319753a1..319753a1 100755
--- a/CPP/7zip/Archive/7z/7z.ico
+++ b/CPP/7zip/Archive/Icons/7z.ico
Binary files differ
diff --git a/CPP/7zip/Archive/Arj/arj.ico b/CPP/7zip/Archive/Icons/arj.ico
index c0f8b141..c0f8b141 100755
--- a/CPP/7zip/Archive/Arj/arj.ico
+++ b/CPP/7zip/Archive/Icons/arj.ico
Binary files differ
diff --git a/CPP/7zip/Archive/BZip2/bz2.ico b/CPP/7zip/Archive/Icons/bz2.ico
index 614e3540..614e3540 100755
--- a/CPP/7zip/Archive/BZip2/bz2.ico
+++ b/CPP/7zip/Archive/Icons/bz2.ico
Binary files differ
diff --git a/CPP/7zip/Archive/Cab/cab.ico b/CPP/7zip/Archive/Icons/cab.ico
index cc2007fc..cc2007fc 100755
--- a/CPP/7zip/Archive/Cab/cab.ico
+++ b/CPP/7zip/Archive/Icons/cab.ico
Binary files differ
diff --git a/CPP/7zip/Archive/Cpio/cpio.ico b/CPP/7zip/Archive/Icons/cpio.ico
index 9abaabc7..9abaabc7 100755
--- a/CPP/7zip/Archive/Cpio/cpio.ico
+++ b/CPP/7zip/Archive/Icons/cpio.ico
Binary files differ
diff --git a/CPP/7zip/Archive/Deb/deb.ico b/CPP/7zip/Archive/Icons/deb.ico
index 97a08654..97a08654 100755
--- a/CPP/7zip/Archive/Deb/deb.ico
+++ b/CPP/7zip/Archive/Icons/deb.ico
Binary files differ
diff --git a/CPP/7zip/Archive/Icons/dmg.ico b/CPP/7zip/Archive/Icons/dmg.ico
new file mode 100755
index 00000000..7d63b09f
--- /dev/null
+++ b/CPP/7zip/Archive/Icons/dmg.ico
Binary files differ
diff --git a/CPP/7zip/Archive/GZip/gz.ico b/CPP/7zip/Archive/Icons/gz.ico
index f50d8c08..f50d8c08 100755
--- a/CPP/7zip/Archive/GZip/gz.ico
+++ b/CPP/7zip/Archive/Icons/gz.ico
Binary files differ
diff --git a/CPP/7zip/Archive/Icons/hfs.ico b/CPP/7zip/Archive/Icons/hfs.ico
new file mode 100755
index 00000000..92a46b81
--- /dev/null
+++ b/CPP/7zip/Archive/Icons/hfs.ico
Binary files differ
diff --git a/CPP/7zip/Archive/Iso/Iso.ico b/CPP/7zip/Archive/Icons/iso.ico
index 2538e408..2538e408 100755
--- a/CPP/7zip/Archive/Iso/Iso.ico
+++ b/CPP/7zip/Archive/Icons/iso.ico
Binary files differ
diff --git a/CPP/7zip/Archive/Lzh/lzh.ico b/CPP/7zip/Archive/Icons/lzh.ico
index 84dab49c..84dab49c 100755
--- a/CPP/7zip/Archive/Lzh/lzh.ico
+++ b/CPP/7zip/Archive/Icons/lzh.ico
Binary files differ
diff --git a/CPP/7zip/Archive/Lzma/lzma.ico b/CPP/7zip/Archive/Icons/lzma.ico
index 1f4f754c..2de2c249 100755
--- a/CPP/7zip/Archive/Lzma/lzma.ico
+++ b/CPP/7zip/Archive/Icons/lzma.ico
Binary files differ
diff --git a/CPP/7zip/Archive/Rar/rar.ico b/CPP/7zip/Archive/Icons/rar.ico
index 2918d294..2918d294 100755
--- a/CPP/7zip/Archive/Rar/rar.ico
+++ b/CPP/7zip/Archive/Icons/rar.ico
Binary files differ
diff --git a/CPP/7zip/Archive/RPM/rpm.ico b/CPP/7zip/Archive/Icons/rpm.ico
index cdeb8d1b..cdeb8d1b 100755
--- a/CPP/7zip/Archive/RPM/rpm.ico
+++ b/CPP/7zip/Archive/Icons/rpm.ico
Binary files differ
diff --git a/CPP/7zip/Archive/Split/Split.ico b/CPP/7zip/Archive/Icons/split.ico
index 5cb93e84..5cb93e84 100755
--- a/CPP/7zip/Archive/Split/Split.ico
+++ b/CPP/7zip/Archive/Icons/split.ico
Binary files differ
diff --git a/CPP/7zip/Archive/Tar/tar.ico b/CPP/7zip/Archive/Icons/tar.ico
index 6835885b..6835885b 100755
--- a/CPP/7zip/Archive/Tar/tar.ico
+++ b/CPP/7zip/Archive/Icons/tar.ico
Binary files differ
diff --git a/CPP/7zip/Archive/Wim/wim.ico b/CPP/7zip/Archive/Icons/wim.ico
index 887975e6..887975e6 100755
--- a/CPP/7zip/Archive/Wim/wim.ico
+++ b/CPP/7zip/Archive/Icons/wim.ico
Binary files differ
diff --git a/CPP/7zip/Archive/Icons/xar.ico b/CPP/7zip/Archive/Icons/xar.ico
new file mode 100755
index 00000000..02707351
--- /dev/null
+++ b/CPP/7zip/Archive/Icons/xar.ico
Binary files differ
diff --git a/CPP/7zip/Archive/Z/Z.ico b/CPP/7zip/Archive/Icons/z.ico
index 2db53583..2db53583 100755
--- a/CPP/7zip/Archive/Z/Z.ico
+++ b/CPP/7zip/Archive/Icons/z.ico
Binary files differ
diff --git a/CPP/7zip/Archive/Zip/zip.ico b/CPP/7zip/Archive/Icons/zip.ico
index 2af46066..2af46066 100755
--- a/CPP/7zip/Archive/Zip/zip.ico
+++ b/CPP/7zip/Archive/Icons/zip.ico
Binary files differ
diff --git a/CPP/7zip/Archive/Iso/IsoHandler.cpp b/CPP/7zip/Archive/Iso/IsoHandler.cpp
index 0ab39c4f..db1b9c06 100755
--- a/CPP/7zip/Archive/Iso/IsoHandler.cpp
+++ b/CPP/7zip/Archive/Iso/IsoHandler.cpp
@@ -26,19 +26,19 @@ using namespace NTime;
namespace NArchive {
namespace NIso {
-STATPROPSTG kProps[] =
+STATPROPSTG kProps[] =
{
{ NULL, kpidPath, VT_BSTR},
- { NULL, kpidIsFolder, VT_BOOL},
+ { NULL, kpidIsDir, VT_BOOL},
{ NULL, kpidSize, VT_UI8},
- { NULL, kpidPackedSize, VT_UI8},
- { NULL, kpidLastWriteTime, VT_FILETIME}
+ { NULL, kpidPackSize, VT_UI8},
+ { NULL, kpidMTime, VT_FILETIME}
};
IMP_IInArchive_Props
IMP_IInArchive_ArcProps_NO
-STDMETHODIMP CHandler::Open(IInStream *stream,
+STDMETHODIMP CHandler::Open(IInStream *stream,
const UInt64 * /* maxCheckStartPosition */,
IArchiveOpenCallback * /* openArchiveCallback */)
{
@@ -89,15 +89,13 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
prop = (const wchar_t *)s;
break;
}
- case kpidIsFolder:
+ case kpidIsDir:
prop = false;
break;
case kpidSize:
- case kpidPackedSize:
- {
+ case kpidPackSize:
prop = (UInt64)_archive.GetBootItemSize(index);
break;
- }
}
}
else
@@ -125,15 +123,15 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
prop = (const wchar_t *)NItemName::GetOSName2(s);
}
break;
- case kpidIsFolder:
+ case kpidIsDir:
prop = item.IsDir();
break;
case kpidSize:
- case kpidPackedSize:
+ case kpidPackSize:
if (!item.IsDir())
prop = (UInt64)item.DataLength;
break;
- case kpidLastWriteTime:
+ case kpidMTime:
{
FILETIME utcFileTime;
if (item.DateTime.GetFileTime(utcFileTime))
@@ -242,7 +240,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
streamSpec->Init(currentItemSize);
RINOK(copyCoder->Code(inStream, realOutStream, NULL, NULL, progress));
realOutStream.Release();
- RINOK(extractCallback->SetOperationResult((copyCoderSpec->TotalSize == currentItemSize) ?
+ RINOK(extractCallback->SetOperationResult((copyCoderSpec->TotalSize == currentItemSize) ?
NArchive::NExtract::NOperationResult::kOK:
NArchive::NExtract::NOperationResult::kDataError));
}
diff --git a/CPP/7zip/Archive/Iso/IsoHandler.h b/CPP/7zip/Archive/Iso/IsoHandler.h
index 5750cbc9..bb905a22 100755
--- a/CPP/7zip/Archive/Iso/IsoHandler.h
+++ b/CPP/7zip/Archive/Iso/IsoHandler.h
@@ -12,7 +12,7 @@
namespace NArchive {
namespace NIso {
-class CHandler:
+class CHandler:
public IInArchive,
public CMyUnknownImp
{
diff --git a/CPP/7zip/Archive/Iso/IsoHeader.cpp b/CPP/7zip/Archive/Iso/IsoHeader.cpp
index 9555e49b..b3e418bb 100755
--- a/CPP/7zip/Archive/Iso/IsoHeader.cpp
+++ b/CPP/7zip/Archive/Iso/IsoHeader.cpp
@@ -9,7 +9,7 @@ namespace NIso {
const char *kElToritoSpec = "EL TORITO SPECIFICATION\0\0\0\0\0\0\0\0\0";
-const wchar_t *kMediaTypes[5] =
+const wchar_t *kMediaTypes[5] =
{
L"NoEmulation",
L"1.2M",
diff --git a/CPP/7zip/Archive/Iso/IsoIn.cpp b/CPP/7zip/Archive/Iso/IsoIn.cpp
index f4896d37..37d2798a 100755
--- a/CPP/7zip/Archive/Iso/IsoIn.cpp
+++ b/CPP/7zip/Archive/Iso/IsoIn.cpp
@@ -174,7 +174,7 @@ void CInArchive::ReadDirRecord2(CDirRecord &r, Byte len)
ReadBytes((Byte *)r.FileId, idLen);
int padSize = 1 - (idLen & 1);
- // SkeepZeros(1 - (idLen & 1));
+ // SkeepZeros(1 - (idLen & 1));
Skeep(1 - (idLen & 1)); // it's bug in some cd's. Must be zeros
int curPos = 33 + idLen + padSize;
@@ -187,7 +187,7 @@ void CInArchive::ReadDirRecord2(CDirRecord &r, Byte len)
void CInArchive::ReadDirRecord(CDirRecord &r)
{
- Byte len = ReadByte();
+ Byte len = ReadByte();
// Some CDs can have incorrect value len = 48 ('0') in VolumeDescriptor.
// But maybe we must use real "len" for other records.
len = 34;
@@ -218,8 +218,8 @@ void CInArchive::ReadVolumeDescriptor(CVolumeDescriptor &d)
ReadBytes(d.CopyrightFileId, sizeof(d.CopyrightFileId));
ReadBytes(d.AbstractFileId, sizeof(d.AbstractFileId));
ReadBytes(d.BibFileId, sizeof(d.BibFileId));
- ReadDateTime(d.CreationTime);
- ReadDateTime(d.ModificationTime);
+ ReadDateTime(d.CTime);
+ ReadDateTime(d.MTime);
ReadDateTime(d.ExpirationTime);
ReadDateTime(d.EffectiveTime);
d.FileStructureVersion = ReadByte(); // = 1
@@ -228,13 +228,19 @@ void CInArchive::ReadVolumeDescriptor(CVolumeDescriptor &d)
SkeepZeros(653);
}
-static inline bool CheckDescriptorSignature(const Byte *sig)
+static const Byte kSig_CD001[5] = { 'C', 'D', '0', '0', '1' };
+
+static const Byte kSig_NSR02[5] = { 'N', 'S', 'R', '0', '2' };
+static const Byte kSig_NSR03[5] = { 'N', 'S', 'R', '0', '3' };
+static const Byte kSig_BEA01[5] = { 'B', 'E', 'A', '0', '1' };
+static const Byte kSig_TEA01[5] = { 'T', 'E', 'A', '0', '1' };
+
+static inline bool CheckSignature(const Byte *sig, const Byte *data)
{
- return sig[0] == 'C' &&
- sig[1] == 'D' &&
- sig[2] == '0' &&
- sig[3] == '0' &&
- sig[4] == '1';
+ for (int i = 0; i < 5; i++)
+ if (sig[i] != data[i])
+ return false;
+ return true;
}
void CInArchive::SeekToBlock(UInt32 blockIndex)
@@ -346,17 +352,41 @@ HRESULT CInArchive::Open2()
VolDescs.Add(CVolumeDescriptor());
for (;;)
{
- Byte sig[6];
- ReadBytes(sig, 6);
- if (!CheckDescriptorSignature(sig + 1))
+ Byte sig[7];
+ ReadBytes(sig, 7);
+ Byte ver = sig[6];
+ if (!CheckSignature(kSig_CD001, sig + 1))
+ {
return S_FALSE;
+ /*
+ if (sig[0] != 0 || ver != 1)
+ break;
+ if (CheckSignature(kSig_BEA01, sig + 1))
+ {
+ }
+ else if (CheckSignature(kSig_TEA01, sig + 1))
+ {
+ break;
+ }
+ else if (CheckSignature(kSig_NSR02, sig + 1))
+ {
+ }
+ else
+ break;
+ SkeepZeros(0x800 - 7);
+ continue;
+ */
+ }
// version = 2 for ISO 9660:1999?
- Byte ver = ReadByte();
if (ver > 2)
throw S_FALSE;
if (sig[0] == NVolDescType::kTerminator)
+ {
break;
+ // Skeep(0x800 - 7);
+ // continue;
+ }
switch(sig[0])
{
case NVolDescType::kBootRecord:
diff --git a/CPP/7zip/Archive/Iso/IsoIn.h b/CPP/7zip/Archive/Iso/IsoIn.h
index 4f9705c4..ce53a1e3 100755
--- a/CPP/7zip/Archive/Iso/IsoIn.h
+++ b/CPP/7zip/Archive/Iso/IsoIn.h
@@ -109,7 +109,7 @@ struct CDateTime
Byte Second;
Byte Hundredths;
signed char GmtOffset; // min intervals from -48 (West) to +52 (East) recorded.
- bool NotSpecified() const { return Year == 0 && Month == 0 && Day == 0 &&
+ bool NotSpecified() const { return Year == 0 && Month == 0 && Day == 0 &&
Hour == 0 && Minute == 0 && Second == 0 && GmtOffset == 0; }
};
@@ -130,7 +130,7 @@ struct CBootInitialEntry
{
bool Bootable;
Byte BootMediaType;
- UInt16 LoadSegment;
+ UInt16 LoadSegment;
/* This is the load segment for the initial boot image. If this
value is 0 the system will use the traditional segment of 7C0. If this value
is non-zero the system will use the specified segment. This applies to x86
@@ -143,10 +143,10 @@ struct CBootInitialEntry
UInt32 LoadRBA; // This is the start address of the virtual disk. CD’s use
// Relative/Logical block addressing.
- UInt64 GetSize() const
- {
+ UInt64 GetSize() const
+ {
// if (BootMediaType == NBootMediaType::k1d44Floppy) (1440 << 10);
- return SectorCount * 512;
+ return SectorCount * 512;
}
UString GetName() const
@@ -173,7 +173,7 @@ struct CBootInitialEntry
struct CVolumeDescriptor
{
Byte VolFlags;
- Byte SystemId[32]; // a-characters. An identification of a system
+ Byte SystemId[32]; // a-characters. An identification of a system
// which can recognize and act upon the content of the Logical
// Sectors with logical Sector Numbers 0 to 15 of the volume.
Byte VolumeId[32]; // d-characters. An identification of the volume.
@@ -195,19 +195,19 @@ struct CVolumeDescriptor
Byte CopyrightFileId[37];
Byte AbstractFileId[37];
Byte BibFileId[37];
- CDateTime CreationTime;
- CDateTime ModificationTime;
+ CDateTime CTime;
+ CDateTime MTime;
CDateTime ExpirationTime;
CDateTime EffectiveTime;
Byte FileStructureVersion; // = 1;
Byte ApplicationUse[512];
- bool IsJoliet() const
+ bool IsJoliet() const
{
if ((VolFlags & 1) != 0)
return false;
Byte b = EscapeSequence[2];
- return (EscapeSequence[0] == 0x25 && EscapeSequence[1] == 0x2F &&
+ return (EscapeSequence[0] == 0x25 && EscapeSequence[1] == 0x2F &&
(b == 0x40 || b == 0x43 || b == 0x45));
}
};
@@ -272,8 +272,8 @@ public:
bool IsJoliet() const { return VolDescs[MainVolDescIndex].IsJoliet(); }
- UInt64 GetBootItemSize(int index) const
- {
+ UInt64 GetBootItemSize(int index) const
+ {
const CBootInitialEntry &be = BootEntries[index];
UInt64 size = be.GetSize();
if (be.BootMediaType == NBootMediaType::k1d2Floppy)
@@ -288,7 +288,7 @@ public:
if (_archiveSize - startPos < size)
size = _archiveSize - startPos;
}
- return size;
+ return size;
}
bool IsSusp;
diff --git a/CPP/7zip/Archive/Iso/IsoItem.h b/CPP/7zip/Archive/Iso/IsoItem.h
index fcb9531f..f39c2f5d 100755
--- a/CPP/7zip/Archive/Iso/IsoItem.h
+++ b/CPP/7zip/Archive/Iso/IsoItem.h
@@ -7,6 +7,8 @@
#include "Common/MyString.h"
#include "Common/Buffer.h"
+#include "Windows/Time.h"
+
#include "IsoHeader.h"
namespace NArchive {
@@ -24,22 +26,16 @@ struct CRecordingDateTime
bool GetFileTime(FILETIME &ft) const
{
- SYSTEMTIME st;
- st.wYear = (WORD)(Year + 1900);
- st.wMonth = Month;
- st.wDayOfWeek = 0; // check it
- st.wDay = Day;
- st.wHour = Hour;
- st.wMinute = Minute;
- st.wSecond = Second;
- st.wMilliseconds = 0;
- if (!SystemTimeToFileTime(&st, &ft))
- return false;
- UInt64 value = (((UInt64)ft.dwHighDateTime) << 32) + ft.dwLowDateTime;
- value -= (UInt64)((Int64)GmtOffset * 15 * 60 * 10000000);
+ UInt64 value;
+ bool res = NWindows::NTime::GetSecondsSince1601(Year + 1900, Month, Day, Hour, Minute, Second, value);
+ if (res)
+ {
+ value -= (UInt64)((Int64)GmtOffset * 15 * 60);
+ value *= 10000000;
+ }
ft.dwLowDateTime = (DWORD)value;
ft.dwHighDateTime = (DWORD)(value >> 32);
- return true;
+ return res;
}
};
@@ -57,8 +53,8 @@ struct CDirRecord
CByteBuffer SystemUse;
bool IsDir() const { return (FileFlags & NFileFlags::kDirectory) != 0; }
- bool IsSystemItem() const
- {
+ bool IsSystemItem() const
+ {
if (FileId.GetCapacity() != 1)
return false;
Byte b = *(const Byte *)FileId;
@@ -111,11 +107,11 @@ struct CDirRecord
bool CheckSusp(const Byte *p, int &startPos) const
{
- if (p[0] == 'S' &&
- p[1] == 'P' &&
- p[2] == 0x7 &&
- p[3] == 0x1 &&
- p[4] == 0xBE &&
+ if (p[0] == 'S' &&
+ p[1] == 'P' &&
+ p[2] == 0x7 &&
+ p[3] == 0x1 &&
+ p[4] == 0xBE &&
p[5] == 0xEF)
{
startPos = p[6];
diff --git a/CPP/7zip/Archive/Iso/StdAfx.cpp b/CPP/7zip/Archive/Iso/StdAfx.cpp
deleted file mode 100755
index d0feea85..00000000
--- a/CPP/7zip/Archive/Iso/StdAfx.cpp
+++ /dev/null
@@ -1,3 +0,0 @@
-// StdAfx.cpp
-
-#include "StdAfx.h"
diff --git a/CPP/7zip/Archive/Lzh/LzhCRC.cpp b/CPP/7zip/Archive/Lzh/LzhCRC.cpp
index ca1235bb..e299bf6c 100755
--- a/CPP/7zip/Archive/Lzh/LzhCRC.cpp
+++ b/CPP/7zip/Archive/Lzh/LzhCRC.cpp
@@ -17,9 +17,9 @@ void CCRC::InitTable()
{
UInt32 r = i;
for (int j = 0; j < 8; j++)
- if (r & 1)
+ if (r & 1)
r = (r >> 1) ^ kCRCPoly;
- else
+ else
r >>= 1;
CCRC::Table[i] = (UInt16)r;
}
diff --git a/CPP/7zip/Archive/Lzh/LzhCRC.h b/CPP/7zip/Archive/Lzh/LzhCRC.h
index e49d649c..be2a4569 100755
--- a/CPP/7zip/Archive/Lzh/LzhCRC.h
+++ b/CPP/7zip/Archive/Lzh/LzhCRC.h
@@ -19,7 +19,7 @@ public:
CCRC(): _value(0){};
void Init() { _value = 0; }
void Update(const void *data, size_t size);
- UInt16 GetDigest() const { return _value; }
+ UInt16 GetDigest() const { return _value; }
};
}}
diff --git a/CPP/7zip/Archive/Lzh/LzhHandler.cpp b/CPP/7zip/Archive/Lzh/LzhHandler.cpp
index c5123f56..ee43a3b0 100755
--- a/CPP/7zip/Archive/Lzh/LzhHandler.cpp
+++ b/CPP/7zip/Archive/Lzh/LzhHandler.cpp
@@ -34,7 +34,7 @@ struct COsPair
const wchar_t *Name;
};
-COsPair g_OsPairs[] =
+COsPair g_OsPairs[] =
{
{ 'M', L"MS-DOS" },
{ '2', L"OS/2" },
@@ -67,14 +67,14 @@ static const wchar_t *GetOS(Byte osId)
return kUnknownOS;
};
-STATPROPSTG kProps[] =
+STATPROPSTG kProps[] =
{
{ NULL, kpidPath, VT_BSTR},
- { NULL, kpidIsFolder, VT_BOOL},
+ { NULL, kpidIsDir, VT_BOOL},
{ NULL, kpidSize, VT_UI8},
- { NULL, kpidPackedSize, VT_UI8},
- { NULL, kpidLastWriteTime, VT_FILETIME},
- { NULL, kpidAttributes, VT_UI4},
+ { NULL, kpidPackSize, VT_UI8},
+ { NULL, kpidMTime, VT_FILETIME},
+ { NULL, kpidAttrib, VT_UI4},
// { NULL, kpidCommented, VT_BOOL},
@@ -114,23 +114,17 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *va
}
break;
}
- case kpidIsFolder:
- prop = item.IsDirectory();
- break;
- case kpidSize:
- prop = item.Size;
- break;
- case kpidPackedSize:
- prop = item.PackSize;
- break;
- case kpidLastWriteTime:
+ case kpidIsDir: prop = item.IsDir(); break;
+ case kpidSize: prop = item.Size; break;
+ case kpidPackSize: prop = item.PackSize; break;
+ case kpidCRC: prop = (UInt32)item.CRC; break;
+ case kpidHostOS: prop = GetOS(item.OsId); break;
+ case kpidMTime:
{
FILETIME utcFileTime;
UInt32 unixTime;
if (item.GetUnixTime(unixTime))
- {
NTime::UnixTimeToFileTime(unixTime, utcFileTime);
- }
else
{
FILETIME localFileTime;
@@ -146,16 +140,9 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *va
break;
}
/*
- case kpidAttributes:
- prop = (UInt32)item.Attributes;
- break;
- case kpidCommented:
- prop = item.IsCommented();
- break;
+ case kpidAttrib: prop = (UInt32)item.Attributes; break;
+ case kpidCommented: prop = item.IsCommented(); break;
*/
- case kpidCRC:
- prop = (UInt32)item.CRC;
- break;
case kpidMethod:
{
wchar_t method2[kMethodIdSize + 1];
@@ -165,9 +152,6 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *va
prop = method2;
break;
}
- case kpidHostOS:
- prop = GetOS(item.OsId);
- break;
}
prop.Detach(value);
return S_OK;
@@ -175,14 +159,14 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *va
}
/*
-class CPropgressImp: public CProgressVirt
+class CProgressImp: public CProgressVirt
{
public:
CMyComPtr<IArchiveOpenCallback> Callback;
STDMETHOD(SetCompleted)(const UInt64 *numFiles);
};
-STDMETHODIMP CPropgressImp::SetCompleted(const UInt64 *numFiles)
+STDMETHODIMP CProgressImp::SetCompleted(const UInt64 *numFiles)
{
if (Callback)
return Callback->SetCompleted(numFiles, NULL);
@@ -190,7 +174,7 @@ STDMETHODIMP CPropgressImp::SetCompleted(const UInt64 *numFiles)
}
*/
-STDMETHODIMP CHandler::Open(IInStream *inStream,
+STDMETHODIMP CHandler::Open(IInStream *stream,
const UInt64 * /* maxCheckStartPosition */, IArchiveOpenCallback *callback)
{
COM_TRY_BEGIN
@@ -198,13 +182,17 @@ STDMETHODIMP CHandler::Open(IInStream *inStream,
{
_items.Clear();
CInArchive archive;
- RINOK(archive.Open(inStream));
+
+ UInt64 endPos = 0;
+ bool needSetTotal = true;
+
if (callback != NULL)
{
- RINOK(callback->SetTotal(NULL, NULL));
- UInt64 numFiles = _items.Size();
- RINOK(callback->SetCompleted(&numFiles, NULL));
+ RINOK(stream->Seek(0, STREAM_SEEK_END, &endPos));
+ RINOK(stream->Seek(0, STREAM_SEEK_SET, NULL));
}
+
+ RINOK(archive.Open(stream));
for (;;)
{
CItemEx item;
@@ -220,14 +208,23 @@ STDMETHODIMP CHandler::Open(IInStream *inStream,
archive.Skeep(item.PackSize);
if (callback != NULL)
{
- UInt64 numFiles = _items.Size();
- RINOK(callback->SetCompleted(&numFiles, NULL));
+ if (needSetTotal)
+ {
+ RINOK(callback->SetTotal(NULL, &endPos));
+ needSetTotal = false;
+ }
+ if (_items.Size() % 100 == 0)
+ {
+ UInt64 numFiles = _items.Size();
+ UInt64 numBytes = item.DataPosition;
+ RINOK(callback->SetCompleted(&numFiles, &numBytes));
+ }
}
}
if (_items.IsEmpty())
return S_FALSE;
- _stream = inStream;
+ _stream = stream;
}
catch(...)
{
@@ -306,7 +303,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
const CItemEx &item = _items[index];
RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
- if(item.IsDirectory())
+ if (item.IsDir())
{
// if (!testMode)
{
@@ -316,7 +313,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
continue;
}
- if (!testMode && (!realOutStream))
+ if (!testMode && (!realOutStream))
continue;
RINOK(extractCallback->PrepareOperation(askMode));
@@ -345,7 +342,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
}
else if (item.IsLh4GroupMethod())
{
- if(!lzhDecoder)
+ if (!lzhDecoder)
{
lzhDecoderSpec = new NCompress::NLzh::NDecoder::CCoder;
lzhDecoder = lzhDecoderSpec;
@@ -356,7 +353,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
/*
else if (item.IsLh1GroupMethod())
{
- if(!lzh1Decoder)
+ if (!lzh1Decoder)
{
lzh1DecoderSpec = new NCompress::NLzh1::NDecoder::CCoder;
lzh1Decoder = lzh1DecoderSpec;
diff --git a/CPP/7zip/Archive/Lzh/LzhHandler.h b/CPP/7zip/Archive/Lzh/LzhHandler.h
index 2caf21fd..ed504dd2 100755
--- a/CPP/7zip/Archive/Lzh/LzhHandler.h
+++ b/CPP/7zip/Archive/Lzh/LzhHandler.h
@@ -10,7 +10,7 @@
namespace NArchive {
namespace NLzh {
-class CHandler:
+class CHandler:
public IInArchive,
public CMyUnknownImp
{
diff --git a/CPP/7zip/Archive/Lzh/LzhItem.h b/CPP/7zip/Archive/Lzh/LzhItem.h
index d0ba25e2..494a65bf 100755
--- a/CPP/7zip/Archive/Lzh/LzhItem.h
+++ b/CPP/7zip/Archive/Lzh/LzhItem.h
@@ -45,15 +45,15 @@ public:
bool IsValidMethod() const { return (Method[0] == '-' && Method[1] == 'l' && Method[4] == '-'); }
bool IsLhMethod() const {return (IsValidMethod() && Method[2] == 'h'); }
- bool IsDirectory() const {return (IsLhMethod() && Method[3] == 'd'); }
+ bool IsDir() const {return (IsLhMethod() && Method[3] == 'd'); }
- bool IsCopyMethod() const
+ bool IsCopyMethod() const
{
- return (IsLhMethod() && Method[3] == '0') ||
+ return (IsLhMethod() && Method[3] == '0') ||
(IsValidMethod() && Method[2] == 'z' && Method[3] == '4');
}
- bool IsLh1GroupMethod() const
+ bool IsLh1GroupMethod() const
{
if (!IsLhMethod())
return false;
@@ -65,7 +65,7 @@ public:
return false;
}
- bool IsLh4GroupMethod() const
+ bool IsLh4GroupMethod() const
{
if (!IsLhMethod())
return false;
@@ -80,7 +80,7 @@ public:
return false;
}
- int GetNumDictBits() const
+ int GetNumDictBits() const
{
if (!IsLhMethod())
return 0;
@@ -124,9 +124,9 @@ public:
return false;
}
const Byte *data = (const Byte *)(Extensions[index].Data);
- value = data[0] |
- ((UInt32)data[1] << 8) |
- ((UInt32)data[2] << 16) |
+ value = data[0] |
+ ((UInt32)data[1] << 8) |
+ ((UInt32)data[2] << 16) |
((UInt32)data[3] << 24);
return true;
}
diff --git a/CPP/7zip/Archive/Lzh/LzhOutStreamWithCRC.h b/CPP/7zip/Archive/Lzh/LzhOutStreamWithCRC.h
index 31b536b7..fd73f4ae 100755
--- a/CPP/7zip/Archive/Lzh/LzhOutStreamWithCRC.h
+++ b/CPP/7zip/Archive/Lzh/LzhOutStreamWithCRC.h
@@ -10,7 +10,7 @@
namespace NArchive {
namespace NLzh {
-class COutStreamWithCRC:
+class COutStreamWithCRC:
public ISequentialOutStream,
public CMyUnknownImp
{
diff --git a/CPP/7zip/Archive/Lzh/StdAfx.cpp b/CPP/7zip/Archive/Lzh/StdAfx.cpp
deleted file mode 100755
index d0feea85..00000000
--- a/CPP/7zip/Archive/Lzh/StdAfx.cpp
+++ /dev/null
@@ -1,3 +0,0 @@
-// StdAfx.cpp
-
-#include "StdAfx.h"
diff --git a/CPP/7zip/Archive/Lzma/LzmaFiltersDecode.cpp b/CPP/7zip/Archive/Lzma/LzmaFiltersDecode.cpp
index d3450616..26c1092f 100755
--- a/CPP/7zip/Archive/Lzma/LzmaFiltersDecode.cpp
+++ b/CPP/7zip/Archive/Lzma/LzmaFiltersDecode.cpp
@@ -13,7 +13,7 @@ static const UInt64 k_BCJ = 0x03030103;
HRESULT CDecoder::Code(
DECL_EXTERNAL_CODECS_LOC_VARS
const CHeader &block,
- ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ ISequentialInStream *inStream, ISequentialOutStream *outStream,
UInt64 *inProcessedSize, ICompressProgressInfo *progress)
{
*inProcessedSize = (UInt64)(Int64)-1;
@@ -57,7 +57,7 @@ HRESULT CDecoder::Code(
if (!setOutStream)
return E_NOTIMPL;
RINOK(setOutStream->SetOutStream(outStream));
- outStream = _bcjStream;
+ outStream = _bcjStream;
}
const UInt64 *unpackSize = block.HasUnpackSize() ? &block.UnpackSize : NULL;
diff --git a/CPP/7zip/Archive/Lzma/LzmaFiltersDecode.h b/CPP/7zip/Archive/Lzma/LzmaFiltersDecode.h
index a9f4927b..36de4966 100755
--- a/CPP/7zip/Archive/Lzma/LzmaFiltersDecode.h
+++ b/CPP/7zip/Archive/Lzma/LzmaFiltersDecode.h
@@ -17,7 +17,7 @@ class CDecoder
public:
HRESULT Code(DECL_EXTERNAL_CODECS_LOC_VARS
const CHeader &block,
- ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ ISequentialInStream *inStream, ISequentialOutStream *outStream,
UInt64 *inProcessedSize, ICompressProgressInfo *progress);
};
diff --git a/CPP/7zip/Archive/Lzma/LzmaHandler.cpp b/CPP/7zip/Archive/Lzma/LzmaHandler.cpp
index 70126aa4..c434595d 100755
--- a/CPP/7zip/Archive/Lzma/LzmaHandler.cpp
+++ b/CPP/7zip/Archive/Lzma/LzmaHandler.cpp
@@ -20,10 +20,10 @@
namespace NArchive {
namespace NLzma {
-STATPROPSTG kProps[] =
+STATPROPSTG kProps[] =
{
{ NULL, kpidSize, VT_UI8},
- { NULL, kpidPackedSize, VT_UI8},
+ { NULL, kpidPackSize, VT_UI8},
{ NULL, kpidMethod, VT_UI1}
};
@@ -82,7 +82,7 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *va
if (m_StreamInfo.HasUnpackSize())
propVariant = (UInt64)m_StreamInfo.UnpackSize;
break;
- case kpidPackedSize:
+ case kpidPackSize:
propVariant = (UInt64)m_PackSize;
break;
case kpidMethod:
@@ -111,7 +111,7 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *va
return S_OK;
}
-STDMETHODIMP CHandler::Open(IInStream *inStream,
+STDMETHODIMP CHandler::Open(IInStream *inStream,
const UInt64 * /* maxCheckStartPosition */,
IArchiveOpenCallback * /* openArchiveCallback */)
{
@@ -169,7 +169,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
{
CMyComPtr<ISequentialOutStream> realOutStream;
- Int32 askMode = testMode ?
+ Int32 askMode = testMode ?
NArchive::NExtract::NAskMode::kTest :
NArchive::NExtract::NAskMode::kExtract;
diff --git a/CPP/7zip/Archive/Lzma/LzmaHandler.h b/CPP/7zip/Archive/Lzma/LzmaHandler.h
index e4078309..e8fdcedc 100755
--- a/CPP/7zip/Archive/Lzma/LzmaHandler.h
+++ b/CPP/7zip/Archive/Lzma/LzmaHandler.h
@@ -15,7 +15,7 @@ namespace NLzma {
// const UInt64 k_LZMA = 0x030101;
-class CHandler:
+class CHandler:
public IInArchive,
PUBLIC_ISetCompressCodecsInfo
public CMyUnknownImp
@@ -27,24 +27,24 @@ public:
MY_QUERYINTERFACE_END
MY_ADDREF_RELEASE
- STDMETHOD(Open)(IInStream *inStream,
+ STDMETHOD(Open)(IInStream *inStream,
const UInt64 *maxCheckStartPosition,
- IArchiveOpenCallback *openArchiveCallback);
- STDMETHOD(Close)();
+ IArchiveOpenCallback *openArchiveCallback);
+ STDMETHOD(Close)();
- STDMETHOD(GetNumberOfItems)(UInt32 *numItems);
+ STDMETHOD(GetNumberOfItems)(UInt32 *numItems);
STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value);
- STDMETHOD(Extract)(const UInt32* indices, UInt32 numItems,
+ STDMETHOD(Extract)(const UInt32* indices, UInt32 numItems,
Int32 testMode, IArchiveExtractCallback *extractCallback);
STDMETHOD(GetArchiveProperty)(PROPID propID, PROPVARIANT *value);
- STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties);
- STDMETHOD(GetPropertyInfo)(UInt32 index,
+ STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties);
+ STDMETHOD(GetPropertyInfo)(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType);
- STDMETHOD(GetNumberOfArchiveProperties)(UInt32 *numProperties);
- STDMETHOD(GetArchivePropertyInfo)(UInt32 index,
+ STDMETHOD(GetNumberOfArchiveProperties)(UInt32 *numProperties);
+ STDMETHOD(GetArchivePropertyInfo)(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType);
UString GetMethodString();
diff --git a/CPP/7zip/Archive/MachoHandler.cpp b/CPP/7zip/Archive/MachoHandler.cpp
new file mode 100755
index 00000000..bbae3150
--- /dev/null
+++ b/CPP/7zip/Archive/MachoHandler.cpp
@@ -0,0 +1,490 @@
+// MachoHandler.cpp
+
+#include "StdAfx.h"
+
+#include "../../../C/CpuArch.h"
+
+#include "Common/Buffer.h"
+#include "Common/ComTry.h"
+
+#include "Windows/PropVariantUtils.h"
+
+#include "../Common/LimitedStreams.h"
+#include "../Common/ProgressUtils.h"
+#include "../Common/RegisterArc.h"
+#include "../Common/StreamUtils.h"
+
+#include "../Compress/Copy/CopyCoder.h"
+
+#include "Common/DummyOutStream.h"
+
+static UInt32 Get32(const Byte *p, int be) { if (be) return GetBe32(p); return GetUi32(p); }
+static UInt64 Get64(const Byte *p, int be) { if (be) return GetBe64(p); return GetUi64(p); }
+
+using namespace NWindows;
+
+namespace NArchive {
+namespace NMacho {
+
+#define MACH_ARCH_ABI64 (1 << 24)
+#define MACH_MACHINE_386 7
+#define MACH_MACHINE_ARM 12
+#define MACH_MACHINE_SPARC 14
+#define MACH_MACHINE_PPC 18
+
+#define MACH_MACHINE_PPC64 (MACH_ARCH_ABI64 | MACH_MACHINE_PPC)
+#define MACH_MACHINE_AMD64 (MACH_ARCH_ABI64 | MACH_MACHINE_386)
+
+#define MACH_CMD_SEGMENT_32 1
+#define MACH_CMD_SEGMENT_64 0x19
+
+#define MACH_SECT_TYPE_MASK 0x000000FF
+#define MACH_SECT_ATTR_MASK 0xFFFFFF00
+
+#define MACH_SECT_ATTR_ZEROFILL 1
+
+const char *g_SectTypes[] =
+{
+ "REGULAR",
+ "ZEROFILL",
+ "CSTRINGS",
+ "4BYTE_LITERALS",
+ "8BYTE_LITERALS",
+ "LITERAL_POINTERS",
+ "NON_LAZY_SYMBOL_POINTERS",
+ "LAZY_SYMBOL_POINTERS",
+ "SYMBOL_STUBS",
+ "MOD_INIT_FUNC_POINTERS",
+ "MOD_TERM_FUNC_POINTERS",
+ "COALESCED",
+ "GB_ZEROFILL",
+ "INTERPOSING",
+ "16BYTE_LITERALS"
+};
+
+const char *g_FileTypes[] =
+{
+ "0",
+ "OBJECT",
+ "EXECUTE",
+ "FVMLIB",
+ "CORE",
+ "PRELOAD",
+ "DYLIB",
+ "DYLINKER",
+ "BUNDLE",
+ "DYLIB_STUB",
+ "DSYM"
+};
+
+static const CUInt32PCharPair g_Flags[] =
+{
+ { (UInt32)1 << 31, "PURE_INSTRUCTIONS" },
+ { 1 << 30, "NO_TOC" },
+ { 1 << 29, "STRIP_STATIC_SYMS" },
+ { 1 << 28, "NO_DEAD_STRIP" },
+ { 1 << 27, "LIVE_SUPPORT" },
+ { 1 << 26, "SELF_MODIFYING_CODE" },
+ { 1 << 25, "DEBUG" },
+ { 1 << 10, "SOME_INSTRUCTIONS" },
+ { 1 << 9, "EXT_RELOC" },
+ { 1 << 8, "LOC_RELOC" }
+};
+
+static const CUInt32PCharPair g_MachinePairs[] =
+{
+ { MACH_MACHINE_386, "x86" },
+ { MACH_MACHINE_ARM, "ARM" },
+ { MACH_MACHINE_SPARC, "SPARC" },
+ { MACH_MACHINE_PPC, "PowerPC" },
+ { MACH_MACHINE_PPC64, "PowerPC 64-bit" },
+ { MACH_MACHINE_AMD64, "x64" }
+};
+
+static const int kNameSize = 16;
+
+struct CSegment
+{
+ char Name[kNameSize];
+};
+
+struct CSection
+{
+ char Name[kNameSize];
+ char SegName[kNameSize];
+ UInt64 Va;
+ UInt64 Size;
+ UInt32 Pa;
+ UInt32 Flags;
+ int SegmentIndex;
+ UInt64 GetPackSize() const { return Flags == MACH_SECT_ATTR_ZEROFILL ? 0 : Size; }
+};
+
+
+class CHandler:
+ public IInArchive,
+ public CMyUnknownImp
+{
+ CMyComPtr<IInStream> _inStream;
+ CObjectVector<CSegment> _segments;
+ CObjectVector<CSection> _sections;
+ bool _mode64;
+ bool _be;
+ UInt32 _machine;
+ UInt32 _type;
+ UInt32 _headersSize;
+ UInt64 _totalSize;
+ HRESULT Open2(ISequentialInStream *stream);
+ bool Parse(const Byte *buf, UInt32 size);
+public:
+ MY_UNKNOWN_IMP1(IInArchive)
+ INTERFACE_IInArchive(;)
+};
+
+bool CHandler::Parse(const Byte *buf, UInt32 size)
+{
+ bool mode64 = _mode64;
+ bool be = _be;
+
+ const Byte *bufStart = buf;
+ bool reduceCommands = false;
+ if (size < 512)
+ return false;
+
+ _machine = Get32(buf + 4, be);
+ _type = Get32(buf + 0xC, be);
+
+ UInt32 numCommands = Get32(buf + 0x10, be);
+ UInt32 commandsSize = Get32(buf + 0x14, be);
+ if (commandsSize > size)
+ return false;
+
+ if (commandsSize > (1 << 24) || numCommands > (1 << 18))
+ return false;
+
+ if (numCommands > 16)
+ {
+ reduceCommands = true;
+ numCommands = 16;
+ }
+
+ _headersSize = 0;
+
+ buf += 0x1C;
+ size -= 0x1C;
+
+ if (mode64)
+ {
+ buf += 4;
+ size -= 4;
+ }
+
+ _totalSize = (UInt32)(buf - bufStart);
+ if (commandsSize < size)
+ size = commandsSize;
+
+ for (UInt32 cmdIndex = 0; cmdIndex < numCommands; cmdIndex++)
+ {
+ if (size < 8)
+ return false;
+ UInt32 cmd = Get32(buf, be);
+ UInt32 cmdSize = Get32(buf + 4, be);
+ if (size < cmdSize)
+ return false;
+ if (cmd == MACH_CMD_SEGMENT_32 || cmd == MACH_CMD_SEGMENT_64)
+ {
+ UInt32 offs = (cmd == MACH_CMD_SEGMENT_64) ? 0x48 : 0x38;
+ if (cmdSize < offs)
+ break;
+
+ {
+ UInt64 vmAddr, vmSize, phAddr, phSize;
+ if (cmd == MACH_CMD_SEGMENT_64)
+ {
+ vmAddr = Get64(buf + 0x18, be);
+ vmSize = Get64(buf + 0x20, be);
+ phAddr = Get64(buf + 0x28, be);
+ phSize = Get64(buf + 0x30, be);
+ }
+ else
+ {
+ vmAddr = Get32(buf + 0x18, be);
+ vmSize = Get32(buf + 0x1C, be);
+ phAddr = Get32(buf + 0x20, be);
+ phSize = Get32(buf + 0x24, be);
+ }
+ {
+ UInt64 totalSize = phAddr + phSize;
+ if (totalSize > _totalSize)
+ _totalSize = totalSize;
+ }
+ }
+
+ CSegment seg;
+ memcpy(seg.Name, buf + 8, kNameSize);
+ _segments.Add(seg);
+
+ UInt32 numSections = Get32(buf + offs - 8, be);
+ if (numSections > (1 << 8))
+ return false;
+
+ while (numSections-- != 0)
+ {
+ CSection section;
+ UInt32 headerSize = (cmd == MACH_CMD_SEGMENT_64) ? 0x50 : 0x44;
+ const Byte *p = buf + offs;
+ if (cmdSize - offs < headerSize)
+ break;
+ if (cmd == MACH_CMD_SEGMENT_64)
+ {
+ section.Va = Get64(p + 0x20, be);
+ section.Size = Get64(p + 0x28, be);
+ section.Pa = Get32(p + 0x30, be);
+ section.Flags = Get32(p + 0x40, be);
+ }
+ else
+ {
+ section.Va = Get32(p + 0x20, be);
+ section.Size = Get32(p + 0x24, be);
+ section.Pa = Get32(p + 0x28, be);
+ section.Flags = Get32(p + 0x38, be);
+ }
+ memcpy(section.Name, p, kNameSize);
+ memcpy(section.SegName, p + kNameSize, kNameSize);
+ section.SegmentIndex = _segments.Size() - 1;
+ _sections.Add(section);
+ offs += headerSize;
+ }
+ if (offs != cmdSize)
+ return false;
+ }
+ buf += cmdSize;
+ size -= cmdSize;
+ }
+ _headersSize = (UInt32)(buf - bufStart);
+ return reduceCommands || (size == 0);
+}
+
+STATPROPSTG kArcProps[] =
+{
+ { NULL, kpidCpu, VT_BSTR},
+ { NULL, kpidBit64, VT_BOOL},
+ { NULL, kpidBigEndian, VT_BOOL},
+ { NULL, kpidCharacts, VT_BSTR},
+ { NULL, kpidPhySize, VT_UI8},
+ { NULL, kpidHeadersSize, VT_UI4}
+};
+
+STATPROPSTG kProps[] =
+{
+ { NULL, kpidPath, VT_BSTR},
+ { NULL, kpidSize, VT_UI8},
+ { NULL, kpidPackSize, VT_UI8},
+ { NULL, kpidCharacts, VT_BSTR},
+ { NULL, kpidOffset, VT_UI8},
+ { NULL, kpidVa, VT_UI8}
+};
+
+IMP_IInArchive_Props
+IMP_IInArchive_ArcProps
+
+STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NCOM::CPropVariant prop;
+ switch(propID)
+ {
+ case kpidCpu: PAIR_TO_PROP(g_MachinePairs, _machine, prop); break;
+ case kpidCharacts: TYPE_TO_PROP(g_FileTypes, _type, prop); break;
+ case kpidPhySize: prop = _totalSize; break;
+ case kpidHeadersSize: prop = _headersSize; break;
+ case kpidBit64: if (_mode64) prop = _mode64; break;
+ case kpidBigEndian: if (_be) prop = _be; break;
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+static AString GetName(const char *name)
+{
+ AString res;
+ char *p = res.GetBuffer(kNameSize);
+ strncpy(p, name, kNameSize);
+ p[kNameSize] = 0;
+ res.ReleaseBuffer();
+ return res;
+}
+
+static AString SectFlagsToString(UInt32 flags)
+{
+ AString res = TypeToString(g_SectTypes, sizeof(g_SectTypes) / sizeof(g_SectTypes[0]),
+ flags & MACH_SECT_TYPE_MASK);
+ AString s = FlagsToString(g_Flags, sizeof(g_Flags) / sizeof(g_Flags[0]),
+ flags & MACH_SECT_ATTR_MASK);
+ if (!s.IsEmpty())
+ {
+ res += ' ';
+ res += s;
+ }
+ return res;
+}
+
+STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NCOM::CPropVariant prop;
+ const CSection &item = _sections[index];
+ switch(propID)
+ {
+ case kpidPath: StringToProp(GetName(_segments[item.SegmentIndex].Name) + GetName(item.Name), prop); break;
+ case kpidSize: prop = (UInt64)item.Size; break;
+ case kpidPackSize: prop = (UInt64)item.GetPackSize(); break;
+ case kpidCharacts: StringToProp(SectFlagsToString(item.Flags), prop); break;
+ case kpidOffset: prop = item.Pa; break;
+ case kpidVa: prop = item.Va; break;
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+HRESULT CHandler::Open2(ISequentialInStream *stream)
+{
+ const UInt32 kBufSize = 1 << 18;
+ const UInt32 kSigSize = 4;
+
+ CByteBuffer buffer;
+ buffer.SetCapacity(kBufSize);
+ Byte *buf = buffer;
+
+ size_t processed = kSigSize;
+ RINOK(ReadStream_FALSE(stream, buf, processed));
+ UInt32 sig = GetUi32(buf);
+ bool be, mode64;
+ switch(sig)
+ {
+ case 0xCEFAEDFE: be = true; mode64 = false; break;
+ case 0xCFFAEDFE: be = true; mode64 = true; break;
+ case 0xFEEDFACE: be = false; mode64 = false; break;
+ case 0xFEEDFACF: be = false; mode64 = true; break;
+ default: return S_FALSE;
+ }
+ processed = kBufSize - kSigSize;
+ RINOK(ReadStream(stream, buf + kSigSize, &processed));
+ _mode64 = mode64;
+ _be = be;
+ return Parse(buf, (UInt32)processed + kSigSize) ? S_OK : S_FALSE;
+}
+
+STDMETHODIMP CHandler::Open(IInStream *inStream,
+ const UInt64 * /* maxCheckStartPosition */,
+ IArchiveOpenCallback * /* openArchiveCallback */)
+{
+ COM_TRY_BEGIN
+ Close();
+ RINOK(Open2(inStream));
+ _inStream = inStream;
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Close()
+{
+ _inStream.Release();
+ _sections.Clear();
+ _segments.Clear();
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
+{
+ *numItems = _sections.Size();
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
+ Int32 _aTestMode, IArchiveExtractCallback *extractCallback)
+{
+ COM_TRY_BEGIN
+ bool testMode = (_aTestMode != 0);
+ bool allFilesMode = (numItems == UInt32(-1));
+ if (allFilesMode)
+ numItems = _sections.Size();
+ if (numItems == 0)
+ return S_OK;
+ UInt64 totalSize = 0;
+ UInt32 i;
+ for (i = 0; i < numItems; i++)
+ totalSize += _sections[allFilesMode ? i : indices[i]].GetPackSize();
+ extractCallback->SetTotal(totalSize);
+
+ UInt64 currentTotalSize = 0;
+ UInt64 currentItemSize;
+
+ NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder();
+ CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;
+
+ CLocalProgress *lps = new CLocalProgress;
+ CMyComPtr<ICompressProgressInfo> progress = lps;
+ lps->Init(extractCallback, false);
+
+
+
+
+
+
+
+
+
+
+ CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
+ CMyComPtr<ISequentialInStream> inStream(streamSpec);
+ streamSpec->SetStream(_inStream);
+
+ CDummyOutStream *outStreamSpec = new CDummyOutStream;
+ CMyComPtr<ISequentialOutStream> outStream(outStreamSpec);
+
+ for (i = 0; i < numItems; i++, currentTotalSize += currentItemSize)
+ {
+ lps->InSize = lps->OutSize = currentTotalSize;
+ RINOK(lps->SetCur());
+ Int32 askMode = testMode ?
+ NArchive::NExtract::NAskMode::kTest :
+ NArchive::NExtract::NAskMode::kExtract;
+ UInt32 index = allFilesMode ? i : indices[i];
+ const CSection &item = _sections[index];
+ currentItemSize = item.GetPackSize();
+ {
+ CMyComPtr<ISequentialOutStream> realOutStream;
+ RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
+ if (!testMode && (!realOutStream))
+ continue;
+ outStreamSpec->SetStream(realOutStream);
+ outStreamSpec->Init();
+ }
+
+ RINOK(extractCallback->PrepareOperation(askMode));
+ RINOK(_inStream->Seek(item.Pa, STREAM_SEEK_SET, NULL));
+ streamSpec->Init(currentItemSize);
+ RINOK(copyCoder->Code(inStream, outStream, NULL, NULL, progress));
+ outStreamSpec->ReleaseStream();
+ RINOK(extractCallback->SetOperationResult((copyCoderSpec->TotalSize == currentItemSize) ?
+
+ NArchive::NExtract::NOperationResult::kOK:
+
+ NArchive::NExtract::NOperationResult::kDataError));
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+static IInArchive *CreateArc() { return new CHandler; }
+
+static CArcInfo g_ArcInfo =
+ { L"MachO", L"", 0, 0xDF, { 0 }, 0, false, CreateArc, 0 };
+
+REGISTER_ARC(Macho)
+
+}}
+ \ No newline at end of file
diff --git a/CPP/7zip/Archive/MubHandler.cpp b/CPP/7zip/Archive/MubHandler.cpp
new file mode 100755
index 00000000..edf00f93
--- /dev/null
+++ b/CPP/7zip/Archive/MubHandler.cpp
@@ -0,0 +1,264 @@
+// MubHandler.cpp
+
+#include "StdAfx.h"
+
+#include "../../../C/CpuArch.h"
+
+#include "Common/ComTry.h"
+
+#include "Windows/PropVariant.h"
+
+#include "../Common/LimitedStreams.h"
+#include "../Common/ProgressUtils.h"
+#include "../Common/RegisterArc.h"
+#include "../Common/StreamUtils.h"
+
+#include "../Compress/Copy/CopyCoder.h"
+
+#define Get32(p) GetBe32(p)
+
+namespace NArchive {
+namespace NMub {
+
+struct CItem
+{
+ UInt32 Type;
+ UInt32 SubType;
+ UInt64 Offset;
+ UInt64 Size;
+ UInt32 Align;
+ bool IsTail;
+};
+
+const UInt32 kNumFilesMax = 10;
+
+class CHandler:
+ public IInArchive,
+ public CMyUnknownImp
+{
+ UInt64 _startPos;
+ CMyComPtr<IInStream> _inStream;
+ UInt32 _numItems;
+ CItem _items[kNumFilesMax + 1];
+ HRESULT Open2(IInStream *stream);
+public:
+ MY_UNKNOWN_IMP1(IInArchive)
+ INTERFACE_IInArchive(;)
+};
+
+STATPROPSTG kProps[] =
+{
+ { NULL, kpidSize, VT_UI8},
+ { NULL, kpidPackSize, VT_UI8}
+};
+
+IMP_IInArchive_Props
+IMP_IInArchive_ArcProps_NO
+
+#define MACH_ARCH_ABI64 0x1000000
+#define MACH_MACHINE_386 7
+#define MACH_MACHINE_ARM 12
+#define MACH_MACHINE_SPARC 14
+#define MACH_MACHINE_PPC 18
+
+#define MACH_MACHINE_PPC64 (MACH_MACHINE_PPC | MACH_ARCH_ABI64)
+#define MACH_MACHINE_AMD64 (MACH_MACHINE_386 | MACH_ARCH_ABI64)
+
+STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
+{
+ NWindows::NCOM::CPropVariant prop;
+ const CItem &item = _items[index];
+ switch(propID)
+ {
+ case kpidExtension:
+ {
+ const wchar_t *ext;
+ if (item.IsTail)
+ ext = L"tail";
+ else
+ {
+ switch(item.Type)
+ {
+ case MACH_MACHINE_386: ext = L"86"; break;
+ case MACH_MACHINE_ARM: ext = L"arm"; break;
+ case MACH_MACHINE_SPARC: ext = L"sparc"; break;
+ case MACH_MACHINE_PPC: ext = L"ppc"; break;
+ case MACH_MACHINE_PPC64: ext = L"ppc64"; break;
+ case MACH_MACHINE_AMD64: ext = L"x64"; break;
+ default: ext = L"unknown"; break;
+ }
+ }
+ prop = ext;
+ break;
+ }
+ case kpidSize:
+ case kpidPackSize:
+ prop = (UInt64)item.Size;
+ break;
+ }
+ prop.Detach(value);
+ return S_OK;
+}
+
+#define MACH_TYPE_ABI64 (1 << 24)
+#define MACH_SUBTYPE_ABI64 (1 << 31)
+
+HRESULT CHandler::Open2(IInStream *stream)
+{
+ RINOK(stream->Seek(0, STREAM_SEEK_SET, &_startPos));
+
+ const UInt32 kHeaderSize = 8;
+ const UInt32 kRecordSize = 5 * 4;
+ const UInt32 kBufSize = kHeaderSize + kNumFilesMax * kRecordSize;
+ Byte buf[kBufSize];
+ size_t processed = kBufSize;
+ RINOK(ReadStream(stream, buf, &processed));
+ if (processed < kHeaderSize)
+ return S_FALSE;
+ UInt32 num = Get32(buf + 4);
+ if (Get32(buf) != 0xCAFEBABE || num > kNumFilesMax || processed < kHeaderSize + num * kRecordSize)
+ return S_FALSE;
+ UInt64 endPosMax = kHeaderSize;
+ for (UInt32 i = 0; i < num; i++)
+ {
+ const Byte *p = buf + kHeaderSize + i * kRecordSize;
+ CItem &sb = _items[i];
+ sb.IsTail = false;
+ sb.Type = Get32(p);
+ sb.SubType = Get32(p + 4);
+ sb.Offset = Get32(p + 8);
+ sb.Size = Get32(p + 12);
+ sb.Align = Get32(p + 16);
+
+ if ((sb.Type & ~MACH_TYPE_ABI64) >= 0x100 ||
+ (sb.SubType & ~MACH_SUBTYPE_ABI64) >= 0x100 ||
+ sb.Align > 31)
+ return S_FALSE;
+
+ UInt64 endPos = (UInt64)sb.Offset + sb.Size;
+ if (endPos > endPosMax)
+ endPosMax = endPos;
+ }
+ UInt64 fileSize;
+ RINOK(stream->Seek(0, STREAM_SEEK_END, &fileSize));
+ fileSize -= _startPos;
+ _numItems = num;
+ if (fileSize > endPosMax)
+ {
+ CItem &sb = _items[_numItems++];
+ sb.IsTail = true;
+ sb.Type = 0;
+ sb.SubType = 0;
+ sb.Offset = endPosMax;
+ sb.Size = fileSize - endPosMax;
+ sb.Align = 0;
+ }
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Open(IInStream *inStream,
+ const UInt64 * /* maxCheckStartPosition */,
+ IArchiveOpenCallback * /* openArchiveCallback */)
+{
+ COM_TRY_BEGIN
+ Close();
+ try
+ {
+ if (Open2(inStream) != S_OK)
+ return S_FALSE;
+ _inStream = inStream;
+ }
+ catch(...) { return S_FALSE; }
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Close()
+{
+ _inStream.Release();
+ _numItems = 0;
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
+{
+ *numItems = _numItems;
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
+ Int32 _aTestMode, IArchiveExtractCallback *extractCallback)
+{
+ COM_TRY_BEGIN
+ bool testMode = (_aTestMode != 0);
+ bool allFilesMode = (numItems == UInt32(-1));
+ if (allFilesMode)
+ numItems = _numItems;
+ if (numItems == 0)
+ return S_OK;
+ UInt64 totalSize = 0;
+ UInt32 i;
+ for (i = 0; i < numItems; i++)
+ totalSize += _items[allFilesMode ? i : indices[i]].Size;
+ extractCallback->SetTotal(totalSize);
+
+ UInt64 currentTotalSize = 0;
+ UInt64 currentItemSize;
+
+ NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder();
+ CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;
+
+ CLocalProgress *lps = new CLocalProgress;
+ CMyComPtr<ICompressProgressInfo> progress = lps;
+ lps->Init(extractCallback, false);
+
+ CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
+ CMyComPtr<ISequentialInStream> inStream(streamSpec);
+ streamSpec->SetStream(_inStream);
+
+ for (i = 0; i < numItems; i++, currentTotalSize += currentItemSize)
+ {
+ lps->InSize = lps->OutSize = currentTotalSize;
+ RINOK(lps->SetCur());
+ CMyComPtr<ISequentialOutStream> realOutStream;
+ Int32 askMode = testMode ?
+ NArchive::NExtract::NAskMode::kTest :
+ NArchive::NExtract::NAskMode::kExtract;
+ UInt32 index = allFilesMode ? i : indices[i];
+ const CItem &item = _items[index];
+ RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
+ currentItemSize = item.Size;
+
+
+
+
+
+
+ if (!testMode && (!realOutStream))
+ continue;
+ RINOK(extractCallback->PrepareOperation(askMode));
+ if (testMode)
+ {
+ RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK));
+ continue;
+ }
+ RINOK(_inStream->Seek(_startPos + item.Offset, STREAM_SEEK_SET, NULL));
+ streamSpec->Init(item.Size);
+ RINOK(copyCoder->Code(inStream, realOutStream, NULL, NULL, progress));
+ realOutStream.Release();
+ RINOK(extractCallback->SetOperationResult((copyCoderSpec->TotalSize == item.Size) ?
+ NArchive::NExtract::NOperationResult::kOK:
+ NArchive::NExtract::NOperationResult::kDataError));
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+static IInArchive *CreateArc() { return new CHandler; }
+
+static CArcInfo g_ArcInfo =
+ { L"Mub", L"", 0, 0xE2, { 0xCA, 0xFE, 0xBA, 0xBE, 0, 0, 0 }, 7, false, CreateArc, 0 };
+
+REGISTER_ARC(Mub)
+
+}}
diff --git a/CPP/7zip/Archive/Nsis/NsisHandler.cpp b/CPP/7zip/Archive/Nsis/NsisHandler.cpp
index b24d966d..b8945130 100755
--- a/CPP/7zip/Archive/Nsis/NsisHandler.cpp
+++ b/CPP/7zip/Archive/Nsis/NsisHandler.cpp
@@ -14,6 +14,10 @@
#include "../Common/ItemNameUtils.h"
#include "../../Common/StreamUtils.h"
+#include "../../../../C/CpuArch.h"
+
+#define Get32(p) GetUi32(p)
+
using namespace NWindows;
namespace NArchive {
@@ -22,7 +26,7 @@ namespace NNsis {
static const wchar_t *kBcjMethod = L"BCJ";
static const wchar_t *kUnknownMethod = L"Unknown";
-static const wchar_t *kMethods[] =
+static const wchar_t *kMethods[] =
{
L"Copy",
L"Deflate",
@@ -32,18 +36,17 @@ static const wchar_t *kMethods[] =
static const int kNumMethods = sizeof(kMethods) / sizeof(kMethods[0]);
-STATPROPSTG kProps[] =
+STATPROPSTG kProps[] =
{
{ NULL, kpidPath, VT_BSTR},
- { NULL, kpidIsFolder, VT_BOOL},
{ NULL, kpidSize, VT_UI8},
- { NULL, kpidPackedSize, VT_UI8},
- { NULL, kpidLastWriteTime, VT_FILETIME},
+ { NULL, kpidPackSize, VT_UI8},
+ { NULL, kpidMTime, VT_FILETIME},
{ NULL, kpidMethod, VT_BSTR},
{ NULL, kpidSolid, VT_BOOL}
};
-STATPROPSTG kArcProps[] =
+STATPROPSTG kArcProps[] =
{
{ NULL, kpidMethod, VT_BSTR},
{ NULL, kpidSolid, VT_BOOL}
@@ -69,7 +72,7 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
if (item.DictionarySize > dict)
dict = item.DictionarySize;
}
- prop = GetMethod(filter, dict);
+ prop = GetMethod(filter, dict);
break;
}
case kpidSolid: prop = _archive.IsSolid; break;
@@ -211,19 +214,10 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
{
switch(propID)
{
- case kpidPath:
- prop = L"[NSIS].nsi";
- break;
- case kpidIsFolder:
- prop = false;
- break;
+ case kpidPath: prop = L"[NSIS].nsi"; break;
case kpidSize:
- case kpidPackedSize:
- prop = (UInt64)_archive.Script.Length();
- break;
- case kpidSolid:
- prop = false;
- break;
+ case kpidPackSize: prop = (UInt64)_archive.Script.Length(); break;
+ case kpidSolid: prop = false; break;
}
}
else
@@ -244,9 +238,6 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
prop = (const wchar_t *)s;
break;
}
- case kpidIsFolder:
- prop = false;
- break;
case kpidSize:
{
UInt32 size;
@@ -254,28 +245,22 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
prop = (UInt64)size;
break;
}
- case kpidPackedSize:
+ case kpidPackSize:
{
UInt32 size;
if (GetCompressedSize(index, size))
prop = (UInt64)size;
break;
}
- case kpidLastWriteTime:
+ case kpidMTime:
{
- if (item.DateTime.dwHighDateTime > 0x01000000 &&
- item.DateTime.dwHighDateTime < 0xFF000000)
- prop = item.DateTime;
+ if (item.MTime.dwHighDateTime > 0x01000000 &&
+ item.MTime.dwHighDateTime < 0xFF000000)
+ prop = item.MTime;
break;
}
- case kpidMethod:
- {
- prop = GetMethod(item.UseFilter, item.DictionarySize);
- break;
- }
- case kpidSolid:
- prop = _archive.IsSolid;
- break;
+ case kpidMethod: prop = GetMethod(item.UseFilter, item.DictionarySize); break;
+ case kpidSolid: prop = _archive.IsSolid; break;
}
}
prop.Detach(value);
@@ -409,7 +394,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
if (processedSize != 4)
return E_FAIL;
streamPos += processedSize;
- fullSize = GetUInt32FromMemLE(buffer);
+ fullSize = Get32(buffer);
sizeIsKnown = true;
needDecompress = true;
}
@@ -424,7 +409,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
RINOK(_archive.Decoder.Init(
EXTERNAL_CODECS_VARS
_inStream, _archive.Method, _archive.FilterFlag, useFilter));
- fullSize = GetUInt32FromMemLE(buffer);
+ fullSize = Get32(buffer);
}
else
fullSize = item.Size;
@@ -461,9 +446,9 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
UInt64 completed;
if (_archive.IsSolid)
- completed = streamPos;
- else
completed = currentTotalSize + offset;
+ else
+ completed = streamPos;
RINOK(extractCallback->SetCompleted(&completed));
if (!testMode)
RINOK(WriteStream(realOutStream, buffer, processedSize));
@@ -491,7 +476,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
}
}
realOutStream.Release();
- RINOK(extractCallback->SetOperationResult(dataError ?
+ RINOK(extractCallback->SetOperationResult(dataError ?
NArchive::NExtract::NOperationResult::kDataError :
NArchive::NExtract::NOperationResult::kOK));
}
diff --git a/CPP/7zip/Archive/Nsis/NsisHandler.h b/CPP/7zip/Archive/Nsis/NsisHandler.h
index 5dc30107..95fea5d0 100755
--- a/CPP/7zip/Archive/Nsis/NsisHandler.h
+++ b/CPP/7zip/Archive/Nsis/NsisHandler.h
@@ -13,7 +13,7 @@
namespace NArchive {
namespace NNsis {
-class CHandler:
+class CHandler:
public IInArchive,
PUBLIC_ISetCompressCodecsInfo
public CMyUnknownImp
diff --git a/CPP/7zip/Archive/Nsis/NsisIn.cpp b/CPP/7zip/Archive/Nsis/NsisIn.cpp
index 5c5c872f..9e7e89bb 100755
--- a/CPP/7zip/Archive/Nsis/NsisIn.cpp
+++ b/CPP/7zip/Archive/Nsis/NsisIn.cpp
@@ -14,17 +14,17 @@
#include "Common/StringConvert.h"
#include "Common/IntToString.h"
+#include "../../../../C/CpuArch.h"
+
+#define Get32(p) GetUi32(p)
+
namespace NArchive {
namespace NNsis {
-Byte kSignature[kSignatureSize] = { 0xEF + 1, 0xBE, 0xAD, 0xDE,
+Byte kSignature[kSignatureSize] = { 0xEF + 1, 0xBE, 0xAD, 0xDE,
0x4E, 0x75, 0x6C, 0x6C, 0x73, 0x6F, 0x66, 0x74, 0x49, 0x6E, 0x73, 0x74};
-class SignatureInitializer
-{
-public:
- SignatureInitializer() { kSignature[0]--; };
-} g_SignatureInitializer;
+struct CSignatureInit { CSignatureInit() { kSignature[0]--; } } g_SignatureInit;
#ifdef NSIS_SCRIPT
static const char *kCrLf = "\x0D\x0A";
@@ -35,13 +35,7 @@ static const char *kCrLf = "\x0D\x0A";
#define NS_UN_SHELL_CODE 0xE002
#define NS_UN_LANG_CODE 0xE003
#define NS_UN_CODES_START NS_UN_SKIP_CODE
-#define NS_UN_CODES_END NS_UN_LANG_CODE
-
-
-UInt32 GetUInt32FromMemLE(const Byte *p)
-{
- return p[0] | (((UInt32)p[1]) << 8) | (((UInt32)p[2]) << 16) | (((UInt32)p[3]) << 24);
-}
+#define NS_UN_CODES_END NS_UN_LANG_CODE
Byte CInArchive::ReadByte()
{
@@ -84,14 +78,30 @@ static int CompareItems(void *const *p1, void *const *p2, void * /* param */)
return 0;
}
-AString CInArchive::ReadStringA(UInt32 pos)
+static AString UIntToString(UInt32 v)
+{
+ char sz[32];
+ ConvertUInt64ToString(v, sz);
+ return sz;
+}
+
+static AString IntToString(Int32 v)
+{
+ char sz[32];
+ ConvertInt64ToString(v, sz);
+ return sz;
+}
+
+AString CInArchive::ReadStringA(UInt32 pos) const
{
AString s;
+ if (pos >= _size)
+ return IntToString((Int32)pos);
UInt32 offset = GetOffset() + _stringsPos + pos;
for (;;)
{
if (offset >= _size)
- throw 1;
+ break; // throw 1;
char c = _data[offset++];
if (c == 0)
break;
@@ -100,14 +110,14 @@ AString CInArchive::ReadStringA(UInt32 pos)
return s;
}
-UString CInArchive::ReadStringU(UInt32 pos)
+UString CInArchive::ReadStringU(UInt32 pos) const
{
UString s;
UInt32 offset = GetOffset() + _stringsPos + (pos * 2);
for (;;)
{
if (offset >= _size || offset + 1 >= _size)
- throw 1;
+ return s; // throw 1;
char c0 = _data[offset++];
char c1 = _data[offset++];
wchar_t c = (c0 | ((wchar_t)c1 << 8));
@@ -287,7 +297,7 @@ enum
};
#ifdef NSIS_SCRIPT
-static CCommandPair kCommandPairs[] =
+static CCommandPair kCommandPairs[] =
{
{ 0, "Invalid" },
{ 0, "Return" },
@@ -315,7 +325,7 @@ static CCommandPair kCommandPairs[] =
{ 2, "Delete" },
{ 5, "MessageBox" },
{ 2, "RMDir" },
- { 2, "Assign" },
+ { 2, "StrLen" },
{ 4, "StrCpy" },
{ 5, "StrCmp" },
{ 3, "ReadEnvStr" },
@@ -368,7 +378,7 @@ static CCommandPair kCommandPairs[] =
#endif
-static const char *kShellStrings[] =
+static const char *kShellStrings[] =
{
"",
"",
@@ -451,7 +461,7 @@ static const int kNumShellStrings = sizeof(kShellStrings) / sizeof(kShellStrings
# define _OUTDIR 29
*/
-static const char *kVarStrings[] =
+static const char *kVarStrings[] =
{
"CMDLINE",
"INSTDIR",
@@ -460,6 +470,8 @@ static const char *kVarStrings[] =
"LANGUAGE",
"TEMP",
"PLUGINSDIR",
+ "EXEPATH", // test it
+ "EXEFILE", // test it
"HWNDPARENT",
"_CLICK",
"_OUTDIR"
@@ -468,20 +480,6 @@ static const char *kVarStrings[] =
static const int kNumVarStrings = sizeof(kVarStrings) / sizeof(kVarStrings[0]);
-static AString UIntToString(UInt32 v)
-{
- char sz[32];
- ConvertUInt64ToString(v, sz);
- return sz;
-}
-
-static AString IntToString(Int32 v)
-{
- char sz[32];
- ConvertInt64ToString(v, sz);
- return sz;
-}
-
static AString GetVar(UInt32 index)
{
AString res = "$";
@@ -586,17 +584,17 @@ UString GetNsisString(const UString &s)
return res;
}
-AString CInArchive::ReadString2A(UInt32 pos)
+AString CInArchive::ReadString2A(UInt32 pos) const
{
return GetNsisString(ReadStringA(pos));
}
-UString CInArchive::ReadString2U(UInt32 pos)
+UString CInArchive::ReadString2U(UInt32 pos) const
{
return GetNsisString(ReadStringU(pos));
}
-AString CInArchive::ReadString2(UInt32 pos)
+AString CInArchive::ReadString2(UInt32 pos) const
{
if (IsUnicode)
return UnicodeStringToMultiByte(ReadString2U(pos));
@@ -604,6 +602,11 @@ AString CInArchive::ReadString2(UInt32 pos)
return ReadString2A(pos);
}
+AString CInArchive::ReadString2Qw(UInt32 pos) const
+{
+ return "\"" + ReadString2(pos) + "\"";
+}
+
#define DEL_DIR 1
#define DEL_RECURSE 2
#define DEL_REBOOT 4
@@ -639,6 +642,31 @@ AString CEntry::GetParamsString(int numParams)
return s;
}
+#ifdef NSIS_SCRIPT
+
+static AString GetRegRootID(UInt32 val)
+{
+ const char *s;
+ switch(val)
+ {
+ case 0: s = "SHCTX"; break;
+ case 0x80000000: s = "HKCR"; break;
+ case 0x80000001: s = "HKCU"; break;
+ case 0x80000002: s = "HKLM"; break;
+ case 0x80000003: s = "HKU"; break;
+ case 0x80000004: s = "HKPD"; break;
+ case 0x80000005: s = "HKCC"; break;
+ case 0x80000006: s = "HKDD"; break;
+ case 0x80000050: s = "HKPT"; break;
+ case 0x80000060: s = "HKPN"; break;
+ default:
+ return UIntToString(val); break;
+ }
+ return s;
+}
+
+#endif
+
HRESULT CInArchive::ReadEntries(const CBlockHeader &bh)
{
_posInData = bh.Offset + GetOffset();
@@ -698,8 +726,8 @@ HRESULT CInArchive::ReadEntries(const CBlockHeader &bh)
}
/* UInt32 overwriteFlag = e.Params[0]; */
item.Pos = e.Params[2];
- item.DateTime.dwLowDateTime = e.Params[3];
- item.DateTime.dwHighDateTime = e.Params[4];
+ item.MTime.dwLowDateTime = e.Params[3];
+ item.MTime.dwHighDateTime = e.Params[4];
/* UInt32 allowIgnore = e.Params[5]; */
if (Items.Size() > 0)
{
@@ -815,18 +843,25 @@ HRESULT CInArchive::ReadEntries(const CBlockHeader &bh)
Script += ReadString2(e.Params[0]);
break;
}
+ case EW_STRLEN:
+ {
+ Script += " ";
+ Script += GetVar(e.Params[0]);;
+ Script += " ";
+ Script += ReadString2Qw(e.Params[1]);
+ break;
+ }
case EW_ASSIGNVAR:
{
Script += " ";
Script += GetVar(e.Params[0]);;
- Script += " \"";
+ Script += " ";
+ Script += ReadString2Qw(e.Params[1]);
AString maxLen, startOffset;
- Script += ReadString2(e.Params[1]);
- Script += "\"";
if (e.Params[2] != 0)
- maxLen = ReadString(e.Params[2]);
+ maxLen = ReadString2(e.Params[2]);
if (e.Params[3] != 0)
- startOffset = ReadString(e.Params[3]);
+ startOffset = ReadString2(e.Params[3]);
if (!maxLen.IsEmpty() || !startOffset.IsEmpty())
{
Script += " ";
@@ -846,13 +881,11 @@ HRESULT CInArchive::ReadEntries(const CBlockHeader &bh)
{
Script += " ";
- Script += " \"";
- Script += ReadString2(e.Params[0]);
- Script += "\"";
+ Script += " ";
+ Script += ReadString2Qw(e.Params[0]);
- Script += " \"";
- Script += ReadString2(e.Params[1]);
- Script += "\"";
+ Script += " ";
+ Script += ReadString2Qw(e.Params[1]);
for (int j = 2; j < 5; j++)
{
@@ -861,6 +894,62 @@ HRESULT CInArchive::ReadEntries(const CBlockHeader &bh)
}
break;
}
+ case EW_INTCMP:
+ {
+ if (e.Params[5] != 0)
+ Script += "U";
+
+ Script += " ";
+ Script += ReadString2(e.Params[0]);
+ Script += " ";
+ Script += ReadString2(e.Params[1]);
+
+ for (int i = 2; i < 5; i++)
+ {
+ Script += " ";
+ Script += UIntToString(e.Params[i]);
+ }
+ break;
+ }
+ case EW_INTOP:
+ {
+ Script += " ";
+ Script += GetVar(e.Params[0]);
+ Script += " ";
+ int numOps = 2;
+ AString op;
+ switch (e.Params[3])
+ {
+ case 0: op = '+'; break;
+ case 1: op = '-'; break;
+ case 2: op = '*'; break;
+ case 3: op = '/'; break;
+ case 4: op = '|'; break;
+ case 5: op = '&'; break;
+ case 6: op = '^'; break;
+ case 7: op = '~'; numOps = 1; break;
+ case 8: op = '!'; numOps = 1; break;
+ case 9: op = "||"; break;
+ case 10: op = "&&"; break;
+ case 11: op = '%'; break;
+ default: op = UIntToString(e.Params[3]);
+ }
+ AString p1 = ReadString2(e.Params[1]);
+ if (numOps == 1)
+ {
+ Script += op;
+ Script += p1;
+ }
+ else
+ {
+ Script += p1;
+ Script += " ";
+ Script += op;
+ Script += " ";
+ Script += ReadString2(e.Params[2]);
+ }
+ break;
+ }
case EW_PUSHPOP:
{
@@ -888,24 +977,55 @@ HRESULT CInArchive::ReadEntries(const CBlockHeader &bh)
break;
}
- /*
case EW_SENDMESSAGE:
{
+ // SendMessage: 6 [output, hwnd, msg, wparam, lparam, [wparamstring?1:0 | lparamstring?2:0 | timeout<<2]
Script += " ";
- Script += IntToString(e.Params[0]);
- Script += " ";
- Script += GetVar(e.Params[1]);
+ // Script += ReadString2(e.Params[0]);
+ // Script += " ";
+ Script += ReadString2(e.Params[1]);
Script += " ";
Script += ReadString2(e.Params[2]);
+
Script += " ";
- Script += UIntToString(e.Params[3]);
- Script += " ";
- Script += IntToString(e.Params[4]);
+ UInt32 spec = e.Params[5];
+ // if (spec & 1)
+ Script += IntToString(e.Params[3]);
+ // else
+ // Script += ReadString2(e.Params[3]);
+
Script += " ";
- Script += UIntToString(e.Params[5]);
+ // if (spec & 2)
+ Script += IntToString(e.Params[4]);
+ // else
+ // Script += ReadString2(e.Params[4]);
+
+ if ((Int32)e.Params[0] >= 0)
+ {
+ Script += " ";
+ Script += GetVar(e.Params[1]);
+ }
+
+ spec >>= 2;
+ if (spec != 0)
+ {
+ Script += " /TIMEOUT=";
+ Script += IntToString(spec);
+ }
break;
}
- */
+
+ case EW_GETDLGITEM:
+ {
+ Script += " ";
+ Script += GetVar(e.Params[0]);;
+ Script += " ";
+ Script += ReadString2(e.Params[1]);
+ Script += " ";
+ Script += ReadString2(e.Params[2]);
+ break;
+ }
+
case EW_REGISTERDLL:
{
@@ -923,14 +1043,10 @@ HRESULT CInArchive::ReadEntries(const CBlockHeader &bh)
AString s;
Script += " ";
- Script += " \"";
- Script += ReadString2(e.Params[0]);
- Script += " \"";
+ Script += ReadString2Qw(e.Params[0]);
Script += " ";
- Script += " \"";
- Script += ReadString2(e.Params[1]);
- Script += " \"";
+ Script += ReadString2Qw(e.Params[1]);
for (int j = 2; j < 5; j++)
{
@@ -968,6 +1084,38 @@ HRESULT CInArchive::ReadEntries(const CBlockHeader &bh)
}
*/
+ case EW_WRITEREG:
+ {
+ AString s;
+ switch(e.Params[4])
+ {
+ case 1: s = "Str"; break;
+ case 2: s = "ExpandStr"; break;
+ case 3: s = "Bin"; break;
+ case 4: s = "DWORD"; break;
+ default: s = "?" + UIntToString(e.Params[4]); break;
+ }
+ Script += s;
+ Script += " ";
+ Script += GetRegRootID(e.Params[0]);
+ Script += " ";
+
+ AString keyName, valueName;
+ keyName = ReadString2Qw(e.Params[1]);
+ Script += keyName;
+ Script += " ";
+
+ valueName = ReadString2Qw(e.Params[2]);
+ Script += valueName;
+ Script += " ";
+
+ valueName = ReadString2Qw(e.Params[3]);
+ Script += valueName;
+ Script += " ";
+
+ break;
+ }
+
case EW_WRITEUNINSTALLER:
{
Script += " ";
@@ -1006,7 +1154,7 @@ HRESULT CInArchive::ReadEntries(const CBlockHeader &bh)
{
Items.Sort(CompareItems, 0);
int i;
- // if (IsSolid)
+ // if (IsSolid)
for (i = 0; i + 1 < Items.Size();)
{
bool sameName = IsUnicode ?
@@ -1035,7 +1183,7 @@ HRESULT CInArchive::ReadEntries(const CBlockHeader &bh)
RINOK(ReadStream(_stream, sig, &processedSize));
if (processedSize < 4)
return S_FALSE;
- UInt32 size = GetUInt32FromMemLE(sig);
+ UInt32 size = Get32(sig);
if ((size & 0x80000000) != 0)
{
item.IsCompressed = true;
@@ -1047,7 +1195,7 @@ HRESULT CInArchive::ReadEntries(const CBlockHeader &bh)
return S_FALSE;
if (FilterFlag)
item.UseFilter = (sig[4] != 0);
- item.DictionarySize = GetUInt32FromMemLE(sig + 5 + (FilterFlag ? 1 : 0));
+ item.DictionarySize = Get32(sig + 5 + (FilterFlag ? 1 : 0));
}
}
else
@@ -1085,7 +1233,7 @@ HRESULT CInArchive::Parse()
int numZeros0 = 0;
int numZeros1 = 0;
int i;
- const kBlockSize = 256;
+ const int kBlockSize = 256;
for (i = 0; i < kBlockSize; i++)
{
if (pos >= _size || pos + 1 >= _size)
@@ -1117,7 +1265,7 @@ HRESULT CInArchive::Parse()
static bool IsLZMA(const Byte *p, UInt32 &dictionary)
{
- dictionary = GetUInt32FromMemLE(p + 1);
+ dictionary = Get32(p + 1);
return (p[0] == 0x5D && p[1] == 0x00 && p[2] == 0x00 && p[5] == 0x00);
}
@@ -1152,7 +1300,7 @@ HRESULT CInArchive::Open2(
IsSolid = true;
FilterFlag = false;
- UInt32 compressedHeaderSize = GetUInt32FromMemLE(sig);
+ UInt32 compressedHeaderSize = Get32(sig);
if (compressedHeaderSize == FirstHeader.HeaderLength)
{
@@ -1218,7 +1366,7 @@ HRESULT CInArchive::Open2(
}
/*
-NsisExe =
+NsisExe =
{
ExeStub
Archive // must start from 512 * N
@@ -1253,51 +1401,39 @@ HRESULT CInArchive::Open(
IInStream *inStream, const UInt64 *maxCheckStartPosition)
{
Clear();
- UInt64 pos;
- RINOK(inStream->Seek(0, STREAM_SEEK_CUR, &pos));
- RINOK(inStream->Seek(0, STREAM_SEEK_END, &_archiveSize));
- UInt64 position;
- RINOK(inStream->Seek(pos, STREAM_SEEK_SET, &position));
- UInt64 maxSize = (maxCheckStartPosition != 0) ? *maxCheckStartPosition : (1 << 20);
+ RINOK(inStream->Seek(0, STREAM_SEEK_SET, NULL));
+ UInt64 maxSize = ((maxCheckStartPosition != 0) ? *maxCheckStartPosition : 0);
const UInt32 kStep = 512;
- const UInt32 kStartHeaderSize = 4 * 7;
Byte buffer[kStep];
- bool found = false;
- UInt64 headerPosition = 0;
- while (position <= maxSize)
+ UInt64 position = 0;
+ for (; position <= maxSize; position += kStep)
{
- RINOK(ReadStream_FALSE(inStream, buffer, kStartHeaderSize));
- headerPosition = position;
- position += kStartHeaderSize;
- if(memcmp(buffer + 4, kSignature, kSignatureSize) == 0)
- {
- found = true;
+ RINOK(ReadStream_FALSE(inStream, buffer, kStep));
+ if (memcmp(buffer + 4, kSignature, kSignatureSize) == 0)
break;
- }
- const UInt32 kRem = kStep - kStartHeaderSize;
- RINOK(ReadStream_FALSE(inStream, buffer + kStartHeaderSize, kRem));
- position += kRem;
}
- if (!found)
+ if (position > maxSize)
return S_FALSE;
- FirstHeader.Flags = GetUInt32FromMemLE(buffer);
- FirstHeader.HeaderLength = GetUInt32FromMemLE(buffer + kSignatureSize + 4);
- FirstHeader.ArchiveSize = GetUInt32FromMemLE(buffer + kSignatureSize + 8);
- if (_archiveSize - headerPosition < FirstHeader.ArchiveSize)
+ const UInt32 kStartHeaderSize = 4 * 7;
+ RINOK(inStream->Seek(0, STREAM_SEEK_END, &_archiveSize));
+ RINOK(inStream->Seek(position + kStartHeaderSize, STREAM_SEEK_SET, 0));
+ FirstHeader.Flags = Get32(buffer);
+ FirstHeader.HeaderLength = Get32(buffer + kSignatureSize + 4);
+ FirstHeader.ArchiveSize = Get32(buffer + kSignatureSize + 8);
+ if (_archiveSize - position < FirstHeader.ArchiveSize)
return S_FALSE;
- _stream = inStream;
- HRESULT res = S_FALSE;
- try
- {
- res = Open2(
- EXTERNAL_CODECS_LOC_VARS2
- );
+ try
+ {
+ _stream = inStream;
+ HRESULT res = Open2(EXTERNAL_CODECS_LOC_VARS2);
+ if (res != S_OK)
+ Clear();
+ _stream.Release();
+ return res;
}
- catch(...) { Clear(); res = S_FALSE; }
- _stream.Release();
- return res;
+ catch(...) { Clear(); return S_FALSE; }
}
void CInArchive::Clear()
@@ -1306,6 +1442,7 @@ void CInArchive::Clear()
Script.Empty();
#endif
Items.Clear();
+ _stream.Release();
}
}}
diff --git a/CPP/7zip/Archive/Nsis/NsisIn.h b/CPP/7zip/Archive/Nsis/NsisIn.h
index e7908862..4257b687 100755
--- a/CPP/7zip/Archive/Nsis/NsisIn.h
+++ b/CPP/7zip/Archive/Nsis/NsisIn.h
@@ -37,7 +37,7 @@ struct CFirstHeader
UInt32 ArchiveSize;
- bool ThereIsCrc() const
+ bool ThereIsCrc() const
{
if ((Flags & NFlags::kForceCrc ) != 0)
return true;
@@ -60,7 +60,7 @@ struct CItem
UString PrefixU;
AString NameA;
UString NameU;
- FILETIME DateTime;
+ FILETIME MTime;
bool IsUnicode;
bool UseFilter;
bool IsCompressed;
@@ -73,7 +73,7 @@ struct CItem
UInt32 EstimatedSize;
UInt32 DictionarySize;
- CItem(): IsUnicode(false), UseFilter(false), IsCompressed(true), SizeIsDefined(false),
+ CItem(): IsUnicode(false), UseFilter(false), IsCompressed(true), SizeIsDefined(false),
CompressedSizeIsDefined(false), EstimatedSizeIsDefined(false), Size(0) {}
bool IsINSTDIR() const
@@ -81,7 +81,7 @@ struct CItem
return (PrefixA.Length() >= 3 || PrefixU.Length() >= 3);
}
- AString GetReducedNameA() const
+ AString GetReducedNameA() const
{
AString prefix = PrefixA;
if (prefix.Length() > 0)
@@ -94,7 +94,7 @@ struct CItem
return s2;
}
- UString GetReducedNameU() const
+ UString GetReducedNameU() const
{
UString prefix = PrefixU;
if (prefix.Length() > 0)
@@ -120,11 +120,12 @@ class CInArchive
DECL_EXTERNAL_CODECS_LOC_VARS2
);
void ReadBlockHeader(CBlockHeader &bh);
- AString ReadStringA(UInt32 pos);
- UString ReadStringU(UInt32 pos);
- AString ReadString2A(UInt32 pos);
- UString ReadString2U(UInt32 pos);
- AString ReadString2(UInt32 pos);
+ AString ReadStringA(UInt32 pos) const;
+ UString ReadStringU(UInt32 pos) const;
+ AString ReadString2A(UInt32 pos) const;
+ UString ReadString2U(UInt32 pos) const;
+ AString ReadString2(UInt32 pos) const;
+ AString ReadString2Qw(UInt32 pos) const;
HRESULT ReadEntries(const CBlockHeader &bh);
HRESULT Parse();
@@ -165,14 +166,14 @@ public:
return GetOffset() + FirstHeader.HeaderLength + item.Pos;
}
- UInt64 GetPosOfSolidItem(int index) const
- {
+ UInt64 GetPosOfSolidItem(int index) const
+ {
const CItem &item = Items[index];
return 4 + FirstHeader.HeaderLength + item.Pos;
}
- UInt64 GetPosOfNonSolidItem(int index) const
- {
+ UInt64 GetPosOfNonSolidItem(int index) const
+ {
const CItem &item = Items[index];
return StreamOffset + _nonSolidStartOffset + 4 + item.Pos;
}
@@ -184,8 +185,6 @@ public:
};
-UInt32 GetUInt32FromMemLE(const Byte *p);
-
}}
#endif
diff --git a/CPP/7zip/Archive/Nsis/NsisRegister.cpp b/CPP/7zip/Archive/Nsis/NsisRegister.cpp
index 81dd2c82..7e6f7acb 100755
--- a/CPP/7zip/Archive/Nsis/NsisRegister.cpp
+++ b/CPP/7zip/Archive/Nsis/NsisRegister.cpp
@@ -8,7 +8,7 @@
static IInArchive *CreateArc() { return new NArchive::NNsis::CHandler; }
static CArcInfo g_ArcInfo =
- { L"Nsis", 0, 0, 0x9, { 0xEF, 0xBE, 0xAD, 0xDE,
+ { L"Nsis", 0, 0, 0x9, { 0xEF, 0xBE, 0xAD, 0xDE,
0x4E, 0x75, 0x6C, 0x6C, 0x73, 0x6F, 0x66, 0x74, 0x49, 0x6E, 0x73, 0x74}, 16, false, CreateArc, 0 };
REGISTER_ARC(Nsis)
diff --git a/CPP/7zip/Archive/Nsis/StdAfx.cpp b/CPP/7zip/Archive/Nsis/StdAfx.cpp
deleted file mode 100755
index d0feea85..00000000
--- a/CPP/7zip/Archive/Nsis/StdAfx.cpp
+++ /dev/null
@@ -1,3 +0,0 @@
-// StdAfx.cpp
-
-#include "StdAfx.h"
diff --git a/CPP/7zip/Archive/PeHandler.cpp b/CPP/7zip/Archive/PeHandler.cpp
new file mode 100755
index 00000000..88808b56
--- /dev/null
+++ b/CPP/7zip/Archive/PeHandler.cpp
@@ -0,0 +1,892 @@
+// PeHandler.cpp
+
+#include "StdAfx.h"
+
+#include "../../../C/CpuArch.h"
+
+#include "Common/Buffer.h"
+#include "Common/ComTry.h"
+#include "Common/IntToString.h"
+
+#include "Windows/PropVariantUtils.h"
+#include "Windows/Time.h"
+
+#include "../Common/LimitedStreams.h"
+#include "../Common/ProgressUtils.h"
+#include "../Common/RegisterArc.h"
+#include "../Common/StreamUtils.h"
+
+#include "../Compress/Copy/CopyCoder.h"
+
+#include "Common/DummyOutStream.h"
+
+#define Get16(p) GetUi16(p)
+#define Get32(p) GetUi32(p)
+#define Get64(p) GetUi64(p)
+
+using namespace NWindows;
+
+namespace NArchive {
+namespace NPe {
+
+#define NUM_SCAN_SECTIONS_MAX (1 << 6)
+
+#define PE_SIG 0x00004550
+#define PE_OptHeader_Magic_32 0x10B
+#define PE_OptHeader_Magic_64 0x20B
+
+static AString GetDecString(UInt32 v)
+{
+ char sz[32];
+ ConvertUInt64ToString(v, sz);
+ return sz;
+}
+
+struct CVersion
+{
+ UInt16 Major;
+ UInt16 Minor;
+
+ void Parse(const Byte *buf);
+ AString GetString() const { return GetDecString(Major) + '.' + GetDecString(Minor); }
+};
+
+void CVersion::Parse(const Byte *p)
+{
+ Major = Get16(p);
+ Minor = Get16(p + 2);
+}
+
+static const UInt32 kHeaderSize = 4 + 20;
+
+struct CHeader
+{
+ UInt16 NumSections;
+ UInt32 Time;
+ UInt32 PointerToSymbolTable;
+ UInt32 NumSymbols;
+ UInt16 OptHeaderSize;
+ UInt16 Flags;
+ UInt16 Machine;
+
+ bool Parse(const Byte *buf);
+};
+
+bool CHeader::Parse(const Byte *p)
+{
+ if (Get32(p) != PE_SIG)
+ return false;
+ p += 4;
+ Machine = Get16(p + 0);
+ NumSections = Get16(p + 2);
+ Time = Get32(p + 4);
+ PointerToSymbolTable = Get32(p + 8);
+ NumSymbols = Get32(p + 12);
+ OptHeaderSize = Get16(p + 16);
+ Flags = Get16(p + 18);
+ return true;
+}
+
+struct CDirLink
+{
+ UInt32 Va;
+ UInt32 Size;
+ void Parse(const Byte *p);
+};
+
+void CDirLink::Parse(const Byte *p)
+{
+ Va = Get32(p);
+ Size = Get32(p + 4);
+};
+
+enum
+{
+ kDirLink_Certificate = 4,
+ kDirLink_Debug = 6
+};
+
+struct CDebugEntry
+{
+ UInt32 Flags;
+ UInt32 Time;
+ CVersion Ver;
+ UInt32 Type;
+ UInt32 Size;
+ UInt32 Va;
+ UInt32 Pa;
+
+ void Parse(const Byte *p);
+};
+
+void CDebugEntry::Parse(const Byte *p)
+{
+ Flags = Get32(p);
+ Time = Get32(p + 4);
+ Ver.Parse(p + 8);
+ Type = Get32(p + 12);
+ Size = Get32(p + 16);
+ Va = Get32(p + 20);
+ Pa = Get32(p + 24);
+}
+
+static const kNumDirItemsMax = 16;
+
+struct COptHeader
+{
+ UInt16 Magic;
+ Byte LinkerVerMajor;
+ Byte LinkerVerMinor;
+
+ UInt32 CodeSize;
+ UInt32 InitDataSize;
+ UInt32 UninitDataSize;
+
+ // UInt32 AddressOfEntryPoint;
+ // UInt32 BaseOfCode;
+ // UInt32 BaseOfData32;
+ // UInt64 ImageBase;
+
+ UInt32 SectAlign;
+ UInt32 FileAlign;
+
+ CVersion OsVer;
+ CVersion ImageVer;
+ CVersion SubsysVer;
+
+ UInt32 ImageSize;
+ UInt32 HeadersSize;
+ UInt32 CheckSum;
+ UInt16 SubSystem;
+ UInt16 DllCharacts;
+
+ UInt64 StackReserve;
+ UInt64 StackCommit;
+ UInt64 HeapReserve;
+ UInt64 HeapCommit;
+
+ UInt32 NumDirItems;
+ CDirLink DirItems[kNumDirItemsMax];
+
+ bool Is64Bit() const { return Magic == PE_OptHeader_Magic_64; }
+ bool Parse(const Byte *p, UInt32 size);
+};
+
+bool COptHeader::Parse(const Byte *p, UInt32 size)
+{
+ Magic = Get16(p);
+ switch (Magic)
+ {
+ case PE_OptHeader_Magic_32:
+ case PE_OptHeader_Magic_64:
+ break;
+ default:
+ return false;
+ }
+ LinkerVerMajor = p[2];
+ LinkerVerMinor = p[3];
+
+ bool hdr64 = Is64Bit();
+
+ CodeSize = Get32(p + 4);
+ InitDataSize = Get32(p + 8);
+ UninitDataSize = Get32(p + 12);
+
+ // AddressOfEntryPoint = Get32(p + 16);
+ // BaseOfCode = Get32(p + 20);
+ // BaseOfData32 = Get32(p + 24);
+ // ImageBase = hdr64 ? GetUi64(p + 24) :Get32(p + 28);
+
+ SectAlign = Get32(p + 32);
+ FileAlign = Get32(p + 36);
+
+ OsVer.Parse(p + 40);
+ ImageVer.Parse(p + 44);
+ SubsysVer.Parse(p + 48);
+
+ // reserved = Get32(p + 52);
+
+ ImageSize = Get32(p + 56);
+ HeadersSize = Get32(p + 60);
+ CheckSum = Get32(p + 64);
+ SubSystem = Get16(p + 68);
+ DllCharacts = Get16(p + 70);
+
+ if (hdr64)
+ {
+ StackReserve = Get64(p + 72);
+ StackCommit = Get64(p + 80);
+ HeapReserve = Get64(p + 88);
+ HeapCommit = Get64(p + 96);
+ }
+ else
+ {
+ StackReserve = Get32(p + 72);
+ StackCommit = Get32(p + 76);
+ HeapReserve = Get32(p + 80);
+ HeapCommit = Get32(p + 84);
+ }
+ UInt32 pos = (hdr64 ? 108 : 92);
+ NumDirItems = Get32(p + pos);
+ pos += 4;
+ if (pos + 8 * NumDirItems != size)
+ return false;
+ for (UInt32 i = 0; i < NumDirItems && i < kNumDirItemsMax; i++)
+ DirItems[i].Parse(p + pos + i * 8);
+ return true;
+}
+
+static const UInt32 kSectionSize = 40;
+
+struct CSection
+{
+ AString Name;
+
+ UInt32 VSize;
+ UInt32 Va;
+ UInt32 PSize;
+ UInt32 Pa;
+ UInt32 Flags;
+ UInt32 Time;
+ // UInt16 NumRelocs;
+ bool IsDebug;
+ bool IsRealSect;
+
+ CSection(): IsRealSect(false), IsDebug(false) {}
+ UInt64 GetPackSize() const { return PSize; }
+
+ void UpdateTotalSize(UInt32 &totalSize)
+ {
+ UInt32 t = Pa + PSize;
+ if (t > totalSize)
+ totalSize = t;
+ }
+ void Parse(const Byte *p);
+};
+
+static AString GetName(const Byte *name)
+{
+ const int kNameSize = 8;
+ AString res;
+ char *p = res.GetBuffer(kNameSize);
+ memcpy(p, name, kNameSize);
+ p[kNameSize] = 0;
+ res.ReleaseBuffer();
+ return res;
+}
+
+void CSection::Parse(const Byte *p)
+{
+ Name = GetName(p);
+ VSize = Get32(p + 8);
+ Va = Get32(p + 12);
+ PSize = Get32(p + 16);
+ Pa = Get32(p + 20);
+ // NumRelocs = Get16(p + 32);
+ Flags = Get32(p + 36);
+}
+
+static const CUInt32PCharPair g_HeaderCharacts[] =
+{
+ { 1 << 1, "Executable" },
+ { 1 << 13, "DLL" },
+ { 1 << 8, "32-bit" },
+ { 1 << 5, "LargeAddress" },
+ { 1 << 0, "NoRelocs" },
+ { 1 << 2, "NoLineNums" },
+ { 1 << 3, "NoLocalSyms" },
+ { 1 << 4, "AggressiveWsTrim" },
+ { 1 << 9, "NoDebugInfo" },
+ { 1 << 10, "RemovableRun" },
+ { 1 << 11, "NetRun" },
+ { 1 << 12, "System" },
+ { 1 << 14, "UniCPU" },
+ { 1 << 7, "Little-Endian" },
+ { 1 << 15, "Big-Endian" }
+};
+
+static const CUInt32PCharPair g_DllCharacts[] =
+{
+ { 1 << 6, "Relocated" },
+ { 1 << 7, "Integrity" },
+ { 1 << 8, "NX-Compatible" },
+ { 1 << 9, "NoIsolation" },
+ { 1 << 10, "NoSEH" },
+ { 1 << 11, "NoBind" },
+ { 1 << 13, "WDM" },
+ { 1 << 15, "TerminalServerAware" }
+};
+
+static const CUInt32PCharPair g_SectFlags[] =
+{
+ { 1 << 3, "NoPad" },
+ { 1 << 5, "Code" },
+ { 1 << 6, "InitializedData" },
+ { 1 << 7, "UninitializedData" },
+ { 1 << 9, "Comments" },
+ { 1 << 11, "Remove" },
+ { 1 << 12, "COMDAT" },
+ { 1 << 15, "GP" },
+ { 1 << 24, "ExtendedRelocations" },
+ { 1 << 25, "Discardable" },
+ { 1 << 26, "NotCached" },
+ { 1 << 27, "NotPaged" },
+ { 1 << 28, "Shared" },
+ { 1 << 29, "Execute" },
+ { 1 << 30, "Read" },
+ { (UInt32)1 << 31, "Write" }
+};
+
+static const CUInt32PCharPair g_MachinePairs[] =
+{
+ { 0x014C, "x86" },
+ { 0x0162, "MIPS-R3000" },
+ { 0x0166, "MIPS-R4000" },
+ { 0x0168, "MIPS-R10000" },
+ { 0x0169, "MIPS-V2" },
+ { 0x0184, "Alpha" },
+ { 0x01A2, "SH3" },
+ { 0x01A3, "SH3-DSP" },
+ { 0x01A4, "SH3E" },
+ { 0x01A6, "SH4" },
+ { 0x01A8, "SH5" },
+ { 0x01C0, "ARM" },
+ { 0x01C2, "ARM-Thumb" },
+ { 0x01F0, "PPC" },
+ { 0x01F1, "PPC-FP" },
+ { 0x0200, "IA-64" },
+ { 0x0284, "Alpha-64" },
+ { 0x0200, "IA-64" },
+ { 0x0366, "MIPSFPU" },
+ { 0x8664, "x64" },
+ { 0x0EBC, "EFI" }
+};
+
+static const CUInt32PCharPair g_SubSystems[] =
+{
+ { 0, "Unknown" },
+ { 1, "Native" },
+ { 2, "Windows GUI" },
+ { 3, "Windows CUI" },
+ { 7, "Posix" },
+ { 9, "Windows CE" },
+ { 10, "EFI" },
+ { 11, "EFI Boot" },
+ { 12, "EFI Runtime" },
+ { 13, "EFI ROM" },
+ { 14, "XBOX" }
+};
+
+class CHandler:
+ public IInArchive,
+ public CMyUnknownImp
+{
+ CMyComPtr<IInStream> _inStream;
+ CObjectVector<CSection> _sections;
+ UInt32 _peOffset;
+ CHeader _header;
+ COptHeader _optHeader;
+ UInt32 _totalSize;
+ UInt32 _totalSizeLimited;
+ HRESULT LoadDebugSections(IInStream *stream, bool &thereIsSection);
+ HRESULT Open2(IInStream *stream);
+ bool Parse(const Byte *buf, UInt32 size);
+public:
+ MY_UNKNOWN_IMP1(IInArchive)
+ INTERFACE_IInArchive(;)
+};
+
+bool CHandler::Parse(const Byte *buf, UInt32 size)
+{
+ UInt32 i;
+ if (size < 512)
+ return false;
+ _peOffset = Get32(buf + 0x3C);
+ if (_peOffset >= 0x1000 || _peOffset + 512 > size || (_peOffset & 7) != 0)
+ return false;
+
+ UInt32 pos = _peOffset;
+ if (!_header.Parse(buf + pos))
+ return false;
+ if (_header.OptHeaderSize > 512 || _header.NumSections > NUM_SCAN_SECTIONS_MAX)
+ return false;
+ pos += kHeaderSize;
+
+ if (!_optHeader.Parse(buf + pos, _header.OptHeaderSize))
+ return false;
+
+ pos += _header.OptHeaderSize;
+ _totalSize = pos;
+
+ for (i = 0; i < _header.NumSections; i++, pos += kSectionSize)
+ {
+ CSection sect;
+ if (pos + kSectionSize > size)
+ return false;
+ sect.Parse(buf + pos);
+ sect.IsRealSect = true;
+ sect.UpdateTotalSize(_totalSize);
+ _sections.Add(sect);
+ }
+
+ return true;
+}
+
+enum
+{
+ kpidSectAlign = kpidUserDefined,
+ kpidFileAlign,
+ kpidLinkerVer,
+ kpidOsVer,
+ kpidImageVer,
+ kpidSubsysVer,
+ kpidCodeSize,
+ kpidImageSize,
+ kpidInitDataSize,
+ kpidUnInitDataSize,
+ kpidHeadersSizeUnInitDataSize,
+ kpidSubSystem,
+ kpidDllCharacts,
+ kpidStackReserve,
+ kpidStackCommit,
+ kpidHeapReserve,
+ kpidHeapCommit,
+};
+
+STATPROPSTG kArcProps[] =
+{
+ { NULL, kpidCpu, VT_BSTR},
+ { NULL, kpidBit64, VT_BOOL},
+ { NULL, kpidCharacts, VT_BSTR},
+ { NULL, kpidCTime, VT_FILETIME},
+ { NULL, kpidPhySize, VT_UI4},
+ { NULL, kpidHeadersSize, VT_UI4},
+ { NULL, kpidChecksum, VT_UI4},
+ { L"Image Size", kpidImageSize, VT_UI4},
+ { L"Section Alignment", kpidSectAlign, VT_UI4},
+ { L"File Alignment", kpidFileAlign, VT_UI4},
+ { L"Code Size", kpidCodeSize, VT_UI4},
+ { L"Initialized Data Size", kpidInitDataSize, VT_UI4},
+ { L"Uninitialized Data Size", kpidUnInitDataSize, VT_UI4},
+ { L"Linker Version", kpidLinkerVer, VT_BSTR},
+ { L"OS Version", kpidOsVer, VT_BSTR},
+ { L"Image Version", kpidImageVer, VT_BSTR},
+ { L"Subsystem Version", kpidSubsysVer, VT_BSTR},
+ { L"Subsystem", kpidSubSystem, VT_BSTR},
+ { L"DLL Characteristics", kpidDllCharacts, VT_BSTR},
+ { L"Stack Reserve", kpidStackReserve, VT_UI8},
+ { L"Stack Commit", kpidStackCommit, VT_UI8},
+ { L"Heap Reserve", kpidHeapReserve, VT_UI8},
+ { L"Heap Commit", kpidHeapCommit, VT_UI8},
+ };
+
+STATPROPSTG kProps[] =
+{
+ { NULL, kpidPath, VT_BSTR},
+ { NULL, kpidSize, VT_UI8},
+ { NULL, kpidPackSize, VT_UI8},
+ { NULL, kpidCharacts, VT_BSTR},
+ { NULL, kpidOffset, VT_UI8},
+ { NULL, kpidVa, VT_UI8}
+};
+
+IMP_IInArchive_Props
+IMP_IInArchive_ArcProps_WITH_NAME
+
+static void VerToProp(const CVersion &v, NCOM::CPropVariant &prop)
+{
+ StringToProp(v.GetString(), prop);
+}
+
+void TimeToProp(UInt32 unixTime, NCOM::CPropVariant &prop)
+{
+ if (unixTime != 0)
+ {
+ FILETIME ft;
+ NTime::UnixTimeToFileTime(unixTime, ft);
+ prop = ft;
+ }
+}
+
+STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NCOM::CPropVariant prop;
+ switch(propID)
+ {
+ case kpidSectAlign: prop = _optHeader.SectAlign; break;
+ case kpidFileAlign: prop = _optHeader.FileAlign; break;
+ case kpidLinkerVer:
+ {
+ CVersion v = { _optHeader.LinkerVerMajor, _optHeader.LinkerVerMinor };
+ VerToProp(v, prop); break;
+ break;
+ }
+
+ case kpidOsVer: VerToProp(_optHeader.OsVer, prop); break;
+ case kpidImageVer: VerToProp(_optHeader.ImageVer, prop); break;
+ case kpidSubsysVer: VerToProp(_optHeader.SubsysVer, prop); break;
+ case kpidCodeSize: prop = _optHeader.CodeSize; break;
+ case kpidInitDataSize: prop = _optHeader.InitDataSize; break;
+ case kpidUnInitDataSize: prop = _optHeader.UninitDataSize; break;
+ case kpidImageSize: prop = _optHeader.ImageSize; break;
+ case kpidPhySize: prop = _totalSize; break;
+ case kpidHeadersSize: prop = _optHeader.HeadersSize; break;
+ case kpidChecksum: prop = _optHeader.CheckSum; break;
+
+ case kpidCpu: PAIR_TO_PROP(g_MachinePairs, _header.Machine, prop); break;
+ case kpidBit64: if (_optHeader.Is64Bit()) prop = true; break;
+ case kpidSubSystem: PAIR_TO_PROP(g_SubSystems, _optHeader.SubSystem, prop); break;
+
+ case kpidMTime:
+ case kpidCTime: TimeToProp(_header.Time, prop); break;
+ case kpidCharacts: FLAGS_TO_PROP(g_HeaderCharacts, _header.Flags, prop); break;
+ case kpidDllCharacts: FLAGS_TO_PROP(g_DllCharacts, _optHeader.DllCharacts, prop); break;
+ case kpidStackReserve: prop = _optHeader.StackReserve; break;
+ case kpidStackCommit: prop = _optHeader.StackCommit; break;
+ case kpidHeapReserve: prop = _optHeader.HeapReserve; break;
+ case kpidHeapCommit: prop = _optHeader.HeapCommit; break;
+
+ /*
+ if (_optHeader.Is64Bit())
+ s += " 64-bit";
+ */
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NCOM::CPropVariant prop;
+ const CSection &item = _sections[index];
+ switch(propID)
+ {
+ case kpidPath: StringToProp(item.Name, prop); break;
+ case kpidSize: prop = (UInt64)item.VSize; break;
+ case kpidPackSize: prop = (UInt64)item.GetPackSize(); break;
+ case kpidOffset: prop = item.Pa; break;
+ case kpidVa: if (item.IsRealSect) prop = item.Va; break;
+ case kpidMTime:
+ case kpidCTime:
+ TimeToProp(item.IsDebug ? item.Time : _header.Time, prop); break;
+ case kpidCharacts: if (item.IsRealSect) FLAGS_TO_PROP(g_SectFlags, item.Flags, prop); break;
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+HRESULT CHandler::LoadDebugSections(IInStream *stream, bool &thereIsSection)
+{
+ thereIsSection = false;
+ const CDirLink &debugLink = _optHeader.DirItems[kDirLink_Debug];
+ if (debugLink.Size == 0)
+ return S_OK;
+ const unsigned kEntrySize = 28;
+ UInt32 numItems = debugLink.Size / kEntrySize;
+ if (numItems * kEntrySize != debugLink.Size || numItems > 16)
+ return S_FALSE;
+
+ UInt64 pa = 0;
+ int i;
+ for (i = 0; i < _sections.Size(); i++)
+ {
+ const CSection &sect = _sections[i];
+ if (sect.Va < debugLink.Va && debugLink.Va + debugLink.Size <= sect.Va + sect.PSize)
+ {
+ pa = sect.Pa + (debugLink.Va - sect.Va);
+ break;
+ }
+ }
+ if (i == _sections.Size())
+ return S_FALSE;
+
+ CByteBuffer buffer;
+ buffer.SetCapacity(debugLink.Size);
+ Byte *buf = buffer;
+
+ RINOK(stream->Seek(pa, STREAM_SEEK_SET, NULL));
+ RINOK(ReadStream_FALSE(stream, buf, debugLink.Size));
+
+ for (i = 0; i < (int)numItems; i++)
+ {
+ CDebugEntry de;
+ de.Parse(buf);
+
+ if (de.Size == 0)
+ continue;
+
+ CSection sect;
+ sect.Name = ".debug" + GetDecString(i);
+
+ sect.IsDebug = true;
+ sect.Time = de.Time;
+ sect.Va = de.Va;
+ sect.Pa = de.Pa;
+ sect.PSize = sect.VSize = de.Size;
+ UInt32 totalSize = sect.Pa + sect.PSize;
+ if (totalSize > _totalSize)
+ {
+ _totalSize = totalSize;
+ _sections.Add(sect);
+ thereIsSection = true;
+ }
+ buf += kEntrySize;
+ }
+
+ return S_OK;
+}
+
+HRESULT CHandler::Open2(IInStream *stream)
+{
+ const UInt32 kBufSize = 1 << 18;
+ const UInt32 kSigSize = 2;
+
+ CByteBuffer buffer;
+ buffer.SetCapacity(kBufSize);
+ Byte *buf = buffer;
+
+ size_t processed = kSigSize;
+ RINOK(ReadStream_FALSE(stream, buf, processed));
+ if (buf[0] != 'M' || buf[1] != 'Z')
+ return S_FALSE;
+ processed = kBufSize - kSigSize;
+ RINOK(ReadStream(stream, buf + kSigSize, &processed));
+ processed += kSigSize;
+ if (!Parse(buf, (UInt32)processed))
+ return S_FALSE;
+ bool thereISDebug;
+ RINOK(LoadDebugSections(stream, thereISDebug));
+
+ const CDirLink &certLink = _optHeader.DirItems[kDirLink_Certificate];
+ if (certLink.Size != 0)
+ {
+ CSection sect;
+ sect.Name = "CERTIFICATE";
+ sect.Va = 0;
+ sect.Pa = certLink.Va;
+ sect.PSize = sect.VSize = certLink.Size;
+ sect.UpdateTotalSize(_totalSize);
+ _sections.Add(sect);
+ }
+
+ if (thereISDebug)
+ {
+ const UInt32 kAlign = 1 << 12;
+ UInt32 alignPos = _totalSize & (kAlign - 1);
+ if (alignPos != 0)
+ {
+ UInt32 size = kAlign - alignPos;
+ RINOK(stream->Seek(_totalSize, STREAM_SEEK_SET, NULL));
+ buffer.Free();
+ buffer.SetCapacity(kAlign);
+ Byte *buf = buffer;
+ size_t processed = size;
+ RINOK(ReadStream(stream, buf, &processed));
+ size_t i;
+ for (i = 0; i < processed; i++)
+ {
+ if (buf[i] != 0)
+ break;
+ }
+ if (processed < size && processed < 100)
+ _totalSize += (UInt32)processed;
+ else if (((_totalSize + i) & 0x1FF) == 0 || processed < size)
+ _totalSize += (UInt32)i;
+ }
+ }
+
+ if (_header.NumSymbols > 0 && _header.PointerToSymbolTable >= 512)
+ {
+ if (_header.NumSymbols >= (1 << 24))
+ return S_FALSE;
+ CSection sect;
+ sect.Name = "COFF_SYMBOLS";
+ UInt32 size = _header.NumSymbols * 18;
+ RINOK(stream->Seek((UInt64)_header.PointerToSymbolTable + size, STREAM_SEEK_SET, NULL));
+ Byte buf[4];
+ RINOK(ReadStream_FALSE(stream, buf, 4));
+ UInt32 size2 = Get32(buf);
+ if (size2 >= (1 << 28))
+ return S_FALSE;
+ size += size2;
+
+ sect.Va = 0;
+ sect.Pa = _header.PointerToSymbolTable;
+ sect.PSize = sect.VSize = size;
+ sect.UpdateTotalSize(_totalSize);
+ _sections.Add(sect);
+ }
+
+ UInt64 fileSize;
+ RINOK(stream->Seek(0, STREAM_SEEK_END, &fileSize));
+ if (fileSize > _totalSize)
+ return S_FALSE;
+ _totalSizeLimited = (_totalSize < fileSize) ? _totalSize : (UInt32)fileSize;
+ return S_OK;
+}
+
+HRESULT CalcCheckSum(ISequentialInStream *stream, UInt32 size, UInt32 excludePos, UInt32 &res)
+{
+ // size &= ~1;
+ const UInt32 kBufSize = 1 << 23;
+ CByteBuffer buffer;
+ buffer.SetCapacity(kBufSize);
+ Byte *buf = buffer;
+
+ UInt32 sum = 0;
+ UInt32 pos;
+ for(pos = 0;;)
+ {
+ UInt32 rem = size - pos;
+ if (rem > kBufSize)
+ rem = kBufSize;
+ if (rem == 0)
+ break;
+ size_t processed = rem;
+ RINOK(ReadStream(stream, buf, &processed));
+
+ /*
+ */
+ /*
+ for (; processed < rem; processed++)
+ buf[processed] = 0;
+ */
+
+ if ((processed & 1) != 0)
+ buf[processed] = 0;
+
+ for (int j = 0; j < 4; j++)
+ {
+ UInt32 p = excludePos + j;
+ if (pos <= p && p < pos + processed)
+ buf[p - pos] = 0;
+ }
+
+ for (size_t i = 0; i < processed; i += 2)
+ {
+ sum += Get16(buf + i);
+ sum = (sum + (sum >> 16)) & 0xFFFF;
+ }
+ pos += (UInt32)processed;
+ if (rem != processed)
+ break;
+ }
+ sum += pos;
+ res = sum;
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Open(IInStream *inStream,
+ const UInt64 * /* maxCheckStartPosition */,
+ IArchiveOpenCallback * /* openArchiveCallback */)
+{
+ COM_TRY_BEGIN
+ Close();
+ RINOK(Open2(inStream));
+ _inStream = inStream;
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Close()
+{
+ _inStream.Release();
+ _sections.Clear();
+
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
+{
+ *numItems = _sections.Size();
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
+ Int32 _aTestMode, IArchiveExtractCallback *extractCallback)
+{
+ COM_TRY_BEGIN
+ bool testMode = (_aTestMode != 0);
+ bool allFilesMode = (numItems == UInt32(-1));
+ if (allFilesMode)
+ numItems = _sections.Size();
+ if (numItems == 0)
+ return S_OK;
+ UInt64 totalSize = 0;
+ UInt32 i;
+ for (i = 0; i < numItems; i++)
+ totalSize += _sections[allFilesMode ? i : indices[i]].GetPackSize();
+ extractCallback->SetTotal(totalSize);
+
+ UInt64 currentTotalSize = 0;
+ UInt64 currentItemSize;
+
+ NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder();
+ CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;
+
+ CLocalProgress *lps = new CLocalProgress;
+ CMyComPtr<ICompressProgressInfo> progress = lps;
+ lps->Init(extractCallback, false);
+
+ bool checkSumOK = true;
+ if (_optHeader.CheckSum != 0 && (int)numItems == _sections.Size())
+ {
+ UInt32 checkSum = 0;
+ RINOK(_inStream->Seek(0, STREAM_SEEK_SET, NULL));
+ CalcCheckSum(_inStream, _totalSizeLimited, _peOffset + kHeaderSize + 64, checkSum);
+ checkSumOK = (checkSum == _optHeader.CheckSum);
+ }
+
+ CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
+ CMyComPtr<ISequentialInStream> inStream(streamSpec);
+ streamSpec->SetStream(_inStream);
+
+ CDummyOutStream *outStreamSpec = new CDummyOutStream;
+ CMyComPtr<ISequentialOutStream> outStream(outStreamSpec);
+
+ for (i = 0; i < numItems; i++, currentTotalSize += currentItemSize)
+ {
+ lps->InSize = lps->OutSize = currentTotalSize;
+ RINOK(lps->SetCur());
+ Int32 askMode = testMode ?
+ NArchive::NExtract::NAskMode::kTest :
+ NArchive::NExtract::NAskMode::kExtract;
+ UInt32 index = allFilesMode ? i : indices[i];
+ const CSection &item = _sections[index];
+ currentItemSize = item.GetPackSize();
+ {
+ CMyComPtr<ISequentialOutStream> realOutStream;
+ RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
+ if (!testMode && (!realOutStream))
+ continue;
+ outStreamSpec->SetStream(realOutStream);
+ outStreamSpec->Init();
+ }
+
+ RINOK(extractCallback->PrepareOperation(askMode));
+ RINOK(_inStream->Seek(item.Pa, STREAM_SEEK_SET, NULL));
+ streamSpec->Init(currentItemSize);
+ RINOK(copyCoder->Code(inStream, outStream, NULL, NULL, progress));
+ outStreamSpec->ReleaseStream();
+ RINOK(extractCallback->SetOperationResult((copyCoderSpec->TotalSize == currentItemSize) ?
+ checkSumOK ?
+ NArchive::NExtract::NOperationResult::kOK:
+ NArchive::NExtract::NOperationResult::kCRCError:
+ NArchive::NExtract::NOperationResult::kDataError));
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+static IInArchive *CreateArc() { return new CHandler; }
+
+static CArcInfo g_ArcInfo =
+ { L"PE", L"", 0, 0xDD, { 0 }, 0, false, CreateArc, 0 };
+
+REGISTER_ARC(Pe)
+
+}}
diff --git a/CPP/7zip/Archive/RPM/RpmHandler.cpp b/CPP/7zip/Archive/RPM/RpmHandler.cpp
deleted file mode 100755
index 9a9f9af4..00000000
--- a/CPP/7zip/Archive/RPM/RpmHandler.cpp
+++ /dev/null
@@ -1,152 +0,0 @@
-// RPM/Handler.cpp
-
-#include "StdAfx.h"
-
-#include "RpmHandler.h"
-#include "RpmIn.h"
-
-#include "Common/ComTry.h"
-#include "Common/MyString.h"
-
-#include "Windows/PropVariant.h"
-
-#include "../../Common/ProgressUtils.h"
-#include "../../Common/StreamUtils.h"
-
-#include "../../Compress/Copy/CopyCoder.h"
-
-using namespace NWindows;
-
-namespace NArchive {
-namespace NRpm {
-
-STATPROPSTG kProps[] =
-{
- { NULL, kpidSize, VT_UI8},
- { NULL, kpidPackedSize, VT_UI8}
-};
-
-IMP_IInArchive_Props
-IMP_IInArchive_ArcProps_NO
-
-STDMETHODIMP CHandler::Open(IInStream *inStream,
- const UInt64 * /* maxCheckStartPosition */,
- IArchiveOpenCallback * /* openArchiveCallback */)
-{
- COM_TRY_BEGIN
- try
- {
- if(OpenArchive(inStream) != S_OK)
- return S_FALSE;
- RINOK(inStream->Seek(0, STREAM_SEEK_CUR, &m_Pos));
- UInt64 endPosition;
- RINOK(inStream->Seek(0, STREAM_SEEK_END, &endPosition));
- m_Size = endPosition - m_Pos;
-
- RINOK(inStream->Seek(m_Pos, STREAM_SEEK_SET, NULL));
- RINOK(ReadStream_FALSE(inStream, _sig, sizeof(_sig) / sizeof(_sig[0])));
-
- m_InStream = inStream;
- return S_OK;
- }
- catch(...)
- {
- return S_FALSE;
- }
- COM_TRY_END
-}
-
-STDMETHODIMP CHandler::Close()
-{
- m_InStream.Release();
- return S_OK;
-}
-
-STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
-{
- *numItems = 1;
- return S_OK;
-}
-
-STDMETHODIMP CHandler::GetProperty(UInt32 /* index */, PROPID propID, PROPVARIANT *value)
-{
- NWindows::NCOM::CPropVariant prop;
- switch(propID)
- {
- case kpidSize:
- case kpidPackedSize:
- prop = m_Size;
- break;
- case kpidExtension:
- {
- wchar_t s[32];
- MyStringCopy(s, L"cpio.");
- const wchar_t *ext;
- if (_sig[0] == 0x1F && _sig[1] == 0x8B)
- ext = L"gz";
- else if (_sig[0] == 'B' && _sig[1] == 'Z' && _sig[2] == 'h')
- ext = L"bz2";
- else
- ext = L"lzma";
- MyStringCopy(s + MyStringLen(s), ext);
- prop = s;
- break;
- }
- }
- prop.Detach(value);
- return S_OK;
-}
-
-STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
- Int32 _aTestMode, IArchiveExtractCallback *extractCallback)
-{
- COM_TRY_BEGIN
- bool allFilesMode = (numItems == UInt32(-1));
- if (allFilesMode)
- numItems = 1;
- if(numItems == 0)
- return S_OK;
- if(numItems != 1)
- return E_FAIL;
- if (indices[0] != 0)
- return E_FAIL;
-
- bool testMode = (_aTestMode != 0);
-
- UInt64 currentTotalSize = 0;
- RINOK(extractCallback->SetTotal(m_Size));
- RINOK(extractCallback->SetCompleted(&currentTotalSize));
- CMyComPtr<ISequentialOutStream> realOutStream;
- Int32 askMode = testMode ?
- NArchive::NExtract::NAskMode::kTest :
- NArchive::NExtract::NAskMode::kExtract;
- Int32 index = 0;
-
- RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
-
- if(!testMode && (!realOutStream))
- return S_OK;
-
- RINOK(extractCallback->PrepareOperation(askMode));
-
- if (testMode)
- {
- RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK));
- return S_OK;
- }
-
- RINOK(m_InStream->Seek(m_Pos, STREAM_SEEK_SET, NULL));
-
- CMyComPtr<ICompressCoder> copyCoder = new NCompress::CCopyCoder;
-
- CLocalProgress *lps = new CLocalProgress;
- CMyComPtr<ICompressProgressInfo> progress = lps;
- lps->Init(extractCallback, false);
-
- RINOK(copyCoder->Code(m_InStream, realOutStream, NULL, NULL, progress));
- realOutStream.Release();
- return extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK);
- COM_TRY_END
-}
-
-}}
diff --git a/CPP/7zip/Archive/RPM/RpmHandler.h b/CPP/7zip/Archive/RPM/RpmHandler.h
deleted file mode 100755
index 92efc107..00000000
--- a/CPP/7zip/Archive/RPM/RpmHandler.h
+++ /dev/null
@@ -1,30 +0,0 @@
-// RPM/Handler.h
-
-#ifndef __RPM_HANDLER_H
-#define __RPM_HANDLER_H
-
-#include "Common/MyCom.h"
-#include "../IArchive.h"
-
-namespace NArchive {
-namespace NRpm {
-
-class CHandler:
- public IInArchive,
- public CMyUnknownImp
-{
-public:
- MY_UNKNOWN_IMP1(IInArchive)
-
- INTERFACE_IInArchive(;)
-
-private:
- CMyComPtr<IInStream> m_InStream;
- UInt64 m_Pos;
- UInt64 m_Size;
- Byte _sig[4];
-};
-
-}}
-
-#endif
diff --git a/CPP/7zip/Archive/RPM/RpmHeader.h b/CPP/7zip/Archive/RPM/RpmHeader.h
deleted file mode 100755
index d76963bd..00000000
--- a/CPP/7zip/Archive/RPM/RpmHeader.h
+++ /dev/null
@@ -1,63 +0,0 @@
-// Archive/RpmHeader.h
-
-#ifndef __ARCHIVE_RPM_HEADER_H
-#define __ARCHIVE_RPM_HEADER_H
-
-#include "Common/Types.h"
-
-namespace NArchive {
-namespace NRpm {
-
-/* Reference: lib/signature.h of rpm package */
-#define RPMSIG_NONE 0 /* Do not change! */
-/* The following types are no longer generated */
-#define RPMSIG_PGP262_1024 1 /* No longer generated */ /* 256 byte */
-/* These are the new-style signatures. They are Header structures. */
-/* Inside them we can put any number of any type of signature we like. */
-
-#define RPMSIG_HEADERSIG 5 /* New Header style signature */
-
-const UInt32 kLeadSize = 96;
-struct CLead
-{
- unsigned char Magic[4];
- unsigned char Major; // not supported ver1, only support 2,3 and lator
- unsigned char Minor;
- UInt16 Type;
- UInt16 ArchNum;
- char Name[66];
- UInt16 OSNum;
- UInt16 SignatureType;
- char Reserved[16]; // pad to 96 bytes -- 8 byte aligned
- bool MagicCheck() const
- { return Magic[0] == 0xed && Magic[1] == 0xab && Magic[2] == 0xee && Magic[3] == 0xdb; };
-};
-
-const UInt32 kEntryInfoSize = 16;
-/*
-struct CEntryInfo
-{
- int Tag;
- int Type;
- int Offset; // Offset from beginning of data segment, only defined on disk
- int Count;
-};
-*/
-
-// case: SignatureType == RPMSIG_HEADERSIG
-const UInt32 kCSigHeaderSigSize = 16;
-struct CSigHeaderSig
-{
- unsigned char Magic[4];
- UInt32 Reserved;
- UInt32 IndexLen; // count of index entries
- UInt32 DataLen; // number of bytes
- bool MagicCheck()
- { return Magic[0] == 0x8e && Magic[1] == 0xad && Magic[2] == 0xe8 && Magic[3] == 0x01; };
- UInt32 GetLostHeaderLen()
- { return IndexLen * kEntryInfoSize + DataLen; };
-};
-
-}}
-
-#endif
diff --git a/CPP/7zip/Archive/RPM/RpmIn.cpp b/CPP/7zip/Archive/RPM/RpmIn.cpp
deleted file mode 100755
index db7a6f63..00000000
--- a/CPP/7zip/Archive/RPM/RpmIn.cpp
+++ /dev/null
@@ -1,106 +0,0 @@
-// Archive/RpmIn.cpp
-
-#include "StdAfx.h"
-
-#include "RpmIn.h"
-
-#include "RpmHeader.h"
-
-#include "Windows/Defs.h"
-#include "Common/MyCom.h"
-
-#include "../../Common/StreamUtils.h"
-
-namespace NArchive {
-namespace NRpm {
-
-static UInt16 GetUInt16(const char *data)
-{
- return (UInt16)((Byte)data[1] | (((UInt16)(Byte)data[0]) << 8));
-}
-
-static UInt32 GetUInt32(const char *data)
-{
- return
- ((UInt32)(Byte)data[3]) |
- (((UInt32)(Byte)data[2]) << 8) |
- (((UInt32)(Byte)data[1]) << 16) |
- (((UInt32)(Byte)data[0]) << 24);
-}
-
-static HRESULT RedSigHeaderSig(IInStream *inStream, CSigHeaderSig &h)
-{
- char dat[kCSigHeaderSigSize];
- char *cur = dat;
- RINOK(ReadStream_FALSE(inStream, dat, kCSigHeaderSigSize));
- memmove(h.Magic, cur, 4);
- cur += 4;
- cur += 4;
- h.IndexLen = GetUInt32(cur);
- cur += 4;
- h.DataLen = GetUInt32(cur);
- return S_OK;
-}
-
-HRESULT OpenArchive(IInStream *inStream)
-{
- UInt64 pos;
- char leadData[kLeadSize];
- char *cur = leadData;
- CLead lead;
- RINOK(ReadStream_FALSE(inStream, leadData, kLeadSize));
- memmove(lead.Magic, cur, 4);
- cur += 4;
- lead.Major = *cur++;
- lead.Minor = *cur++;
- lead.Type = GetUInt16(cur);
- cur += 2;
- lead.ArchNum = GetUInt16(cur);
- cur += 2;
- memmove(lead.Name, cur, sizeof(lead.Name));
- cur += sizeof(lead.Name);
- lead.OSNum = GetUInt16(cur);
- cur += 2;
- lead.SignatureType = GetUInt16(cur);
- cur += 2;
-
- if (!lead.MagicCheck() || lead.Major < 3)
- return S_FALSE;
-
- CSigHeaderSig sigHeader, header;
- if(lead.SignatureType == RPMSIG_NONE)
- {
- ;
- }
- else if(lead.SignatureType == RPMSIG_PGP262_1024)
- {
- UInt64 pos;
- RINOK(inStream->Seek(256, STREAM_SEEK_CUR, &pos));
- }
- else if(lead.SignatureType == RPMSIG_HEADERSIG)
- {
- RINOK(RedSigHeaderSig(inStream, sigHeader));
- if(!sigHeader.MagicCheck())
- return S_FALSE;
- UInt32 len = sigHeader.GetLostHeaderLen();
- RINOK(inStream->Seek(len, STREAM_SEEK_CUR, &pos));
- if((pos % 8) != 0)
- {
- RINOK(inStream->Seek((pos / 8 + 1) * 8 - pos,
- STREAM_SEEK_CUR, &pos));
- }
- }
- else
- return S_FALSE;
-
- RINOK(RedSigHeaderSig(inStream, header));
- if(!header.MagicCheck())
- return S_FALSE;
- int headerLen = header.GetLostHeaderLen();
- if(headerLen == -1)
- return S_FALSE;
- RINOK(inStream->Seek(headerLen, STREAM_SEEK_CUR, &pos));
- return S_OK;
-}
-
-}}
diff --git a/CPP/7zip/Archive/RPM/RpmIn.h b/CPP/7zip/Archive/RPM/RpmIn.h
deleted file mode 100755
index ec798cb8..00000000
--- a/CPP/7zip/Archive/RPM/RpmIn.h
+++ /dev/null
@@ -1,15 +0,0 @@
-// Archive/RpmIn.h
-
-#ifndef __ARCHIVE_RPM_IN_H
-#define __ARCHIVE_RPM_IN_H
-
-#include "../../IStream.h"
-
-namespace NArchive {
-namespace NRpm {
-
-HRESULT OpenArchive(IInStream *inStream);
-
-}}
-
-#endif
diff --git a/CPP/7zip/Archive/RPM/RpmRegister.cpp b/CPP/7zip/Archive/RPM/RpmRegister.cpp
deleted file mode 100755
index 61082bac..00000000
--- a/CPP/7zip/Archive/RPM/RpmRegister.cpp
+++ /dev/null
@@ -1,13 +0,0 @@
-// RpmRegister.cpp
-
-#include "StdAfx.h"
-
-#include "../../Common/RegisterArc.h"
-
-#include "RpmHandler.h"
-static IInArchive *CreateArc() { return new NArchive::NRpm::CHandler; }
-
-static CArcInfo g_ArcInfo =
- { L"Rpm", L"rpm", 0, 0xEB, { 0}, 0, false, CreateArc, 0 };
-
-REGISTER_ARC(Rpm)
diff --git a/CPP/7zip/Archive/RPM/StdAfx.cpp b/CPP/7zip/Archive/RPM/StdAfx.cpp
deleted file mode 100755
index d0feea85..00000000
--- a/CPP/7zip/Archive/RPM/StdAfx.cpp
+++ /dev/null
@@ -1,3 +0,0 @@
-// StdAfx.cpp
-
-#include "StdAfx.h"
diff --git a/CPP/7zip/Archive/RPM/StdAfx.h b/CPP/7zip/Archive/RPM/StdAfx.h
deleted file mode 100755
index e7fb6986..00000000
--- a/CPP/7zip/Archive/RPM/StdAfx.h
+++ /dev/null
@@ -1,8 +0,0 @@
-// StdAfx.h
-
-#ifndef __STDAFX_H
-#define __STDAFX_H
-
-#include "../../../Common/MyWindows.h"
-
-#endif
diff --git a/CPP/7zip/Archive/Rar/RarHandler.cpp b/CPP/7zip/Archive/Rar/RarHandler.cpp
index 435c5c17..c8a20643 100755
--- a/CPP/7zip/Archive/Rar/RarHandler.cpp
+++ b/CPP/7zip/Archive/Rar/RarHandler.cpp
@@ -42,16 +42,16 @@ static const int kNumHostOSes = sizeof(kHostOS) / sizeof(kHostOS[0]);
static const wchar_t *kUnknownOS = L"Unknown";
-STATPROPSTG kProps[] =
+STATPROPSTG kProps[] =
{
{ NULL, kpidPath, VT_BSTR},
- { NULL, kpidIsFolder, VT_BOOL},
+ { NULL, kpidIsDir, VT_BOOL},
{ NULL, kpidSize, VT_UI8},
- { NULL, kpidPackedSize, VT_UI8},
- { NULL, kpidLastWriteTime, VT_FILETIME},
- { NULL, kpidCreationTime, VT_FILETIME},
- { NULL, kpidLastAccessTime, VT_FILETIME},
- { NULL, kpidAttributes, VT_UI4},
+ { NULL, kpidPackSize, VT_UI8},
+ { NULL, kpidMTime, VT_FILETIME},
+ { NULL, kpidCTime, VT_FILETIME},
+ { NULL, kpidATime, VT_FILETIME},
+ { NULL, kpidAttrib, VT_UI4},
{ NULL, kpidEncrypted, VT_BOOL},
{ NULL, kpidSolid, VT_BOOL},
@@ -64,13 +64,14 @@ STATPROPSTG kProps[] =
{ NULL, kpidUnpackVer, VT_UI1}
};
-STATPROPSTG kArcProps[] =
+STATPROPSTG kArcProps[] =
{
{ NULL, kpidSolid, VT_BOOL},
{ NULL, kpidNumBlocks, VT_UI4},
{ NULL, kpidEncrypted, VT_BOOL},
{ NULL, kpidIsVolume, VT_BOOL},
{ NULL, kpidNumVolumes, VT_UI4},
+ { NULL, kpidPhySize, VT_UI8}
// { NULL, kpidCommented, VT_BOOL}
};
@@ -95,18 +96,18 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
case kpidSolid: prop = _archiveInfo.IsSolid(); break;
case kpidEncrypted: prop = _archiveInfo.IsEncrypted(); break;
case kpidIsVolume: prop = _archiveInfo.IsVolume(); break;
+ case kpidNumVolumes: prop = (UInt32)_archives.Size(); break;
+ case kpidOffset: if (_archiveInfo.StartPosition != 0) prop = _archiveInfo.StartPosition; break;
+ // case kpidCommented: prop = _archiveInfo.IsCommented(); break;
case kpidNumBlocks:
{
UInt32 numBlocks = 0;
for (int i = 0; i < _refItems.Size(); i++)
if (!IsSolid(i))
numBlocks++;
- prop = (UInt32)numBlocks;
+ prop = (UInt32)numBlocks;
break;
}
- case kpidNumVolumes: prop = (UInt32)_archives.Size();
-
- // case kpidCommented: prop = _archiveInfo.IsCommented(); break;
}
prop.Detach(value);
return S_OK;
@@ -125,7 +126,7 @@ static bool RarTimeToFileTime(const CRarTime &rarTime, FILETIME &result)
return false;
UInt64 value = (((UInt64)result.dwHighDateTime) << 32) + result.dwLowDateTime;
value += (UInt64)rarTime.LowSecond * 10000000;
- value += ((UInt64)rarTime.SubTime[2] << 16) +
+ value += ((UInt64)rarTime.SubTime[2] << 16) +
((UInt64)rarTime.SubTime[1] << 8) +
((UInt64)rarTime.SubTime[0]);
result.dwLowDateTime = (DWORD)value;
@@ -164,13 +165,13 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *va
prop = (const wchar_t *)NItemName::WinNameToOSName(u);
break;
}
- case kpidIsFolder: prop = item.IsDirectory(); break;
- case kpidSize: prop = item.UnPackSize; break;
- case kpidPackedSize: prop = GetPackSize(index); break;
- case kpidLastWriteTime: RarTimeToProp(item.LastWriteTime, prop); break;
- case kpidCreationTime: if (item.IsCreationTimeDefined) RarTimeToProp(item.CreationTime, prop); break;
- case kpidLastAccessTime: if (item.IsLastAccessTimeDefined) RarTimeToProp(item.LastAccessTime, prop); break;
- case kpidAttributes: prop = item.GetWinAttributes(); break;
+ case kpidIsDir: prop = item.IsDir(); break;
+ case kpidSize: prop = item.Size; break;
+ case kpidPackSize: prop = GetPackSize(index); break;
+ case kpidMTime: RarTimeToProp(item.MTime, prop); break;
+ case kpidCTime: if (item.CTimeDefined) RarTimeToProp(item.CTime, prop); break;
+ case kpidATime: if (item.ATimeDefined) RarTimeToProp(item.ATime, prop); break;
+ case kpidAttrib: prop = item.GetWinAttributes(); break;
case kpidEncrypted: prop = item.IsEncrypted(); break;
case kpidSolid: prop = IsSolid(index); break;
case kpidCommented: prop = item.IsCommented(); break;
@@ -192,7 +193,7 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *va
wchar_t temp[32];
ConvertUInt64ToString(item.Method - Byte('0'), temp);
method += temp;
- if (!item.IsDirectory())
+ if (!item.IsDir())
{
method += L":";
ConvertUInt64ToString(16 + item.GetDictSize(), temp);
@@ -220,8 +221,8 @@ class CVolumeName
bool _first;
bool _newStyle;
UString _unchangedPart;
- UString _changedPart;
- UString _afterPart;
+ UString _changedPart;
+ UString _afterPart;
public:
CVolumeName(): _newStyle(true) {};
@@ -243,7 +244,7 @@ public:
{
_afterPart = L".rar";
basePart = name.Left(dotPos);
- }
+ }
else if (!_newStyle)
{
if (ext.CompareNoCase(L"000") == 0 || ext.CompareNoCase(L"001") == 0)
@@ -275,7 +276,7 @@ public:
numLetters++;
}
}
- else
+ else
return false;
_unchangedPart = basePart.Left(basePart.Length() - numLetters);
_changedPart = basePart.Right(numLetters);
@@ -284,7 +285,7 @@ public:
UString GetNextName()
{
- UString newName;
+ UString newName;
if (_newStyle || !_first)
{
int i;
@@ -314,13 +315,10 @@ public:
}
};
-STDMETHODIMP CHandler::Open(IInStream *stream,
+HRESULT CHandler::Open2(IInStream *stream,
const UInt64 *maxCheckStartPosition,
IArchiveOpenCallback *openArchiveCallback)
{
- COM_TRY_BEGIN
- Close();
- try
{
CMyComPtr<IArchiveOpenVolumeCallback> openVolumeCallback;
CMyComPtr<ICryptoGetTextPassword> getTextPassword;
@@ -328,12 +326,12 @@ STDMETHODIMP CHandler::Open(IInStream *stream,
CVolumeName seqName;
+ UInt64 totalBytes = 0;
+ UInt64 curBytes = 0;
+
if (openArchiveCallback != NULL)
{
openArchiveCallbackWrap.QueryInterface(IID_IArchiveOpenVolumeCallback, &openVolumeCallback);
- RINOK(openArchiveCallback->SetTotal(NULL, NULL));
- UInt64 numFiles = _items.Size();
- RINOK(openArchiveCallback->SetCompleted(&numFiles, NULL));
openArchiveCallbackWrap.QueryInterface(IID_ICryptoGetTextPassword, &getTextPassword);
}
@@ -371,10 +369,18 @@ STDMETHODIMP CHandler::Open(IInStream *stream,
}
else
inStream = stream;
+
+ UInt64 endPos = 0;
+ if (openArchiveCallback != NULL)
+ {
+ RINOK(stream->Seek(0, STREAM_SEEK_END, &endPos));
+ RINOK(stream->Seek(0, STREAM_SEEK_SET, NULL));
+ totalBytes += endPos;
+ RINOK(openArchiveCallback->SetTotal(NULL, &totalBytes));
+ }
NArchive::NRar::CInArchive archive;
- if(!archive.Open(inStream, maxCheckStartPosition))
- return S_FALSE;
+ RINOK(archive.Open(inStream, maxCheckStartPosition));
if (_archives.IsEmpty())
archive.GetArchiveInfo(_archiveInfo);
@@ -408,20 +414,35 @@ STDMETHODIMP CHandler::Open(IInStream *stream,
_refItems.Add(refItem);
}
_items.Add(item);
- if (openArchiveCallback != NULL)
+ if (openArchiveCallback != NULL && _items.Size() % 100 == 0)
{
UInt64 numFiles = _items.Size();
- RINOK(openArchiveCallback->SetCompleted(&numFiles, NULL));
+ UInt64 numBytes = curBytes + item.Position;
+ RINOK(openArchiveCallback->SetCompleted(&numFiles, &numBytes));
}
}
+ curBytes += endPos;
_archives.Add(archive);
}
}
- catch(...)
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Open(IInStream *stream,
+ const UInt64 *maxCheckStartPosition,
+ IArchiveOpenCallback *openArchiveCallback)
+{
+ COM_TRY_BEGIN
+ Close();
+ try
{
- return S_FALSE;
+ HRESULT res = Open2(stream, maxCheckStartPosition, openArchiveCallback);
+ if (res != S_OK)
+ Close();
+ return res;
}
- return S_OK;
+ catch(const CInArchiveException &) { Close(); return S_FALSE; }
+ catch(...) { Close(); throw; }
COM_TRY_END
}
@@ -449,9 +470,9 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
CMyComPtr<ICryptoGetTextPassword> getTextPassword;
bool testMode = (_aTestMode != 0);
CMyComPtr<IArchiveExtractCallback> extractCallback = _anExtractCallback;
- UInt64 censoredTotalUnPacked = 0,
+ UInt64 censoredTotalUnPacked = 0,
// censoredTotalPacked = 0,
- importantTotalUnPacked = 0;
+ importantTotalUnPacked = 0;
// importantTotalPacked = 0;
bool allFilesMode = (numItems == UInt32(-1));
if (allFilesMode)
@@ -467,7 +488,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
int index = allFilesMode ? t : indices[t];
const CRefItem &refItem = _refItems[index];
const CItemEx &item = _items[refItem.ItemIndex];
- censoredTotalUnPacked += item.UnPackSize;
+ censoredTotalUnPacked += item.Size;
// censoredTotalPacked += item.PackSize;
int j;
for(j = lastIndex; j <= index; j++)
@@ -481,7 +502,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
// const CItemEx &item = _items[j];
- importantTotalUnPacked += item.UnPackSize;
+ importantTotalUnPacked += item.Size;
// importantTotalPacked += item.PackSize;
importantIndexes.Add(j);
extractStatuses.Add(j == index);
@@ -515,7 +536,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
lps->Init(extractCallback, false);
bool solidStart = true;
- for(int i = 0; i < importantIndexes.Size(); i++,
+ for(int i = 0; i < importantIndexes.Size(); i++,
currentImportantTotalUnPacked += currentUnPackSize,
currentImportantTotalPacked += currentPackSize)
{
@@ -526,7 +547,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
Int32 askMode;
if(extractStatuses[i])
- askMode = testMode ?
+ askMode = testMode ?
NArchive::NExtract::NAskMode::kTest :
NArchive::NExtract::NAskMode::kExtract;
else
@@ -537,7 +558,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
const CRefItem &refItem = _refItems[index];
const CItemEx &item = _items[refItem.ItemIndex];
- currentUnPackSize = item.UnPackSize;
+ currentUnPackSize = item.Size;
currentPackSize = GetPackSize(index);
@@ -548,7 +569,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
if (!IsSolid(index))
solidStart = true;
- if(item.IsDirectory())
+ if(item.IsDir())
{
RINOK(extractCallback->PrepareOperation(askMode));
RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK));
@@ -618,7 +639,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
}
rar29CryptoDecoderSpec->SetRar350Mode(item.UnPackVersion < 36);
CMyComPtr<ICompressSetDecoderProperties2> cryptoProperties;
- RINOK(rar29CryptoDecoder.QueryInterface(IID_ICompressSetDecoderProperties2,
+ RINOK(rar29CryptoDecoder.QueryInterface(IID_ICompressSetDecoderProperties2,
&cryptoProperties));
RINOK(cryptoProperties->SetDecoderProperties2(item.Salt, item.HasSalt() ? sizeof(item.Salt) : 0));
filterStreamSpec->Filter = rar29CryptoDecoder;
@@ -639,11 +660,11 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kUnSupportedMethod));
continue;
}
- RINOK(filterStreamSpec->Filter.QueryInterface(IID_ICryptoSetPassword,
+ RINOK(filterStreamSpec->Filter.QueryInterface(IID_ICryptoSetPassword,
&cryptoSetPassword));
if (!getTextPassword)
- extractCallback.QueryInterface(IID_ICryptoGetTextPassword,
+ extractCallback.QueryInterface(IID_ICryptoGetTextPassword,
&getTextPassword);
if (getTextPassword)
{
@@ -722,7 +743,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
methodID += 1;
else if (item.UnPackVersion < 29)
methodID += 2;
- else
+ else
methodID += 3;
RINOK(CreateCoder(EXTERNAL_CODECS_VARS methodID, mi.Coder, false));
}
@@ -739,7 +760,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
CMyComPtr<ICompressCoder> decoder = methodItems[m].Coder;
CMyComPtr<ICompressSetDecoderProperties2> compressSetDecoderProperties;
- RINOK(decoder.QueryInterface(IID_ICompressSetDecoderProperties2,
+ RINOK(decoder.QueryInterface(IID_ICompressSetDecoderProperties2,
&compressSetDecoderProperties));
Byte isSolid = (Byte)((IsSolid(index) || item.IsSplitBefore()) ? 1: 0);
@@ -760,7 +781,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kUnSupportedMethod));
continue;
}
- HRESULT result = commonCoder->Code(inStream, outStream, &packSize, &item.UnPackSize, progress);
+ HRESULT result = commonCoder->Code(inStream, outStream, &packSize, &item.Size, progress);
if (item.IsEncrypted())
filterStreamSpec->ReleaseInStream();
if (result == S_FALSE)
@@ -773,7 +794,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
return result;
/*
- if (refItem.NumItems == 1 &&
+ if (refItem.NumItems == 1 &&
!item.IsSplitBefore() && !item.IsSplitAfter())
*/
{
diff --git a/CPP/7zip/Archive/Rar/RarHandler.h b/CPP/7zip/Archive/Rar/RarHandler.h
index 811802a9..58e3fefc 100755
--- a/CPP/7zip/Archive/Rar/RarHandler.h
+++ b/CPP/7zip/Archive/Rar/RarHandler.h
@@ -12,7 +12,7 @@
namespace NArchive {
namespace NRar {
-class CHandler:
+class CHandler:
public IInArchive,
PUBLIC_ISetCompressCodecsInfo
public CMyUnknownImp
@@ -49,6 +49,10 @@ private:
}
return item.IsSolid();
}
+
+ HRESULT Open2(IInStream *stream,
+ const UInt64 *maxCheckStartPosition,
+ IArchiveOpenCallback *openArchiveCallback);
};
}}
diff --git a/CPP/7zip/Archive/Rar/RarHeader.h b/CPP/7zip/Archive/Rar/RarHeader.h
index 832a21c0..4df42e62 100755
--- a/CPP/7zip/Archive/Rar/RarHeader.h
+++ b/CPP/7zip/Archive/Rar/RarHeader.h
@@ -17,7 +17,7 @@ const int kArchiveSolid = 0x1;
namespace NBlockType
{
enum EBlockType
- {
+ {
kMarker = 0x72,
kArchiveHeader = 0x73,
kFileHeader = 0x74,
@@ -129,7 +129,7 @@ namespace NFile
Byte Method;
UInt16 NameSize;
UInt32 Attributes;
- UInt16 GetRealCRC(const void *aName, UInt32 aNameSize,
+ UInt16 GetRealCRC(const void *aName, UInt32 aNameSize,
bool anExtraDataDefined = false, Byte *anExtraData = 0) const;
};
struct CBlock64
@@ -157,10 +157,10 @@ namespace NFile
const int kWinFileDirectoryAttributeMask = 0x10;
enum CHostOS
- {
- kHostMSDOS = 0,
- kHostOS2 = 1,
- kHostWin32 = 2,
+ {
+ kHostMSDOS = 0,
+ kHostOS2 = 1,
+ kHostWin32 = 2,
kHostUnix = 3,
kHostMacOS = 4,
kHostBeOS = 5
diff --git a/CPP/7zip/Archive/Rar/RarIn.cpp b/CPP/7zip/Archive/Rar/RarIn.cpp
index efb87fb7..18669405 100755
--- a/CPP/7zip/Archive/Rar/RarIn.cpp
+++ b/CPP/7zip/Archive/Rar/RarIn.cpp
@@ -9,9 +9,11 @@
#include "../../Common/LimitedStreams.h"
#include "../../Common/StreamUtils.h"
-extern "C"
-{
- #include "../../../../C/7zCrc.h"
+#include "../Common/FindSignature.h"
+
+extern "C"
+{
+ #include "../../../../C/7zCrc.h"
}
namespace NArchive {
@@ -23,17 +25,18 @@ void CInArchive::ThrowExceptionWithCode(
throw CInArchiveException(cause);
}
-bool CInArchive::Open(IInStream *inStream, const UInt64 *searchHeaderSizeLimit)
+HRESULT CInArchive::Open(IInStream *inStream, const UInt64 *searchHeaderSizeLimit)
{
- m_CryptoMode = false;
- if(inStream->Seek(0, STREAM_SEEK_CUR, &m_StreamStartPosition) != S_OK)
- return false;
- m_Position = m_StreamStartPosition;
- m_Stream = inStream;
- if (ReadMarkerAndArchiveHeader(searchHeaderSizeLimit))
- return true;
- m_Stream.Release();
- return false;
+ try
+ {
+ Close();
+ HRESULT res = Open2(inStream, searchHeaderSizeLimit);
+ if (res == S_OK)
+ return res;
+ Close();
+ return res;
+ }
+ catch(...) { Close(); throw; }
}
void CInArchive::Close()
@@ -50,56 +53,14 @@ static inline bool TestMarkerCandidate(const void *aTestBytes)
return true;
}
-bool CInArchive::FindAndReadMarker(const UInt64 *searchHeaderSizeLimit)
+HRESULT CInArchive::FindAndReadMarker(IInStream *stream, const UInt64 *searchHeaderSizeLimit)
{
- // if (m_Length < NHeader::kMarkerSize)
- // return false;
- m_ArchiveStartPosition = 0;
- m_Position = m_StreamStartPosition;
- if(m_Stream->Seek(m_StreamStartPosition, STREAM_SEEK_SET, NULL) != S_OK)
- return false;
-
- Byte marker[NHeader::kMarkerSize];
- UInt32 processedSize;
- ReadBytes(marker, NHeader::kMarkerSize, &processedSize);
- if(processedSize != NHeader::kMarkerSize)
- return false;
- if (TestMarkerCandidate(marker))
- return true;
-
- CByteDynamicBuffer dynamicBuffer;
- static const UInt32 kSearchMarkerBufferSize = 0x10000;
- dynamicBuffer.EnsureCapacity(kSearchMarkerBufferSize);
- Byte *buffer = dynamicBuffer;
- UInt32 numBytesPrev = NHeader::kMarkerSize - 1;
- memmove(buffer, marker + 1, numBytesPrev);
- UInt64 curTestPos = m_StreamStartPosition + 1;
- for (;;)
- {
- if (searchHeaderSizeLimit != NULL)
- if (curTestPos - m_StreamStartPosition > *searchHeaderSizeLimit)
- break;
- UInt32 numReadBytes = kSearchMarkerBufferSize - numBytesPrev;
- ReadBytes(buffer + numBytesPrev, numReadBytes, &processedSize);
- UInt32 numBytesInBuffer = numBytesPrev + processedSize;
- if (numBytesInBuffer < NHeader::kMarkerSize)
- break;
- UInt32 numTests = numBytesInBuffer - NHeader::kMarkerSize + 1;
- for(UInt32 pos = 0; pos < numTests; pos++, curTestPos++)
- {
- if (TestMarkerCandidate(buffer + pos))
- {
- m_ArchiveStartPosition = curTestPos;
- m_Position = curTestPos + NHeader::kMarkerSize;
- if(m_Stream->Seek(m_Position, STREAM_SEEK_SET, NULL) != S_OK)
- return false;
- return true;
- }
- }
- numBytesPrev = numBytesInBuffer - numTests;
- memmove(buffer, buffer + numTests, numBytesPrev);
- }
- return false;
+ RINOK(FindSignatureInStream(stream,
+ NHeader::kMarker, NHeader::kMarkerSize,
+ searchHeaderSizeLimit, m_ArchiveStartPosition));
+ m_Stream = stream;
+ m_Position = m_ArchiveStartPosition + NHeader::kMarkerSize;
+ return m_Stream->Seek(m_Position, STREAM_SEEK_SET, NULL);
}
void CInArchive::ThrowUnexpectedEndOfArchiveException()
@@ -154,18 +115,21 @@ static UInt32 CrcUpdateUInt32(UInt32 crc, UInt32 v)
}
-bool CInArchive::ReadMarkerAndArchiveHeader(const UInt64 *searchHeaderSizeLimit)
+HRESULT CInArchive::Open2(IInStream *stream, const UInt64 *searchHeaderSizeLimit)
{
- if (!FindAndReadMarker(searchHeaderSizeLimit))
- return false;
+ m_CryptoMode = false;
+ RINOK(stream->Seek(0, STREAM_SEEK_SET, &m_StreamStartPosition));
+ m_Position = m_StreamStartPosition;
+
+ RINOK(FindAndReadMarker(stream, searchHeaderSizeLimit));
Byte buf[NHeader::NArchive::kArchiveHeaderSize];
UInt32 processedSize;
ReadBytes(buf, sizeof(buf), &processedSize);
if (processedSize != sizeof(buf))
- return false;
+ return S_FALSE;
m_CurData = buf;
- m_CurPos = 0;
+ m_CurPos = 0;
m_PosLimit = sizeof(buf);
m_ArchiveHeader.CRC = ReadUInt16();
@@ -187,17 +151,17 @@ bool CInArchive::ReadMarkerAndArchiveHeader(const UInt64 *searchHeaderSizeLimit)
{
ReadBytes(&m_ArchiveHeader.EncryptVersion, 1, &processedSize);
if (processedSize != 1)
- return false;
+ return S_FALSE;
crc = CRC_UPDATE_BYTE(crc, m_ArchiveHeader.EncryptVersion);
}
if(m_ArchiveHeader.CRC != (CRC_GET_DIGEST(crc) & 0xFFFF))
ThrowExceptionWithCode(CInArchiveException::kArchiveHeaderCRCError);
if (m_ArchiveHeader.Type != NHeader::NBlockType::kArchiveHeader)
- return false;
+ return S_FALSE;
m_ArchiveCommentPosition = m_Position;
m_SeekOnArchiveComment = true;
- return true;
+ return S_OK;
}
void CInArchive::SkipArchiveComment()
@@ -216,7 +180,7 @@ void CInArchive::GetArchiveInfo(CInArchiveInfo &archiveInfo) const
archiveInfo.CommentSize = (UInt16)(m_ArchiveHeader.Size - NHeader::NArchive::kArchiveHeaderSize);
}
-static void DecodeUnicodeFileName(const char *name, const Byte *encName,
+static void DecodeUnicodeFileName(const char *name, const Byte *encName,
int encSize, wchar_t *unicodeName, int maxDecSize)
{
int encPos = 0;
@@ -249,7 +213,7 @@ static void DecodeUnicodeFileName(const char *name, const Byte *encName,
if (length & 0x80)
{
Byte correction = encName[encPos++];
- for (length = (length & 0x7f) + 2;
+ for (length = (length & 0x7f) + 2;
length > 0 && decPos < maxDecSize; length--, decPos++)
unicodeName[decPos] = (wchar_t)(((name[decPos] + correction) & 0xff) + (highByte << 8));
}
@@ -289,7 +253,7 @@ void CInArchive::ReadName(CItemEx &item, int nameSize)
{
int unicodeNameSizeMax = MyMin(nameSize, (0x400));
_unicodeNameBuffer.EnsureCapacity(unicodeNameSizeMax + 1);
- DecodeUnicodeFileName(buffer, (const Byte *)buffer + mainLen + 1,
+ DecodeUnicodeFileName(buffer, (const Byte *)buffer + mainLen + 1,
nameSize - (mainLen + 1), _unicodeNameBuffer, unicodeNameSizeMax);
item.UnicodeName = _unicodeNameBuffer;
}
@@ -341,26 +305,26 @@ void CInArchive::ReadTime(Byte mask, CRarTime &rarTime)
void CInArchive::ReadHeaderReal(CItemEx &item)
{
- item.Flags = m_BlockHeader.Flags;
+ item.Flags = m_BlockHeader.Flags;
item.PackSize = ReadUInt32();
- item.UnPackSize = ReadUInt32();
+ item.Size = ReadUInt32();
item.HostOS = ReadByte();
item.FileCRC = ReadUInt32();
- item.LastWriteTime.DosTime = ReadUInt32();
+ item.MTime.DosTime = ReadUInt32();
item.UnPackVersion = ReadByte();
item.Method = ReadByte();
int nameSize = ReadUInt16();
- item.Attributes = ReadUInt32();
+ item.Attrib = ReadUInt32();
- item.LastWriteTime.LowSecond = 0;
- item.LastWriteTime.SubTime[0] =
- item.LastWriteTime.SubTime[1] =
- item.LastWriteTime.SubTime[2] = 0;
+ item.MTime.LowSecond = 0;
+ item.MTime.SubTime[0] =
+ item.MTime.SubTime[1] =
+ item.MTime.SubTime[2] = 0;
if((item.Flags & NHeader::NFile::kSize64Bits) != 0)
{
item.PackSize |= ((UInt64)ReadUInt32() << 32);
- item.UnPackSize |= ((UInt64)ReadUInt32() << 32);
+ item.Size |= ((UInt64)ReadUInt32() << 32);
}
ReadName(item, nameSize);
@@ -377,18 +341,18 @@ void CInArchive::ReadHeaderReal(CItemEx &item)
Byte modifMask = (Byte)(b >> 4);
Byte createMask = (Byte)(b & 0xF);
if ((modifMask & 8) != 0)
- ReadTime(modifMask, item.LastWriteTime);
- item.IsCreationTimeDefined = ((createMask & 8) != 0);
- if (item.IsCreationTimeDefined)
+ ReadTime(modifMask, item.MTime);
+ item.CTimeDefined = ((createMask & 8) != 0);
+ if (item.CTimeDefined)
{
- item.CreationTime.DosTime = ReadUInt32();
- ReadTime(createMask, item.CreationTime);
+ item.CTime.DosTime = ReadUInt32();
+ ReadTime(createMask, item.CTime);
}
- item.IsLastAccessTimeDefined = ((accessMask & 8) != 0);
- if (item.IsLastAccessTimeDefined)
+ item.ATimeDefined = ((accessMask & 8) != 0);
+ if (item.ATimeDefined)
{
- item.LastAccessTime.DosTime = ReadUInt32();
- ReadTime(accessMask, item.LastAccessTime);
+ item.ATime.DosTime = ReadUInt32();
+ ReadTime(accessMask, item.ATime);
}
}
@@ -418,7 +382,7 @@ HRESULT CInArchive::GetNextItem(CItemEx &item, ICryptoGetTextPassword *getTextPa
{
if(!SeekInArchive(m_Position))
return S_FALSE;
- if (!m_CryptoMode && (m_ArchiveHeader.Flags &
+ if (!m_CryptoMode && (m_ArchiveHeader.Flags &
NHeader::NArchive::kBlockHeadersAreEncrypted) != 0)
{
m_CryptoMode = false;
@@ -487,23 +451,23 @@ HRESULT CInArchive::GetNextItem(CItemEx &item, ICryptoGetTextPassword *getTextPa
if (m_BlockHeader.HeadSize < 7)
ThrowExceptionWithCode(CInArchiveException::kIncorrectArchive);
- if (m_BlockHeader.Type == NHeader::NBlockType::kEndOfArchive)
+ if (m_BlockHeader.Type == NHeader::NBlockType::kEndOfArchive)
return S_FALSE;
- if (m_BlockHeader.Type == NHeader::NBlockType::kFileHeader)
+ if (m_BlockHeader.Type == NHeader::NBlockType::kFileHeader)
{
m_FileHeaderData.EnsureCapacity(m_BlockHeader.HeadSize);
m_CurData = (Byte *)m_FileHeaderData;
m_PosLimit = m_BlockHeader.HeadSize;
ReadBytesAndTestResult(m_CurData + m_CurPos, m_BlockHeader.HeadSize - 7);
- ReadHeaderReal(item);
- if ((CrcCalc(m_CurData + 2,
+ ReadHeaderReal(item);
+ if ((CrcCalc(m_CurData + 2,
m_BlockHeader.HeadSize - item.CommentSize - 2) & 0xFFFF) != m_BlockHeader.CRC)
ThrowExceptionWithCode(CInArchiveException::kFileHeaderCRCError);
FinishCryptoBlock();
m_CryptoMode = false;
- SeekInArchive(m_Position); // Move Position to compressed Data;
+ SeekInArchive(m_Position); // Move Position to compressed Data;
AddToSeekValue(item.PackSize); // m_Position points to next header;
return S_OK;
}
diff --git a/CPP/7zip/Archive/Rar/RarIn.h b/CPP/7zip/Archive/Rar/RarIn.h
index 94cea223..7be3f53c 100755
--- a/CPP/7zip/Archive/Rar/RarIn.h
+++ b/CPP/7zip/Archive/Rar/RarIn.h
@@ -24,7 +24,7 @@ public:
kArchiveHeaderCRCError,
kFileHeaderCRCError,
kIncorrectArchive
- }
+ }
Cause;
CInArchiveException(CCauseType cause) : Cause(cause) {}
};
@@ -64,7 +64,9 @@ class CInArchive
bool ReadBytesAndTestSize(void *data, UInt32 size);
void ReadBytesAndTestResult(void *data, UInt32 size);
- bool FindAndReadMarker(const UInt64 *searchHeaderSizeLimit);
+ HRESULT FindAndReadMarker(IInStream *stream, const UInt64 *searchHeaderSizeLimit);
+ HRESULT Open2(IInStream *stream, const UInt64 *searchHeaderSizeLimit);
+
void ThrowExceptionWithCode(CInArchiveException::CCauseType cause);
void ThrowUnexpectedEndOfArchiveException();
@@ -102,9 +104,8 @@ protected:
}
}
- bool ReadMarkerAndArchiveHeader(const UInt64 *searchHeaderSizeLimit);
public:
- bool Open(IInStream *inStream, const UInt64 *searchHeaderSizeLimit);
+ HRESULT Open(IInStream *inStream, const UInt64 *searchHeaderSizeLimit);
void Close();
HRESULT GetNextItem(CItemEx &item, ICryptoGetTextPassword *getTextPassword);
diff --git a/CPP/7zip/Archive/Rar/RarItem.cpp b/CPP/7zip/Archive/Rar/RarItem.cpp
index 61a72557..9216ae57 100755
--- a/CPP/7zip/Archive/Rar/RarItem.cpp
+++ b/CPP/7zip/Archive/Rar/RarItem.cpp
@@ -3,47 +3,24 @@
#include "StdAfx.h"
#include "RarItem.h"
-#include "RarHeader.h"
namespace NArchive{
namespace NRar{
-bool CItem::IsEncrypted() const
- { return (Flags & NHeader::NFile::kEncrypted) != 0; }
-bool CItem::IsSolid() const
- { return (Flags & NHeader::NFile::kSolid) != 0; }
-bool CItem::IsCommented() const
- { return (Flags & NHeader::NFile::kComment) != 0; }
-bool CItem::IsSplitBefore() const
- { return (Flags & NHeader::NFile::kSplitBefore) != 0; }
-bool CItem::IsSplitAfter() const
- { return (Flags & NHeader::NFile::kSplitAfter) != 0; }
-bool CItem::HasSalt() const
- { return (Flags & NHeader::NFile::kSalt) != 0; }
-bool CItem::HasExtTime() const
- { return (Flags & NHeader::NFile::kExtTime) != 0; }
-bool CItem::HasUnicodeName() const
- { return (Flags & NHeader::NFile::kUnicodeName) != 0; }
-bool CItem::IsOldVersion() const
- { return (Flags & NHeader::NFile::kOldVersion) != 0; }
-
bool CItem::IgnoreItem() const
-{
+{
switch(HostOS)
{
- case NHeader::NFile::kHostMSDOS:
- case NHeader::NFile::kHostOS2:
- case NHeader::NFile::kHostWin32:
- return ((Attributes & NHeader::NFile::kLabelFileAttribute) != 0);
+ case NHeader::NFile::kHostMSDOS:
+ case NHeader::NFile::kHostOS2:
+ case NHeader::NFile::kHostWin32:
+ return ((Attrib & NHeader::NFile::kLabelFileAttribute) != 0);
}
return false;
}
-UInt32 CItem::GetDictSize() const
-{ return (Flags >> NHeader::NFile::kDictBitStart) & NHeader::NFile::kDictMask; }
-
-bool CItem::IsDirectory() const
-{
+bool CItem::IsDir() const
+{
if (GetDictSize() == NHeader::NFile::kDictDirectoryValue)
return true;
switch(HostOS)
@@ -51,7 +28,7 @@ bool CItem::IsDirectory() const
case NHeader::NFile::kHostMSDOS:
case NHeader::NFile::kHostOS2:
case NHeader::NFile::kHostWin32:
- if ((Attributes & FILE_ATTRIBUTE_DIRECTORY) != 0)
+ if ((Attrib & FILE_ATTRIBUTE_DIRECTORY) != 0)
return true;
}
return false;
@@ -62,57 +39,17 @@ UInt32 CItem::GetWinAttributes() const
UInt32 winAttributes;
switch(HostOS)
{
- case NHeader::NFile::kHostMSDOS:
- case NHeader::NFile::kHostOS2:
- case NHeader::NFile::kHostWin32:
- winAttributes = Attributes;
- break;
- default:
- winAttributes = 0; // must be converted from unix value;;
+ case NHeader::NFile::kHostMSDOS:
+ case NHeader::NFile::kHostOS2:
+ case NHeader::NFile::kHostWin32:
+ winAttributes = Attrib;
+ break;
+ default:
+ winAttributes = 0; // must be converted from unix value;
}
- if (IsDirectory()) // test it;
+ if (IsDir())
winAttributes |= NHeader::NFile::kWinFileDirectoryAttributeMask;
return winAttributes;
}
-void CItem::ClearFlags()
-{ Flags = 0; }
-
-void CItem::SetFlagBits(int startBitNumber, int numBits, int value)
-{
- UInt16 mask = (UInt16)(((1 << numBits) - 1) << startBitNumber);
- Flags &= ~mask;
- Flags |= value << startBitNumber;
-}
-
-void CItem::SetBitMask(int bitMask, bool enable)
-{
- if(enable)
- Flags |= bitMask;
- else
- Flags &= ~bitMask;
-}
-
-void CItem::SetDictSize(UInt32 size)
-{
- SetFlagBits(NHeader::NFile::kDictBitStart, NHeader::NFile::kNumDictBits, (size & NHeader::NFile::kDictMask));
-}
-
-void CItem::SetAsDirectory(bool directory)
-{
- if (directory)
- SetDictSize(NHeader::NFile::kDictDirectoryValue);
-}
-
-void CItem::SetEncrypted(bool encrypted)
- { SetBitMask(NHeader::NFile::kEncrypted, encrypted); }
-void CItem::SetSolid(bool solid)
- { SetBitMask(NHeader::NFile::kSolid, solid); }
-void CItem::SetCommented(bool commented)
- { SetBitMask(NHeader::NFile::kComment, commented); }
-void CItem::SetSplitBefore(bool splitBefore)
- { SetBitMask(NHeader::NFile::kSplitBefore, splitBefore); }
-void CItem::SetSplitAfter(bool splitAfter)
- { SetBitMask(NHeader::NFile::kSplitAfter, splitAfter); }
-
}}
diff --git a/CPP/7zip/Archive/Rar/RarItem.h b/CPP/7zip/Archive/Rar/RarItem.h
index 5ab8a46e..4aa4d866 100755
--- a/CPP/7zip/Archive/Rar/RarItem.h
+++ b/CPP/7zip/Archive/Rar/RarItem.h
@@ -6,6 +6,8 @@
#include "Common/Types.h"
#include "Common/MyString.h"
+#include "RarHeader.h"
+
namespace NArchive{
namespace NRar{
@@ -16,59 +18,47 @@ struct CRarTime
Byte SubTime[3];
};
-class CItem
+struct CItem
{
-public:
- UInt16 Flags;
+ UInt64 Size;
UInt64 PackSize;
- UInt64 UnPackSize;
- Byte HostOS;
- UInt32 FileCRC;
- CRarTime CreationTime;
- CRarTime LastWriteTime;
- CRarTime LastAccessTime;
- bool IsCreationTimeDefined;
- // bool IsLastWriteTimeDefined;
- bool IsLastAccessTimeDefined;
+ CRarTime CTime;
+ CRarTime ATime;
+ CRarTime MTime;
+
+ UInt32 FileCRC;
+ UInt32 Attrib;
+ UInt16 Flags;
+ Byte HostOS;
Byte UnPackVersion;
Byte Method;
- UInt32 Attributes;
+
+ bool CTimeDefined;
+ bool ATimeDefined;
+
AString Name;
UString UnicodeName;
Byte Salt[8];
- bool IsEncrypted() const;
- bool IsSolid() const;
- bool IsCommented() const;
- bool IsSplitBefore() const;
- bool IsSplitAfter() const;
- bool HasSalt() const;
- bool HasExtTime() const;
-
- bool HasUnicodeName() const;
- bool IsOldVersion() const;
+ bool IsEncrypted() const { return (Flags & NHeader::NFile::kEncrypted) != 0; }
+ bool IsSolid() const { return (Flags & NHeader::NFile::kSolid) != 0; }
+ bool IsCommented() const { return (Flags & NHeader::NFile::kComment) != 0; }
+ bool IsSplitBefore() const { return (Flags & NHeader::NFile::kSplitBefore) != 0; }
+ bool IsSplitAfter() const { return (Flags & NHeader::NFile::kSplitAfter) != 0; }
+ bool HasSalt() const { return (Flags & NHeader::NFile::kSalt) != 0; }
+ bool HasExtTime() const { return (Flags & NHeader::NFile::kExtTime) != 0; }
+ bool HasUnicodeName()const { return (Flags & NHeader::NFile::kUnicodeName) != 0; }
+ bool IsOldVersion() const { return (Flags & NHeader::NFile::kOldVersion) != 0; }
- UInt32 GetDictSize() const;
- bool IsDirectory() const;
+ UInt32 GetDictSize() const { return (Flags >> NHeader::NFile::kDictBitStart) & NHeader::NFile::kDictMask; }
+ bool IsDir() const;
bool IgnoreItem() const;
UInt32 GetWinAttributes() const;
- CItem(): IsCreationTimeDefined(false), IsLastAccessTimeDefined(false) {}
-private:
- void SetFlagBits(int startBitNumber, int numBits, int value);
- void SetBitMask(int bitMask, bool enable);
-public:
- void ClearFlags();
- void SetDictSize(UInt32 size);
- void SetAsDirectory(bool directory);
- void SetEncrypted(bool encrypted);
- void SetSolid(bool solid);
- void SetCommented(bool commented);
- void SetSplitBefore(bool splitBefore);
- void SetSplitAfter(bool splitAfter);
+ CItem(): CTimeDefined(false), ATimeDefined(false) {}
};
class CItemEx: public CItem
@@ -87,5 +77,3 @@ public:
}}
#endif
-
-
diff --git a/CPP/7zip/Archive/Rar/RarVolumeInStream.cpp b/CPP/7zip/Archive/Rar/RarVolumeInStream.cpp
index aeb52ecc..1845e20a 100755
--- a/CPP/7zip/Archive/Rar/RarVolumeInStream.cpp
+++ b/CPP/7zip/Archive/Rar/RarVolumeInStream.cpp
@@ -7,16 +7,16 @@
#include "Windows/Defs.h"
#include "Common/Defs.h"
-extern "C"
-{
- #include "../../../../C/7zCrc.h"
+extern "C"
+{
+ #include "../../../../C/7zCrc.h"
}
namespace NArchive {
namespace NRar {
void CFolderInStream::Init(
- CObjectVector<CInArchive> *archives,
+ CObjectVector<CInArchive> *archives,
const CObjectVector<CItemEx> *items,
const CRefItem &refItem)
{
diff --git a/CPP/7zip/Archive/Rar/RarVolumeInStream.h b/CPP/7zip/Archive/Rar/RarVolumeInStream.h
index 7c5902b5..78d95b10 100755
--- a/CPP/7zip/Archive/Rar/RarVolumeInStream.h
+++ b/CPP/7zip/Archive/Rar/RarVolumeInStream.h
@@ -16,7 +16,7 @@ struct CRefItem
int NumItems;
};
-class CFolderInStream:
+class CFolderInStream:
public ISequentialInStream,
public CMyUnknownImp
{
@@ -37,7 +37,7 @@ private:
HRESULT OpenStream();
HRESULT CloseStream();
public:
- void Init(CObjectVector<CInArchive> *archives,
+ void Init(CObjectVector<CInArchive> *archives,
const CObjectVector<CItemEx> *items,
const CRefItem &refItem);
diff --git a/CPP/7zip/Archive/RpmHandler.cpp b/CPP/7zip/Archive/RpmHandler.cpp
new file mode 100755
index 00000000..f39ee3c5
--- /dev/null
+++ b/CPP/7zip/Archive/RpmHandler.cpp
@@ -0,0 +1,303 @@
+// RpmHandler.cpp
+
+#include "StdAfx.h"
+
+#include "../../../C/CpuArch.h"
+
+#include "Common/ComTry.h"
+#include "Common/MyString.h"
+
+#include "Windows/PropVariant.h"
+
+#include "../Common/ProgressUtils.h"
+#include "../Common/RegisterArc.h"
+#include "../Common/StreamUtils.h"
+
+#include "../Compress/Copy/CopyCoder.h"
+
+using namespace NWindows;
+
+#define Get16(p) GetBe16(p)
+#define Get32(p) GetBe32(p)
+
+namespace NArchive {
+namespace NRpm {
+
+/* Reference: lib/signature.h of rpm package */
+#define RPMSIG_NONE 0 /* Do not change! */
+/* The following types are no longer generated */
+#define RPMSIG_PGP262_1024 1 /* No longer generated */ /* 256 byte */
+/* These are the new-style signatures. They are Header structures. */
+/* Inside them we can put any number of any type of signature we like. */
+
+#define RPMSIG_HEADERSIG 5 /* New Header style signature */
+
+const UInt32 kLeadSize = 96;
+struct CLead
+{
+ unsigned char Magic[4];
+ unsigned char Major; // not supported ver1, only support 2,3 and lator
+ unsigned char Minor;
+ UInt16 Type;
+ UInt16 ArchNum;
+ char Name[66];
+ UInt16 OSNum;
+ UInt16 SignatureType;
+ char Reserved[16]; // pad to 96 bytes -- 8 byte aligned
+ bool MagicCheck() const
+ { return Magic[0] == 0xed && Magic[1] == 0xab && Magic[2] == 0xee && Magic[3] == 0xdb; };
+};
+
+const UInt32 kEntryInfoSize = 16;
+/*
+struct CEntryInfo
+{
+ int Tag;
+ int Type;
+ int Offset; // Offset from beginning of data segment, only defined on disk
+ int Count;
+};
+*/
+
+// case: SignatureType == RPMSIG_HEADERSIG
+const UInt32 kCSigHeaderSigSize = 16;
+struct CSigHeaderSig
+{
+ unsigned char Magic[4];
+ UInt32 Reserved;
+ UInt32 IndexLen; // count of index entries
+ UInt32 DataLen; // number of bytes
+ bool MagicCheck()
+ { return Magic[0] == 0x8e && Magic[1] == 0xad && Magic[2] == 0xe8 && Magic[3] == 0x01; };
+ UInt32 GetLostHeaderLen()
+ { return IndexLen * kEntryInfoSize + DataLen; };
+};
+
+static HRESULT RedSigHeaderSig(IInStream *inStream, CSigHeaderSig &h)
+{
+ char dat[kCSigHeaderSigSize];
+ char *cur = dat;
+ RINOK(ReadStream_FALSE(inStream, dat, kCSigHeaderSigSize));
+ memmove(h.Magic, cur, 4);
+ cur += 4;
+ cur += 4;
+ h.IndexLen = Get32(cur);
+ cur += 4;
+ h.DataLen = Get32(cur);
+ return S_OK;
+}
+
+HRESULT OpenArchive(IInStream *inStream)
+{
+ UInt64 pos;
+ char leadData[kLeadSize];
+ char *cur = leadData;
+ CLead lead;
+ RINOK(ReadStream_FALSE(inStream, leadData, kLeadSize));
+ memmove(lead.Magic, cur, 4);
+ cur += 4;
+ lead.Major = *cur++;
+ lead.Minor = *cur++;
+ lead.Type = Get16(cur);
+ cur += 2;
+ lead.ArchNum = Get16(cur);
+ cur += 2;
+ memmove(lead.Name, cur, sizeof(lead.Name));
+ cur += sizeof(lead.Name);
+ lead.OSNum = Get16(cur);
+ cur += 2;
+ lead.SignatureType = Get16(cur);
+ cur += 2;
+
+ if (!lead.MagicCheck() || lead.Major < 3)
+ return S_FALSE;
+
+ CSigHeaderSig sigHeader, header;
+ if(lead.SignatureType == RPMSIG_NONE)
+ {
+ ;
+ }
+ else if(lead.SignatureType == RPMSIG_PGP262_1024)
+ {
+ UInt64 pos;
+ RINOK(inStream->Seek(256, STREAM_SEEK_CUR, &pos));
+ }
+ else if(lead.SignatureType == RPMSIG_HEADERSIG)
+ {
+ RINOK(RedSigHeaderSig(inStream, sigHeader));
+ if(!sigHeader.MagicCheck())
+ return S_FALSE;
+ UInt32 len = sigHeader.GetLostHeaderLen();
+ RINOK(inStream->Seek(len, STREAM_SEEK_CUR, &pos));
+ if((pos % 8) != 0)
+ {
+ RINOK(inStream->Seek((pos / 8 + 1) * 8 - pos,
+ STREAM_SEEK_CUR, &pos));
+ }
+ }
+ else
+ return S_FALSE;
+
+ RINOK(RedSigHeaderSig(inStream, header));
+ if(!header.MagicCheck())
+ return S_FALSE;
+ int headerLen = header.GetLostHeaderLen();
+ if(headerLen == -1)
+ return S_FALSE;
+ RINOK(inStream->Seek(headerLen, STREAM_SEEK_CUR, &pos));
+ return S_OK;
+}
+
+class CHandler:
+ public IInArchive,
+ public CMyUnknownImp
+{
+public:
+ MY_UNKNOWN_IMP1(IInArchive)
+
+ INTERFACE_IInArchive(;)
+
+private:
+ CMyComPtr<IInStream> m_InStream;
+ UInt64 m_Pos;
+ UInt64 m_Size;
+ Byte _sig[4];
+};
+
+STATPROPSTG kProps[] =
+{
+ { NULL, kpidSize, VT_UI8},
+ { NULL, kpidPackSize, VT_UI8}
+};
+
+IMP_IInArchive_Props
+IMP_IInArchive_ArcProps_NO
+
+STDMETHODIMP CHandler::Open(IInStream *inStream,
+ const UInt64 * /* maxCheckStartPosition */,
+ IArchiveOpenCallback * /* openArchiveCallback */)
+{
+ COM_TRY_BEGIN
+ try
+ {
+ if(OpenArchive(inStream) != S_OK)
+ return S_FALSE;
+ RINOK(inStream->Seek(0, STREAM_SEEK_CUR, &m_Pos));
+ UInt64 endPosition;
+ RINOK(inStream->Seek(0, STREAM_SEEK_END, &endPosition));
+ m_Size = endPosition - m_Pos;
+
+ RINOK(inStream->Seek(m_Pos, STREAM_SEEK_SET, NULL));
+ RINOK(ReadStream_FALSE(inStream, _sig, sizeof(_sig) / sizeof(_sig[0])));
+
+ m_InStream = inStream;
+ return S_OK;
+ }
+ catch(...)
+ {
+ return S_FALSE;
+ }
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Close()
+{
+ m_InStream.Release();
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
+{
+ *numItems = 1;
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetProperty(UInt32 /* index */, PROPID propID, PROPVARIANT *value)
+{
+ NWindows::NCOM::CPropVariant prop;
+ switch(propID)
+ {
+ case kpidSize:
+ case kpidPackSize:
+ prop = m_Size;
+ break;
+ case kpidExtension:
+ {
+ wchar_t s[32];
+ MyStringCopy(s, L"cpio.");
+ const wchar_t *ext;
+ if (_sig[0] == 0x1F && _sig[1] == 0x8B)
+ ext = L"gz";
+ else if (_sig[0] == 'B' && _sig[1] == 'Z' && _sig[2] == 'h')
+ ext = L"bz2";
+ else
+ ext = L"lzma";
+ MyStringCopy(s + MyStringLen(s), ext);
+ prop = s;
+ break;
+ }
+ }
+ prop.Detach(value);
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
+ Int32 _aTestMode, IArchiveExtractCallback *extractCallback)
+{
+ COM_TRY_BEGIN
+ bool allFilesMode = (numItems == UInt32(-1));
+ if (allFilesMode)
+ numItems = 1;
+ if(numItems == 0)
+ return S_OK;
+ if(numItems != 1)
+ return E_FAIL;
+ if (indices[0] != 0)
+ return E_FAIL;
+
+ bool testMode = (_aTestMode != 0);
+
+ UInt64 currentTotalSize = 0;
+ RINOK(extractCallback->SetTotal(m_Size));
+ RINOK(extractCallback->SetCompleted(&currentTotalSize));
+ CMyComPtr<ISequentialOutStream> realOutStream;
+ Int32 askMode = testMode ?
+ NArchive::NExtract::NAskMode::kTest :
+ NArchive::NExtract::NAskMode::kExtract;
+ Int32 index = 0;
+
+ RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
+
+ if(!testMode && (!realOutStream))
+ return S_OK;
+
+ RINOK(extractCallback->PrepareOperation(askMode));
+
+ if (testMode)
+ {
+ RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK));
+ return S_OK;
+ }
+
+ RINOK(m_InStream->Seek(m_Pos, STREAM_SEEK_SET, NULL));
+
+ CMyComPtr<ICompressCoder> copyCoder = new NCompress::CCopyCoder;
+
+ CLocalProgress *lps = new CLocalProgress;
+ CMyComPtr<ICompressProgressInfo> progress = lps;
+ lps->Init(extractCallback, false);
+
+ RINOK(copyCoder->Code(m_InStream, realOutStream, NULL, NULL, progress));
+ realOutStream.Release();
+ return extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK);
+ COM_TRY_END
+}
+
+static IInArchive *CreateArc() { return new NArchive::NRpm::CHandler; }
+
+static CArcInfo g_ArcInfo =
+ { L"Rpm", L"rpm", 0, 0xEB, { 0}, 0, false, CreateArc, 0 };
+
+REGISTER_ARC(Rpm)
+
+}}
diff --git a/CPP/7zip/Archive/Split/SplitHandler.cpp b/CPP/7zip/Archive/Split/SplitHandler.cpp
index 0cd31639..380e6ce3 100755
--- a/CPP/7zip/Archive/Split/SplitHandler.cpp
+++ b/CPP/7zip/Archive/Split/SplitHandler.cpp
@@ -23,12 +23,11 @@ using namespace NTime;
namespace NArchive {
namespace NSplit {
-STATPROPSTG kProps[] =
+STATPROPSTG kProps[] =
{
{ NULL, kpidPath, VT_BSTR},
-// { NULL, kpidIsFolder, VT_BOOL},
{ NULL, kpidSize, VT_UI8},
- { NULL, kpidPackedSize, VT_UI8},
+ { NULL, kpidPackSize, VT_UI8},
};
IMP_IInArchive_Props
@@ -38,11 +37,11 @@ class CSeqName
{
public:
UString _unchangedPart;
- UString _changedPart;
+ UString _changedPart;
bool _splitStyle;
UString GetNextName()
{
- UString newName;
+ UString newName;
if (_splitStyle)
{
int i;
@@ -108,7 +107,7 @@ public:
}
};
-STDMETHODIMP CHandler::Open(IInStream *stream,
+STDMETHODIMP CHandler::Open(IInStream *stream,
const UInt64 * /* maxCheckStartPosition */,
IArchiveOpenCallback *openArchiveCallback)
{
@@ -120,7 +119,7 @@ STDMETHODIMP CHandler::Open(IInStream *stream,
{
CMyComPtr<IArchiveOpenVolumeCallback> openVolumeCallback;
CMyComPtr<IArchiveOpenCallback> openArchiveCallbackWrap = openArchiveCallback;
- if (openArchiveCallbackWrap.QueryInterface(IID_IArchiveOpenVolumeCallback,
+ if (openArchiveCallbackWrap.QueryInterface(IID_IArchiveOpenVolumeCallback,
&openVolumeCallback) != S_OK)
return S_FALSE;
@@ -169,7 +168,7 @@ STDMETHODIMP CHandler::Open(IInStream *stream,
if (numLetters != ext.Length())
return S_FALSE;
}
- else
+ else
return S_FALSE;
_streams.Add(stream);
@@ -197,7 +196,6 @@ STDMETHODIMP CHandler::Open(IInStream *stream,
if (openArchiveCallback != NULL)
{
- RINOK(openArchiveCallback->SetTotal(NULL, NULL));
UInt64 numFiles = _streams.Size();
RINOK(openArchiveCallback->SetCompleted(&numFiles, NULL));
}
@@ -261,11 +259,8 @@ STDMETHODIMP CHandler::GetProperty(UInt32 /* index */, PROPID propID, PROPVARIAN
case kpidPath:
prop = _subName;
break;
- case kpidIsFolder:
- prop = false;
- break;
case kpidSize:
- case kpidPackedSize:
+ case kpidPackSize:
prop = _totalSize;
break;
}
diff --git a/CPP/7zip/Archive/Split/SplitHandler.h b/CPP/7zip/Archive/Split/SplitHandler.h
index 79e63353..9e020763 100755
--- a/CPP/7zip/Archive/Split/SplitHandler.h
+++ b/CPP/7zip/Archive/Split/SplitHandler.h
@@ -10,10 +10,10 @@
namespace NArchive {
namespace NSplit {
-class CHandler:
+class CHandler:
public IInArchive,
public IInArchiveGetStream,
- // public IOutArchive,
+ // public IOutArchive,
public CMyUnknownImp
{
public:
@@ -21,7 +21,7 @@ public:
INTERFACE_IInArchive(;)
- STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **stream);
+ STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **stream);
private:
UString _subName;
diff --git a/CPP/7zip/Archive/Split/SplitHandlerOut.cpp b/CPP/7zip/Archive/Split/SplitHandlerOut.cpp
index 26e19669..6edf86f4 100755
--- a/CPP/7zip/Archive/Split/SplitHandlerOut.cpp
+++ b/CPP/7zip/Archive/Split/SplitHandlerOut.cpp
@@ -30,7 +30,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
UInt64 volumeSize = 0;
CMyComPtr<IArchiveUpdateCallback2> callback2;
- updateCallback->QueryInterface(IID_IArchiveUpdateCallback2,
+ updateCallback->QueryInterface(IID_IArchiveUpdateCallback2,
(void **)&callback2);
RINOK(callback2->GetVolumeSize(0, &volumeSize));
diff --git a/CPP/7zip/Archive/Split/StdAfx.cpp b/CPP/7zip/Archive/Split/StdAfx.cpp
deleted file mode 100755
index d0feea85..00000000
--- a/CPP/7zip/Archive/Split/StdAfx.cpp
+++ /dev/null
@@ -1,3 +0,0 @@
-// StdAfx.cpp
-
-#include "StdAfx.h"
diff --git a/CPP/7zip/Archive/StdAfx.h b/CPP/7zip/Archive/StdAfx.h
index 99a8aa46..ef555ec1 100755
--- a/CPP/7zip/Archive/StdAfx.h
+++ b/CPP/7zip/Archive/StdAfx.h
@@ -4,5 +4,6 @@
#define __STDAFX_H
#include "../../Common/MyWindows.h"
+#include "../../Common/NewHandler.h"
#endif
diff --git a/CPP/7zip/Archive/Tar/StdAfx.cpp b/CPP/7zip/Archive/Tar/StdAfx.cpp
deleted file mode 100755
index d0feea85..00000000
--- a/CPP/7zip/Archive/Tar/StdAfx.cpp
+++ /dev/null
@@ -1,3 +0,0 @@
-// StdAfx.cpp
-
-#include "StdAfx.h"
diff --git a/CPP/7zip/Archive/Tar/TarHandler.cpp b/CPP/7zip/Archive/Tar/TarHandler.cpp
index 33866d61..f70f7e4e 100755
--- a/CPP/7zip/Archive/Tar/TarHandler.cpp
+++ b/CPP/7zip/Archive/Tar/TarHandler.cpp
@@ -15,104 +15,99 @@
#include "../../Common/ProgressUtils.h"
#include "../../Common/LimitedStreams.h"
+#include "../Common/DummyOutStream.h"
#include "../../Compress/Copy/CopyCoder.h"
#include "../Common/ItemNameUtils.h"
using namespace NWindows;
-using namespace NTime;
namespace NArchive {
namespace NTar {
-STATPROPSTG kProps[] =
+STATPROPSTG kProps[] =
{
{ NULL, kpidPath, VT_BSTR},
- { NULL, kpidIsFolder, VT_BOOL},
+ { NULL, kpidIsDir, VT_BOOL},
{ NULL, kpidSize, VT_UI8},
- { NULL, kpidPackedSize, VT_UI8},
- { NULL, kpidLastWriteTime, VT_FILETIME},
+ { NULL, kpidPackSize, VT_UI8},
+ { NULL, kpidMTime, VT_FILETIME},
{ NULL, kpidUser, VT_BSTR},
- { NULL, kpidGroup, VT_BSTR},
+ { NULL, kpidGroup, VT_BSTR}
};
-
-
-
-
-
-
-
-
IMP_IInArchive_Props
IMP_IInArchive_ArcProps_NO
-STDMETHODIMP CHandler::Open(IInStream *stream,
- const UInt64 * /* maxCheckStartPosition */,
- IArchiveOpenCallback *openArchiveCallback)
+HRESULT CHandler::Open2(IInStream *stream, IArchiveOpenCallback *callback)
{
- COM_TRY_BEGIN
- // try
+ UInt64 endPos = 0;
+ if (callback != NULL)
{
- CInArchive archive;
-
- if (archive.Open(stream) != S_OK)
+ RINOK(stream->Seek(0, STREAM_SEEK_END, &endPos));
+ RINOK(stream->Seek(0, STREAM_SEEK_SET, NULL));
+ }
+
+ UInt64 pos = 0;
+ for (;;)
+ {
+ CItemEx item;
+ bool filled;
+ item.HeaderPosition = pos;
+ RINOK(ReadItem(stream, filled, item));
+ if (!filled)
+ break;
+ _items.Add(item);
+
+ RINOK(stream->Seek(item.GetPackSize(), STREAM_SEEK_CUR, &pos));
+ if (pos >= endPos)
return S_FALSE;
-
- _items.Clear();
-
- if (openArchiveCallback != NULL)
+ if (callback != NULL)
{
- RINOK(openArchiveCallback->SetTotal(NULL, NULL));
- UInt64 numFiles = _items.Size();
- RINOK(openArchiveCallback->SetCompleted(&numFiles, NULL));
- }
-
- for (;;)
- {
- CItemEx item;
- bool filled;
- HRESULT result = archive.GetNextItem(filled, item);
- if (result == S_FALSE)
- return S_FALSE;
- if (result != S_OK)
- return S_FALSE;
- if (!filled)
- break;
- _items.Add(item);
- archive.SkeepDataRecords(item.Size);
- if (openArchiveCallback != NULL)
+ if (_items.Size() == 1)
+ {
+ RINOK(callback->SetTotal(NULL, &endPos));
+ }
+ if (_items.Size() % 100 == 0)
{
UInt64 numFiles = _items.Size();
- RINOK(openArchiveCallback->SetCompleted(&numFiles, NULL));
+ RINOK(callback->SetCompleted(&numFiles, &pos));
}
}
- if (_items.Size() == 0)
- {
- CMyComPtr<IArchiveOpenVolumeCallback> openVolumeCallback;
- if (!openArchiveCallback)
- return S_FALSE;
- openArchiveCallback->QueryInterface(IID_IArchiveOpenVolumeCallback, (void **)&openVolumeCallback);
- if (!openVolumeCallback)
- return S_FALSE;
- NCOM::CPropVariant prop;
- RINOK(openVolumeCallback->GetProperty(kpidName, &prop));
- if (prop.vt != VT_BSTR)
- return S_FALSE;
- UString baseName = prop.bstrVal;
- baseName = baseName.Right(4);
- if (baseName.CompareNoCase(L".tar") != 0)
- return S_FALSE;
- }
- _inStream = stream;
}
- /*
- catch(...)
+
+ if (_items.Size() == 0)
+ {
+ CMyComPtr<IArchiveOpenVolumeCallback> openVolumeCallback;
+ if (!callback)
+ return S_FALSE;
+ callback->QueryInterface(IID_IArchiveOpenVolumeCallback, (void **)&openVolumeCallback);
+ if (!openVolumeCallback)
+ return S_FALSE;
+ NCOM::CPropVariant prop;
+ if (openVolumeCallback->GetProperty(kpidName, &prop) != S_OK)
+ return S_FALSE;
+ if (prop.vt != VT_BSTR)
+ return S_FALSE;
+ UString baseName = prop.bstrVal;
+ baseName = baseName.Right(4);
+ if (baseName.CompareNoCase(L".tar") != 0)
+ return S_FALSE;
+ }
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Open(IInStream *stream,
+ const UInt64 * /* maxCheckStartPosition */,
+ IArchiveOpenCallback *openArchiveCallback)
+{
+ COM_TRY_BEGIN
{
- return S_FALSE;
+ Close();
+ RINOK(Open2(stream, openArchiveCallback));
+ _inStream = stream;
}
- */
return S_OK;
COM_TRY_END
}
@@ -138,38 +133,20 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
switch(propID)
{
- case kpidPath:
- prop = (const wchar_t *)NItemName::GetOSName2(
- MultiByteToUnicodeString(item.Name, CP_OEMCP));
- break;
- case kpidIsFolder:
- prop = item.IsDirectory();
- break;
- case kpidSize:
- case kpidPackedSize:
- prop = (UInt64)item.Size;
- break;
- case kpidLastWriteTime:
- {
- FILETIME utcFileTime;
- if (item.ModificationTime != 0)
- NTime::UnixTimeToFileTime(item.ModificationTime, utcFileTime);
- else
+ case kpidPath: prop = NItemName::GetOSName2(MultiByteToUnicodeString(item.Name, CP_OEMCP)); break;
+ case kpidIsDir: prop = item.IsDir(); break;
+ case kpidSize: prop = item.Size; break;
+ case kpidPackSize: prop = item.GetPackSize(); break;
+ case kpidMTime:
+ if (item.MTime != 0)
{
- utcFileTime.dwLowDateTime = 0;
- utcFileTime.dwHighDateTime = 0;
+ FILETIME ft;
+ NTime::UnixTimeToFileTime(item.MTime, ft);
+ prop = ft;
}
- prop = utcFileTime;
- break;
- }
- case kpidUser:
- prop = (const wchar_t *)
- MultiByteToUnicodeString(item.UserName, CP_OEMCP);
- break;
- case kpidGroup:
- prop = (const wchar_t *)
- MultiByteToUnicodeString(item.GroupName, CP_OEMCP);
break;
+ case kpidUser: prop = MultiByteToUnicodeString(item.UserName, CP_OEMCP); break;
+ case kpidGroup: prop = MultiByteToUnicodeString(item.GroupName, CP_OEMCP); break;
}
prop.Detach(value);
return S_OK;
@@ -192,8 +169,8 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
totalSize += _items[allFilesMode ? i : indices[i]].Size;
extractCallback->SetTotal(totalSize);
- UInt64 currentTotalSize = 0;
- UInt64 currentItemSize;
+ UInt64 totalPackSize, curPackSize, curSize;
+ totalSize = totalPackSize = 0;
NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder();
CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;
@@ -206,19 +183,24 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
CMyComPtr<ISequentialInStream> inStream(streamSpec);
streamSpec->SetStream(_inStream);
- for (i = 0; i < numItems; i++, currentTotalSize += currentItemSize)
+ CDummyOutStream *outStreamSpec = new CDummyOutStream;
+ CMyComPtr<ISequentialOutStream> outStream(outStreamSpec);
+
+ for (i = 0; i < numItems; i++, totalSize += curSize, totalPackSize += curPackSize)
{
- lps->InSize = lps->OutSize = currentTotalSize;
+ lps->InSize = totalPackSize;
+ lps->OutSize = totalSize;
RINOK(lps->SetCur());
CMyComPtr<ISequentialOutStream> realOutStream;
- Int32 askMode = testMode ?
+ Int32 askMode = testMode ?
NArchive::NExtract::NAskMode::kTest :
NArchive::NExtract::NAskMode::kExtract;
Int32 index = allFilesMode ? i : indices[i];
const CItemEx &item = _items[index];
RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
- currentItemSize = item.Size;
- if (item.IsDirectory())
+ curSize = item.Size;
+ curPackSize = item.GetPackSize();
+ if (item.IsDir())
{
RINOK(extractCallback->PrepareOperation(askMode));
RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK));
@@ -227,16 +209,16 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
if (!testMode && (!realOutStream))
continue;
RINOK(extractCallback->PrepareOperation(askMode));
- if (testMode)
- {
- RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK));
- continue;
- }
+
+ outStreamSpec->SetStream(realOutStream);
+ realOutStream.Release();
+ outStreamSpec->Init();
+
RINOK(_inStream->Seek(item.GetDataPosition(), STREAM_SEEK_SET, NULL));
streamSpec->Init(item.Size);
- RINOK(copyCoder->Code(inStream, realOutStream, NULL, NULL, progress));
- realOutStream.Release();
- RINOK(extractCallback->SetOperationResult((copyCoderSpec->TotalSize == item.Size) ?
+ RINOK(copyCoder->Code(inStream, outStream, NULL, NULL, progress));
+ outStreamSpec->ReleaseStream();
+ RINOK(extractCallback->SetOperationResult(copyCoderSpec->TotalSize == item.Size ?
NArchive::NExtract::NOperationResult::kOK:
NArchive::NExtract::NOperationResult::kDataError));
}
diff --git a/CPP/7zip/Archive/Tar/TarHandler.h b/CPP/7zip/Archive/Tar/TarHandler.h
index 8332fbfe..a98b5404 100755
--- a/CPP/7zip/Archive/Tar/TarHandler.h
+++ b/CPP/7zip/Archive/Tar/TarHandler.h
@@ -11,7 +11,7 @@
namespace NArchive {
namespace NTar {
-class CHandler:
+class CHandler:
public IInArchive,
public IOutArchive,
public CMyUnknownImp
@@ -25,6 +25,8 @@ public:
INTERFACE_IInArchive(;)
INTERFACE_IOutArchive(;)
+ HRESULT Open2(IInStream *stream, IArchiveOpenCallback *callback);
+
private:
CObjectVector<CItemEx> _items;
CMyComPtr<IInStream> _inStream;
diff --git a/CPP/7zip/Archive/Tar/TarHandlerOut.cpp b/CPP/7zip/Archive/Tar/TarHandlerOut.cpp
index ea39d7e2..3454868e 100755
--- a/CPP/7zip/Archive/Tar/TarHandlerOut.cpp
+++ b/CPP/7zip/Archive/Tar/TarHandlerOut.cpp
@@ -15,7 +15,6 @@
using namespace NWindows;
using namespace NCOM;
-using namespace NTime;
namespace NArchive {
namespace NTar {
@@ -27,34 +26,33 @@ STDMETHODIMP CHandler::GetFileTimeType(UInt32 *type)
}
STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numItems,
- IArchiveUpdateCallback *updateCallback)
+ IArchiveUpdateCallback *callback)
{
COM_TRY_BEGIN
- CObjectVector<CUpdateItemInfo> updateItems;
- for(UInt32 i = 0; i < numItems; i++)
+ CObjectVector<CUpdateItem> updateItems;
+ for (UInt32 i = 0; i < numItems; i++)
{
- CUpdateItemInfo updateItem;
+ CUpdateItem ui;
Int32 newData;
Int32 newProperties;
UInt32 indexInArchive;
- if (!updateCallback)
+ if (!callback)
return E_FAIL;
- RINOK(updateCallback->GetUpdateItemInfo(i,
- &newData, &newProperties, &indexInArchive));
- updateItem.NewProperties = IntToBool(newProperties);
- updateItem.NewData = IntToBool(newData);
- updateItem.IndexInArchive = indexInArchive;
- updateItem.IndexInClient = i;
+ RINOK(callback->GetUpdateItemInfo(i, &newData, &newProperties, &indexInArchive));
+ ui.NewProperties = IntToBool(newProperties);
+ ui.NewData = IntToBool(newData);
+ ui.IndexInArchive = indexInArchive;
+ ui.IndexInClient = i;
if (IntToBool(newProperties))
{
FILETIME utcTime;
UString name;
- bool isDirectoryStatusDefined;
+ /*
UInt32 attributes;
{
NCOM::CPropVariant prop;
- RINOK(updateCallback->GetProperty(i, kpidAttributes, &prop));
+ RINOK(callback->GetProperty(i, kpidAttrib, &prop));
if (prop.vt == VT_EMPTY)
attributes = 0;
else if (prop.vt != VT_UI4)
@@ -62,16 +60,17 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
else
attributes = prop.ulVal;
}
+ */
{
NCOM::CPropVariant prop;
- RINOK(updateCallback->GetProperty(i, kpidLastWriteTime, &prop));
+ RINOK(callback->GetProperty(i, kpidMTime, &prop));
if (prop.vt != VT_FILETIME)
return E_INVALIDARG;
utcTime = prop.filetime;
}
{
NCOM::CPropVariant prop;
- RINOK(updateCallback->GetProperty(i, kpidPath, &prop));
+ RINOK(callback->GetProperty(i, kpidPath, &prop));
if (prop.vt == VT_EMPTY)
name.Empty();
else if (prop.vt != VT_BSTR)
@@ -81,27 +80,21 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
}
{
NCOM::CPropVariant prop;
- RINOK(updateCallback->GetProperty(i, kpidIsFolder, &prop));
+ RINOK(callback->GetProperty(i, kpidIsDir, &prop));
if (prop.vt == VT_EMPTY)
- isDirectoryStatusDefined = false;
+ ui.IsDir = false;
else if (prop.vt != VT_BOOL)
return E_INVALIDARG;
else
- {
- updateItem.IsDirectory = (prop.boolVal != VARIANT_FALSE);
- isDirectoryStatusDefined = true;
- }
+ ui.IsDir = (prop.boolVal != VARIANT_FALSE);
}
- updateItem.Name = UnicodeStringToMultiByte(
- NItemName::MakeLegalName(name), CP_OEMCP);
- if (!isDirectoryStatusDefined)
- updateItem.IsDirectory = ((attributes & FILE_ATTRIBUTE_DIRECTORY) != 0);
- if (updateItem.IsDirectory)
- updateItem.Name += '/';
+ ui.Name = UnicodeStringToMultiByte(NItemName::MakeLegalName(name), CP_OEMCP);
+ if (ui.IsDir)
+ ui.Name += '/';
- if(!FileTimeToUnixTime(utcTime, updateItem.Time))
+ if (!NTime::FileTimeToUnixTime(utcTime, ui.Time))
{
- updateItem.Time = 0;
+ ui.Time = 0;
// return E_INVALIDARG;
}
}
@@ -110,16 +103,16 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
UInt64 size;
{
NCOM::CPropVariant prop;
- RINOK(updateCallback->GetProperty(i, kpidSize, &prop));
+ RINOK(callback->GetProperty(i, kpidSize, &prop));
if (prop.vt != VT_UI8)
return E_INVALIDARG;
size = prop.uhVal.QuadPart;
}
- updateItem.Size = size;
+ ui.Size = size;
}
- updateItems.Add(updateItem);
+ updateItems.Add(ui);
}
- return UpdateArchive(_inStream, outStream, _items, updateItems, updateCallback);
+ return UpdateArchive(_inStream, outStream, _items, updateItems, callback);
COM_TRY_END
}
diff --git a/CPP/7zip/Archive/Tar/TarHeader.cpp b/CPP/7zip/Archive/Tar/TarHeader.cpp
index 35f0d0cf..3275b284 100755
--- a/CPP/7zip/Archive/Tar/TarHeader.cpp
+++ b/CPP/7zip/Archive/Tar/TarHeader.cpp
@@ -15,7 +15,7 @@ namespace NFileHeader {
const char *kLongLink2 = "@LongLink";
// The magic field is filled with this if uname and gname are valid.
- namespace NMagic
+ namespace NMagic
{
const char *kUsTar = "ustar"; // 5 chars
const char *kGNUTar = "GNUtar "; // 7 chars and a null
diff --git a/CPP/7zip/Archive/Tar/TarHeader.h b/CPP/7zip/Archive/Tar/TarHeader.h
index 19bb1cac..0b78bdc2 100755
--- a/CPP/7zip/Archive/Tar/TarHeader.h
+++ b/CPP/7zip/Archive/Tar/TarHeader.h
@@ -45,7 +45,7 @@ namespace NFileHeader
namespace NMode
{
const int kSetUID = 04000; // Set UID on execution
- const int kSetGID = 02000; // Set GID on execution
+ const int kSetGID = 02000; // Set GID on execution
const int kSaveText = 01000; // Save text (sticky bit)
}
@@ -67,7 +67,7 @@ namespace NFileHeader
namespace NLinkFlag
{
const char kOldNormal = '\0'; // Normal disk file, Unix compatible
- const char kNormal = '0'; // Normal disk file
+ const char kNormal = '0'; // Normal disk file
const char kLink = '1'; // Link to previously dumped file
const char kSymbolicLink = '2'; // Symbolic link
const char kCharacter = '3'; // Character special file
@@ -76,12 +76,12 @@ namespace NFileHeader
const char kFIFO = '6'; // FIFO special file
const char kContiguous = '7'; // Contiguous file
- const char kDumpDir = 'D'; /* GNUTYPE_DUMPDIR.
+ const char kDumpDir = 'D'; /* GNUTYPE_DUMPDIR.
data: list of files created by the --incremental (-G) option
- Each file name is preceded by either
- - 'Y' (file should be in this archive)
- - 'N' (file is a directory, or is not stored in the archive.)
- Each file name is terminated by a null + an additional null after
+ Each file name is preceded by either
+ - 'Y' (file should be in this archive)
+ - 'N' (file is a directory, or is not stored in the archive.)
+ Each file name is terminated by a null + an additional null after
the last file name. */
}
@@ -94,7 +94,7 @@ namespace NFileHeader
extern const char *kLongLink2; // = "@LongLink";
// The magic field is filled with this if uname and gname are valid.
- namespace NMagic
+ namespace NMagic
{
extern const char *kUsTar; // = "ustar"; // 5 chars
extern const char *kGNUTar; // = "GNUtar "; // 7 chars and a null
diff --git a/CPP/7zip/Archive/Tar/TarIn.cpp b/CPP/7zip/Archive/Tar/TarIn.cpp
index 1318613a..55215ac7 100755
--- a/CPP/7zip/Archive/Tar/TarIn.cpp
+++ b/CPP/7zip/Archive/Tar/TarIn.cpp
@@ -13,21 +13,6 @@
namespace NArchive {
namespace NTar {
-HRESULT CInArchive::ReadBytes(void *data, size_t size, size_t &processedSize)
-{
- processedSize = size;
- RINOK(ReadStream(m_Stream, data, &processedSize));
- m_Position += processedSize;
- return S_OK;
-}
-
-HRESULT CInArchive::Open(IInStream *inStream)
-{
- RINOK(inStream->Seek(0, STREAM_SEEK_CUR, &m_Position));
- m_Stream = inStream;
- return S_OK;
-}
-
static void MyStrNCpy(char *dest, const char *src, int size)
{
for (int i = 0; i < size; i++)
@@ -62,130 +47,76 @@ static bool OctalToNumber32(const char *srcString, int size, UInt32 &res)
#define RIF(x) { if (!(x)) return S_FALSE; }
-static bool IsRecordLast(const char *record)
+static bool IsRecordLast(const char *buf)
{
for (int i = 0; i < NFileHeader::kRecordSize; i++)
- if (record[i] != 0)
+ if (buf[i] != 0)
return false;
return true;
}
static void ReadString(const char *s, int size, AString &result)
{
- if (size > NFileHeader::kRecordSize)
- size = NFileHeader::kNameSize;
- char tempString[NFileHeader::kRecordSize + 1];
- MyStrNCpy(tempString, s, size);
- tempString[size] = '\0';
- result = tempString;
-}
-
-static char GetHex(Byte value)
-{
- return (char)((value < 10) ? ('0' + value) : ('A' + (value - 10)));
+ char temp[NFileHeader::kRecordSize + 1];
+ MyStrNCpy(temp, s, size);
+ temp[size] = '\0';
+ result = temp;
}
-HRESULT CInArchive::GetNextItemReal(bool &filled, CItemEx &item)
+static HRESULT GetNextItemReal(ISequentialInStream *stream, bool &filled, CItemEx &item, size_t &processedSize)
{
item.LongLinkSize = 0;
- // NFileHeader::CRecord record;
- char record[NFileHeader::kRecordSize];
- char *cur = record;
+ char buf[NFileHeader::kRecordSize];
+ char *p = buf;
filled = false;
- size_t processedSize;
- item.HeaderPosition = m_Position;
- RINOK(ReadBytes(record, NFileHeader::kRecordSize, processedSize));
- if (processedSize == 0 ||
- (processedSize == NFileHeader::kRecordSize && IsRecordLast(record)))
+ processedSize = NFileHeader::kRecordSize;
+ RINOK(ReadStream(stream, buf, &processedSize));
+ if (processedSize == 0 || (processedSize == NFileHeader::kRecordSize && IsRecordLast(buf)))
return S_OK;
if (processedSize < NFileHeader::kRecordSize)
return S_FALSE;
- // NFileHeader::CHeader &header = record.Header;
-
- AString name;
- ReadString(cur, NFileHeader::kNameSize, name);
- cur += NFileHeader::kNameSize;
-
- item.Name.Empty();
- int i;
- for (i = 0; i < name.Length(); i++)
- {
- char c = name[i];
- if (((Byte)c) < 0x08)
- {
- return S_FALSE;
- }
- if (((Byte)c) < 0x20)
- {
- item.Name += '[';
- item.Name += GetHex((Byte)(((Byte)c) >> 4));
- item.Name += GetHex((Byte)(((Byte)c) & 0xF));
- item.Name += ']';
- }
- else
- item.Name += c;
- }
+ ReadString(p, NFileHeader::kNameSize, item.Name); p += NFileHeader::kNameSize;
- RIF(OctalToNumber32(cur, 8, item.Mode));
- cur += 8;
+ RIF(OctalToNumber32(p, 8, item.Mode)); p += 8;
- if (!OctalToNumber32(cur, 8, item.UID))
- item.UID = 0;
- cur += 8;
+ if (!OctalToNumber32(p, 8, item.UID)) item.UID = 0; p += 8;
+ if (!OctalToNumber32(p, 8, item.GID)) item.GID = 0; p += 8;
- if (!OctalToNumber32(cur, 8, item.GID))
- item.GID = 0;
- cur += 8;
-
- RIF(OctalToNumber(cur, 12, item.Size));
- cur += 12;
-
- RIF(OctalToNumber32(cur, 12, item.ModificationTime));
- cur += 12;
+ RIF(OctalToNumber(p, 12, item.Size)); p += 12;
+ RIF(OctalToNumber32(p, 12, item.MTime)); p += 12;
UInt32 checkSum;
- RIF(OctalToNumber32(cur, 8, checkSum));
- memmove(cur, NFileHeader::kCheckSumBlanks, 8);
- cur += 8;
+ RIF(OctalToNumber32(p, 8, checkSum));
+ memcpy(p, NFileHeader::kCheckSumBlanks, 8); p += 8;
- item.LinkFlag = *cur++;
+ item.LinkFlag = *p++;
- ReadString(cur, NFileHeader::kNameSize, item.LinkName);
- cur += NFileHeader::kNameSize;
+ ReadString(p, NFileHeader::kNameSize, item.LinkName); p += NFileHeader::kNameSize;
- memmove(item.Magic, cur, 8);
- cur += 8;
+ memcpy(item.Magic, p, 8); p += 8;
- ReadString(cur, NFileHeader::kUserNameSize, item.UserName);
- cur += NFileHeader::kUserNameSize;
- ReadString(cur, NFileHeader::kUserNameSize, item.GroupName);
- cur += NFileHeader::kUserNameSize;
+ ReadString(p, NFileHeader::kUserNameSize, item.UserName); p += NFileHeader::kUserNameSize;
+ ReadString(p, NFileHeader::kUserNameSize, item.GroupName); p += NFileHeader::kUserNameSize;
- item.DeviceMajorDefined = (cur[0] != 0);
- RIF(OctalToNumber32(cur, 8, item.DeviceMajor));
- cur += 8;
-
- item.DeviceMinorDefined = (cur[0] != 0);
- RIF(OctalToNumber32(cur, 8, item.DeviceMinor));
- cur += 8;
+ item.DeviceMajorDefined = (p[0] != 0); RIF(OctalToNumber32(p, 8, item.DeviceMajor)); p += 8;
+ item.DeviceMinorDefined = (p[0] != 0); RIF(OctalToNumber32(p, 8, item.DeviceMinor)); p += 8;
AString prefix;
- ReadString(cur, NFileHeader::kPrefixSize, prefix);
- cur += NFileHeader::kPrefixSize;
- if (!prefix.IsEmpty() && item.IsMagic() &&
+ ReadString(p, NFileHeader::kPrefixSize, prefix);
+ p += NFileHeader::kPrefixSize;
+ if (!prefix.IsEmpty() && item.IsMagic() &&
(item.LinkFlag != 'L' /* || prefix != "00000000000" */ ))
item.Name = prefix + AString('/') + item.Name;
if (item.LinkFlag == NFileHeader::NLinkFlag::kLink)
item.Size = 0;
-
UInt32 checkSumReal = 0;
- for(i = 0; i < NFileHeader::kRecordSize; i++)
- checkSumReal += Byte(record[i]);
+ for (int i = 0; i < NFileHeader::kRecordSize; i++)
+ checkSumReal += (Byte)buf[i];
if (checkSumReal != checkSum)
return S_FALSE;
@@ -194,9 +125,10 @@ HRESULT CInArchive::GetNextItemReal(bool &filled, CItemEx &item)
return S_OK;
}
-HRESULT CInArchive::GetNextItem(bool &filled, CItemEx &item)
+HRESULT ReadItem(ISequentialInStream *stream, bool &filled, CItemEx &item)
{
- RINOK(GetNextItemReal(filled, item));
+ size_t processedSize;
+ RINOK(GetNextItemReal(stream, filled, item, processedSize));
if (!filled)
return S_OK;
// GNUtar extension
@@ -205,22 +137,25 @@ HRESULT CInArchive::GetNextItem(bool &filled, CItemEx &item)
if (item.Name.Compare(NFileHeader::kLongLink) != 0)
if (item.Name.Compare(NFileHeader::kLongLink2) != 0)
return S_FALSE;
- UInt64 headerPosition = item.HeaderPosition;
- size_t processedSize;
AString fullName;
if (item.Size > (1 << 15))
return S_FALSE;
- char *buffer = fullName.GetBuffer((int)item.Size + 1);
- RINOK(ReadBytes(buffer, (size_t)item.Size, processedSize));
+ int packSize = (int)item.GetPackSize();
+ char *buffer = fullName.GetBuffer(packSize + 1);
+
+ RINOK(ReadStream_FALSE(stream, buffer, packSize));
+ processedSize += packSize;
buffer[item.Size] = '\0';
fullName.ReleaseBuffer();
- if (processedSize != item.Size)
- return S_FALSE;
- RINOK(Skeep((0 - item.Size) & 0x1FF));
- RINOK(GetNextItemReal(filled, item));
+
+ UInt64 headerPosition = item.HeaderPosition;
+ {
+ size_t processedSize2;
+ RINOK(GetNextItemReal(stream, filled, item, processedSize2));
+ }
+ item.LongLinkSize = (unsigned)processedSize;
item.Name = fullName;
- item.LongLinkSize = item.HeaderPosition - headerPosition;
item.HeaderPosition = headerPosition;
}
else if (item.LinkFlag == 'g' || item.LinkFlag == 'x' || item.LinkFlag == 'X')
@@ -238,20 +173,4 @@ HRESULT CInArchive::GetNextItem(bool &filled, CItemEx &item)
return S_OK;
}
-HRESULT CInArchive::Skeep(UInt64 numBytes)
-{
- UInt64 newPostion;
- RINOK(m_Stream->Seek(numBytes, STREAM_SEEK_CUR, &newPostion));
- m_Position += numBytes;
- if (m_Position != newPostion)
- return E_FAIL;
- return S_OK;
-}
-
-
-HRESULT CInArchive::SkeepDataRecords(UInt64 dataSize)
-{
- return Skeep((dataSize + 0x1FF) & (~((UInt64)0x1FF)));
-}
-
}}
diff --git a/CPP/7zip/Archive/Tar/TarIn.h b/CPP/7zip/Archive/Tar/TarIn.h
index 20c030ef..cc6e3f5b 100755
--- a/CPP/7zip/Archive/Tar/TarIn.h
+++ b/CPP/7zip/Archive/Tar/TarIn.h
@@ -11,20 +11,8 @@
namespace NArchive {
namespace NTar {
-class CInArchive
-{
- CMyComPtr<IInStream> m_Stream;
- UInt64 m_Position;
-
- HRESULT ReadBytes(void *data, size_t size, size_t &processedSize);
-public:
- HRESULT Open(IInStream *inStream);
- HRESULT GetNextItemReal(bool &filled, CItemEx &itemInfo);
- HRESULT GetNextItem(bool &filled, CItemEx &itemInfo);
- HRESULT Skeep(UInt64 numBytes);
- HRESULT SkeepDataRecords(UInt64 dataSize);
-};
-
+HRESULT ReadItem(ISequentialInStream *stream, bool &filled, CItemEx &itemInfo);
+
}}
#endif
diff --git a/CPP/7zip/Archive/Tar/TarItem.h b/CPP/7zip/Archive/Tar/TarItem.h
index 451d74bc..7d95844d 100755
--- a/CPP/7zip/Archive/Tar/TarItem.h
+++ b/CPP/7zip/Archive/Tar/TarItem.h
@@ -3,8 +3,6 @@
#ifndef __ARCHIVE_TAR_ITEM_H
#define __ARCHIVE_TAR_ITEM_H
-#include <time.h>
-
#include "Common/Types.h"
#include "Common/MyString.h"
@@ -14,28 +12,29 @@
namespace NArchive {
namespace NTar {
-class CItem
+struct CItem
{
-public:
AString Name;
+ UInt64 Size;
+
UInt32 Mode;
UInt32 UID;
UInt32 GID;
- UInt64 Size;
- UInt32 ModificationTime;
- char LinkFlag;
+ UInt32 MTime;
+ UInt32 DeviceMajor;
+ UInt32 DeviceMinor;
+
AString LinkName;
- char Magic[8];
AString UserName;
AString GroupName;
+ char Magic[8];
+ char LinkFlag;
bool DeviceMajorDefined;
- UInt32 DeviceMajor;
bool DeviceMinorDefined;
- UInt32 DeviceMinor;
- bool IsDirectory() const
- {
+ bool IsDir() const
+ {
switch(LinkFlag)
{
case NFileHeader::NLinkFlag::kDirectory:
@@ -48,22 +47,23 @@ public:
return false;
}
- bool IsMagic() const
- {
+ bool IsMagic() const
+ {
for (int i = 0; i < 5; i++)
if (Magic[i] != NFileHeader::NMagic::kUsTar[i])
return false;
return true;
}
+
+ UInt64 GetPackSize() const { return (Size + 0x1FF) & (~((UInt64)0x1FF)); }
};
-class CItemEx: public CItem
+struct CItemEx: public CItem
{
-public:
UInt64 HeaderPosition;
- UInt64 LongLinkSize;
- UInt64 GetDataPosition() const { return HeaderPosition + LongLinkSize + NFileHeader::kRecordSize; };
- UInt64 GetFullSize() const { return LongLinkSize + NFileHeader::kRecordSize + Size; };
+ unsigned LongLinkSize;
+ UInt64 GetDataPosition() const { return HeaderPosition + LongLinkSize + NFileHeader::kRecordSize; }
+ UInt64 GetFullSize() const { return LongLinkSize + NFileHeader::kRecordSize + Size; }
};
}}
diff --git a/CPP/7zip/Archive/Tar/TarOut.cpp b/CPP/7zip/Archive/Tar/TarOut.cpp
index a697b4d2..0892748f 100755
--- a/CPP/7zip/Archive/Tar/TarOut.cpp
+++ b/CPP/7zip/Archive/Tar/TarOut.cpp
@@ -100,7 +100,7 @@ HRESULT COutArchive::WriteHeaderReal(const CItem &item)
RETURN_IF_NOT_TRUE(MakeOctalString12(cur, item.Size));
cur += 12;
- RETURN_IF_NOT_TRUE(MakeOctalString12(cur, item.ModificationTime));
+ RETURN_IF_NOT_TRUE(MakeOctalString12(cur, item.MTime));
cur += 12;
memmove(cur, NFileHeader::kCheckSumBlanks, 8);
diff --git a/CPP/7zip/Archive/Tar/TarUpdate.cpp b/CPP/7zip/Archive/Tar/TarUpdate.cpp
index b4241e0d..62c6bff6 100755
--- a/CPP/7zip/Archive/Tar/TarUpdate.cpp
+++ b/CPP/7zip/Archive/Tar/TarUpdate.cpp
@@ -18,7 +18,7 @@ namespace NTar {
HRESULT UpdateArchive(IInStream *inStream, ISequentialOutStream *outStream,
const CObjectVector<NArchive::NTar::CItemEx> &inputItems,
- const CObjectVector<CUpdateItemInfo> &updateItems,
+ const CObjectVector<CUpdateItem> &updateItems,
IArchiveUpdateCallback *updateCallback)
{
COutArchive outArchive;
@@ -29,11 +29,11 @@ HRESULT UpdateArchive(IInStream *inStream, ISequentialOutStream *outStream,
int i;
for(i = 0; i < updateItems.Size(); i++)
{
- const CUpdateItemInfo &updateItem = updateItems[i];
- if (updateItem.NewData)
- complexity += updateItem.Size;
+ const CUpdateItem &ui = updateItems[i];
+ if (ui.NewData)
+ complexity += ui.Size;
else
- complexity += inputItems[updateItem.IndexInArchive].GetFullSize();
+ complexity += inputItems[ui.IndexInArchive].GetFullSize();
}
RINOK(updateCallback->SetTotal(complexity));
@@ -56,13 +56,13 @@ HRESULT UpdateArchive(IInStream *inStream, ISequentialOutStream *outStream,
lps->InSize = lps->OutSize = complexity;
RINOK(lps->SetCur());
- const CUpdateItemInfo &updateItem = updateItems[i];
+ const CUpdateItem &ui = updateItems[i];
CItem item;
- if (updateItem.NewProperties)
+ if (ui.NewProperties)
{
item.Mode = 0777;
- item.Name = (updateItem.Name);
- if (updateItem.IsDirectory)
+ item.Name = (ui.Name);
+ if (ui.IsDir)
{
item.LinkFlag = NFileHeader::NLinkFlag::kDirectory;
item.Size = 0;
@@ -70,9 +70,9 @@ HRESULT UpdateArchive(IInStream *inStream, ISequentialOutStream *outStream,
else
{
item.LinkFlag = NFileHeader::NLinkFlag::kNormal;
- item.Size = updateItem.Size;
+ item.Size = ui.Size;
}
- item.ModificationTime = updateItem.Time;
+ item.MTime = ui.Time;
item.DeviceMajorDefined = false;
item.DeviceMinorDefined = false;
item.UID = 0;
@@ -81,30 +81,30 @@ HRESULT UpdateArchive(IInStream *inStream, ISequentialOutStream *outStream,
}
else
{
- const CItemEx &existItemInfo = inputItems[updateItem.IndexInArchive];
+ const CItemEx &existItemInfo = inputItems[ui.IndexInArchive];
item = existItemInfo;
}
- if (updateItem.NewData)
+ if (ui.NewData)
{
- item.Size = updateItem.Size;
+ item.Size = ui.Size;
if (item.Size == UInt64(Int64(-1)))
return E_INVALIDARG;
}
else
{
- const CItemEx &existItemInfo = inputItems[updateItem.IndexInArchive];
+ const CItemEx &existItemInfo = inputItems[ui.IndexInArchive];
item.Size = existItemInfo.Size;
}
- if (updateItem.NewData)
+ if (ui.NewData)
{
CMyComPtr<ISequentialInStream> fileInStream;
- HRESULT res = updateCallback->GetStream(updateItem.IndexInClient, &fileInStream);
+ HRESULT res = updateCallback->GetStream(ui.IndexInClient, &fileInStream);
if (res != S_FALSE)
{
RINOK(res);
RINOK(outArchive.WriteHeader(item));
- if (!updateItem.IsDirectory)
+ if (!ui.IsDir)
{
RINOK(copyCoder->Code(fileInStream, outStream, NULL, NULL, progress));
if (copyCoderSpec->TotalSize != item.Size)
@@ -112,14 +112,14 @@ HRESULT UpdateArchive(IInStream *inStream, ISequentialOutStream *outStream,
RINOK(outArchive.FillDataResidual(item.Size));
}
}
- complexity += updateItem.Size;
+ complexity += ui.Size;
RINOK(updateCallback->SetOperationResult(NArchive::NUpdate::NOperationResult::kOK));
}
else
{
- const CItemEx &existItemInfo = inputItems[updateItem.IndexInArchive];
+ const CItemEx &existItemInfo = inputItems[ui.IndexInArchive];
UInt64 size;
- if (updateItem.NewProperties)
+ if (ui.NewProperties)
{
RINOK(outArchive.WriteHeader(item));
RINOK(inStream->Seek(existItemInfo.GetDataPosition(), STREAM_SEEK_SET, NULL));
diff --git a/CPP/7zip/Archive/Tar/TarUpdate.h b/CPP/7zip/Archive/Tar/TarUpdate.h
index 67d671f5..7d196d1c 100755
--- a/CPP/7zip/Archive/Tar/TarUpdate.h
+++ b/CPP/7zip/Archive/Tar/TarUpdate.h
@@ -9,7 +9,7 @@
namespace NArchive {
namespace NTar {
-struct CUpdateItemInfo
+struct CUpdateItem
{
bool NewData;
bool NewProperties;
@@ -19,12 +19,12 @@ struct CUpdateItemInfo
UInt32 Time;
UInt64 Size;
AString Name;
- bool IsDirectory;
+ bool IsDir;
};
HRESULT UpdateArchive(IInStream *inStream, ISequentialOutStream *outStream,
const CObjectVector<CItemEx> &inputItems,
- const CObjectVector<CUpdateItemInfo> &updateItems,
+ const CObjectVector<CUpdateItem> &updateItems,
IArchiveUpdateCallback *updateCallback);
}}
diff --git a/CPP/7zip/Archive/Arj/StdAfx.h b/CPP/7zip/Archive/Udf/StdAfx.h
index e7fb6986..2e4be10b 100755
--- a/CPP/7zip/Archive/Arj/StdAfx.h
+++ b/CPP/7zip/Archive/Udf/StdAfx.h
@@ -4,5 +4,6 @@
#define __STDAFX_H
#include "../../../Common/MyWindows.h"
+#include "../../../Common/NewHandler.h"
#endif
diff --git a/CPP/7zip/Archive/Udf/UdfHandler.cpp b/CPP/7zip/Archive/Udf/UdfHandler.cpp
new file mode 100755
index 00000000..10a1a900
--- /dev/null
+++ b/CPP/7zip/Archive/Udf/UdfHandler.cpp
@@ -0,0 +1,361 @@
+// Udf/Handler.cpp
+
+#include "StdAfx.h"
+
+#include "UdfHandler.h"
+
+#include "Common/NewHandler.h"
+#include "Common/ComTry.h"
+
+#include "Windows/Time.h"
+#include "Windows/PropVariant.h"
+
+#include "../../Common/ProgressUtils.h"
+#include "../../Compress/Copy/CopyCoder.h"
+#include "../Common/DummyOutStream.h"
+
+namespace NArchive {
+namespace NUdf {
+
+void UdfTimeToFileTime(const CTime &t, NWindows::NCOM::CPropVariant &prop)
+{
+ UInt64 numSecs;
+ const Byte *d = t.Data;
+ if (!NWindows::NTime::GetSecondsSince1601(t.GetYear(), d[4], d[5], d[6], d[7], d[8], numSecs))
+ return;
+ if (t.IsLocal())
+ numSecs -= t.GetMinutesOffset() * 60;
+ FILETIME ft;
+ UInt64 v = (((numSecs * 100 + d[9]) * 100 + d[10]) * 100 + d[11]) * 10;
+ ft.dwLowDateTime = (UInt32)v;
+ ft.dwHighDateTime = (UInt32)(v >> 32);
+ prop = ft;
+}
+
+STATPROPSTG kProps[] =
+{
+ { NULL, kpidPath, VT_BSTR},
+ { NULL, kpidIsDir, VT_BOOL},
+ { NULL, kpidSize, VT_UI8},
+ { NULL, kpidPackSize, VT_UI8},
+ { NULL, kpidMTime, VT_FILETIME},
+ { NULL, kpidATime, VT_FILETIME}
+};
+
+STATPROPSTG kArcProps[] =
+{
+ { NULL, kpidComment, VT_BSTR},
+ { NULL, kpidClusterSize, VT_UI4},
+ { NULL, kpidCTime, VT_FILETIME}
+};
+
+IMP_IInArchive_Props
+IMP_IInArchive_ArcProps
+
+STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NWindows::NCOM::CPropVariant prop;
+ switch(propID)
+ {
+ case kpidComment:
+ {
+ UString comment = _archive.GetComment();
+ if (!comment.IsEmpty())
+ prop = comment;
+ break;
+ }
+
+ case kpidClusterSize:
+ if (_archive.LogVols.Size() > 0)
+ {
+ UInt32 blockSize = _archive.LogVols[0].BlockSize;
+ int i;
+ for (i = 1; i < _archive.LogVols.Size(); i++)
+ if (_archive.LogVols[i].BlockSize != blockSize)
+ break;
+ if (i == _archive.LogVols.Size())
+ prop = blockSize;
+ }
+ break;
+
+ case kpidCTime:
+ if (_archive.LogVols.Size() == 1)
+ {
+ const CLogVol &vol = _archive.LogVols[0];
+ if (vol.FileSets.Size() >= 1)
+ UdfTimeToFileTime(vol.FileSets[0].RecodringTime, prop);
+ }
+ break;
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+class CProgressImp: public CProgressVirt
+{
+ CMyComPtr<IArchiveOpenCallback> _callback;
+ UInt64 _numFiles;
+ UInt64 _numBytes;
+public:
+ HRESULT SetTotal(UInt64 numBytes);
+ HRESULT SetCompleted(UInt64 numFiles, UInt64 numBytes);
+ HRESULT SetCompleted();
+ CProgressImp(IArchiveOpenCallback *callback): _callback(callback), _numFiles(0), _numBytes(0) {}
+};
+
+HRESULT CProgressImp::SetTotal(UInt64 numBytes)
+{
+ if (_callback)
+ return _callback->SetTotal(NULL, &numBytes);
+ return S_OK;
+}
+
+HRESULT CProgressImp::SetCompleted(UInt64 numFiles, UInt64 numBytes)
+{
+ _numFiles = numFiles;
+ _numBytes = numBytes;
+ return SetCompleted();
+}
+
+HRESULT CProgressImp::SetCompleted()
+{
+ if (_callback)
+ return _callback->SetCompleted(&_numFiles, &_numBytes);
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Open(IInStream *stream,
+ const UInt64 * /* maxCheckStartPosition */,
+ IArchiveOpenCallback *callback)
+{
+ COM_TRY_BEGIN
+ {
+ Close();
+ CProgressImp progressImp(callback);
+ RINOK(_archive.Open(stream, &progressImp));
+ bool showVolName = (_archive.LogVols.Size() > 1);
+ for (int volIndex = 0; volIndex < _archive.LogVols.Size(); volIndex++)
+ {
+ const CLogVol &vol = _archive.LogVols[volIndex];
+ bool showFileSetName = (vol.FileSets.Size() > 1);
+ for (int fsIndex = 0; fsIndex < vol.FileSets.Size(); fsIndex++)
+ {
+ const CFileSet &fs = vol.FileSets[fsIndex];
+ for (int i = ((showVolName || showFileSetName) ? 0 : 1); i < fs.Refs.Size(); i++)
+ {
+ CRef2 ref2;
+ ref2.Vol = volIndex;
+ ref2.Fs = fsIndex;
+ ref2.Ref = i;
+ _refs2.Add(ref2);
+ }
+ }
+ }
+ _inStream = stream;
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Close()
+{
+ _inStream.Release();
+ _archive.Clear();
+ _refs2.Clear();
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
+{
+ *numItems = _refs2.Size();
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NWindows::NCOM::CPropVariant prop;
+ {
+ const CRef2 &ref2 = _refs2[index];
+ const CLogVol &vol = _archive.LogVols[ref2.Vol];
+ const CRef &ref = vol.FileSets[ref2.Fs].Refs[ref2.Ref];
+ const CFile &file = _archive.Files[ref.FileIndex];
+ const CItem &item = _archive.Items[file.ItemIndex];
+ switch(propID)
+ {
+ case kpidPath: prop = _archive.GetItemPath(ref2.Vol, ref2.Fs, ref2.Ref,
+ _archive.LogVols.Size() > 1, vol.FileSets.Size() > 1); break;
+ case kpidIsDir: prop = item.IsDir(); break;
+ case kpidSize: if (!item.IsDir()) prop = (UInt64)item.Size; break;
+ case kpidPackSize: if (!item.IsDir()) prop = (UInt64)item.NumLogBlockRecorded * vol.BlockSize; break;
+ case kpidMTime: UdfTimeToFileTime(item.MTime, prop); break;
+ case kpidATime: UdfTimeToFileTime(item.ATime, prop); break;
+ }
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+class CUdfInStream:
+ public ISequentialInStream,
+ public CMyUnknownImp
+{
+ MY_UNKNOWN_IMP
+
+ STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
+ UInt64 _rem;
+public:
+ CInArchive *_archive;
+ CMyComPtr<IInStream> _stream;
+ CRef2 _ref2;
+ int _extentIndex;
+ UInt32 _offsetInExtent;
+
+ void Init(UInt64 size)
+ {
+ _extentIndex = 0;
+ _offsetInExtent = 0;
+ _rem = size;
+ }
+ void ReleaseStream() { _stream.Release(); }
+};
+
+STDMETHODIMP CUdfInStream::Read(void *data, UInt32 size, UInt32 *processedSize)
+{
+ if (processedSize)
+ *processedSize = 0;
+ if (size > _rem)
+ size = (UInt32)_rem;
+ while (size > 0)
+ {
+ const CLogVol &vol = _archive->LogVols[_ref2.Vol];
+ const CRef &ref = vol.FileSets[_ref2.Fs].Refs[_ref2.Ref];
+ const CFile &file = _archive->Files[ref.FileIndex];
+ const CItem &item = _archive->Items[file.ItemIndex];
+
+ const CMyExtent &extent = item.Extents[_extentIndex];
+ UInt32 rem = extent.GetLen() - _offsetInExtent;
+ if (rem == 0)
+ {
+ _extentIndex++;
+ _offsetInExtent = 0;
+ continue;
+ }
+ if (size > rem)
+ size = rem;
+
+ int partitionIndex = vol.PartitionMaps[extent.PartitionRef].PartitionIndex;
+ UInt32 logBlockNumber = extent.Pos;
+ const CPartition &partition = _archive->Partitions[partitionIndex];
+ UInt64 offset = ((UInt64)partition.Pos << _archive->SecLogSize) +
+ (UInt64)logBlockNumber * vol.BlockSize + _offsetInExtent;
+
+ RINOK(_stream->Seek(offset, STREAM_SEEK_SET, NULL));
+ HRESULT res = _stream->Read(data, size, &size);
+ _offsetInExtent += size;
+ _rem -= size;
+ if (processedSize)
+ *processedSize = size;
+ return res;
+ }
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
+ Int32 _aTestMode, IArchiveExtractCallback *extractCallback)
+{
+ COM_TRY_BEGIN
+ bool testMode = (_aTestMode != 0);
+ bool allFilesMode = (numItems == UInt32(-1));
+ if (allFilesMode)
+ numItems = _refs2.Size();
+ if (numItems == 0)
+ return S_OK;
+ UInt64 totalSize = 0;
+ UInt32 i;
+
+ for (i = 0; i < numItems; i++)
+ {
+ UInt32 index = (allFilesMode ? i : indices[i]);
+ const CRef2 &ref2 = _refs2[index];
+ const CRef &ref = _archive.LogVols[ref2.Vol].FileSets[ref2.Fs].Refs[ref2.Ref];
+ const CFile &file = _archive.Files[ref.FileIndex];
+ const CItem &item = _archive.Items[file.ItemIndex];
+ if (!item.IsDir())
+ totalSize += item.Size;
+ }
+ extractCallback->SetTotal(totalSize);
+
+ UInt64 currentTotalSize = 0;
+ UInt64 currentItemSize;
+
+ NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder();
+ CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;
+
+ CLocalProgress *lps = new CLocalProgress;
+ CMyComPtr<ICompressProgressInfo> progress = lps;
+ lps->Init(extractCallback, false);
+
+ CUdfInStream *udfInStreamSpec = new CUdfInStream();
+ CMyComPtr<ISequentialInStream> udfInStream = udfInStreamSpec;
+
+ udfInStreamSpec->_archive = &_archive;
+ udfInStreamSpec->_stream = _inStream;
+
+ CDummyOutStream *outStreamSpec = new CDummyOutStream;
+ CMyComPtr<ISequentialOutStream> outStream(outStreamSpec);
+
+ for (i = 0; i < numItems; i++, currentTotalSize += currentItemSize)
+ {
+ lps->InSize = lps->OutSize = currentTotalSize;
+ RINOK(lps->SetCur());
+ currentItemSize = 0;
+ CMyComPtr<ISequentialOutStream> realOutStream;
+ Int32 askMode = testMode ?
+ NArchive::NExtract::NAskMode::kTest :
+ NArchive::NExtract::NAskMode::kExtract;
+ UInt32 index = allFilesMode ? i : indices[i];
+
+ RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
+
+ const CRef2 &ref2 = _refs2[index];
+ const CRef &ref = _archive.LogVols[ref2.Vol].FileSets[ref2.Fs].Refs[ref2.Ref];
+ const CFile &file = _archive.Files[ref.FileIndex];
+ const CItem &item = _archive.Items[file.ItemIndex];
+
+ if (item.IsDir())
+ {
+ RINOK(extractCallback->PrepareOperation(askMode));
+ RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK));
+ continue;
+ }
+ currentItemSize = item.Size;
+
+ if (!testMode && (!realOutStream))
+ continue;
+ RINOK(extractCallback->PrepareOperation(askMode));
+
+ outStreamSpec->SetStream(realOutStream);
+ realOutStream.Release();
+ outStreamSpec->Init();
+ Int32 opRes = NArchive::NExtract::NOperationResult::kUnSupportedMethod;
+ if (item.IsRecAndAlloc() && item.CheckChunkSizes() && _archive.CheckItemExtents(ref2.Vol, item))
+ {
+ udfInStreamSpec->_ref2 = ref2;
+ udfInStreamSpec->Init(item.Size);
+ RINOK(copyCoder->Code(udfInStream, outStream, NULL, NULL, progress));
+ opRes = (outStreamSpec->GetSize() == currentItemSize) ?
+ NArchive::NExtract::NOperationResult::kOK:
+ NArchive::NExtract::NOperationResult::kDataError;
+ }
+ outStreamSpec->ReleaseStream();
+ RINOK(extractCallback->SetOperationResult(opRes));
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+}}
diff --git a/CPP/7zip/Archive/Deb/DebHandler.h b/CPP/7zip/Archive/Udf/UdfHandler.h
index 297a91be..ceab85ae 100755
--- a/CPP/7zip/Archive/Deb/DebHandler.h
+++ b/CPP/7zip/Archive/Udf/UdfHandler.h
@@ -1,30 +1,36 @@
-// DebHandler.h
+// Udf/Handler.h
-#ifndef __DEB_HANDLER_H
-#define __DEB_HANDLER_H
+#ifndef __UDF_HANDLER_H
+#define __UDF_HANDLER_H
#include "Common/MyCom.h"
#include "../IArchive.h"
-#include "DebItem.h"
+#include "UdfIn.h"
namespace NArchive {
-namespace NDeb {
+namespace NUdf {
-class CHandler:
+struct CRef2
+{
+ int Vol;
+ int Fs;
+ int Ref;
+};
+
+class CHandler:
public IInArchive,
public CMyUnknownImp
{
+ CMyComPtr<IInStream> _inStream;
+ CInArchive _archive;
+ CRecordVector<CRef2> _refs2;
public:
MY_UNKNOWN_IMP1(IInArchive)
-
INTERFACE_IInArchive(;)
-
-private:
- CObjectVector<CItemEx> _items;
- CMyComPtr<IInStream> _inStream;
};
}}
#endif
+ \ No newline at end of file
diff --git a/CPP/7zip/Archive/Udf/UdfIn.cpp b/CPP/7zip/Archive/Udf/UdfIn.cpp
new file mode 100755
index 00000000..3637bbc6
--- /dev/null
+++ b/CPP/7zip/Archive/Udf/UdfIn.cpp
@@ -0,0 +1,853 @@
+// Archive/UdfIn.cpp
+
+#include "StdAfx.h"
+
+#include "UdfIn.h"
+
+#include "../../Common/StreamUtils.h"
+
+extern "C"
+{
+ #include "../../../../C/CpuArch.h"
+}
+
+#define Get16(p) GetUi16(p)
+#define Get32(p) GetUi32(p)
+#define Get64(p) GetUi64(p)
+
+namespace NArchive {
+namespace NUdf {
+
+const int kNumPartitionsMax = 64;
+const int kNumLogVolumesMax = 64;
+const int kNumRecureseLevelsMax = 1 << 10;
+const int kNumItemsMax = 1 << 27;
+const int kNumFilesMax = 1 << 28;
+const int kNumRefsMax = 1 << 28;
+const UInt32 kNumExtentsMax = (UInt32)1 << 30;
+const UInt64 kFileNameLengthTotalMax = (UInt64)1 << 33;
+
+void MY_FAST_CALL Crc16GenerateTable(void);
+
+#define CRC16_INIT_VAL 0
+#define CRC16_GET_DIGEST(crc) (crc)
+#define CRC16_UPDATE_BYTE(crc, b) (g_Crc16Table[(((crc) >> 8) ^ (b)) & 0xFF] ^ ((crc) << 8))
+
+#define kCrc16Poly 0x1021
+UInt16 g_Crc16Table[256];
+
+void MY_FAST_CALL Crc16GenerateTable(void)
+{
+ UInt32 i;
+ for (i = 0; i < 256; i++)
+ {
+ UInt32 r = (i << 8);
+ for (int j = 8; j > 0; j--)
+ r = ((r & 0x8000) ? ((r << 1) ^ kCrc16Poly) : (r << 1)) & 0xFFFF;
+ g_Crc16Table[i] = (UInt16)r;
+ }
+}
+
+UInt16 MY_FAST_CALL Crc16_Update(UInt16 v, const void *data, size_t size)
+{
+ const Byte *p = (const Byte *)data;
+ for (; size > 0 ; size--, p++)
+ v = CRC16_UPDATE_BYTE(v, *p);
+ return v;
+}
+
+UInt16 MY_FAST_CALL Crc16Calc(const void *data, size_t size)
+{
+ return Crc16_Update(CRC16_INIT_VAL, data, size);
+}
+
+struct CCrc16TableInit { CCrc16TableInit() { Crc16GenerateTable(); } } g_Crc16TableInit;
+
+void CDString128::Parse(const Byte *buf) { memcpy(Data, buf, sizeof(Data)); }
+
+void CDString::Parse(const Byte *p, unsigned size)
+{
+ Data.SetCapacity(size);
+ memcpy(Data, p, size);
+}
+
+static UString ParseDString(const Byte *data, int size)
+{
+ UString res;
+ wchar_t *p;
+ if (size > 0)
+ {
+ Byte type = data[0];
+ if (type == 8)
+ {
+ p = res.GetBuffer((int)size + 1);
+ for (int i = 1; i < size; i++)
+ {
+ wchar_t c = data[i];
+ if (c == 0)
+ break;
+ *p++ = c;
+ }
+ }
+ else if (type == 16)
+ {
+ p = res.GetBuffer((int)size / 2 + 1);
+ for (int i = 1; i + 2 <= size; i += 2)
+ {
+ wchar_t c = ((wchar_t)data[i] << 8) | data[i + 1];
+ if (c == 0)
+ break;
+ *p++ = c;
+ }
+ }
+ else
+ return L"[unknow]";
+ *p++ = 0;
+ res.ReleaseBuffer();
+ }
+ return res;
+}
+
+UString CDString:: GetString() const { return ParseDString(Data, (int)Data.GetCapacity()); }
+UString CDString128::GetString() const
+{
+ int size = Data[sizeof(Data) - 1];
+ return ParseDString(Data, MyMin(size, (int)(sizeof(Data) - 1)));
+}
+
+void CTime::Parse(const Byte *buf) { memcpy(Data, buf, sizeof(Data)); }
+
+/*
+void CRegId::Parse(const Byte *buf)
+{
+ Flags = buf[0];
+ memcpy(Id, buf + 1, sizeof(Id));
+ memcpy(Suffix, buf + 24, sizeof(Suffix));
+}
+*/
+
+// ECMA 3/7.1
+
+struct CExtent
+{
+ UInt32 Len;
+ UInt32 Pos;
+
+ void Parse(const Byte *buf);
+};
+
+void CExtent::Parse(const Byte *buf)
+{
+ Len = Get32(buf);
+ Pos = Get32(buf + 4);
+}
+
+// ECMA 3/7.2
+
+struct CTag
+{
+ UInt16 Id;
+ UInt16 Version;
+ // Byte Checksum;
+ // UInt16 SerialNumber;
+ // UInt16 Crc;
+ // UInt16 CrcLen;
+ // UInt32 TagLocation;
+
+ HRESULT Parse(const Byte *buf, size_t size);
+};
+
+HRESULT CTag::Parse(const Byte *buf, size_t size)
+{
+ if (size < 16)
+ return S_FALSE;
+ Byte sum = 0;
+ int i;
+ for (i = 0; i < 4; i++) sum = sum + buf[i];
+ for (i = 5; i < 16; i++) sum = sum + buf[i];
+ if (sum != buf[4] || buf[5] != 0) return S_FALSE;
+
+ Id = Get16(buf);
+ Version = Get16(buf + 2);
+ // SerialNumber = Get16(buf + 6);
+ UInt16 crc = Get16(buf + 8);
+ UInt16 crcLen = Get16(buf + 10);
+ // TagLocation = Get32(buf + 12);
+
+ if (size >= 16 + (size_t)crcLen)
+ if (crc == Crc16Calc(buf + 16, crcLen))
+ return S_OK;
+ return S_FALSE;
+}
+
+// ECMA 3/7.2.1
+
+enum EDescriptorType
+{
+ DESC_TYPE_SpoaringTable = 0, // UDF
+ DESC_TYPE_PrimVol = 1,
+ DESC_TYPE_AnchorVolPtr = 2,
+ DESC_TYPE_VolPtr = 3,
+ DESC_TYPE_ImplUseVol = 4,
+ DESC_TYPE_Partition = 5,
+ DESC_TYPE_LogicalVol = 6,
+ DESC_TYPE_UnallocSpace = 7,
+ DESC_TYPE_Terminating = 8,
+ DESC_TYPE_LogicalVolIntegrity = 9,
+ DESC_TYPE_FileSet = 256,
+ DESC_TYPE_FileId = 257,
+ DESC_TYPE_AllocationExtent = 258,
+ DESC_TYPE_Indirect = 259,
+ DESC_TYPE_Terminal = 260,
+ DESC_TYPE_File = 261,
+ DESC_TYPE_ExtendedAttrHeader = 262,
+ DESC_TYPE_UnallocatedSpace = 263,
+ DESC_TYPE_SpaceBitmap = 264,
+ DESC_TYPE_PartitionIntegrity = 265,
+ DESC_TYPE_ExtendedFile = 266,
+};
+
+
+void CLogBlockAddr::Parse(const Byte *buf)
+{
+ Pos = Get32(buf);
+ PartitionRef = Get16(buf + 4);
+}
+
+void CShortAllocDesc::Parse(const Byte *buf)
+{
+ Len = Get32(buf);
+ Pos = Get32(buf + 4);
+}
+
+/*
+void CADImpUse::Parse(const Byte *buf)
+{
+ Flags = Get16(buf);
+ UdfUniqueId = Get32(buf + 2);
+}
+*/
+
+void CLongAllocDesc::Parse(const Byte *buf)
+{
+ Len = Get32(buf);
+ Location.Parse(buf + 4);
+ // memcpy(ImplUse, buf + 10, sizeof(ImplUse));
+ // adImpUse.Parse(ImplUse);
+}
+
+bool CInArchive::CheckExtent(int volIndex, int partitionRef, UInt32 blockPos, UInt32 len) const
+{
+ const CLogVol &vol = LogVols[volIndex];
+ const CPartition &partition = Partitions[vol.PartitionMaps[partitionRef].PartitionIndex];
+ UInt64 offset = ((UInt64)partition.Pos << SecLogSize) + (UInt64)blockPos * vol.BlockSize;
+ return (offset + len) <= (((UInt64)partition.Pos + partition.Len) << SecLogSize);
+}
+
+bool CInArchive::CheckItemExtents(int volIndex, const CItem &item) const
+{
+ for (int i = 0; i < item.Extents.Size(); i++)
+ {
+ const CMyExtent &e = item.Extents[i];
+ if (!CheckExtent(volIndex, e.PartitionRef, e.Pos, e.GetLen()))
+ return false;
+ }
+ return true;
+}
+
+HRESULT CInArchive::Read(int volIndex, int partitionRef, UInt32 blockPos, UInt32 len, Byte *buf)
+{
+ if (!CheckExtent(volIndex, partitionRef, blockPos, len))
+ return S_FALSE;
+ const CLogVol &vol = LogVols[volIndex];
+ const CPartition &partition = Partitions[vol.PartitionMaps[partitionRef].PartitionIndex];
+ RINOK(_stream->Seek(((UInt64)partition.Pos << SecLogSize) +
+ (UInt64)blockPos * vol.BlockSize, STREAM_SEEK_SET, NULL));
+ return ReadStream_FALSE(_stream, buf, len);
+}
+
+HRESULT CInArchive::Read(int volIndex, const CLongAllocDesc &lad, Byte *buf)
+{
+ return Read(volIndex, lad.Location.PartitionRef, lad.Location.Pos, lad.GetLen(), (Byte *)buf);
+}
+
+HRESULT CInArchive::ReadFromFile(int volIndex, const CItem &item, CByteBuffer &buf)
+{
+ if (item.Size >= (UInt32)1 << 30)
+ return S_FALSE;
+ buf.SetCapacity((size_t)item.Size);
+ size_t pos = 0;
+ for (int i = 0; i < item.Extents.Size(); i++)
+ {
+ const CMyExtent &e = item.Extents[i];
+ UInt32 len = e.GetLen();
+ RINOK(Read(volIndex, e.PartitionRef, e.Pos, len, (Byte *)buf + pos));
+ pos += len;
+ }
+ return S_OK;
+}
+
+
+void CIcbTag::Parse(const Byte *p)
+{
+ // PriorDirectNum = Get32(p);
+ // StrategyType = Get16(p + 4);
+ // StrategyParam = Get16(p + 6);
+ // MaxNumOfEntries = Get16(p + 8);
+ FileType = p[11];
+ // ParentIcb.Parse(p + 12);
+ Flags = Get16(p + 18);
+}
+
+void CItem::Parse(const Byte *p)
+{
+ // Uid = Get32(p + 36);
+ // Gid = Get32(p + 40);
+ // Permissions = Get32(p + 44);
+ // FileLinkCount = Get16(p + 48);
+ // RecordFormat = p[50];
+ // RecordDisplayAttr = p[51];
+ // RecordLen = Get32(p + 52);
+ Size = Get64(p + 56);
+ NumLogBlockRecorded = Get64(p + 64);
+ ATime.Parse(p + 72);
+ MTime.Parse(p + 84);
+ // AttrtTime.Parse(p + 96);
+ // CheckPoint = Get32(p + 108);
+ // ExtendedAttrIcb.Parse(p + 112);
+ // ImplId.Parse(p + 128);
+ // UniqueId = Get64(p + 160);
+}
+
+// 4/14.4
+struct CFileId
+{
+ // UInt16 FileVersion;
+ Byte FileCharacteristics;
+ // CByteBuffer ImplUse;
+ CDString Id;
+ CLongAllocDesc Icb;
+
+ bool IsItLinkParent() const { return (FileCharacteristics & FILEID_CHARACS_Parent) != 0; }
+ HRESULT Parse(const Byte *p, size_t size, size_t &processed);
+};
+
+HRESULT CFileId::Parse(const Byte *p, size_t size, size_t &processed)
+{
+ processed = 0;
+ if (size < 38)
+ return S_FALSE;
+ CTag tag;
+ RINOK(tag.Parse(p, size));
+ if (tag.Id != DESC_TYPE_FileId)
+ return S_FALSE;
+ // FileVersion = Get16(p + 16);
+ FileCharacteristics = p[18];
+ unsigned idLen = p[19];
+ Icb.Parse(p + 20);
+ unsigned impLen = Get16(p + 36);
+ if (size < 38 + idLen + impLen)
+ return S_FALSE;
+ // ImplUse.SetCapacity(impLen);
+ processed = 38;
+ // memcpy(ImplUse, p + processed, impLen);
+ processed += impLen;
+ Id.Parse(p + processed, idLen);
+ processed += idLen;
+ for (;(processed & 3) != 0; processed++)
+ if (p[processed] != 0)
+ return S_FALSE;
+ return (processed <= size) ? S_OK : S_FALSE;
+}
+
+HRESULT CInArchive::ReadFileItem(int volIndex, int fsIndex, const CLongAllocDesc &lad, int numRecurseAllowed)
+{
+ if (Files.Size() % 100 == 0)
+ RINOK(_progress->SetCompleted(Files.Size(), _processedProgressBytes));
+ if (numRecurseAllowed-- == 0)
+ return S_FALSE;
+ CFile &file = Files.Back();
+ const CLogVol &vol = LogVols[volIndex];
+ CPartition &partition = Partitions[vol.PartitionMaps[lad.Location.PartitionRef].PartitionIndex];
+
+ UInt32 key = lad.Location.Pos;
+ UInt32 value;
+ const UInt32 kRecursedErrorValue = (UInt32)(Int32)-1;
+ if (partition.Map.Find(key, value))
+ {
+ if (value == kRecursedErrorValue)
+ return S_FALSE;
+ file.ItemIndex = value;
+ }
+ else
+ {
+ value = Items.Size();
+ file.ItemIndex = (int)value;
+ if (partition.Map.Set(key, kRecursedErrorValue))
+ return S_FALSE;
+ RINOK(ReadItem(volIndex, fsIndex, lad, numRecurseAllowed));
+ if (!partition.Map.Set(key, value))
+ return S_FALSE;
+ }
+ return S_OK;
+}
+
+HRESULT CInArchive::ReadItem(int volIndex, int fsIndex, const CLongAllocDesc &lad, int numRecurseAllowed)
+{
+ if (Items.Size() > kNumItemsMax)
+ return S_FALSE;
+ Items.Add(CItem());
+ CItem &item = Items.Back();
+
+ const CLogVol &vol = LogVols[volIndex];
+
+ if (lad.GetLen() != vol.BlockSize)
+ return S_FALSE;
+
+ CByteBuffer buf;
+ size_t size = lad.GetLen();
+ buf.SetCapacity(size);
+ RINOK(Read(volIndex, lad, buf));
+
+ CTag tag;
+ const Byte *p = buf;
+ RINOK(tag.Parse(p, size));
+ if (tag.Id != DESC_TYPE_File)
+ return S_FALSE;
+
+ item.IcbTag.Parse(p + 16);
+ if (item.IcbTag.FileType != ICB_FILE_TYPE_DIR &&
+ item.IcbTag.FileType != ICB_FILE_TYPE_FILE)
+ return S_FALSE;
+
+ item.Parse(p);
+
+ _processedProgressBytes += (UInt64)item.NumLogBlockRecorded * vol.BlockSize + size;
+
+ UInt32 extendedAttrLen = Get32(p + 168);
+ UInt32 allocDescriptorsLen = Get32(p + 172);
+
+ if ((extendedAttrLen & 3) != 0)
+ return S_FALSE;
+ int pos = 176;
+ if (extendedAttrLen > size - pos)
+ return S_FALSE;
+ /*
+ if (extendedAttrLen != 16)
+ {
+ if (extendedAttrLen < 24)
+ return S_FALSE;
+ CTag attrTag;
+ RINOK(attrTag.Parse(p + pos, size));
+ if (attrTag.Id != DESC_TYPE_ExtendedAttrHeader)
+ return S_FALSE;
+ // UInt32 implAttrLocation = Get32(p + pos + 16);
+ // UInt32 applicationlAttrLocation = Get32(p + pos + 20);
+ }
+ */
+ pos += extendedAttrLen;
+
+ int desctType = item.IcbTag.GetDescriptorType();
+ // if (desctType == ICB_DESC_TYPE_INLINE || desctType == ICB_DESC_TYPE_EXTENDED)
+ if (desctType != ICB_DESC_TYPE_SHORT && desctType != ICB_DESC_TYPE_LONG)
+ return S_FALSE;
+ if (allocDescriptorsLen > size - pos)
+ return S_FALSE;
+ for (UInt32 i = 0; i < allocDescriptorsLen;)
+ {
+ CMyExtent e;
+ if (desctType == ICB_DESC_TYPE_SHORT)
+ {
+ if (i + 8 > allocDescriptorsLen)
+ return S_FALSE;
+ CShortAllocDesc sad;
+ sad.Parse(p + pos + i);
+ e.Pos = sad.Pos;
+ e.Len = sad.Len;
+ e.PartitionRef = lad.Location.PartitionRef;
+ i += 8;
+ }
+ else
+ {
+ if (i + 16 > allocDescriptorsLen)
+ return S_FALSE;
+ CLongAllocDesc ladNew;
+ ladNew.Parse(p + pos + i);
+ e.Pos = ladNew.Location.Pos;
+ e.PartitionRef = ladNew.Location.PartitionRef;
+ e.Len = ladNew.Len;
+ i += 16;
+ }
+ item.Extents.Add(e);
+ }
+
+ if (item.IcbTag.IsDir())
+ {
+ if (!item.CheckChunkSizes() || !CheckItemExtents(volIndex, item))
+ return S_FALSE;
+ CByteBuffer buf;
+ RINOK(ReadFromFile(volIndex, item, buf));
+ item.Size = 0;
+ item.Extents.ClearAndFree();
+
+ const Byte *p = buf;
+ size = buf.GetCapacity();
+ size_t processedTotal = 0;
+ for (; processedTotal < size;)
+ {
+ size_t processedCur;
+ CFileId fileId;
+ RINOK(fileId.Parse(p + processedTotal, size - processedTotal, processedCur));
+ if (!fileId.IsItLinkParent())
+ {
+ CFile file;
+ // file.FileVersion = fileId.FileVersion;
+ // file.FileCharacteristics = fileId.FileCharacteristics;
+ // file.ImplUse = fileId.ImplUse;
+ file.Id = fileId.Id;
+
+ _fileNameLengthTotal += file.Id.Data.GetCapacity();
+ if (_fileNameLengthTotal > kFileNameLengthTotalMax)
+ return S_FALSE;
+
+ item.SubFiles.Add(Files.Size());
+ if (Files.Size() > kNumFilesMax)
+ return S_FALSE;
+ Files.Add(file);
+ RINOK(ReadFileItem(volIndex, fsIndex, fileId.Icb, numRecurseAllowed));
+ }
+ processedTotal += processedCur;
+ }
+ }
+ else
+ {
+ if ((UInt32)item.Extents.Size() > kNumExtentsMax - _numExtents)
+ return S_FALSE;
+ _numExtents += item.Extents.Size();
+ }
+
+ return S_OK;
+}
+
+HRESULT CInArchive::FillRefs(CFileSet &fs, int fileIndex, int parent, int numRecurseAllowed)
+{
+ if (_numRefs % 10000 == 0)
+ {
+ RINOK(_progress->SetCompleted());
+ }
+ if (numRecurseAllowed-- == 0)
+ return S_FALSE;
+ if (_numRefs >= kNumRefsMax)
+ return S_FALSE;
+ _numRefs++;
+ CRef ref;
+ ref.FileIndex = fileIndex;
+ ref.Parent = parent;
+ parent = fs.Refs.Size();
+ fs.Refs.Add(ref);
+ const CItem &item = Items[Files[fileIndex].ItemIndex];
+ for (int i = 0; i < item.SubFiles.Size(); i++)
+ {
+ RINOK(FillRefs(fs, item.SubFiles[i], parent, numRecurseAllowed));
+ }
+ return S_OK;
+}
+
+HRESULT CInArchive::Open2()
+{
+ Clear();
+
+ UInt64 fileSize;
+ RINOK(_stream->Seek(0, STREAM_SEEK_END, &fileSize));
+
+ const int kSecLogSizeMax = 11;
+ const int kSecLogSizeMin = 8;
+ Byte buf[1 << kSecLogSizeMax];
+ for (SecLogSize = kSecLogSizeMax; SecLogSize >= kSecLogSizeMin; SecLogSize -= 3)
+ {
+ Int32 bufSize = 1 << SecLogSize;
+ if (bufSize > fileSize)
+ return S_FALSE;
+ RINOK(_stream->Seek(-bufSize, STREAM_SEEK_END, NULL));
+ RINOK(ReadStream_FALSE(_stream, buf, bufSize));
+ CTag tag;
+ if (tag.Parse(buf, bufSize) == S_OK)
+ if (tag.Id == DESC_TYPE_AnchorVolPtr)
+ break;
+ }
+ if (SecLogSize < kSecLogSizeMin)
+ return S_FALSE;
+
+ CExtent extentVDS;
+ extentVDS.Parse(buf + 16);
+
+ for (UInt32 location = extentVDS.Pos; ; location++)
+ {
+ size_t bufSize = 1 << SecLogSize;
+ size_t pos = 0;
+ RINOK(_stream->Seek((UInt64)location << SecLogSize, STREAM_SEEK_SET, NULL));
+ RINOK(ReadStream_FALSE(_stream, buf, bufSize));
+ CTag tag;
+ RINOK(tag.Parse(buf + pos, bufSize - pos));
+ if (tag.Id == DESC_TYPE_Terminating)
+ break;
+ if (tag.Id == DESC_TYPE_Partition)
+ {
+ if (Partitions.Size() >= kNumPartitionsMax)
+ return S_FALSE;
+ CPartition partition;
+ // UInt32 volDescSeqNumer = Get32(buf + 16);
+ // partition.Flags = Get16(buf + 20);
+ partition.Number = Get16(buf + 22);
+ // partition.ContentsId.Parse(buf + 24);
+
+ // memcpy(partition.ContentsUse, buf + 56, sizeof(partition.ContentsUse));
+ // ContentsUse is Partition Header Description.
+
+ // partition.AccessType = Get32(buf + 184);
+ partition.Pos = Get32(buf + 188);
+ partition.Len = Get32(buf + 192);
+ // partition.ImplId.Parse(buf + 196);
+ // memcpy(partition.ImplUse, buf + 228, sizeof(partition.ImplUse));
+
+ Partitions.Add(partition);
+ }
+ else if (tag.Id == DESC_TYPE_LogicalVol)
+ {
+ if (LogVols.Size() >= kNumLogVolumesMax)
+ return S_FALSE;
+ CLogVol vol;
+ vol.Id.Parse(buf + 84);
+ vol.BlockSize = Get32(buf + 212);
+ // vol.DomainId.Parse(buf + 216);
+
+ if (vol.BlockSize < 512 || vol.BlockSize > ((UInt32)1 << 30))
+ return S_FALSE;
+
+ // memcpy(vol.ContentsUse, buf + 248, sizeof(vol.ContentsUse));
+ vol.FileSetLocation.Parse(buf + 248);
+
+ // UInt32 mapTableLength = Get32(buf + 264);
+ UInt32 numPartitionMaps = Get32(buf + 268);
+ if (numPartitionMaps > kNumPartitionsMax)
+ return S_FALSE;
+ // vol.ImplId.Parse(buf + 272);
+ // memcpy(vol.ImplUse, buf + 128, sizeof(vol.ImplUse));
+ size_t pos = 440;
+ for (UInt32 i = 0; i < numPartitionMaps; i++)
+ {
+ if (pos + 2 > bufSize)
+ return S_FALSE;
+ CPartitionMap pm;
+ pm.Type = buf[pos];
+ // pm.Length = buf[pos + 1];
+ Byte len = buf[pos + 1];
+
+ if (pos + len > bufSize)
+ return S_FALSE;
+
+ // memcpy(pm.Data, buf + pos + 2, pm.Length - 2);
+ if (pm.Type == 1)
+ {
+ if (pos + 6 > bufSize)
+ return S_FALSE;
+ // pm.VolSeqNumber = Get16(buf + pos + 2);
+ pm.PartitionNumber = Get16(buf + pos + 4);
+ }
+ else
+ return S_FALSE;
+ pos += len;
+ vol.PartitionMaps.Add(pm);
+ }
+ LogVols.Add(vol);
+ }
+ }
+
+ UInt64 totalSize = 0;
+
+ int volIndex;
+ for (volIndex = 0; volIndex < LogVols.Size(); volIndex++)
+ {
+ CLogVol &vol = LogVols[volIndex];
+ for (int pmIndex = 0; pmIndex < vol.PartitionMaps.Size(); pmIndex++)
+ {
+ CPartitionMap &pm = vol.PartitionMaps[pmIndex];
+ int i;
+ for (i = 0; i < Partitions.Size(); i++)
+ {
+ CPartition &part = Partitions[i];
+ if (part.Number == pm.PartitionNumber)
+ {
+ if (part.VolIndex >= 0)
+ return S_FALSE;
+ pm.PartitionIndex = i;
+ part.VolIndex = volIndex;
+
+ totalSize += (UInt64)part.Len << SecLogSize;
+ break;
+ }
+ }
+ if (i == Partitions.Size())
+ return S_FALSE;
+ }
+ }
+
+ RINOK(_progress->SetTotal(totalSize));
+
+ for (volIndex = 0; volIndex < LogVols.Size(); volIndex++)
+ {
+ CLogVol &vol = LogVols[volIndex];
+
+ CLongAllocDesc nextExtent = vol.FileSetLocation;
+ // while (nextExtent.ExtentLen != 0)
+ // for (int i = 0; i < 1; i++)
+ {
+ if (nextExtent.GetLen() < 512)
+ return S_FALSE;
+ CByteBuffer buf;
+ buf.SetCapacity(nextExtent.GetLen());
+ RINOK(Read(volIndex, nextExtent, buf));
+ const Byte *p = buf;
+ size_t size = nextExtent.GetLen();
+
+ CTag tag;
+ RINOK(tag.Parse(p, size));
+ if (tag.Id != DESC_TYPE_FileSet)
+ return S_FALSE;
+
+ CFileSet fs;
+ fs.RecodringTime.Parse(p + 16);
+ // fs.InterchangeLevel = Get16(p + 18);
+ // fs.MaxInterchangeLevel = Get16(p + 20);
+ // fs.FileSetNumber = Get32(p + 40);
+ // fs.FileSetDescNumber = Get32(p + 44);
+
+ // fs.Id.Parse(p + 304);
+ // fs.CopyrightId.Parse(p + 336);
+ // fs.AbstractId.Parse(p + 368);
+
+ fs.RootDirICB.Parse(p + 400);
+ // fs.DomainId.Parse(p + 416);
+
+ // fs.SystemStreamDirICB.Parse(p + 464);
+
+ vol.FileSets.Add(fs);
+
+ // nextExtent.Parse(p + 448);
+ }
+
+ for (int fsIndex = 0; fsIndex < vol.FileSets.Size(); fsIndex++)
+ {
+ CFileSet &fs = vol.FileSets[fsIndex];
+ int fileIndex = Files.Size();
+ Files.Add(CFile());
+ RINOK(ReadFileItem(volIndex, fsIndex, fs.RootDirICB, kNumRecureseLevelsMax));
+ RINOK(FillRefs(fs, fileIndex, -1, kNumRecureseLevelsMax));
+ }
+ }
+
+ return S_OK;
+}
+
+HRESULT CInArchive::Open(IInStream *inStream, CProgressVirt *progress)
+{
+ _progress = progress;
+ _stream = inStream;
+ HRESULT res;
+ try { res = Open2(); }
+ catch(...) { Clear(); res = S_FALSE; }
+ _stream.Release();
+ return res;
+}
+
+void CInArchive::Clear()
+{
+ Partitions.Clear();
+ LogVols.Clear();
+ Items.Clear();
+ Files.Clear();
+ _fileNameLengthTotal = 0;
+ _numRefs = 0;
+ _numExtents = 0;
+ _processedProgressBytes = 0;
+}
+
+UString CInArchive::GetComment() const
+{
+ UString res;
+ for (int i = 0; i < LogVols.Size(); i++)
+ {
+ if (i > 0)
+ res += L" ";
+ res += LogVols[i].GetName();
+ }
+ return res;
+}
+
+static UString GetSpecName(const UString &name)
+{
+ UString name2 = name;
+ name2.Trim();
+ if (name2.IsEmpty())
+ {
+ /*
+ wchar_t s[32];
+ ConvertUInt64ToString(id, s);
+ return L"[" + (UString)s + L"]";
+ */
+ return L"[]";
+ }
+ return name;
+}
+
+static void UpdateWithName(UString &res, const UString &addString)
+{
+ if (res.IsEmpty())
+ res = addString;
+ else
+ res = addString + WCHAR_PATH_SEPARATOR + res;
+}
+
+UString CInArchive::GetItemPath(int volIndex, int fsIndex, int refIndex,
+ bool showVolName, bool showFsName) const
+{
+ // showVolName = true;
+ const CLogVol &vol = LogVols[volIndex];
+ const CFileSet &fs = vol.FileSets[fsIndex];
+
+ UString name;
+
+ for (;;)
+ {
+ const CRef &ref = fs.Refs[refIndex];
+ refIndex = ref.Parent;
+ if (refIndex < 0)
+ break;
+ UpdateWithName(name, GetSpecName(Files[ref.FileIndex].GetName()));
+ }
+
+ if (showFsName)
+ {
+ wchar_t s[32];
+ ConvertUInt64ToString(fsIndex, s);
+ UString newName = L"File Set ";
+ newName += s;
+ UpdateWithName(name, newName);
+ }
+
+ if (showVolName)
+ {
+ wchar_t s[32];
+ ConvertUInt64ToString(volIndex, s);
+ UString newName = s;
+ UString newName2 = vol.GetName();
+ if (newName2.IsEmpty())
+ newName2 = L"Volume";
+ newName += L'-';
+ newName += newName2;
+ UpdateWithName(name, newName);
+ }
+ return name;
+}
+
+}}
diff --git a/CPP/7zip/Archive/Udf/UdfIn.h b/CPP/7zip/Archive/Udf/UdfIn.h
new file mode 100755
index 00000000..f99991a0
--- /dev/null
+++ b/CPP/7zip/Archive/Udf/UdfIn.h
@@ -0,0 +1,368 @@
+// Archive/UdfIn.h -- UDF / ECMA-167
+
+#ifndef __ARCHIVE_UDF_IN_H
+#define __ARCHIVE_UDF_IN_H
+
+#include "Common/MyCom.h"
+#include "Common/IntToString.h"
+#include "Common/Buffer.h"
+#include "Common/MyString.h"
+#include "Common/MyMap.h"
+
+#include "../../IStream.h"
+
+namespace NArchive {
+namespace NUdf {
+
+// ---------- ECMA Part 1 ----------
+
+// ECMA 1/7.2.12
+
+/*
+struct CDString32
+{
+ Byte Data[32];
+ void Parse(const Byte *buf);
+ // UString GetString() const;
+};
+*/
+
+struct CDString128
+{
+ Byte Data[128];
+ void Parse(const Byte *buf);
+ UString GetString() const;
+};
+
+struct CDString
+{
+ CByteBuffer Data;
+ void Parse(const Byte *p, unsigned size);
+ UString GetString() const;
+};
+
+
+// ECMA 1/7.3
+
+struct CTime
+{
+ Byte Data[12];
+
+ unsigned GetType() const { return Data[1] >> 4; }
+ bool IsLocal() const { return GetType() == 1; }
+ int GetMinutesOffset() const
+ {
+ int t = (Data[0] | ((UInt16)Data[1] << 8)) & 0xFFF;
+ if ((t >> 11) != 0)
+ t -= (1 << 12);
+ return (t > (60 * 24) || t < -(60 * 24)) ? 0 : t;
+ }
+ unsigned GetYear() const { return (Data[2] | ((UInt16)Data[3] << 8)); }
+ void Parse(const Byte *buf);
+};
+
+
+// ECMA 1/7.4
+
+/*
+struct CRegId
+{
+ Byte Flags;
+ char Id[23];
+ char Suffix[8];
+
+ void Parse(const Byte *buf);
+};
+*/
+
+// ---------- ECMA Part 3: Volume Structure ----------
+
+// ECMA 3/10.5
+
+struct CPartition
+{
+ // UInt16 Flags;
+ UInt16 Number;
+ // CRegId ContentsId;
+ // Byte ContentsUse[128];
+ // UInt32 AccessType;
+
+ UInt32 Pos;
+ UInt32 Len;
+
+ // CRegId ImplId;
+ // Byte ImplUse[128];
+
+ int VolIndex;
+ CMap32 Map;
+
+ CPartition(): VolIndex(-1) {}
+
+ // bool IsNsr() const { return (strncmp(ContentsId.Id, "+NSR0", 5) == 0); }
+ // bool IsAllocated() const { return ((Flags & 1) != 0); }
+};
+
+struct CLogBlockAddr
+{
+ UInt32 Pos;
+ UInt16 PartitionRef;
+
+ void Parse(const Byte *buf);
+};
+
+enum EShortAllocDescType
+{
+ SHORT_ALLOC_DESC_TYPE_RecordedAndAllocated = 0,
+ SHORT_ALLOC_DESC_TYPE_NotRecordedButAllocated = 1,
+ SHORT_ALLOC_DESC_TYPE_NotRecordedAndNotAllocated = 2,
+ SHORT_ALLOC_DESC_TYPE_NextExtent = 3
+};
+
+struct CShortAllocDesc
+{
+ UInt32 Len;
+ UInt32 Pos;
+
+ // 4/14.14.1
+ // UInt32 GetLen() const { return Len & 0x3FFFFFFF; }
+ // UInt32 GetType() const { return Len >> 30; }
+ // bool IsRecAndAlloc() const { return GetType() == SHORT_ALLOC_DESC_TYPE_RecordedAndAllocated; }
+ void Parse(const Byte *buf);
+};
+
+/*
+struct CADImpUse
+{
+ UInt16 Flags;
+ UInt32 UdfUniqueId;
+ void Parse(const Byte *buf);
+};
+*/
+
+struct CLongAllocDesc
+{
+ UInt32 Len;
+ CLogBlockAddr Location;
+
+ // Byte ImplUse[6];
+ // CADImpUse adImpUse; // UDF
+
+ UInt32 GetLen() const { return Len & 0x3FFFFFFF; }
+ UInt32 GetType() const { return Len >> 30; }
+ bool IsRecAndAlloc() const { return GetType() == SHORT_ALLOC_DESC_TYPE_RecordedAndAllocated; }
+ void Parse(const Byte *buf);
+};
+
+struct CPartitionMap
+{
+ Byte Type;
+ // Byte Len;
+
+ // Type - 1
+ // UInt16 VolSeqNumber;
+ UInt16 PartitionNumber;
+
+ // Byte Data[256];
+
+ int PartitionIndex;
+};
+
+enum EIcbFileType
+{
+ ICB_FILE_TYPE_DIR = 4,
+ ICB_FILE_TYPE_FILE = 5
+};
+
+enum EIcbDescriptorType
+{
+ ICB_DESC_TYPE_SHORT = 0,
+ ICB_DESC_TYPE_LONG = 1,
+ ICB_DESC_TYPE_EXTENDED = 2,
+ ICB_DESC_TYPE_INLINE = 3
+};
+
+struct CIcbTag
+{
+ // UInt32 PriorDirectNum;
+ // UInt16 StrategyType;
+ // UInt16 StrategyParam;
+ // UInt16 MaxNumOfEntries;
+ Byte FileType;
+ // CLogBlockAddr ParentIcb;
+ UInt16 Flags;
+
+ bool IsDir() const { return FileType == ICB_FILE_TYPE_DIR; }
+ int GetDescriptorType() const { return Flags & 3; }
+ void Parse(const Byte *p);
+};
+
+// const Byte FILEID_CHARACS_Existance = (1 << 0);
+const Byte FILEID_CHARACS_Parent = (1 << 3);
+
+struct CFile
+{
+ // UInt16 FileVersion;
+ // Byte FileCharacteristics;
+ // CByteBuffer ImplUse;
+ CDString Id;
+
+ CFile(): /* FileVersion(0), FileCharacteristics(0), */ ItemIndex(-1) {}
+ int ItemIndex;
+ UString GetName() const { return Id.GetString(); }
+};
+
+struct CMyExtent
+{
+ UInt32 Pos;
+ UInt32 Len;
+ int PartitionRef;
+
+ UInt32 GetLen() const { return Len & 0x3FFFFFFF; }
+ UInt32 GetType() const { return Len >> 30; }
+ bool IsRecAndAlloc() const { return GetType() == SHORT_ALLOC_DESC_TYPE_RecordedAndAllocated; }
+};
+
+struct CItem
+{
+ CIcbTag IcbTag;
+
+ // UInt32 Uid;
+ // UInt32 Gid;
+ // UInt32 Permissions;
+ // UInt16 FileLinkCount;
+ // Byte RecordFormat;
+ // Byte RecordDisplayAttr;
+ // UInt32 RecordLen;
+ UInt64 Size;
+ UInt64 NumLogBlockRecorded;
+ CTime ATime;
+ CTime MTime;
+ // CTime AttrtTime;
+ // UInt32 CheckPoint;
+ // CLongAllocDesc ExtendedAttrIcb;
+ // CRegId ImplId;
+ // UInt64 UniqueId;
+
+ CRecordVector<CMyExtent> Extents;
+ CRecordVector<int> SubFiles;
+
+ void Parse(const Byte *buf);
+
+ bool IsRecAndAlloc() const
+ {
+ for (int i = 0; i < Extents.Size(); i++)
+ if (!Extents[i].IsRecAndAlloc())
+ return false;
+ return true;
+ }
+
+ UInt64 GetChunksSumSize() const
+ {
+ UInt64 size = 0;
+ for (int i = 0; i < Extents.Size(); i++)
+ size += Extents[i].GetLen();
+ return size;
+ }
+
+ bool CheckChunkSizes() const { return GetChunksSumSize() == Size; }
+
+ bool IsDir() const { return IcbTag.IsDir(); }
+};
+
+struct CRef
+{
+ int Parent;
+ int FileIndex;
+};
+
+
+// ECMA 4 / 14.1
+struct CFileSet
+{
+ CTime RecodringTime;
+ // UInt16 InterchangeLevel;
+ // UInt16 MaxInterchangeLevel;
+ // UInt32 FileSetNumber;
+ // UInt32 FileSetDescNumber;
+ // CDString32 Id;
+ // CDString32 CopyrightId;
+ // CDString32 AbstractId;
+
+ CLongAllocDesc RootDirICB;
+ // CRegId DomainId;
+ // CLongAllocDesc SystemStreamDirICB;
+
+ CRecordVector<CRef> Refs;
+};
+
+
+// ECMA 3/10.6
+
+struct CLogVol
+{
+ CDString128 Id;
+ UInt32 BlockSize;
+ // CRegId DomainId;
+
+ // Byte ContentsUse[16];
+ CLongAllocDesc FileSetLocation; // UDF
+
+ // CRegId ImplId;
+ // Byte ImplUse[128];
+
+ CObjectVector<CPartitionMap> PartitionMaps;
+ CObjectVector<CFileSet> FileSets;
+
+ UString GetName() const { return Id.GetString(); }
+};
+
+struct CProgressVirt
+{
+ virtual HRESULT SetTotal(UInt64 numBytes) PURE;
+ virtual HRESULT SetCompleted(UInt64 numFiles, UInt64 numBytes) PURE;
+ virtual HRESULT SetCompleted() PURE;
+};
+
+class CInArchive
+{
+ CMyComPtr<IInStream> _stream;
+ CProgressVirt *_progress;
+
+ HRESULT Read(int volIndex, int partitionRef, UInt32 blockPos, UInt32 len, Byte *buf);
+ HRESULT Read(int volIndex, const CLongAllocDesc &lad, Byte *buf);
+ HRESULT ReadFromFile(int volIndex, const CItem &item, CByteBuffer &buf);
+
+ HRESULT ReadFileItem(int volIndex, int fsIndex, const CLongAllocDesc &lad, int numRecurseAllowed);
+ HRESULT ReadItem(int volIndex, int fsIndex, const CLongAllocDesc &lad, int numRecurseAllowed);
+
+ HRESULT Open2();
+ HRESULT FillRefs(CFileSet &fs, int fileIndex, int parent, int numRecurseAllowed);
+
+ UInt64 _processedProgressBytes;
+
+ UInt64 _fileNameLengthTotal;
+ int _numRefs;
+ UInt32 _numExtents;
+ bool CheckExtent(int volIndex, int partitionRef, UInt32 blockPos, UInt32 len) const;
+public:
+ HRESULT Open(IInStream *inStream, CProgressVirt *progress);
+ void Clear();
+
+ CObjectVector<CPartition> Partitions;
+ CObjectVector<CLogVol> LogVols;
+
+ CObjectVector<CItem> Items;
+ CObjectVector<CFile> Files;
+
+ int SecLogSize;
+
+ UString GetComment() const;
+ UString GetItemPath(int volIndex, int fsIndex, int refIndex,
+ bool showVolName, bool showFsName) const;
+
+ bool CheckItemExtents(int volIndex, const CItem &item) const;
+};
+
+}}
+
+#endif
diff --git a/CPP/7zip/Archive/Udf/UdfRegister.cpp b/CPP/7zip/Archive/Udf/UdfRegister.cpp
new file mode 100755
index 00000000..b3a6c152
--- /dev/null
+++ b/CPP/7zip/Archive/Udf/UdfRegister.cpp
@@ -0,0 +1,13 @@
+// UdfRegister.cpp
+
+#include "StdAfx.h"
+
+#include "../../Common/RegisterArc.h"
+
+#include "UdfHandler.h"
+static IInArchive *CreateArc() { return new NArchive::NUdf::CHandler; }
+
+static CArcInfo g_ArcInfo =
+ { L"Udf", L"iso", 0, 0xE0, { 0, 'N', 'S', 'R', '0' }, 5, false, CreateArc, 0 };
+
+REGISTER_ARC(Udf)
diff --git a/CPP/7zip/Archive/Wim/WimHandler.cpp b/CPP/7zip/Archive/Wim/WimHandler.cpp
index baa2c824..1b8661c9 100755
--- a/CPP/7zip/Archive/Wim/WimHandler.cpp
+++ b/CPP/7zip/Archive/Wim/WimHandler.cpp
@@ -5,14 +5,22 @@
#include "Common/IntToString.h"
#include "Common/Defs.h"
#include "Common/ComTry.h"
+#include "Common/StringToInt.h"
+#include "Common/UTFConvert.h"
#include "Windows/PropVariant.h"
#include "../../Common/StreamUtils.h"
#include "../../Common/ProgressUtils.h"
+#include "../../../../C/CpuArch.h"
+
#include "WimHandler.h"
+#define Get16(p) GetUi16(p)
+#define Get32(p) GetUi32(p)
+#define Get64(p) GetUi64(p)
+
using namespace NWindows;
namespace NArchive {
@@ -20,17 +28,17 @@ namespace NWim {
#define WIM_DETAILS
-STATPROPSTG kProps[] =
+STATPROPSTG kProps[] =
{
{ NULL, kpidPath, VT_BSTR},
- { NULL, kpidIsFolder, VT_BOOL},
+ { NULL, kpidIsDir, VT_BOOL},
{ NULL, kpidSize, VT_UI8},
- { NULL, kpidPackedSize, VT_UI8},
- { NULL, kpidAttributes, VT_UI8},
+ { NULL, kpidPackSize, VT_UI8},
+ { NULL, kpidAttrib, VT_UI4},
{ NULL, kpidMethod, VT_BSTR},
- { NULL, kpidCreationTime, VT_FILETIME},
- { NULL, kpidLastAccessTime, VT_FILETIME},
- { NULL, kpidLastWriteTime, VT_FILETIME}
+ { NULL, kpidMTime, VT_FILETIME},
+ { NULL, kpidCTime, VT_FILETIME},
+ { NULL, kpidATime, VT_FILETIME}
#ifdef WIM_DETAILS
, { NULL, kpidVolume, VT_UI4}
@@ -39,17 +47,113 @@ STATPROPSTG kProps[] =
#endif
};
-STATPROPSTG kArcProps[] =
+STATPROPSTG kArcProps[] =
{
{ NULL, kpidSize, VT_UI8},
- { NULL, kpidPackedSize, VT_UI8},
+ { NULL, kpidPackSize, VT_UI8},
+ { NULL, kpidMethod, VT_BSTR},
+ { NULL, kpidCTime, VT_FILETIME},
+ { NULL, kpidMTime, VT_FILETIME},
+ { NULL, kpidComment, VT_FILETIME},
{ NULL, kpidIsVolume, VT_BOOL},
{ NULL, kpidVolume, VT_UI4},
{ NULL, kpidNumVolumes, VT_UI4}
};
+static bool ParseNumber64(const AString &s, UInt64 &res)
+{
+ const char *end;
+ if (s.Left(2) == "0x")
+ {
+ if (s.Length() == 2)
+ return false;
+ res = ConvertHexStringToUInt64((const char *)s + 2, &end);
+ }
+ else
+ {
+ if (s.IsEmpty())
+ return false;
+ res = ConvertStringToUInt64(s, &end);
+ }
+ return *end == 0;
+}
+
+static bool ParseNumber32(const AString &s, UInt32 &res)
+{
+ UInt64 res64;
+ if (!ParseNumber64(s, res64) || res64 >= ((UInt64)1 << 32))
+ return false;
+ res = (UInt32)res64;
+ return true;
+}
+
+void ParseTime(const CXmlItem &item, bool &defined, FILETIME &ft, const AString &s)
+{
+ defined = false;
+ int cTimeIndex = item.FindSubTag(s);
+ if (cTimeIndex >= 0)
+ {
+ const CXmlItem &timeItem = item.SubItems[cTimeIndex];
+ UInt32 high = 0, low = 0;
+ if (ParseNumber32(timeItem.GetSubStringForTag("HIGHPART"), high) &&
+ ParseNumber32(timeItem.GetSubStringForTag("LOWPART"), low))
+ {
+ defined = true;
+ ft.dwHighDateTime = high;
+ ft.dwLowDateTime = low;
+ }
+ }
+}
+
+void CImageInfo::Parse(const CXmlItem &item)
+{
+ ParseTime(item, CTimeDefined, CTime, "CREATIONTIME");
+ ParseTime(item, MTimeDefined, MTime, "LASTMODIFICATIONTIME");
+ NameDefined = ConvertUTF8ToUnicode(item.GetSubStringForTag("NAME"), Name);
+ // IndexDefined = ParseNumber32(item.GetPropertyValue("INDEX"), Index);
+}
+
+void CXml::Parse()
+{
+ size_t size = Data.GetCapacity();
+ if (size < 2 || (size & 1) != 0 || (size > 1 << 24))
+ return;
+ const Byte *p = Data;
+ if (Get16(p) != 0xFEFF)
+ return;
+ UString s;
+ {
+ wchar_t *chars = s.GetBuffer((int)size / 2 + 1);
+ for (size_t i = 2; i < size; i += 2)
+ *chars++ = (wchar_t)Get16(p + i);
+ *chars = 0;
+ s.ReleaseBuffer();
+ }
+
+ AString utf;
+ if (!ConvertUnicodeToUTF8(s, utf))
+ return;
+ ::CXml xml;
+ if (!xml.Parse(utf))
+ return;
+ if (xml.Root.Name != "WIM")
+ return;
+
+ for (int i = 0; i < xml.Root.SubItems.Size(); i++)
+ {
+ const CXmlItem &item = xml.Root.SubItems[i];
+ if (item.IsTagged("IMAGE"))
+ {
+ CImageInfo imageInfo;
+ imageInfo.Parse(item);
+ Images.Add(imageInfo);
+ }
+ }
+}
+
static const wchar_t *kStreamsNamePrefix = L"Files" WSTRING_PATH_SEPARATOR;
static const wchar_t *kMethodLZX = L"LZX";
+static const wchar_t *kMethodXpress = L"XPress";
static const wchar_t *kMethodCopy = L"Copy";
IMP_IInArchive_Props
@@ -59,11 +163,57 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
{
COM_TRY_BEGIN
NWindows::NCOM::CPropVariant prop;
+
+ const CImageInfo *image = NULL;
+ if (m_Xmls.Size() == 1)
+ {
+ const CXml &xml = m_Xmls[0];
+ if (xml.Images.Size() == 1)
+ image = &xml.Images[0];
+ }
+
switch(propID)
{
case kpidSize: prop = m_Database.GetUnpackSize(); break;
- case kpidPackedSize: prop = m_Database.GetPackSize(); break;
- case kpidIsVolume:
+ case kpidPackSize: prop = m_Database.GetPackSize(); break;
+
+ case kpidCTime:
+ if (m_Xmls.Size() == 1)
+ {
+ const CXml &xml = m_Xmls[0];
+ int index = -1;
+ for (int i = 0; i < xml.Images.Size(); i++)
+ {
+ const CImageInfo &image = xml.Images[i];
+ if (image.CTimeDefined)
+ if (index < 0 || ::CompareFileTime(&image.CTime, &xml.Images[index].CTime) < 0)
+ index = i;
+ }
+ if (index >= 0)
+ prop = xml.Images[index].CTime;
+ }
+ break;
+
+ case kpidMTime:
+ if (m_Xmls.Size() == 1)
+ {
+ const CXml &xml = m_Xmls[0];
+ int index = -1;
+ for (int i = 0; i < xml.Images.Size(); i++)
+ {
+ const CImageInfo &image = xml.Images[i];
+ if (image.MTimeDefined)
+ if (index < 0 || ::CompareFileTime(&image.MTime, &xml.Images[index].MTime) > 0)
+ index = i;
+ }
+ if (index >= 0)
+ prop = xml.Images[index].MTime;
+ }
+ break;
+
+ case kpidComment: if (image != NULL && image->NameDefined) prop = image->Name; break;
+
+ case kpidIsVolume:
if (m_Xmls.Size() > 0)
{
UInt16 volIndex = m_Xmls[0].VolIndex;
@@ -71,7 +221,7 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
prop = (m_Volumes[volIndex].Header.NumParts > 1);
}
break;
- case kpidVolume:
+ case kpidVolume:
if (m_Xmls.Size() > 0)
{
UInt16 volIndex = m_Xmls[0].VolIndex;
@@ -79,7 +229,39 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
prop = (UInt32)m_Volumes[volIndex].Header.PartNumber;
}
break;
- case kpidNumVolumes: if (m_Volumes.Size() > 0) prop = (UInt32)(m_Volumes.Size() - 1);
+ case kpidNumVolumes: if (m_Volumes.Size() > 0) prop = (UInt32)(m_Volumes.Size() - 1); break;
+ case kpidMethod:
+ {
+ bool lzx = false, xpress = false, copy = false;
+ for (int i = 0; i < m_Xmls.Size(); i++)
+ {
+ const CVolume &vol = m_Volumes[m_Xmls[i].VolIndex];
+ const CHeader &header = vol.Header;
+ if (header.IsCompressed())
+ if (header.IsLzxMode())
+ lzx = true;
+ else
+ xpress = true;
+ else
+ copy = true;
+ }
+ UString res;
+ if (lzx)
+ res = kMethodLZX;
+ if (xpress)
+ {
+ if (!res.IsEmpty())
+ res += L' ';
+ res += kMethodXpress;
+ }
+ if (copy)
+ {
+ if (!res.IsEmpty())
+ res += L' ';
+ res += kMethodCopy;
+ }
+ prop = res;
+ }
}
prop.Detach(value);
return S_OK;
@@ -94,8 +276,12 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
{
const CItem &item = m_Database.Items[index];
const CStreamInfo *si = NULL;
+ const CVolume *vol = NULL;
if (item.StreamIndex >= 0)
+ {
si = &m_Database.Streams[item.StreamIndex];
+ vol = &m_Volumes[si->PartNumber];
+ }
switch(propID)
{
@@ -114,59 +300,19 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
break;
}
break;
- case kpidIsFolder:
- prop = item.IsDirectory();
- break;
- case kpidAttributes:
- if (item.HasMetadata)
- prop = item.Attributes;
- break;
- case kpidCreationTime:
- if (item.HasMetadata)
- prop = item.CreationTime;
- break;
- case kpidLastAccessTime:
- if (item.HasMetadata)
- prop = item.LastAccessTime;
- break;
- case kpidLastWriteTime:
- if (item.HasMetadata)
- prop = item.LastWriteTime;
- break;
- case kpidPackedSize:
- if (si)
- prop = si->Resource.PackSize;
- else
- prop = (UInt64)0;
- break;
- case kpidSize:
- if (si)
- prop = si->Resource.UnpackSize;
- else
- prop = (UInt64)0;
- break;
- case kpidMethod:
- if (si)
- if (si->Resource.IsCompressed())
- prop = kMethodLZX;
- else
- prop = kMethodCopy;
- break;
+ case kpidIsDir: prop = item.isDir(); break;
+ case kpidAttrib: if (item.HasMetadata) prop = item.Attrib; break;
+ case kpidCTime: if (item.HasMetadata) prop = item.CTime; break;
+ case kpidATime: if (item.HasMetadata) prop = item.ATime; break;
+ case kpidMTime: if (item.HasMetadata) prop = item.MTime; break;
+ case kpidPackSize: prop = si ? si->Resource.PackSize : (UInt64)0; break;
+ case kpidSize: prop = si ? si->Resource.UnpackSize : (UInt64)0; break;
+ case kpidMethod: if (si) prop = si->Resource.IsCompressed() ?
+ (vol->Header.IsLzxMode() ? kMethodLZX : kMethodXpress) : kMethodCopy; break;
#ifdef WIM_DETAILS
- case kpidVolume:
- if (si)
- prop = (UInt32)si->PartNumber;
- break;
- case kpidOffset:
- if (si)
- prop = (UInt64)si->Resource.Offset;
- break;
- case kpidLinks:
- if (si)
- prop = (UInt32)si->RefCount;
- else
- prop = (UInt64)0;
- break;
+ case kpidVolume: if (si) prop = (UInt32)si->PartNumber; break;
+ case kpidOffset: if (si) prop = (UInt64)si->Resource.Offset; break;
+ case kpidLinks: prop = si ? (UInt32)si->RefCount : (UInt32)0; break;
#endif
}
}
@@ -184,16 +330,10 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
prop = s;
break;
}
- case kpidIsFolder:
- prop = false;
- break;
- case kpidPackedSize:
- case kpidSize:
- prop = (UInt64)m_Xmls[index].Data.GetCapacity();
- break;
- case kpidMethod:
- prop = L"Copy";
- break;
+ case kpidIsDir: prop = false; break;
+ case kpidPackSize:
+ case kpidSize: prop = (UInt64)m_Xmls[index].Data.GetCapacity(); break;
+ case kpidMethod: prop = L"Copy"; break;
}
}
}
@@ -206,7 +346,7 @@ class CVolumeName
{
// UInt32 _volIndex;
UString _before;
- UString _after;
+ UString _after;
public:
CVolumeName() {};
@@ -228,7 +368,7 @@ public:
}
};
-STDMETHODIMP CHandler::Open(IInStream *inStream,
+STDMETHODIMP CHandler::Open(IInStream *inStream,
const UInt64 * /* maxCheckStartPosition */,
IArchiveOpenCallback *openArchiveCallback)
{
@@ -300,7 +440,10 @@ STDMETHODIMP CHandler::Open(IInStream *inStream,
if (xml.Data == m_Xmls[0].Data)
needAddXml = false;
if (needAddXml)
+ {
+ xml.Parse();
m_Xmls.Add(xml);
+ }
if (i == 1)
{
@@ -398,7 +541,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
RINOK(lps->SetCur());
UInt32 index = allFilesMode ? i : indices[i];
i++;
- Int32 askMode = testMode ?
+ Int32 askMode = testMode ?
NExtract::NAskMode::kTest :
NExtract::NAskMode::kExtract;
@@ -428,7 +571,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
continue;
RINOK(extractCallback->PrepareOperation(askMode));
realOutStream.Release();
- RINOK(extractCallback->SetOperationResult(item.HasStream() ?
+ RINOK(extractCallback->SetOperationResult(item.HasStream() ?
NExtract::NOperationResult::kDataError :
NExtract::NOperationResult::kOK));
continue;
@@ -445,7 +588,9 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
if (streamIndex != prevSuccessStreamIndex || realOutStream)
{
Byte digest[20];
- HRESULT res = unpacker.Unpack(m_Volumes[si.PartNumber].Stream, si.Resource, realOutStream, progress, digest);
+ const CVolume &vol = m_Volumes[si.PartNumber];
+ HRESULT res = unpacker.Unpack(vol.Stream, si.Resource, vol.Header.IsLzxMode(),
+ realOutStream, progress, digest);
if (res == S_OK)
{
if (memcmp(digest, si.Hash, kHashSize) == 0)
diff --git a/CPP/7zip/Archive/Wim/WimHandler.h b/CPP/7zip/Archive/Wim/WimHandler.h
index 25567743..b7df3606 100755
--- a/CPP/7zip/Archive/Wim/WimHandler.h
+++ b/CPP/7zip/Archive/Wim/WimHandler.h
@@ -4,6 +4,8 @@
#define __ARCHIVE_WIM_HANDLER_H
#include "Common/MyCom.h"
+#include "Common/MyXml.h"
+
#include "../IArchive.h"
#include "WimIn.h"
@@ -16,13 +18,35 @@ struct CVolume
CMyComPtr<IInStream> Stream;
};
+struct CImageInfo
+{
+ bool CTimeDefined;
+ bool MTimeDefined;
+ bool NameDefined;
+ // bool IndexDefined;
+
+ FILETIME CTime;
+ FILETIME MTime;
+ UString Name;
+ // UInt32 Index;
+
+ CImageInfo(): CTimeDefined(false), MTimeDefined(false), NameDefined(false)
+ // , IndexDefined(false)
+ {}
+ void Parse(const CXmlItem &item);
+};
+
struct CXml
{
CByteBuffer Data;
UInt16 VolIndex;
+
+ CObjectVector<CImageInfo> Images;
+
+ void Parse();
};
-class CHandler:
+class CHandler:
public IInArchive,
public CMyUnknownImp
{
diff --git a/CPP/7zip/Archive/Wim/WimIn.cpp b/CPP/7zip/Archive/Wim/WimIn.cpp
index e9efdaa4..5c741f8f 100755
--- a/CPP/7zip/Archive/Wim/WimIn.cpp
+++ b/CPP/7zip/Archive/Wim/WimIn.cpp
@@ -15,19 +15,127 @@
#include "WimIn.h"
+#define Get16(p) GetUi16(p)
+#define Get32(p) GetUi32(p)
+#define Get64(p) GetUi64(p)
+
namespace NArchive{
namespace NWim{
static const int kChunkSizeBits = 15;
static const UInt32 kChunkSize = (1 << kChunkSizeBits);
+namespace NXpress {
+
+class CDecoderFlusher
+{
+ CDecoder *m_Decoder;
+public:
+ bool NeedFlush;
+ CDecoderFlusher(CDecoder *decoder): m_Decoder(decoder), NeedFlush(true) {}
+ ~CDecoderFlusher()
+ {
+ if (NeedFlush)
+ m_Decoder->Flush();
+ m_Decoder->ReleaseStreams();
+ }
+};
+
+HRESULT CDecoder::CodeSpec(UInt32 outSize)
+{
+ {
+ Byte levels[kMainTableSize];
+ for (int i = 0; i < kMainTableSize; i += 2)
+ {
+ Byte b = m_InBitStream.DirectReadByte();
+ levels[i] = b & 0xF;
+ levels[i + 1] = b >> 4;
+ }
+ if (!m_MainDecoder.SetCodeLengths(levels))
+ return S_FALSE;
+ }
+
+ while (outSize > 0)
+ {
+ UInt32 number = m_MainDecoder.DecodeSymbol(&m_InBitStream);
+ if (number < 256)
+ {
+ m_OutWindowStream.PutByte((Byte)number);
+ outSize--;
+ }
+ else
+ {
+ if (number >= kMainTableSize)
+ return S_FALSE;
+ UInt32 posLenSlot = number - 256;
+ UInt32 posSlot = posLenSlot / kNumLenSlots;
+ UInt32 len = posLenSlot % kNumLenSlots;
+ UInt32 distance = (1 << posSlot) - 1 + m_InBitStream.ReadBits(posSlot);
+
+ if (len == kNumLenSlots - 1)
+ {
+ len = m_InBitStream.DirectReadByte();
+ if (len == 0xFF)
+ {
+ len = m_InBitStream.DirectReadByte();
+ len |= (UInt32)m_InBitStream.DirectReadByte() << 8;
+ }
+ else
+ len += kNumLenSlots - 1;
+ }
+
+ len += kMatchMinLen;
+ UInt32 locLen = (len <= outSize ? len : outSize);
+
+ if (!m_OutWindowStream.CopyBlock(distance, locLen))
+ return S_FALSE;
+
+ len -= locLen;
+ outSize -= locLen;
+ if (len != 0)
+ return S_FALSE;
+ }
+ }
+ return S_OK;
+}
+
+const UInt32 kDictSize = (1 << kNumPosSlots);
+
+HRESULT CDecoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream, UInt32 outSize)
+{
+ if (!m_OutWindowStream.Create(kDictSize) || !m_InBitStream.Create(1 << 16))
+ return E_OUTOFMEMORY;
+
+ CDecoderFlusher flusher(this);
+
+ m_InBitStream.SetStream(inStream);
+ m_OutWindowStream.SetStream(outStream);
+ m_InBitStream.Init();
+ m_OutWindowStream.Init(false);
+
+ RINOK(CodeSpec(outSize));
+
+ flusher.NeedFlush = false;
+ return Flush();
+}
+
+HRESULT CDecoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream, UInt32 outSize)
+{
+ try { return CodeReal(inStream, outStream, outSize); }
+ catch(const CInBufferException &e) { return e.ErrorCode; } \
+ catch(const CLZOutWindowException &e) { return e.ErrorCode; }
+ catch(...) { return S_FALSE; }
+}
+
+}
+
static void GetFileTimeFromMem(const Byte *p, FILETIME *ft)
{
- ft->dwLowDateTime = GetUi32(p);
- ft->dwHighDateTime = GetUi32(p + 4);
+ ft->dwLowDateTime = Get32(p);
+ ft->dwHighDateTime = Get32(p + 4);
}
-HRESULT CUnpacker::Unpack(IInStream *inStream, const CResource &resource,
+HRESULT CUnpacker::Unpack(IInStream *inStream, const CResource &resource, bool lzxMode,
ISequentialOutStream *outStream, ICompressProgressInfo *progress)
{
RINOK(inStream->Seek(resource.Offset, STREAM_SEEK_SET, NULL));
@@ -64,7 +172,7 @@ HRESULT CUnpacker::Unpack(IInStream *inStream, const CResource &resource,
RINOK(ReadStream_FALSE(inStream, (Byte *)sizesBuf, sizesBufSize));
const Byte *p = (const Byte *)sizesBuf;
- if (!lzxDecoder)
+ if (lzxMode && !lzxDecoder)
{
lzxDecoderSpec = new NCompress::NLzx::CDecoder(true);
lzxDecoder = lzxDecoderSpec;
@@ -78,18 +186,12 @@ HRESULT CUnpacker::Unpack(IInStream *inStream, const CResource &resource,
UInt64 offset = 0;
if (i > 0)
{
- if (entrySize == 4)
- offset = GetUi32(p);
- else
- offset = GetUi64(p);
+ offset = (entrySize == 4) ? Get32(p): Get64(p);
p += entrySize;
}
UInt64 nextOffset = resource.PackSize - sizesBufSize64;
if (i + 1 < (UInt32)numChunks)
- if (entrySize == 4)
- nextOffset = GetUi32(p);
- else
- nextOffset = GetUi64(p);
+ nextOffset = (entrySize == 4) ? Get32(p): Get64(p);
if (nextOffset < offset)
return S_FALSE;
@@ -106,28 +208,41 @@ HRESULT CUnpacker::Unpack(IInStream *inStream, const CResource &resource,
if (outProcessed + outSize > resource.UnpackSize)
outSize = (UInt32)(resource.UnpackSize - outProcessed);
UInt64 outSize64 = outSize;
- lzxDecoderSpec->SetKeepHistory(false);
- ICompressCoder *coder = (inSize == outSize) ? copyCoder : lzxDecoder;
- RINOK(coder->Code(limitedStreamSpec, outStream, NULL, &outSize64, NULL));
+ if (inSize == outSize)
+ {
+ RINOK(copyCoder->Code(limitedStreamSpec, outStream, NULL, &outSize64, NULL));
+ }
+ else
+ {
+ if (lzxMode)
+ {
+ lzxDecoderSpec->SetKeepHistory(false);
+ RINOK(lzxDecoder->Code(limitedStreamSpec, outStream, NULL, &outSize64, NULL));
+ }
+ else
+ {
+ RINOK(xpressDecoder.Code(limitedStreamSpec, outStream, outSize));
+ }
+ }
outProcessed += outSize;
}
return S_OK;
}
-HRESULT CUnpacker::Unpack(IInStream *inStream, const CResource &resource,
+HRESULT CUnpacker::Unpack(IInStream *inStream, const CResource &resource, bool lzxMode,
ISequentialOutStream *outStream, ICompressProgressInfo *progress, Byte *digest)
{
COutStreamWithSha1 *shaStreamSpec = new COutStreamWithSha1();
CMyComPtr<ISequentialOutStream> shaStream = shaStreamSpec;
shaStreamSpec->SetStream(outStream);
shaStreamSpec->Init(digest != NULL);
- HRESULT result = Unpack(inStream, resource, shaStream, progress);
+ HRESULT result = Unpack(inStream, resource, lzxMode, shaStream, progress);
if (digest)
shaStreamSpec->Final(digest);
return result;
}
-static HRESULT UnpackData(IInStream *inStream, const CResource &resource, CByteBuffer &buf, Byte *digest)
+static HRESULT UnpackData(IInStream *inStream, const CResource &resource, bool lzxMode, CByteBuffer &buf, Byte *digest)
{
size_t size = (size_t)resource.UnpackSize;
if (size != resource.UnpackSize)
@@ -140,29 +255,31 @@ static HRESULT UnpackData(IInStream *inStream, const CResource &resource, CByteB
outStreamSpec->Init((Byte *)buf, size);
CUnpacker unpacker;
- return unpacker.Unpack(inStream, resource, outStream, NULL, digest);
+ return unpacker.Unpack(inStream, resource, lzxMode, outStream, NULL, digest);
}
static const UInt32 kSignatureSize = 8;
static const Byte kSignature[kSignatureSize] = { 'M', 'S', 'W', 'I', 'M', 0, 0, 0 };
-static void GetResource(const Byte *p, CResource &res)
+void CResource::Parse(const Byte *p)
{
- res.Flags = p[7];
- res.PackSize = GetUi64(p) & (((UInt64)1 << 56) - 1);
- res.Offset = GetUi64(p + 8);
- res.UnpackSize = GetUi64(p + 16);
+ Flags = p[7];
+ PackSize = Get64(p) & (((UInt64)1 << 56) - 1);
+ Offset = Get64(p + 8);
+ UnpackSize = Get64(p + 16);
}
+#define GetResource(p, res) res.Parse(p)
+
static void GetStream(const Byte *p, CStreamInfo &s)
{
- GetResource(p, s.Resource);
- s.PartNumber = GetUi16(p + 24);
- s.RefCount = GetUi32(p + 26);
+ s.Resource.Parse(p);
+ s.PartNumber = Get16(p + 24);
+ s.RefCount = Get32(p + 26);
memcpy(s.Hash, p + 30, kHashSize);
}
-static HRESULT ParseDirItem(const Byte *base, size_t pos, size_t size,
+static HRESULT ParseDirItem(const Byte *base, size_t pos, size_t size,
const UString &prefix, CObjectVector<CItem> &items)
{
for (;;)
@@ -170,22 +287,22 @@ static HRESULT ParseDirItem(const Byte *base, size_t pos, size_t size,
if (pos + 8 > size)
return S_FALSE;
const Byte *p = base + pos;
- UInt64 length = GetUi64(p);
+ UInt64 length = Get64(p);
if (length == 0)
return S_OK;
if (pos + 102 > size || pos + length + 8 > size || length > ((UInt64)1 << 62))
return S_FALSE;
CItem item;
- item.Attributes = GetUi32(p + 8);
- // item.SecurityId = GetUi32(p + 0xC);
- UInt64 subdirOffset = GetUi64(p + 0x10);
- GetFileTimeFromMem(p + 0x28, &item.CreationTime);
- GetFileTimeFromMem(p + 0x30, &item.LastAccessTime);
- GetFileTimeFromMem(p + 0x38, &item.LastWriteTime);
+ item.Attrib = Get32(p + 8);
+ // item.SecurityId = Get32(p + 0xC);
+ UInt64 subdirOffset = Get64(p + 0x10);
+ GetFileTimeFromMem(p + 0x28, &item.CTime);
+ GetFileTimeFromMem(p + 0x30, &item.ATime);
+ GetFileTimeFromMem(p + 0x38, &item.MTime);
memcpy(item.Hash, p + 0x40, kHashSize);
- // UInt16 shortNameLen = GetUi16(p + 98);
- UInt16 fileNameLen = GetUi16(p + 100);
+ // UInt16 shortNameLen = Get16(p + 98);
+ UInt16 fileNameLen = Get16(p + 100);
size_t tempPos = pos + 102;
if (tempPos + fileNameLen > size)
@@ -195,17 +312,17 @@ static HRESULT ParseDirItem(const Byte *base, size_t pos, size_t size,
MyStringCopy(sz, (const wchar_t *)prefix);
sz += prefix.Length();
for (UInt16 i = 0; i + 2 <= fileNameLen; i += 2)
- *sz++ = GetUi16(base + tempPos + i);
+ *sz++ = Get16(base + tempPos + i);
*sz++ = '\0';
item.Name.ReleaseBuffer();
- if (fileNameLen == 0 && item.IsDirectory() && !item.HasStream())
+ if (fileNameLen == 0 && item.isDir() && !item.HasStream())
{
- item.Attributes = 0x10; // some swm archives have system/hidden attributes for root
+ item.Attrib = 0x10; // some swm archives have system/hidden attributes for root
item.Name.Delete(item.Name.Length() - 1);
}
items.Add(item);
pos += (size_t)length;
- if (item.IsDirectory() && (subdirOffset != 0))
+ if (item.isDir() && (subdirOffset != 0))
{
if (subdirOffset >= size)
return S_FALSE;
@@ -214,15 +331,15 @@ static HRESULT ParseDirItem(const Byte *base, size_t pos, size_t size,
}
}
-static HRESULT ParseDir(const Byte *base, size_t size,
+static HRESULT ParseDir(const Byte *base, size_t size,
const UString &prefix, CObjectVector<CItem> &items)
{
- size_t pos = 0;
+ size_t pos = 0;
if (pos + 8 > size)
return S_FALSE;
const Byte *p = base + pos;
- UInt32 totalLength = GetUi32(p);
- // UInt32 numEntries = GetUi32(p + 4);
+ UInt32 totalLength = Get32(p);
+ // UInt32 numEntries = Get32(p + 4);
pos += 8;
{
/*
@@ -232,7 +349,7 @@ static HRESULT ParseDir(const Byte *base, size_t size,
{
if (pos + 8 > size)
return S_FALSE;
- UInt64 len = GetUi64(p + pos);
+ UInt64 len = Get64(p + pos);
entryLens.Add(len);
sum += len;
pos += 8;
@@ -267,9 +384,9 @@ int CompareItems(void *const *a1, void *const *a2, void * /* param */)
const CItem &i1 = **((const CItem **)a1);
const CItem &i2 = **((const CItem **)a2);
- if (i1.IsDirectory() != i2.IsDirectory())
- return (i1.IsDirectory()) ? 1 : -1;
- if (i1.IsDirectory())
+ if (i1.isDir() != i2.isDir())
+ return (i1.isDir()) ? 1 : -1;
+ if (i1.isDir())
return -MyStringCompareNoCase(i1.Name, i2.Name);
int res = MyCompare(i1.StreamIndex, i2.StreamIndex);
@@ -278,10 +395,10 @@ int CompareItems(void *const *a1, void *const *a2, void * /* param */)
return MyStringCompareNoCase(i1.Name, i2.Name);
}
-static int FindHash(const CRecordVector<CStreamInfo> &streams,
+static int FindHash(const CRecordVector<CStreamInfo> &streams,
const CRecordVector<int> &sortedByHash, const Byte *hash)
{
- int left = 0, right = streams.Size();
+ int left = 0, right = streams.Size();
while (left != right)
{
int mid = (left + right) / 2;
@@ -301,50 +418,56 @@ static int FindHash(const CRecordVector<CStreamInfo> &streams,
return -1;
}
-HRESULT ReadHeader(IInStream *inStream, CHeader &h)
+HRESULT CHeader::Parse(const Byte *p)
{
- const UInt32 kHeaderSizeMax = 0xD0;
- Byte p[kHeaderSizeMax];
- RINOK(ReadStream_FALSE(inStream, p, kHeaderSizeMax));
- UInt32 haderSize = GetUi32(p + 8);
- if (memcmp(p, kSignature, kSignatureSize) != 0)
- return S_FALSE;
+ UInt32 haderSize = Get32(p + 8);
if (haderSize < 0x74)
return S_FALSE;
- h.Version = GetUi32(p + 0x0C);
- h.Flags = GetUi32(p + 0x10);
- if (!h.IsSupported())
+ Version = Get32(p + 0x0C);
+ Flags = Get32(p + 0x10);
+ if (!IsSupported())
return S_FALSE;
- if (GetUi32(p + 0x14) != kChunkSize)
+ UInt32 chunkSize = Get32(p + 0x14);
+ if (chunkSize != kChunkSize && chunkSize != 0)
return S_FALSE;
- memcpy(h.Guid, p + 0x18, 16);
- h.PartNumber = GetUi16(p + 0x28);
- h.NumParts = GetUi16(p + 0x2A);
+ memcpy(Guid, p + 0x18, 16);
+ PartNumber = Get16(p + 0x28);
+ NumParts = Get16(p + 0x2A);
int offset = 0x2C;
- if (h.IsNewVersion())
+ if (IsNewVersion())
{
- h.NumImages = GetUi32(p + offset);
+ NumImages = Get32(p + offset);
offset += 4;
}
- GetResource(p + offset, h.OffsetResource);
- GetResource(p + offset + 0x18, h.XmlResource);
- GetResource(p + offset + 0x30, h.MetadataResource);
+ GetResource(p + offset, OffsetResource);
+ GetResource(p + offset + 0x18, XmlResource);
+ GetResource(p + offset + 0x30, MetadataResource);
/*
- if (h.IsNewVersion())
+ if (IsNewVersion())
{
if (haderSize < 0xD0)
return S_FALSE;
- GetResource(p + offset + 0x4C, h.IntegrityResource);
- h.BootIndex = GetUi32(p + 0x48);
+ IntegrityResource.Parse(p + offset + 0x4C);
+ BootIndex = Get32(p + 0x48);
}
*/
return S_OK;
}
+HRESULT ReadHeader(IInStream *inStream, CHeader &h)
+{
+ const UInt32 kHeaderSizeMax = 0xD0;
+ Byte p[kHeaderSizeMax];
+ RINOK(ReadStream_FALSE(inStream, p, kHeaderSizeMax));
+ if (memcmp(p, kSignature, kSignatureSize) != 0)
+ return S_FALSE;
+ return h.Parse(p);
+}
+
HRESULT ReadStreams(IInStream *inStream, const CHeader &h, CDatabase &db)
{
CByteBuffer offsetBuf;
- RINOK(UnpackData(inStream, h.OffsetResource, offsetBuf, NULL));
+ RINOK(UnpackData(inStream, h.OffsetResource, h.IsLzxMode(), offsetBuf, NULL));
for (size_t i = 0; i + kStreamInfoSize <= offsetBuf.GetCapacity(); i += kStreamInfoSize)
{
CStreamInfo s;
@@ -357,7 +480,7 @@ HRESULT ReadStreams(IInStream *inStream, const CHeader &h, CDatabase &db)
HRESULT OpenArchive(IInStream *inStream, const CHeader &h, CByteBuffer &xml, CDatabase &db)
{
- RINOK(UnpackData(inStream, h.XmlResource, xml, NULL));
+ RINOK(UnpackData(inStream, h.XmlResource, h.IsLzxMode(), xml, NULL));
RINOK(ReadStreams(inStream, h, db));
bool needBootMetadata = !h.MetadataResource.IsEmpty();
@@ -372,13 +495,13 @@ HRESULT OpenArchive(IInStream *inStream, const CHeader &h, CByteBuffer &xml, CDa
continue;
Byte hash[kHashSize];
CByteBuffer metadata;
- RINOK(UnpackData(inStream, si.Resource, metadata, hash));
+ RINOK(UnpackData(inStream, si.Resource, h.IsLzxMode(), metadata, hash));
if (memcmp(hash, si.Hash, kHashSize) != 0)
return S_FALSE;
wchar_t sz[32];
ConvertUInt64ToString(imageIndex++, sz);
UString s = sz;
- s += WCHAR_PATH_SEPARATOR;
+ s += WCHAR_PATH_SEPARATOR;
RINOK(ParseDir(metadata, metadata.GetCapacity(), s, db.Items));
if (needBootMetadata)
if (h.MetadataResource.Offset == si.Resource.Offset)
@@ -389,7 +512,7 @@ HRESULT OpenArchive(IInStream *inStream, const CHeader &h, CByteBuffer &xml, CDa
if (needBootMetadata)
{
CByteBuffer metadata;
- RINOK(UnpackData(inStream, h.MetadataResource, metadata, NULL));
+ RINOK(UnpackData(inStream, h.MetadataResource, h.IsLzxMode(), metadata, NULL));
RINOK(ParseDir(metadata, metadata.GetCapacity(), L"0" WSTRING_PATH_SEPARATOR, db.Items));
}
return S_OK;
diff --git a/CPP/7zip/Archive/Wim/WimIn.h b/CPP/7zip/Archive/Wim/WimIn.h
index 467b99ae..79e7bd01 100755
--- a/CPP/7zip/Archive/Wim/WimIn.h
+++ b/CPP/7zip/Archive/Wim/WimIn.h
@@ -12,6 +12,77 @@
namespace NArchive {
namespace NWim {
+namespace NXpress {
+
+class CBitStream
+{
+ CInBuffer m_Stream;
+ UInt32 m_Value;
+ unsigned m_BitPos;
+public:
+ bool Create(UInt32 bufferSize) { return m_Stream.Create(bufferSize); }
+ void SetStream(ISequentialInStream *s) { m_Stream.SetStream(s); }
+ void ReleaseStream() { m_Stream.ReleaseStream(); }
+
+ void Init() { m_Stream.Init(); m_BitPos = 0; }
+ // UInt64 GetProcessedSize() const { return m_Stream.GetProcessedSize() - m_BitPos / 8; }
+ Byte DirectReadByte() { return m_Stream.ReadByte(); }
+
+ void Normalize()
+ {
+ if (m_BitPos < 16)
+ {
+ Byte b0 = m_Stream.ReadByte();
+ Byte b1 = m_Stream.ReadByte();
+ m_Value = (m_Value << 8) | b1;
+ m_Value = (m_Value << 8) | b0;
+ m_BitPos += 16;
+ }
+ }
+
+ UInt32 GetValue(unsigned numBits)
+ {
+ Normalize();
+ return (m_Value >> (m_BitPos - numBits)) & ((1 << numBits) - 1);
+ }
+
+ void MovePos(unsigned numBits) { m_BitPos -= numBits; }
+
+ UInt32 ReadBits(unsigned numBits)
+ {
+ UInt32 res = GetValue(numBits);
+ m_BitPos -= numBits;
+ return res;
+ }
+};
+
+const int kNumHuffmanBits = 16;
+const UInt32 kMatchMinLen = 3;
+const UInt32 kNumLenSlots = 16;
+const UInt32 kNumPosSlots = 16;
+const UInt32 kNumPosLenSlots = kNumPosSlots * kNumLenSlots;
+const UInt32 kMainTableSize = 256 + kNumPosLenSlots;
+
+class CDecoder
+{
+ CBitStream m_InBitStream;
+ CLZOutWindow m_OutWindowStream;
+ NCompress::NHuffman::CDecoder<kNumHuffmanBits, kMainTableSize> m_MainDecoder;
+
+ HRESULT CodeSpec(UInt32 size);
+ HRESULT CodeReal(ISequentialInStream *inStream, ISequentialOutStream *outStream, UInt32 outSize);
+public:
+ void ReleaseStreams()
+ {
+ m_OutWindowStream.ReleaseStream();
+ m_InBitStream.ReleaseStream();
+ }
+ HRESULT Flush() { return m_OutWindowStream.Flush(); }
+ HRESULT Code(ISequentialInStream *inStream, ISequentialOutStream *outStream, UInt32 outSize);
+};
+
+}
+
namespace NResourceFlags
{
const Byte Compressed = 4;
@@ -24,6 +95,8 @@ struct CResource
UInt64 Offset;
UInt64 UnpackSize;
Byte Flags;
+
+ void Parse(const Byte *p);
bool IsCompressed() const { return (Flags & NResourceFlags::Compressed) != 0; }
bool IsMetadata() const { return (Flags & NResourceFlags::kMetadata) != 0; }
bool IsEmpty() const { return (UnpackSize == 0); }
@@ -47,6 +120,7 @@ struct CHeader
UInt16 NumParts;
UInt32 NumImages;
Byte Guid[16];
+
CResource OffsetResource;
CResource XmlResource;
CResource MetadataResource;
@@ -54,8 +128,11 @@ struct CHeader
CResource IntegrityResource;
UInt32 BootIndex;
*/
+
+ HRESULT Parse(const Byte *p);
bool IsCompressed() const { return (Flags & NHeaderFlags::kCompression) != 0; }
- bool IsSupported() const { return (!IsCompressed() || (Flags & NHeaderFlags::kLZX) != 0); }
+ bool IsSupported() const { return (!IsCompressed() || (Flags & NHeaderFlags::kLZX) != 0 || (Flags & NHeaderFlags::kXPRESS) != 0 ) ; }
+ bool IsLzxMode() const { return (Flags & NHeaderFlags::kLZX) != 0; }
bool IsSpanned() const { return (!IsCompressed() || (Flags & NHeaderFlags::kSpanned) != 0); }
bool IsNewVersion()const { return (Version > 0x010C00); }
@@ -80,12 +157,12 @@ struct CStreamInfo
struct CItem
{
UString Name;
- UInt32 Attributes;
+ UInt32 Attrib;
// UInt32 SecurityId;
BYTE Hash[kHashSize];
- FILETIME CreationTime;
- FILETIME LastAccessTime;
- FILETIME LastWriteTime;
+ FILETIME CTime;
+ FILETIME ATime;
+ FILETIME MTime;
// UInt32 ReparseTag;
// UInt64 HardLink;
// UInt16 NumStreams;
@@ -93,9 +170,9 @@ struct CItem
int StreamIndex;
bool HasMetadata;
CItem(): HasMetadata(true), StreamIndex(-1) {}
- bool IsDirectory() const { return HasMetadata && ((Attributes & 0x10) != 0); }
- bool HasStream() const
- {
+ bool isDir() const { return HasMetadata && ((Attrib & 0x10) != 0); }
+ bool HasStream() const
+ {
for (int i = 0; i < kHashSize; i++)
if (Hash[i] != 0)
return true;
@@ -143,11 +220,13 @@ class CUnpacker
NCompress::NLzx::CDecoder *lzxDecoderSpec;
CMyComPtr<ICompressCoder> lzxDecoder;
+ NXpress::CDecoder xpressDecoder;
+
CByteBuffer sizesBuf;
- HRESULT Unpack(IInStream *inStream, const CResource &res,
+ HRESULT Unpack(IInStream *inStream, const CResource &res, bool lzxMode,
ISequentialOutStream *outStream, ICompressProgressInfo *progress);
public:
- HRESULT Unpack(IInStream *inStream, const CResource &res,
+ HRESULT Unpack(IInStream *inStream, const CResource &res, bool lzxMode,
ISequentialOutStream *outStream, ICompressProgressInfo *progress, Byte *digest);
};
diff --git a/CPP/7zip/Archive/XarHandler.cpp b/CPP/7zip/Archive/XarHandler.cpp
new file mode 100755
index 00000000..1069d15d
--- /dev/null
+++ b/CPP/7zip/Archive/XarHandler.cpp
@@ -0,0 +1,586 @@
+// XarHandler.cpp
+
+#include "StdAfx.h"
+
+#include "../../../C/CpuArch.h"
+
+#include "Common/ComTry.h"
+#include "Common/MyXml.h"
+#include "Common/StringToInt.h"
+#include "Common/UTFConvert.h"
+
+#include "Windows/PropVariant.h"
+#include "Windows/Time.h"
+
+#include "../Common/LimitedStreams.h"
+#include "../Common/ProgressUtils.h"
+#include "../Common/RegisterArc.h"
+#include "../Common/StreamObjects.h"
+#include "../Common/StreamUtils.h"
+
+#include "../Compress/BZip2/BZip2Decoder.h"
+#include "../Compress/Copy/CopyCoder.h"
+#include "../Compress/Deflate/ZlibDecoder.h"
+
+#include "Common/OutStreamWithSha1.h"
+
+#define XAR_SHOW_RAW
+
+#define Get16(p) GetBe16(p)
+#define Get32(p) GetBe32(p)
+#define Get64(p) GetBe64(p)
+
+namespace NArchive {
+namespace NXar {
+
+struct CFile
+{
+ AString Name;
+ AString Method;
+ UInt64 Size;
+ UInt64 PackSize;
+ UInt64 Offset;
+
+ // UInt32 mode;
+ UInt64 CTime;
+ UInt64 MTime;
+ UInt64 ATime;
+
+ bool IsDir;
+ bool HasData;
+
+ bool Sha1IsDefined;
+ Byte Sha1[20];
+ // bool packSha1IsDefined;
+ // Byte packSha1[20];
+
+ int Parent;
+
+ CFile(): IsDir(false), HasData(false), Sha1IsDefined(false),
+ /* packSha1IsDefined(false), */
+ Parent(-1), Size(0), PackSize(0), CTime(0), MTime(0), ATime(0) {}
+};
+
+class CHandler:
+ public IInArchive,
+ public CMyUnknownImp
+{
+ UInt64 _dataStartPos;
+ CMyComPtr<IInStream> _inStream;
+ AString _xml;
+ CObjectVector<CFile> _files;
+
+ HRESULT Open2(IInStream *stream);
+ HRESULT Extract(IInStream *stream);
+public:
+ MY_UNKNOWN_IMP1(IInArchive)
+ INTERFACE_IInArchive(;)
+};
+
+const UInt32 kXmlSizeMax = ((UInt32)1 << 30) - (1 << 14);
+
+STATPROPSTG kProps[] =
+{
+ { NULL, kpidPath, VT_BSTR},
+ { NULL, kpidSize, VT_UI8},
+ { NULL, kpidPackSize, VT_UI8},
+ { NULL, kpidMTime, VT_FILETIME},
+ { NULL, kpidCTime, VT_FILETIME},
+ { NULL, kpidATime, VT_FILETIME},
+ { NULL, kpidMethod, VT_BSTR}
+};
+
+IMP_IInArchive_Props
+IMP_IInArchive_ArcProps_NO
+
+static bool ParseNumber(const char *s, int size, UInt32 &res)
+{
+ const char *end;
+ res = (UInt32)ConvertStringToUInt64(s, &end);
+ return (end - s == size);
+}
+
+static bool ParseUInt64(const CXmlItem &item, const char *name, UInt64 &res)
+{
+ AString s = item.GetSubStringForTag(name);
+ const char *end;
+ res = ConvertStringToUInt64(s, &end);
+ return (end - (const char *)s == s.Length());
+}
+
+static UInt64 ParseTime(const CXmlItem &item, const char *name)
+{
+ AString s = item.GetSubStringForTag(name);
+ if (s.Length() < 20)
+ return 0;
+ const char *p = s;
+ if (p[ 4] != '-' || p[ 7] != '-' || p[10] != 'T' ||
+ p[13] != ':' || p[16] != ':' || p[19] != 'Z')
+ return 0;
+ UInt32 year, month, day, hour, min, sec;
+ if (!ParseNumber(p, 4, year )) return 0;
+ if (!ParseNumber(p + 5, 2, month)) return 0;
+ if (!ParseNumber(p + 8, 2, day )) return 0;
+ if (!ParseNumber(p + 11, 2, hour )) return 0;
+ if (!ParseNumber(p + 14, 2, min )) return 0;
+ if (!ParseNumber(p + 17, 2, sec )) return 0;
+
+ UInt64 numSecs;
+ if (!NWindows::NTime::GetSecondsSince1601(year, month, day, hour, min, sec, numSecs))
+ return 0;
+ return numSecs * 10000000;
+}
+
+static bool HexToByte(char c, Byte &res)
+{
+ if (c >= '0' && c <= '9') res = c - '0';
+ else if (c >= 'A' && c <= 'F') res = c - 'A' + 10;
+ else if (c >= 'a' && c <= 'f') res = c - 'a' + 10;
+ else return false;
+ return true;
+}
+
+#define METHOD_NAME_ZLIB "zlib"
+
+static bool ParseSha1(const CXmlItem &item, const char *name, Byte *digest)
+{
+ int index = item.FindSubTag(name);
+ if (index < 0)
+ return false;
+ const CXmlItem &checkItem = item.SubItems[index];
+ AString style = checkItem.GetPropertyValue("style");
+ if (style == "SHA1")
+ {
+ AString s = checkItem.GetSubString();
+ if (s.Length() != 40)
+ return false;
+ for (int i = 0; i < s.Length(); i += 2)
+ {
+ Byte b0, b1;
+ if (!HexToByte(s[i], b0) || !HexToByte(s[i + 1], b1))
+ return false;
+ digest[i / 2] = (b0 << 4) | b1;
+ }
+ return true;
+ }
+ return false;
+}
+
+static bool AddItem(const CXmlItem &item, CObjectVector<CFile> &files, int parent)
+{
+ if (!item.IsTag)
+ return true;
+ if (item.Name == "file")
+ {
+ CFile file;
+ file.Parent = parent;
+ parent = files.Size();
+ file.Name = item.GetSubStringForTag("name");
+ AString type = item.GetSubStringForTag("type");
+ if (type == "directory")
+ file.IsDir = true;
+ else if (type == "file")
+ file.IsDir = false;
+ else
+ return false;
+
+ int dataIndex = item.FindSubTag("data");
+ if (dataIndex >= 0 && !file.IsDir)
+ {
+ file.HasData = true;
+ const CXmlItem &dataItem = item.SubItems[dataIndex];
+ if (!ParseUInt64(dataItem, "size", file.Size))
+ return false;
+ if (!ParseUInt64(dataItem, "length", file.PackSize))
+ return false;
+ if (!ParseUInt64(dataItem, "offset", file.Offset))
+ return false;
+ file.Sha1IsDefined = ParseSha1(dataItem, "extracted-checksum", file.Sha1);
+ // file.packSha1IsDefined = ParseSha1(dataItem, "archived-checksum", file.packSha1);
+ int encodingIndex = dataItem.FindSubTag("encoding");
+ const CXmlItem &encodingItem = dataItem.SubItems[encodingIndex];
+ if (encodingItem.IsTag)
+ {
+ AString s = encodingItem.GetPropertyValue("style");
+ if (s.Length() >= 0)
+ {
+ AString appl = "application/";
+ if (s.Left(appl.Length()) == appl)
+ {
+ s = s.Mid(appl.Length());
+ AString xx = "x-";
+ if (s.Left(xx.Length()) == xx)
+ {
+ s = s.Mid(xx.Length());
+ if (s == "gzip")
+ s = METHOD_NAME_ZLIB;
+ }
+ }
+ file.Method = s;
+ }
+ }
+ }
+
+ file.CTime = ParseTime(item, "ctime");
+ file.MTime = ParseTime(item, "mtime");
+ file.ATime = ParseTime(item, "atime");
+ files.Add(file);
+ }
+ for (int i = 0; i < item.SubItems.Size(); i++)
+ if (!AddItem(item.SubItems[i], files, parent))
+ return false;
+ return true;
+}
+
+HRESULT CHandler::Open2(IInStream *stream)
+{
+ UInt64 archiveStartPos;
+ RINOK(stream->Seek(0, STREAM_SEEK_SET, &archiveStartPos));
+
+ const UInt32 kHeaderSize = 0x1C;
+ Byte buf[kHeaderSize];
+ RINOK(ReadStream_FALSE(stream, buf, kHeaderSize));
+
+ UInt32 size = Get16(buf + 4);
+ // UInt32 ver = Get16(buf + 6); // == 0
+ if (Get32(buf) != 0x78617221 || size != kHeaderSize)
+ return S_FALSE;
+
+ UInt64 packSize = Get64(buf + 8);
+ UInt64 unpackSize = Get64(buf + 0x10);
+ // UInt32 checkSumAlogo = Get32(buf + 0x18);
+
+ if (unpackSize >= kXmlSizeMax)
+ return S_FALSE;
+
+ _dataStartPos = archiveStartPos + kHeaderSize + packSize;
+
+ char *ss = _xml.GetBuffer((int)unpackSize + 1);
+
+ NCompress::NZlib::CDecoder *zlibCoderSpec = new NCompress::NZlib::CDecoder();
+ CMyComPtr<ICompressCoder> zlibCoder = zlibCoderSpec;
+
+ CLimitedSequentialInStream *inStreamLimSpec = new CLimitedSequentialInStream;
+ CMyComPtr<ISequentialInStream> inStreamLim(inStreamLimSpec);
+ inStreamLimSpec->SetStream(stream);
+ inStreamLimSpec->Init(packSize);
+
+ CSequentialOutStreamImp2 *outStreamLimSpec = new CSequentialOutStreamImp2;
+ CMyComPtr<ISequentialOutStream> outStreamLim(outStreamLimSpec);
+ outStreamLimSpec->Init((Byte *)ss, (size_t)unpackSize);
+
+ RINOK(zlibCoder->Code(inStreamLim, outStreamLim, NULL, NULL, NULL));
+
+ if (outStreamLimSpec->GetPos() != (size_t)unpackSize)
+ return S_FALSE;
+
+ ss[(size_t)unpackSize] = 0;
+ _xml.ReleaseBuffer();
+
+ CXml xml;
+ if (!xml.Parse(_xml))
+ return S_FALSE;
+
+ if (!xml.Root.IsTagged("xar") || xml.Root.SubItems.Size() != 1)
+ return S_FALSE;
+ const CXmlItem &toc = xml.Root.SubItems[0];
+ if (!toc.IsTagged("toc"))
+ return S_FALSE;
+ if (!AddItem(toc, _files, -1))
+ return S_FALSE;
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::Open(IInStream *stream,
+ const UInt64 * /* maxCheckStartPosition */,
+ IArchiveOpenCallback * /* openArchiveCallback */)
+{
+ COM_TRY_BEGIN
+ {
+ Close();
+ if (Open2(stream) != S_OK)
+ return S_FALSE;
+ _inStream = stream;
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Close()
+{
+ _inStream.Release();
+ _files.Clear();
+ _xml.Empty();
+ return S_OK;
+}
+
+STDMETHODIMP CHandler::GetNumberOfItems(UInt32 *numItems)
+{
+ *numItems = _files.Size()
+ #ifdef XAR_SHOW_RAW
+ + 1
+ #endif
+ ;
+ return S_OK;
+}
+
+static void TimeToProp(UInt64 t, NWindows::NCOM::CPropVariant &prop)
+{
+ if (t != 0)
+ {
+ FILETIME ft;
+ ft.dwLowDateTime = (UInt32)(t);
+ ft.dwHighDateTime = (UInt32)(t >> 32);
+ prop = ft;
+ }
+}
+
+STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NWindows::NCOM::CPropVariant prop;
+
+ #ifdef XAR_SHOW_RAW
+ if ((int)index == _files.Size())
+ {
+ switch(propID)
+ {
+ case kpidPath: prop = L"[TOC].xml"; break;
+ case kpidSize:
+ case kpidPackSize: prop = (UInt64)_xml.Length(); break;
+ }
+ }
+ else
+ #endif
+ {
+ const CFile &item = _files[index];
+ switch(propID)
+ {
+ case kpidMethod:
+ {
+ UString name;
+ if (ConvertUTF8ToUnicode(item.Method, name))
+ prop = name;
+ break;
+ }
+ case kpidPath:
+ {
+ AString path;
+ int cur = index;
+ do
+ {
+ const CFile &item = _files[cur];
+ AString s = item.Name;
+ if (s.IsEmpty())
+ s = "unknown";
+ if (path.IsEmpty())
+ path = s;
+ else
+ path = s + CHAR_PATH_SEPARATOR + path;
+ cur = item.Parent;
+ }
+ while (cur >= 0);
+
+ UString name;
+ if (ConvertUTF8ToUnicode(path, name))
+ prop = name;
+ break;
+ }
+
+ case kpidIsDir: prop = item.IsDir; break;
+ case kpidSize: if (!item.IsDir) prop = item.Size; break;
+ case kpidPackSize: if (!item.IsDir) prop = item.PackSize; break;
+
+ case kpidMTime: TimeToProp(item.MTime, prop); break;
+ case kpidCTime: TimeToProp(item.CTime, prop); break;
+ case kpidATime: TimeToProp(item.ATime, prop); break;
+ }
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
+ Int32 _aTestMode, IArchiveExtractCallback *extractCallback)
+{
+ COM_TRY_BEGIN
+ bool testMode = (_aTestMode != 0);
+ bool allFilesMode = (numItems == UInt32(-1));
+ if (allFilesMode)
+ numItems = _files.Size();
+ if (numItems == 0)
+ return S_OK;
+ UInt64 totalSize = 0;
+ UInt32 i;
+ for (i = 0; i < numItems; i++)
+ {
+ int index = (int)(allFilesMode ? i : indices[i]);
+ #ifdef XAR_SHOW_RAW
+ if (index == _files.Size())
+ totalSize += _xml.Length();
+ else
+ #endif
+ totalSize += _files[index].Size;
+ }
+ extractCallback->SetTotal(totalSize);
+
+ UInt64 currentPackTotal = 0;
+ UInt64 currentUnpTotal = 0;
+ UInt64 currentPackSize = 0;
+ UInt64 currentUnpSize = 0;
+
+ const UInt32 kZeroBufSize = (1 << 14);
+ CByteBuffer zeroBuf;
+ zeroBuf.SetCapacity(kZeroBufSize);
+ memset(zeroBuf, 0, kZeroBufSize);
+
+ NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder();
+ CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;
+
+ NCompress::NZlib::CDecoder *zlibCoderSpec = new NCompress::NZlib::CDecoder();
+ CMyComPtr<ICompressCoder> zlibCoder = zlibCoderSpec;
+
+ NCompress::NBZip2::CDecoder *bzip2CoderSpec = new NCompress::NBZip2::CDecoder();
+ CMyComPtr<ICompressCoder> bzip2Coder = bzip2CoderSpec;
+
+ NCompress::NDeflate::NDecoder::CCOMCoder *deflateCoderSpec = new NCompress::NDeflate::NDecoder::CCOMCoder();
+ CMyComPtr<ICompressCoder> deflateCoder = deflateCoderSpec;
+
+ CLocalProgress *lps = new CLocalProgress;
+ CMyComPtr<ICompressProgressInfo> progress = lps;
+ lps->Init(extractCallback, false);
+
+ CLimitedSequentialInStream *inStreamSpec = new CLimitedSequentialInStream;
+ CMyComPtr<ISequentialInStream> inStream(inStreamSpec);
+ inStreamSpec->SetStream(_inStream);
+
+
+ CLimitedSequentialOutStream *outStreamLimSpec = new CLimitedSequentialOutStream;
+ CMyComPtr<ISequentialOutStream> outStream(outStreamLimSpec);
+
+ COutStreamWithSha1 *outStreamSha1Spec = new COutStreamWithSha1;
+ {
+ CMyComPtr<ISequentialOutStream> outStreamSha1(outStreamSha1Spec);
+ outStreamLimSpec->SetStream(outStreamSha1);
+ }
+
+ for (i = 0; i < numItems; i++, currentPackTotal += currentPackSize, currentUnpTotal += currentUnpSize)
+ {
+ lps->InSize = currentPackTotal;
+ lps->OutSize = currentUnpTotal;
+ currentPackSize = 0;
+ currentUnpSize = 0;
+ RINOK(lps->SetCur());
+ CMyComPtr<ISequentialOutStream> realOutStream;
+ Int32 askMode = testMode ?
+ NArchive::NExtract::NAskMode::kTest :
+ NArchive::NExtract::NAskMode::kExtract;
+ Int32 index = allFilesMode ? i : indices[i];
+ RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
+
+ if (index < _files.Size())
+ {
+ const CFile &item = _files[index];
+ if (item.IsDir)
+ {
+ RINOK(extractCallback->PrepareOperation(askMode));
+ RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK));
+ continue;
+ }
+ }
+
+ if (!testMode && (!realOutStream))
+ continue;
+ RINOK(extractCallback->PrepareOperation(askMode));
+
+ outStreamSha1Spec->SetStream(realOutStream);
+ realOutStream.Release();
+
+ Int32 opRes = NArchive::NExtract::NOperationResult::kOK;
+ #ifdef XAR_SHOW_RAW
+ if (index == _files.Size())
+ {
+ outStreamSha1Spec->Init(false);
+ outStreamLimSpec->Init(_xml.Length());
+ RINOK(WriteStream(outStream, (const char *)_xml, _xml.Length()));
+ currentPackSize = currentUnpSize = _xml.Length();
+ }
+ else
+ #endif
+ {
+ const CFile &item = _files[index];
+ if (item.HasData)
+ {
+ currentPackSize = item.PackSize;
+ currentUnpSize = item.Size;
+
+ RINOK(_inStream->Seek(_dataStartPos + item.Offset, STREAM_SEEK_SET, NULL));
+ inStreamSpec->Init(item.PackSize);
+ outStreamSha1Spec->Init(item.Sha1IsDefined);
+ outStreamLimSpec->Init(item.Size);
+ HRESULT res = S_OK;
+
+ ICompressCoder *coder = NULL;
+ if (item.Method == "octet-stream")
+ if (item.PackSize == item.Size)
+ coder = copyCoder;
+ else
+ opRes = NArchive::NExtract::NOperationResult::kUnSupportedMethod;
+ else if (item.Method == METHOD_NAME_ZLIB)
+ coder = zlibCoder;
+ else if (item.Method == "bzip2")
+ coder = bzip2Coder;
+ else
+ opRes = NArchive::NExtract::NOperationResult::kUnSupportedMethod;
+
+ if (coder)
+ res = coder->Code(inStream, outStream, NULL, NULL, progress);
+
+ if (res != S_OK)
+ {
+ if (!outStreamLimSpec->IsFinishedOK())
+ opRes = NArchive::NExtract::NOperationResult::kDataError;
+ else if (res != S_FALSE)
+ return res;
+ if (opRes == NArchive::NExtract::NOperationResult::kOK)
+ opRes = NArchive::NExtract::NOperationResult::kDataError;
+ }
+
+ if (opRes == NArchive::NExtract::NOperationResult::kOK)
+ {
+ if (outStreamLimSpec->IsFinishedOK() &&
+ outStreamSha1Spec->GetSize() == item.Size)
+ {
+ if (!outStreamLimSpec->IsFinishedOK())
+ {
+ opRes = NArchive::NExtract::NOperationResult::kDataError;
+ }
+ else if (item.Sha1IsDefined)
+ {
+ Byte digest[NCrypto::NSha1::kDigestSize];
+ outStreamSha1Spec->Final(digest);
+ if (memcmp(digest, item.Sha1, NCrypto::NSha1::kDigestSize) != 0)
+ opRes = NArchive::NExtract::NOperationResult::kCRCError;
+ }
+ }
+ else
+ opRes = NArchive::NExtract::NOperationResult::kDataError;
+ }
+ }
+ }
+ outStreamSha1Spec->ReleaseStream();
+ RINOK(extractCallback->SetOperationResult(opRes));
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+static IInArchive *CreateArc() { return new NArchive::NXar::CHandler; }
+
+static CArcInfo g_ArcInfo =
+ { L"Xar", L"xar", 0, 0xE1, { 'x', 'a', 'r', '!', 0, 0x1C }, 6, false, CreateArc, 0 };
+
+REGISTER_ARC(Xar)
+
+}}
diff --git a/CPP/7zip/Archive/Z/StdAfx.cpp b/CPP/7zip/Archive/Z/StdAfx.cpp
deleted file mode 100755
index d0feea85..00000000
--- a/CPP/7zip/Archive/Z/StdAfx.cpp
+++ /dev/null
@@ -1,3 +0,0 @@
-// StdAfx.cpp
-
-#include "StdAfx.h"
diff --git a/CPP/7zip/Archive/Z/StdAfx.h b/CPP/7zip/Archive/Z/StdAfx.h
deleted file mode 100755
index e7fb6986..00000000
--- a/CPP/7zip/Archive/Z/StdAfx.h
+++ /dev/null
@@ -1,8 +0,0 @@
-// StdAfx.h
-
-#ifndef __STDAFX_H
-#define __STDAFX_H
-
-#include "../../../Common/MyWindows.h"
-
-#endif
diff --git a/CPP/7zip/Archive/Z/ZHandler.h b/CPP/7zip/Archive/Z/ZHandler.h
deleted file mode 100755
index e8b3b8c5..00000000
--- a/CPP/7zip/Archive/Z/ZHandler.h
+++ /dev/null
@@ -1,29 +0,0 @@
-// ZHandler.h
-
-#ifndef __Z_HANDLER_H
-#define __Z_HANDLER_H
-
-#include "Common/MyCom.h"
-#include "../IArchive.h"
-
-namespace NArchive {
-namespace NZ {
-
-class CHandler:
- public IInArchive,
- public CMyUnknownImp
-{
-public:
- MY_UNKNOWN_IMP1(IInArchive)
- INTERFACE_IInArchive(;)
-
-private:
- CMyComPtr<IInStream> _stream;
- UInt64 _streamStartPosition;
- UInt64 _packSize;
- Byte _properties;
-};
-
-}}
-
-#endif
diff --git a/CPP/7zip/Archive/Z/ZRegister.cpp b/CPP/7zip/Archive/Z/ZRegister.cpp
deleted file mode 100755
index 288dc6ca..00000000
--- a/CPP/7zip/Archive/Z/ZRegister.cpp
+++ /dev/null
@@ -1,13 +0,0 @@
-// ZRegister.cpp
-
-#include "StdAfx.h"
-
-#include "../../Common/RegisterArc.h"
-
-#include "ZHandler.h"
-static IInArchive *CreateArc() { return new NArchive::NZ::CHandler; }
-
-static CArcInfo g_ArcInfo =
- { L"Z", L"z taz", L"* .tar", 5, { 0x1F, 0x9D }, 2, false, CreateArc, 0 };
-
-REGISTER_ARC(Z)
diff --git a/CPP/7zip/Archive/Z/ZHandler.cpp b/CPP/7zip/Archive/ZHandler.cpp
index 81289050..bc006eda 100755
--- a/CPP/7zip/Archive/Z/ZHandler.cpp
+++ b/CPP/7zip/Archive/ZHandler.cpp
@@ -2,26 +2,46 @@
#include "StdAfx.h"
-#include "ZHandler.h"
+#include "Common/ComTry.h"
-#include "Common/Defs.h"
+#include "Windows/PropVariant.h"
-#include "../../Common/ProgressUtils.h"
-#include "../../Compress/Z/ZDecoder.h"
-#include "../../Common/StreamUtils.h"
+#include "../Common/ProgressUtils.h"
+#include "../Common/RegisterArc.h"
+#include "../Common/StreamUtils.h"
-#include "Windows/PropVariant.h"
-#include "Windows/Defs.h"
-#include "Common/ComTry.h"
+#include "../Compress/Z/ZDecoder.h"
-#include "../Common/DummyOutStream.h"
+#include "Common/DummyOutStream.h"
namespace NArchive {
namespace NZ {
-STATPROPSTG kProps[] =
+class CHandler:
+ public IInArchive,
+ public CMyUnknownImp
+{
+public:
+ MY_UNKNOWN_IMP1(IInArchive)
+ INTERFACE_IInArchive(;)
+
+private:
+ CMyComPtr<IInStream> _stream;
+ UInt64 _streamStartPosition;
+ UInt64 _packSize;
+ Byte _properties;
+};
+
+static IInArchive *CreateArc() { return new CHandler; }
+
+static CArcInfo g_ArcInfo =
+ { L"Z", L"z taz", L"* .tar", 5, { 0x1F, 0x9D }, 2, false, CreateArc, 0 };
+
+REGISTER_ARC(Z)
+
+STATPROPSTG kProps[] =
{
- { NULL, kpidPackedSize, VT_UI8},
+ { NULL, kpidPackSize, VT_UI8}
};
IMP_IInArchive_Props
@@ -38,7 +58,7 @@ STDMETHODIMP CHandler::GetProperty(UInt32 /* index */, PROPID propID, PROPVARIA
NWindows::NCOM::CPropVariant prop;
switch(propID)
{
- case kpidPackedSize: prop = _packSize; break;
+ case kpidPackSize: prop = _packSize; break;
}
prop.Detach(value);
return S_OK;
@@ -46,12 +66,11 @@ STDMETHODIMP CHandler::GetProperty(UInt32 /* index */, PROPID propID, PROPVARIA
static const int kSignatureSize = 3;
-STDMETHODIMP CHandler::Open(IInStream *stream,
+STDMETHODIMP CHandler::Open(IInStream *stream,
const UInt64 * /* maxCheckStartPosition */,
IArchiveOpenCallback * /* openArchiveCallback */)
{
COM_TRY_BEGIN
- try
{
RINOK(stream->Seek(0, STREAM_SEEK_CUR, &_streamStartPosition));
Byte buffer[kSignatureSize];
@@ -66,10 +85,6 @@ STDMETHODIMP CHandler::Open(IInStream *stream,
_stream = stream;
}
- catch(...)
- {
- return S_FALSE;
- }
return S_OK;
COM_TRY_END
}
@@ -105,7 +120,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
RINOK(extractCallback->SetCompleted(&currentTotalPacked));
CMyComPtr<ISequentialOutStream> realOutStream;
- Int32 askMode = testMode ?
+ Int32 askMode = testMode ?
NExtract::NAskMode::kTest :
NExtract::NAskMode::kExtract;
@@ -124,7 +139,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
CLocalProgress *lps = new CLocalProgress;
CMyComPtr<ICompressProgressInfo> progress = lps;
- lps->Init(extractCallback, false);
+ lps->Init(extractCallback, true);
RINOK(_stream->Seek(_streamStartPosition + kSignatureSize, STREAM_SEEK_SET, NULL));
diff --git a/CPP/7zip/Archive/Zip/StdAfx.cpp b/CPP/7zip/Archive/Zip/StdAfx.cpp
deleted file mode 100755
index d0feea85..00000000
--- a/CPP/7zip/Archive/Zip/StdAfx.cpp
+++ /dev/null
@@ -1,3 +0,0 @@
-// StdAfx.cpp
-
-#include "StdAfx.h"
diff --git a/CPP/7zip/Archive/Zip/ZipAddCommon.cpp b/CPP/7zip/Archive/Zip/ZipAddCommon.cpp
index 0f76b04a..ca16ef97 100755
--- a/CPP/7zip/Archive/Zip/ZipAddCommon.cpp
+++ b/CPP/7zip/Archive/Zip/ZipAddCommon.cpp
@@ -2,8 +2,8 @@
#include "StdAfx.h"
-extern "C"
-{
+extern "C"
+{
#include "../../../../C/7zCrc.h"
}
@@ -49,7 +49,7 @@ static HRESULT GetStreamCRC(ISequentialInStream *inStream, UInt32 &resultCRC)
HRESULT CAddCommon::Compress(
DECL_EXTERNAL_CODECS_LOC_VARS
- ISequentialInStream *inStream, IOutStream *outStream,
+ ISequentialInStream *inStream, IOutStream *outStream,
ICompressProgressInfo *progress, CCompressingResult &operationResult)
{
CSequentialInStreamWithCRC *inSecCrcStreamSpec = 0;
@@ -57,7 +57,7 @@ HRESULT CAddCommon::Compress(
CMyComPtr<ISequentialInStream> inCrcStream;
{
CMyComPtr<IInStream> inStream2;
- // we don't support stdin, since stream from stdin can require 64-bit size header
+ // we don't support stdin, since stream from stdin can require 64-bit size header
RINOK(inStream->QueryInterface(IID_IInStream, (void **)&inStream2));
if (inStream2)
{
@@ -149,10 +149,10 @@ HRESULT CAddCommon::Compress(
switch(method)
{
case NFileHeader::NCompressionMethod::kBZip2:
- methodId = kMethodId_BZip2;
+ methodId = kMethodId_BZip2;
break;
default:
- methodId = kMethodId_ZipBase + method;
+ methodId = kMethodId_ZipBase + method;
break;
}
RINOK(CreateCoder(
@@ -164,14 +164,14 @@ HRESULT CAddCommon::Compress(
if (method == NFileHeader::NCompressionMethod::kDeflated ||
method == NFileHeader::NCompressionMethod::kDeflated64)
{
- NWindows::NCOM::CPropVariant properties[] =
+ NWindows::NCOM::CPropVariant properties[] =
{
- _options.Algo,
- _options.NumPasses,
+ _options.Algo,
+ _options.NumPasses,
_options.NumFastBytes,
_options.NumMatchFinderCycles
};
- PROPID propIDs[] =
+ PROPID propIDs[] =
{
NCoderPropID::kAlgorithm,
NCoderPropID::kNumPasses,
@@ -187,18 +187,18 @@ HRESULT CAddCommon::Compress(
{
RINOK(setCoderProperties->SetCoderProperties(propIDs, properties, numProps));
}
- }
+ }
else if (method == NFileHeader::NCompressionMethod::kBZip2)
{
- NWindows::NCOM::CPropVariant properties[] =
+ NWindows::NCOM::CPropVariant properties[] =
{
- _options.DicSize,
+ _options.DicSize,
_options.NumPasses
#ifdef COMPRESS_MT
, _options.NumThreads
#endif
};
- PROPID propIDs[] =
+ PROPID propIDs[] =
{
NCoderPropID::kDictionarySize,
NCoderPropID::kNumPasses
@@ -240,11 +240,11 @@ HRESULT CAddCommon::Compress(
if (_options.PasswordIsDefined)
{
- if (operationResult.PackSize < operationResult.UnpackSize +
+ if (operationResult.PackSize < operationResult.UnpackSize +
(_options.IsAesMode ? _filterAesSpec->GetHeaderSize() : NCrypto::NZip::kHeaderSize))
break;
}
- else if (operationResult.PackSize < operationResult.UnpackSize)
+ else if (operationResult.PackSize < operationResult.UnpackSize)
break;
}
if (_options.IsAesMode)
diff --git a/CPP/7zip/Archive/Zip/ZipAddCommon.h b/CPP/7zip/Archive/Zip/ZipAddCommon.h
index 7bce0cbe..6c766037 100755
--- a/CPP/7zip/Archive/Zip/ZipAddCommon.h
+++ b/CPP/7zip/Archive/Zip/ZipAddCommon.h
@@ -48,7 +48,7 @@ public:
CAddCommon(const CCompressionMethodMode &options);
HRESULT Compress(
DECL_EXTERNAL_CODECS_LOC_VARS
- ISequentialInStream *inStream, IOutStream *outStream,
+ ISequentialInStream *inStream, IOutStream *outStream,
ICompressProgressInfo *progress, CCompressingResult &operationResult);
};
diff --git a/CPP/7zip/Archive/Zip/ZipCompressionMode.h b/CPP/7zip/Archive/Zip/ZipCompressionMode.h
index 37f22f77..ae29a5a4 100755
--- a/CPP/7zip/Archive/Zip/ZipCompressionMode.h
+++ b/CPP/7zip/Archive/Zip/ZipCompressionMode.h
@@ -26,12 +26,12 @@ struct CCompressionMethodMode
bool IsAesMode;
Byte AesKeyMode;
- CCompressionMethodMode():
- NumMatchFinderCyclesDefined(false),
- PasswordIsDefined(false),
- IsAesMode(false),
- AesKeyMode(3)
- {}
+ CCompressionMethodMode():
+ NumMatchFinderCyclesDefined(false),
+ PasswordIsDefined(false),
+ IsAesMode(false),
+ AesKeyMode(3)
+ {}
};
}}
diff --git a/CPP/7zip/Archive/Zip/ZipHandler.cpp b/CPP/7zip/Archive/Zip/ZipHandler.cpp
index 7d478a36..aba36b3b 100755
--- a/CPP/7zip/Archive/Zip/ZipHandler.cpp
+++ b/CPP/7zip/Archive/Zip/ZipHandler.cpp
@@ -36,7 +36,6 @@
#endif
using namespace NWindows;
-using namespace NTime;
namespace NArchive {
namespace NZip {
@@ -45,7 +44,7 @@ namespace NZip {
static const CMethodId kMethodId_ZipBase = 0x040100;
static const CMethodId kMethodId_BZip2 = 0x040202;
-const wchar_t *kHostOS[] =
+const wchar_t *kHostOS[] =
{
L"FAT",
L"AMIGA",
@@ -74,17 +73,17 @@ static const int kNumHostOSes = sizeof(kHostOS) / sizeof(kHostOS[0]);
static const wchar_t *kUnknownOS = L"Unknown";
-STATPROPSTG kProps[] =
+STATPROPSTG kProps[] =
{
{ NULL, kpidPath, VT_BSTR},
- { NULL, kpidIsFolder, VT_BOOL},
+ { NULL, kpidIsDir, VT_BOOL},
{ NULL, kpidSize, VT_UI8},
- { NULL, kpidPackedSize, VT_UI8},
- { NULL, kpidLastWriteTime, VT_FILETIME},
- { NULL, kpidCreationTime, VT_FILETIME},
- { NULL, kpidLastAccessTime, VT_FILETIME},
+ { NULL, kpidPackSize, VT_UI8},
+ { NULL, kpidMTime, VT_FILETIME},
+ { NULL, kpidCTime, VT_FILETIME},
+ { NULL, kpidATime, VT_FILETIME},
- { NULL, kpidAttributes, VT_UI4},
+ { NULL, kpidAttrib, VT_UI4},
{ NULL, kpidEncrypted, VT_BOOL},
{ NULL, kpidComment, VT_BSTR},
@@ -97,7 +96,7 @@ STATPROPSTG kProps[] =
// { NULL, kpidUnpackVer, VT_UI1},
};
-const wchar_t *kMethods[] =
+const wchar_t *kMethods[] =
{
L"Store",
L"Shrink",
@@ -116,6 +115,7 @@ const wchar_t *kMethods[] =
const int kNumMethods = sizeof(kMethods) / sizeof(kMethods[0]);
// const wchar_t *kUnknownMethod = L"Unknown";
+const wchar_t *kWavPackMethod = L"WavPack";
const wchar_t *kPPMdMethod = L"PPMd";
const wchar_t *kAESMethod = L"AES";
const wchar_t *kZipCryptoMethod = L"ZipCrypto";
@@ -127,7 +127,7 @@ struct CStrongCryptoPair
const wchar_t *Name;
};
-CStrongCryptoPair g_StrongCryptoPairs[] =
+CStrongCryptoPair g_StrongCryptoPairs[] =
{
{ NStrongCryptoFlags::kDES, L"DES" },
{ NStrongCryptoFlags::kRC2old, L"RC2a" },
@@ -142,13 +142,13 @@ CStrongCryptoPair g_StrongCryptoPairs[] =
{ NStrongCryptoFlags::kRC4, L"RC4" }
};
-STATPROPSTG kArcProps[] =
+STATPROPSTG kArcProps[] =
{
+ { NULL, kpidBit64, VT_BOOL},
{ NULL, kpidComment, VT_BSTR}
};
-CHandler::CHandler():
- m_ArchiveIsOpen(false)
+CHandler::CHandler()
{
InitMethodProperties();
}
@@ -176,6 +176,7 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
NWindows::NCOM::CPropVariant prop;
switch(propID)
{
+ case kpidBit64: if (m_Archive.IsZip64) prop = m_Archive.IsZip64; break;
case kpidComment:
prop = MultiByteToUnicodeString(BytesToString(m_Archive.m_ArchiveInfo.Comment), CP_ACP);
break;
@@ -198,44 +199,38 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
const CItemEx &item = m_Items[index];
switch(propID)
{
- case kpidPath:
- prop = NItemName::GetOSName2(item.GetUnicodeString(item.Name));
- break;
- case kpidIsFolder:
- prop = item.IsDirectory();
- break;
- case kpidSize:
- prop = item.UnPackSize;
- break;
- case kpidPackedSize:
- prop = item.PackSize;
- break;
+ case kpidPath: prop = NItemName::GetOSName2(item.GetUnicodeString(item.Name)); break;
+ case kpidIsDir: prop = item.IsDir(); break;
+ case kpidSize: prop = item.UnPackSize; break;
+ case kpidPackSize: prop = item.PackSize; break;
case kpidTimeType:
+ {
FILETIME utcFileTime;
if (item.CentralExtra.GetNtfsTime(NFileHeader::NNtfsExtra::kTagTime, utcFileTime))
prop = (UInt32)NFileTimeType::kWindows;
break;
- case kpidCreationTime:
+ }
+ case kpidCTime:
{
FILETIME ft;
if (item.CentralExtra.GetNtfsTime(NFileHeader::NNtfsExtra::kCTime, ft))
prop = ft;
break;
}
- case kpidLastAccessTime:
+ case kpidATime:
{
FILETIME ft;
if (item.CentralExtra.GetNtfsTime(NFileHeader::NNtfsExtra::kATime, ft))
prop = ft;
break;
}
- case kpidLastWriteTime:
+ case kpidMTime:
{
FILETIME utcFileTime;
if (!item.CentralExtra.GetNtfsTime(NFileHeader::NNtfsExtra::kMTime, utcFileTime))
{
FILETIME localFileTime;
- if (DosTimeToFileTime(item.Time, localFileTime))
+ if (NTime::DosTimeToFileTime(item.Time, localFileTime))
{
if (!LocalFileTimeToFileTime(&localFileTime, &utcFileTime))
utcFileTime.dwHighDateTime = utcFileTime.dwLowDateTime = 0;
@@ -246,21 +241,10 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
prop = utcFileTime;
break;
}
- case kpidAttributes:
- prop = item.GetWinAttributes();
- break;
- case kpidEncrypted:
- prop = item.IsEncrypted();
- break;
- case kpidComment:
- {
- prop = item.GetUnicodeString(BytesToString(item.Comment));
- break;
- }
- case kpidCRC:
- if (item.IsThereCrc())
- prop = item.FileCRC;
- break;
+ case kpidAttrib: prop = item.GetWinAttributes(); break;
+ case kpidEncrypted: prop = item.IsEncrypted(); break;
+ case kpidComment: prop = item.GetUnicodeString(BytesToString(item.Comment)); break;
+ case kpidCRC: if (item.IsThereCrc()) prop = item.FileCRC; break;
case kpidMethod:
{
UInt16 methodId = item.CompressionMethod;
@@ -310,8 +294,10 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
}
if (methodId < kNumMethods)
method += kMethods[methodId];
- else if (methodId == NFileHeader::NCompressionMethod::kWzPPMd)
+ else if (methodId == NFileHeader::NCompressionMethod::kPPMd)
method += kPPMdMethod;
+ else if (methodId == NFileHeader::NCompressionMethod::kWavPack)
+ method += kWavPackMethod;
else
{
wchar_t s[32];
@@ -331,55 +317,50 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
COM_TRY_END
}
-class CPropgressImp: public CProgressVirt
+class CProgressImp: public CProgressVirt
{
- CMyComPtr<IArchiveOpenCallback> m_OpenArchiveCallback;
+ CMyComPtr<IArchiveOpenCallback> _callback;
public:
- STDMETHOD(SetCompleted)(const UInt64 *numFiles);
- void Init(IArchiveOpenCallback *openArchiveCallback)
- { m_OpenArchiveCallback = openArchiveCallback; }
+ STDMETHOD(SetTotal)(UInt64 numFiles);
+ STDMETHOD(SetCompleted)(UInt64 numFiles);
+ CProgressImp(IArchiveOpenCallback *callback): _callback(callback) {}
};
-STDMETHODIMP CPropgressImp::SetCompleted(const UInt64 *numFiles)
+STDMETHODIMP CProgressImp::SetTotal(UInt64 numFiles)
+{
+ if (_callback)
+ return _callback->SetTotal(&numFiles, NULL);
+ return S_OK;
+}
+
+STDMETHODIMP CProgressImp::SetCompleted(UInt64 numFiles)
{
- if (m_OpenArchiveCallback)
- return m_OpenArchiveCallback->SetCompleted(numFiles, NULL);
+ if (_callback)
+ return _callback->SetCompleted(&numFiles, NULL);
return S_OK;
}
-STDMETHODIMP CHandler::Open(IInStream *inStream,
- const UInt64 *maxCheckStartPosition, IArchiveOpenCallback *openArchiveCallback)
+STDMETHODIMP CHandler::Open(IInStream *inStream,
+ const UInt64 *maxCheckStartPosition, IArchiveOpenCallback *callback)
{
COM_TRY_BEGIN
- // try
+ try
{
- if(!m_Archive.Open(inStream, maxCheckStartPosition))
- return S_FALSE;
- m_ArchiveIsOpen = true;
- m_Items.Clear();
- if (openArchiveCallback != NULL)
- {
- RINOK(openArchiveCallback->SetTotal(NULL, NULL));
- }
- CPropgressImp propgressImp;
- propgressImp.Init(openArchiveCallback);
- RINOK(m_Archive.ReadHeaders(m_Items, &propgressImp));
- }
- /*
- catch(...)
- {
- return S_FALSE;
+ Close();
+ RINOK(inStream->Seek(0, STREAM_SEEK_SET, NULL));
+ RINOK(m_Archive.Open(inStream, maxCheckStartPosition));
+ CProgressImp progressImp(callback);
+ return m_Archive.ReadHeaders(m_Items, &progressImp);
}
- */
+ catch(const CInArchiveException &) { Close(); return S_FALSE; }
+ catch(...) { Close(); throw; }
COM_TRY_END
- return S_OK;
}
STDMETHODIMP CHandler::Close()
{
m_Items.Clear();
m_Archive.Close();
- m_ArchiveIsOpen = false;
return S_OK;
}
@@ -412,17 +393,17 @@ public:
HRESULT Decode(
DECL_EXTERNAL_CODECS_LOC_VARS
- CInArchive &archive, const CItemEx &item,
- ISequentialOutStream *realOutStream,
- IArchiveExtractCallback *extractCallback,
+ CInArchive &archive, const CItemEx &item,
+ ISequentialOutStream *realOutStream,
+ IArchiveExtractCallback *extractCallback,
ICompressProgressInfo *compressProgress,
UInt32 numThreads, Int32 &res);
};
HRESULT CZipDecoder::Decode(
DECL_EXTERNAL_CODECS_LOC_VARS
- CInArchive &archive, const CItemEx &item,
- ISequentialOutStream *realOutStream,
+ CInArchive &archive, const CItemEx &item,
+ ISequentialOutStream *realOutStream,
IArchiveExtractCallback *extractCallback,
ICompressProgressInfo *compressProgress,
UInt32 numThreads, Int32 &res)
@@ -534,7 +515,7 @@ HRESULT CZipDecoder::Decode(
CMyComBSTR password;
RINOK(getTextPassword->CryptoGetTextPassword(&password));
AString charPassword;
- if (aesMode
+ if (aesMode
#ifdef ZIP_STRONG_SUPORT
|| pkAesMode
#endif
@@ -662,7 +643,7 @@ HRESULT CZipDecoder::Decode(
}
RINOK(filterStreamSpec->SetInStream(inStream));
inStreamReleaser.FilterCoder = filterStreamSpec;
- inStreamNew = filterStream;
+ inStreamNew = filterStream;
if (aesMode)
{
@@ -671,7 +652,7 @@ HRESULT CZipDecoder::Decode(
}
}
else
- inStreamNew = inStream;
+ inStreamNew = inStream;
result = coder->Code(inStreamNew, outStream, NULL, &item.UnPackSize, compressProgress);
if (result == S_FALSE)
return S_OK;
@@ -688,7 +669,7 @@ HRESULT CZipDecoder::Decode(
authOk = false;
}
- res = ((crcOK && authOk) ?
+ res = ((crcOK && authOk) ?
NArchive::NExtract::NOperationResult::kOK :
NArchive::NExtract::NOperationResult::kCRCError);
return S_OK;
@@ -734,7 +715,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
RINOK(lps->SetCur());
CMyComPtr<ISequentialOutStream> realOutStream;
- Int32 askMode = testMode ?
+ Int32 askMode = testMode ?
NArchive::NExtract::NAskMode::kTest :
NArchive::NExtract::NAskMode::kExtract;
Int32 index = allFilesMode ? i : indices[i];
@@ -747,7 +728,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
HRESULT res = m_Archive.ReadLocalItemAfterCdItem(item);
if (res == S_FALSE)
{
- if (item.IsDirectory() || realOutStream || testMode)
+ if (item.IsDir() || realOutStream || testMode)
{
RINOK(extractCallback->PrepareOperation(askMode));
realOutStream.Release();
@@ -758,7 +739,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
RINOK(res);
}
- if (item.IsDirectory() || item.IgnoreItem())
+ if (item.IsDir() || item.IgnoreItem())
{
// if (!testMode)
{
@@ -772,7 +753,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
currentItemUnPacked = item.UnPackSize;
currentItemPacked = item.PackSize;
- if (!testMode && (!realOutStream))
+ if (!testMode && (!realOutStream))
continue;
RINOK(extractCallback->PrepareOperation(askMode));
@@ -780,7 +761,7 @@ STDMETHODIMP CHandler::Extract(const UInt32* indices, UInt32 numItems,
Int32 res;
RINOK(myDecoder.Decode(
EXTERNAL_CODECS_VARS
- m_Archive, item, realOutStream, extractCallback,
+ m_Archive, item, realOutStream, extractCallback,
progress, _numThreads, res));
realOutStream.Release();
diff --git a/CPP/7zip/Archive/Zip/ZipHandler.h b/CPP/7zip/Archive/Zip/ZipHandler.h
index c8fa392c..09179111 100755
--- a/CPP/7zip/Archive/Zip/ZipHandler.h
+++ b/CPP/7zip/Archive/Zip/ZipHandler.h
@@ -19,7 +19,7 @@
namespace NArchive {
namespace NZip {
-class CHandler:
+class CHandler:
public IInArchive,
public IOutArchive,
public ISetProperties,
@@ -45,7 +45,6 @@ public:
private:
CObjectVector<CItemEx> m_Items;
CInArchive m_Archive;
- bool m_ArchiveIsOpen;
int m_Level;
int m_MainMethod;
@@ -73,10 +72,10 @@ private:
{
m_Level = -1;
m_MainMethod = -1;
- m_Algo =
- m_DicSize =
- m_NumPasses =
- m_NumFastBytes =
+ m_Algo =
+ m_DicSize =
+ m_NumPasses =
+ m_NumFastBytes =
m_NumMatchFinderCycles = 0xFFFFFFFF;
m_NumMatchFinderCyclesDefined = false;
m_IsAesMode = false;
diff --git a/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp b/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp
index 2846c988..c493b0c9 100755
--- a/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp
+++ b/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp
@@ -83,7 +83,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
{
COM_TRY_BEGIN2
CObjectVector<CUpdateItem> updateItems;
- for(UInt32 i = 0; i < numItems; i++)
+ for (UInt32 i = 0; i < numItems; i++)
{
CUpdateItem ui;
Int32 newData;
@@ -91,10 +91,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
UInt32 indexInArchive;
if (!callback)
return E_FAIL;
- RINOK(callback->GetUpdateItemInfo(i,
- &newData, // 1 - compress 0 - copy
- &newProperties,
- &indexInArchive));
+ RINOK(callback->GetUpdateItemInfo(i, &newData, &newProperties, &indexInArchive));
ui.NewProperties = IntToBool(newProperties);
ui.NewData = IntToBool(newData);
ui.IndexInArchive = indexInArchive;
@@ -103,10 +100,9 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
if (IntToBool(newProperties))
{
UString name;
- bool isDirectoryStatusDefined;
{
NCOM::CPropVariant prop;
- RINOK(callback->GetProperty(i, kpidAttributes, &prop));
+ RINOK(callback->GetProperty(i, kpidAttrib, &prop));
if (prop.vt == VT_EMPTY)
ui.Attributes = 0;
else if (prop.vt != VT_UI4)
@@ -127,16 +123,13 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
}
{
NCOM::CPropVariant prop;
- RINOK(callback->GetProperty(i, kpidIsFolder, &prop));
+ RINOK(callback->GetProperty(i, kpidIsDir, &prop));
if (prop.vt == VT_EMPTY)
- isDirectoryStatusDefined = false;
+ ui.IsDir = false;
else if (prop.vt != VT_BOOL)
return E_INVALIDARG;
else
- {
- ui.IsDirectory = (prop.boolVal != VARIANT_FALSE);
- isDirectoryStatusDefined = true;
- }
+ ui.IsDir = (prop.boolVal != VARIANT_FALSE);
}
{
@@ -147,9 +140,9 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
else
ui.NtfsTimeIsDefined = m_WriteNtfsTimeExtra;
}
- RINOK(GetTime(callback, i, kpidLastWriteTime, ui.NtfsMTime));
- RINOK(GetTime(callback, i, kpidLastAccessTime, ui.NtfsATime));
- RINOK(GetTime(callback, i, kpidCreationTime, ui.NtfsCTime));
+ RINOK(GetTime(callback, i, kpidMTime, ui.NtfsMTime));
+ RINOK(GetTime(callback, i, kpidATime, ui.NtfsATime));
+ RINOK(GetTime(callback, i, kpidCTime, ui.NtfsCTime));
{
FILETIME localFileTime = { 0, 0 };
@@ -160,17 +153,14 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
FileTimeToDosTime(localFileTime, ui.Time);
}
- if (!isDirectoryStatusDefined)
- ui.IsDirectory = ((ui.Attributes & FILE_ATTRIBUTE_DIRECTORY) != 0);
-
name = NItemName::MakeLegalName(name);
- bool needSlash = ui.IsDirectory;
+ bool needSlash = ui.IsDir;
const wchar_t kSlash = L'/';
if (!name.IsEmpty())
{
if (name[name.Length() - 1] == kSlash)
{
- if (!ui.IsDirectory)
+ if (!ui.IsDir)
return E_INVALIDARG;
needSlash = false;
}
@@ -205,12 +195,12 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
ui.IndexInClient = i;
/*
- if(existInArchive)
+ if (existInArchive)
{
const CItemEx &itemInfo = m_Items[indexInArchive];
// ui.Commented = itemInfo.IsCommented();
ui.Commented = false;
- if(ui.Commented)
+ if (ui.Commented)
{
ui.CommentRange.Position = itemInfo.GetCommentPosition();
ui.CommentRange.Size = itemInfo.CommentSize;
@@ -280,7 +270,7 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
options.MethodSequence.Add(mainMethod);
if (mainMethod != NFileHeader::NCompressionMethod::kStored)
options.MethodSequence.Add(NFileHeader::NCompressionMethod::kStored);
- bool isDeflate = (mainMethod == NFileHeader::NCompressionMethod::kDeflated) ||
+ bool isDeflate = (mainMethod == NFileHeader::NCompressionMethod::kDeflated) ||
(mainMethod == NFileHeader::NCompressionMethod::kDeflated64);
bool isBZip2 = (mainMethod == NFileHeader::NCompressionMethod::kBZip2);
options.NumPasses = m_NumPasses;
@@ -295,34 +285,34 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
if (isDeflate)
{
if (options.NumPasses == 0xFFFFFFFF)
- options.NumPasses = (level >= 9 ? kDeflateNumPassesX9 :
- (level >= 7 ? kDeflateNumPassesX7 :
+ options.NumPasses = (level >= 9 ? kDeflateNumPassesX9 :
+ (level >= 7 ? kDeflateNumPassesX7 :
kDeflateNumPassesX1));
if (options.NumFastBytes == 0xFFFFFFFF)
- options.NumFastBytes = (level >= 9 ? kNumFastBytesX9 :
- (level >= 7 ? kNumFastBytesX7 :
+ options.NumFastBytes = (level >= 9 ? kNumFastBytesX9 :
+ (level >= 7 ? kNumFastBytesX7 :
kNumFastBytesX1));
if (options.Algo == 0xFFFFFFFF)
- options.Algo =
- (level >= 5 ? kDeflateAlgoX5 :
- kDeflateAlgoX1);
+ options.Algo =
+ (level >= 5 ? kDeflateAlgoX5 :
+ kDeflateAlgoX1);
}
if (isBZip2)
{
if (options.NumPasses == 0xFFFFFFFF)
- options.NumPasses = (level >= 9 ? kBZip2NumPassesX9 :
- (level >= 7 ? kBZip2NumPassesX7 :
+ options.NumPasses = (level >= 9 ? kBZip2NumPassesX9 :
+ (level >= 7 ? kBZip2NumPassesX7 :
kBZip2NumPassesX1));
if (options.DicSize == 0xFFFFFFFF)
- options.DicSize = (level >= 5 ? kBZip2DicSizeX5 :
- (level >= 3 ? kBZip2DicSizeX3 :
+ options.DicSize = (level >= 5 ? kBZip2DicSizeX5 :
+ (level >= 3 ? kBZip2DicSizeX3 :
kBZip2DicSizeX1));
}
return Update(
EXTERNAL_CODECS_VARS
- m_Items, updateItems, outStream,
- m_ArchiveIsOpen ? &m_Archive : NULL, &options, callback);
+ m_Items, updateItems, outStream,
+ m_Archive.IsOpen() ? &m_Archive : NULL, &options, callback);
COM_TRY_END2
}
@@ -363,7 +353,7 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *v
m_MainMethod = NFileHeader::NCompressionMethod::kDeflated64;
else if (valueString == L"BZIP2")
m_MainMethod = NFileHeader::NCompressionMethod::kBZip2;
- else
+ else
return E_INVALIDARG;
}
else if (prop.vt == VT_UI4)
@@ -463,10 +453,10 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *v
m_ForseLocal = false;
return S_OK;
}
- else
+ else
return E_INVALIDARG;
}
return S_OK;
-}
+}
}}
diff --git a/CPP/7zip/Archive/Zip/ZipHeader.cpp b/CPP/7zip/Archive/Zip/ZipHeader.cpp
index fd8856bb..582187b5 100755
--- a/CPP/7zip/Archive/Zip/ZipHeader.cpp
+++ b/CPP/7zip/Archive/Zip/ZipHeader.cpp
@@ -19,9 +19,9 @@ namespace NSignature
class CMarkersInitializer
{
public:
- CMarkersInitializer()
- {
- kLocalFileHeader--;
+ CMarkersInitializer()
+ {
+ kLocalFileHeader--;
kDataDescriptor--;
kCentralFileHeader--;
kEndOfCentralDir--;
diff --git a/CPP/7zip/Archive/Zip/ZipHeader.h b/CPP/7zip/Archive/Zip/ZipHeader.h
index 0c978a7c..3af72369 100755
--- a/CPP/7zip/Archive/Zip/ZipHeader.h
+++ b/CPP/7zip/Archive/Zip/ZipHeader.h
@@ -55,7 +55,7 @@ namespace NFileHeader
namespace NCompressionMethod
{
enum EType
- {
+ {
kStored = 0,
kShrunk = 1,
kReduced1 = 2,
@@ -64,12 +64,13 @@ namespace NFileHeader
kReduced4 = 5,
kImploded = 6,
kReservedTokenizing = 7, // reserved for tokenizing
- kDeflated = 8,
+ kDeflated = 8,
kDeflated64 = 9,
kPKImploding = 10,
kBZip2 = 12,
- kWzPPMd = 0x62,
+ kWavPack = 0x61,
+ kPPMd = 0x62,
kWzAES = 0x63
};
const int kNumCompressionMethods = 11;
@@ -83,8 +84,8 @@ namespace NFileHeader
namespace NExtraID
{
- enum
- {
+ enum
+ {
kZip64 = 0x01,
kNTFS = 0x0A,
kStrongEncrypt = 0x17,
@@ -166,7 +167,7 @@ namespace NFileHeader
};
*/
- namespace NFlags
+ namespace NFlags
{
const int kEncrypted = 1 << 0;
const int kDescriptorUsedMask = 1 << 3;
@@ -196,8 +197,8 @@ namespace NFileHeader
kMac = 7,
kZ_System = 8,
kCPM = 9,
- kTOPS20 = 10, // pkzip 2.50 NTFS
- kNTFS = 11, // filesystem used by Windows NT
+ kTOPS20 = 10, // pkzip 2.50 NTFS
+ kNTFS = 11, // filesystem used by Windows NT
kQDOS = 12, // SMS/QDOS
kAcorn = 13, // Archimedes Acorn RISC OS
kVFAT = 14, // filesystem used by Windows 95, NT
diff --git a/CPP/7zip/Archive/Zip/ZipIn.cpp b/CPP/7zip/Archive/Zip/ZipIn.cpp
index f8e81c59..d67713ce 100755
--- a/CPP/7zip/Archive/Zip/ZipIn.cpp
+++ b/CPP/7zip/Archive/Zip/ZipIn.cpp
@@ -9,18 +9,29 @@
#include "../../Common/LimitedStreams.h"
#include "../../Common/StreamUtils.h"
+extern "C"
+{
+ #include "../../../../C/CpuArch.h"
+}
+
+#define Get16(p) GetUi16(p)
+#define Get32(p) GetUi32(p)
+#define Get64(p) GetUi64(p)
+
namespace NArchive {
namespace NZip {
// static const char kEndOfString = '\0';
-
-bool CInArchive::Open(IInStream *inStream, const UInt64 *searchHeaderSizeLimit)
+
+HRESULT CInArchive::Open(IInStream *stream, const UInt64 *searchHeaderSizeLimit)
{
- m_Stream = inStream;
- if(m_Stream->Seek(0, STREAM_SEEK_CUR, &m_StreamStartPosition) != S_OK)
- return false;
+ Close();
+ RINOK(stream->Seek(0, STREAM_SEEK_CUR, &m_StreamStartPosition));
m_Position = m_StreamStartPosition;
- return FindAndReadMarker(searchHeaderSizeLimit);
+ RINOK(FindAndReadMarker(stream, searchHeaderSizeLimit));
+ RINOK(stream->Seek(m_Position, STREAM_SEEK_SET, NULL));
+ m_Stream = stream;
+ return S_OK;
}
void CInArchive::Close()
@@ -38,85 +49,76 @@ HRESULT CInArchive::Seek(UInt64 offset)
static inline bool TestMarkerCandidate(const Byte *p, UInt32 &value)
{
- value = p[0] | (((UInt32)p[1]) << 8) | (((UInt32)p[2]) << 16) | (((UInt32)p[3]) << 24);
- return (value == NSignature::kLocalFileHeader) ||
+ value = Get32(p);
+ return
+ (value == NSignature::kLocalFileHeader) ||
(value == NSignature::kEndOfCentralDir);
}
static const UInt32 kNumMarkerAddtionalBytes = 2;
static inline bool TestMarkerCandidate2(const Byte *p, UInt32 &value)
{
- value = p[0] | (((UInt32)p[1]) << 8) | (((UInt32)p[2]) << 16) | (((UInt32)p[3]) << 24);
+ value = Get32(p);
if (value == NSignature::kEndOfCentralDir)
- {
- UInt16 nextWord = p[0] | (((UInt16)p[1]) << 8);
- return (nextWord == 0);
- }
- if (value != NSignature::kLocalFileHeader)
- return false;
- if (p[0] > 128)
- return false;
- return true;
+ return (Get16(p + 4) == 0);
+ return (value == NSignature::kLocalFileHeader && p[4] < 128);
}
-bool CInArchive::FindAndReadMarker(const UInt64 *searchHeaderSizeLimit)
+HRESULT CInArchive::FindAndReadMarker(IInStream *stream, const UInt64 *searchHeaderSizeLimit)
{
m_ArchiveInfo.Clear();
m_Position = m_StreamStartPosition;
- if(Seek(m_StreamStartPosition) != S_OK)
- return false;
Byte marker[NSignature::kMarkerSize];
- UInt32 processedSize;
- ReadBytes(marker, NSignature::kMarkerSize, &processedSize);
- if(processedSize != NSignature::kMarkerSize)
- return false;
+ RINOK(ReadStream_FALSE(stream, marker, NSignature::kMarkerSize));
+ m_Position += NSignature::kMarkerSize;
if (TestMarkerCandidate(marker, m_Signature))
- return true;
+ return S_OK;
CByteDynamicBuffer dynamicBuffer;
- static const UInt32 kSearchMarkerBufferSize = 0x10000;
+ const UInt32 kSearchMarkerBufferSize = 0x10000;
dynamicBuffer.EnsureCapacity(kSearchMarkerBufferSize);
Byte *buffer = dynamicBuffer;
UInt32 numBytesPrev = NSignature::kMarkerSize - 1;
- memmove(buffer, marker + 1, numBytesPrev);
+ memcpy(buffer, marker + 1, numBytesPrev);
UInt64 curTestPos = m_StreamStartPosition + 1;
for (;;)
{
if (searchHeaderSizeLimit != NULL)
if (curTestPos - m_StreamStartPosition > *searchHeaderSizeLimit)
break;
- UInt32 numReadBytes = kSearchMarkerBufferSize - numBytesPrev;
- ReadBytes(buffer + numBytesPrev, numReadBytes, &processedSize);
- UInt32 numBytesInBuffer = numBytesPrev + processedSize;
+ size_t numReadBytes = kSearchMarkerBufferSize - numBytesPrev;
+ RINOK(ReadStream(stream, buffer + numBytesPrev, &numReadBytes));
+ m_Position += numReadBytes;
+ UInt32 numBytesInBuffer = numBytesPrev + (UInt32)numReadBytes;
const UInt32 kMarker2Size = NSignature::kMarkerSize + kNumMarkerAddtionalBytes;
if (numBytesInBuffer < kMarker2Size)
break;
UInt32 numTests = numBytesInBuffer - kMarker2Size + 1;
- for(UInt32 pos = 0; pos < numTests; pos++, curTestPos++)
- {
+ for (UInt32 pos = 0; pos < numTests; pos++)
+ {
+ if (buffer[pos] != 0x50)
+ continue;
if (TestMarkerCandidate2(buffer + pos, m_Signature))
{
+ curTestPos += pos;
m_ArchiveInfo.StartPosition = curTestPos;
- // m_ArchiveInfo.Base = m_ArchiveInfo.StartPosition;
- // m_ArchiveInfo.Base = 0;
m_Position = curTestPos + NSignature::kMarkerSize;
- if(Seek(m_Position) != S_OK)
- return false;
- return true;
+ return S_OK;
}
}
+ curTestPos += numTests;
numBytesPrev = numBytesInBuffer - numTests;
memmove(buffer, buffer + numTests, numBytesPrev);
}
- return false;
+ return S_FALSE;
}
HRESULT CInArchive::ReadBytes(void *data, UInt32 size, UInt32 *processedSize)
{
size_t realProcessedSize = size;
HRESULT result = ReadStream(m_Stream, data, &realProcessedSize);
- if(processedSize != NULL)
+ if (processedSize != NULL)
*processedSize = (UInt32)realProcessedSize;
m_Position += realProcessedSize;
return result;
@@ -124,21 +126,21 @@ HRESULT CInArchive::ReadBytes(void *data, UInt32 size, UInt32 *processedSize)
void CInArchive::IncreaseRealPosition(UInt64 addValue)
{
- if(m_Stream->Seek(addValue, STREAM_SEEK_CUR, &m_Position) != S_OK)
+ if (m_Stream->Seek(addValue, STREAM_SEEK_CUR, &m_Position) != S_OK)
throw CInArchiveException(CInArchiveException::kSeekStreamError);
}
bool CInArchive::ReadBytesAndTestSize(void *data, UInt32 size)
{
UInt32 realProcessedSize;
- if(ReadBytes(data, size, &realProcessedSize) != S_OK)
+ if (ReadBytes(data, size, &realProcessedSize) != S_OK)
throw CInArchiveException(CInArchiveException::kReadStreamError);
return (realProcessedSize == size);
}
void CInArchive::SafeReadBytes(void *data, UInt32 size)
{
- if(!ReadBytesAndTestSize(data, size))
+ if (!ReadBytesAndTestSize(data, size))
throw CInArchiveException(CInArchiveException::kUnexpectedEndOfArchive);
}
@@ -198,8 +200,10 @@ AString CInArchive::ReadFileName(UInt32 nameSize)
{
if (nameSize == 0)
return AString();
- SafeReadBytes(m_NameBuffer.GetBuffer(nameSize), nameSize);
- m_NameBuffer.ReleaseBuffer(nameSize);
+ char *p = m_NameBuffer.GetBuffer(nameSize);
+ SafeReadBytes(p, nameSize);
+ p[nameSize] = 0;
+ m_NameBuffer.ReleaseBuffer();
return m_NameBuffer;
}
@@ -217,7 +221,7 @@ void CInArchive::ThrowIncorrectArchiveException()
static UInt32 GetUInt32(const Byte *data)
{
- return
+ return
((UInt32)(Byte)data[0]) |
(((UInt32)(Byte)data[1]) << 8) |
(((UInt32)(Byte)data[2]) << 16) |
@@ -227,7 +231,7 @@ static UInt32 GetUInt32(const Byte *data)
/*
static UInt16 GetUInt16(const Byte *data)
{
- return
+ return
((UInt16)(Byte)data[0]) |
(((UInt16)(Byte)data[1]) << 8);
}
@@ -240,7 +244,7 @@ static UInt64 GetUInt64(const Byte *data)
-void CInArchive::ReadExtra(UInt32 extraSize, CExtraBlock &extraBlock,
+void CInArchive::ReadExtra(UInt32 extraSize, CExtraBlock &extraBlock,
UInt64 &unpackSize, UInt64 &packSize, UInt64 &localHeaderOffset, UInt32 &diskStartNumber)
{
extraBlock.Clear();
@@ -318,11 +322,11 @@ HRESULT CInArchive::ReadLocalItem(CItemEx &item)
{
UInt64 localHeaderOffset = 0;
UInt32 diskStartNumber = 0;
- ReadExtra(item.LocalExtraSize, item.LocalExtra, item.UnPackSize, item.PackSize,
+ ReadExtra(item.LocalExtraSize, item.LocalExtra, item.UnPackSize, item.PackSize,
localHeaderOffset, diskStartNumber);
}
/*
- if (item.IsDirectory())
+ if (item.IsDir())
item.UnPackSize = 0; // check It
*/
return S_OK;
@@ -354,10 +358,10 @@ HRESULT CInArchive::ReadLocalItemAfterCdItem(CItemEx &item)
if (item.CompressionMethod != localItem.CompressionMethod ||
// item.Time != localItem.Time ||
- (!localItem.HasDescriptor() &&
- (
+ (!localItem.HasDescriptor() &&
+ (
item.FileCRC != localItem.FileCRC ||
- item.PackSize != localItem.PackSize ||
+ item.PackSize != localItem.PackSize ||
item.UnPackSize != localItem.UnPackSize
)
) ||
@@ -394,7 +398,7 @@ HRESULT CInArchive::ReadLocalItemDescriptor(CItemEx &item)
UInt32 i;
for (i = 0; i <= numBytesInBuffer - NFileHeader::kDataDescriptorSize; i++)
{
- // descriptorSignature field is Info-ZIP's extension
+ // descriptorSignature field is Info-ZIP's extension
// to Zip specification.
UInt32 descriptorSignature = GetUInt32(buffer + i);
@@ -415,7 +419,7 @@ HRESULT CInArchive::ReadLocalItemDescriptor(CItemEx &item)
packedSize += i;
int j;
for (j = 0; i < numBytesInBuffer; i++, j++)
- buffer[j] = buffer[i];
+ buffer[j] = buffer[i];
numBytesInBuffer = j;
}
}
@@ -463,28 +467,31 @@ HRESULT CInArchive::ReadLocalItemAfterCdItemFull(CItemEx &item)
HRESULT CInArchive::ReadCdItem(CItemEx &item)
{
item.FromCentral = true;
- item.MadeByVersion.Version = ReadByte();
- item.MadeByVersion.HostOS = ReadByte();
- item.ExtractVersion.Version = ReadByte();
- item.ExtractVersion.HostOS = ReadByte();
- item.Flags = ReadUInt16();
- item.CompressionMethod = ReadUInt16();
- item.Time = ReadUInt32();
- item.FileCRC = ReadUInt32();
- item.PackSize = ReadUInt32();
- item.UnPackSize = ReadUInt32();
- UInt16 headerNameSize = ReadUInt16();
- UInt16 headerExtraSize = ReadUInt16();
- UInt16 headerCommentSize = ReadUInt16();
- UInt32 headerDiskNumberStart = ReadUInt16();
- item.InternalAttributes = ReadUInt16();
- item.ExternalAttributes = ReadUInt32();
- item.LocalHeaderPosition = ReadUInt32();
+ const int kBufSize = 42;
+ Byte p[kBufSize];
+ SafeReadBytes(p, kBufSize);
+ item.MadeByVersion.Version = p[0];
+ item.MadeByVersion.HostOS = p[1];
+ item.ExtractVersion.Version = p[2];
+ item.ExtractVersion.HostOS = p[3];
+ item.Flags = Get16(p + 4);
+ item.CompressionMethod = Get16(p + 6);
+ item.Time = Get32(p + 8);
+ item.FileCRC = Get32(p + 12);
+ item.PackSize = Get32(p + 16);
+ item.UnPackSize = Get32(p + 20);
+ UInt16 headerNameSize = Get16(p + 24);
+ UInt16 headerExtraSize = Get16(p + 26);
+ UInt16 headerCommentSize = Get16(p + 28);
+ UInt32 headerDiskNumberStart = Get16(p + 30);
+ item.InternalAttributes = Get16(p + 32);
+ item.ExternalAttributes = Get32(p + 34);
+ item.LocalHeaderPosition = Get32(p + 38);
item.Name = ReadFileName(headerNameSize);
if (headerExtraSize > 0)
{
- ReadExtra(headerExtraSize, item.CentralExtra, item.UnPackSize, item.PackSize,
+ ReadExtra(headerExtraSize, item.CentralExtra, item.UnPackSize, item.PackSize,
item.LocalHeaderPosition, headerDiskNumberStart);
}
@@ -493,7 +500,7 @@ HRESULT CInArchive::ReadCdItem(CItemEx &item)
// May be these strings must be deleted
/*
- if (item.IsDirectory())
+ if (item.IsDir())
item.UnPackSize = 0;
*/
@@ -506,7 +513,7 @@ HRESULT CInArchive::TryEcd64(UInt64 offset, CCdInfo &cdInfo)
RINOK(Seek(offset));
const UInt32 kEcd64Size = 56;
Byte buf[kEcd64Size];
- if(!ReadBytesAndTestSize(buf, kEcd64Size))
+ if (!ReadBytesAndTestSize(buf, kEcd64Size))
return S_FALSE;
if (GetUInt32(buf) != NSignature::kZip64EndOfCentralDir)
return S_FALSE;
@@ -531,7 +538,7 @@ HRESULT CInArchive::FindCd(CCdInfo &cdInfo)
return S_FALSE;
if (!ReadBytesAndTestSize(buf, bufSize))
return S_FALSE;
- for (int i = (int)(bufSize - kEcdSize); i >= 0; i--)
+ for (int i = (int)(bufSize - kEcdSize); i >= 0; i--)
{
if (GetUInt32(buf + i) == NSignature::kEndOfCentralDir)
{
@@ -566,7 +573,7 @@ HRESULT CInArchive::FindCd(CCdInfo &cdInfo)
return S_FALSE;
}
-HRESULT CInArchive::TryReadCd(CObjectVector<CItemEx> &items, UInt64 cdOffset, UInt64 cdSize)
+HRESULT CInArchive::TryReadCd(CObjectVector<CItemEx> &items, UInt64 cdOffset, UInt64 cdSize, CProgressVirt *progress)
{
items.Clear();
RINOK(m_Stream->Seek(cdOffset, STREAM_SEEK_SET, &m_Position));
@@ -574,16 +581,18 @@ HRESULT CInArchive::TryReadCd(CObjectVector<CItemEx> &items, UInt64 cdOffset, UI
return S_FALSE;
while(m_Position - cdOffset < cdSize)
{
- if(ReadUInt32() != NSignature::kCentralFileHeader)
+ if (ReadUInt32() != NSignature::kCentralFileHeader)
return S_FALSE;
CItemEx cdItem;
RINOK(ReadCdItem(cdItem));
items.Add(cdItem);
+ if (progress && items.Size() % 1000 == 0)
+ RINOK(progress->SetCompleted(items.Size()));
}
return (m_Position - cdOffset == cdSize) ? S_OK : S_FALSE;
}
-HRESULT CInArchive::ReadCd(CObjectVector<CItemEx> &items, UInt64 &cdOffset, UInt64 &cdSize)
+HRESULT CInArchive::ReadCd(CObjectVector<CItemEx> &items, UInt64 &cdOffset, UInt64 &cdSize, CProgressVirt *progress)
{
m_ArchiveInfo.Base = 0;
CCdInfo cdInfo;
@@ -591,10 +600,10 @@ HRESULT CInArchive::ReadCd(CObjectVector<CItemEx> &items, UInt64 &cdOffset, UInt
HRESULT res = S_FALSE;
cdSize = cdInfo.Size;
cdOffset = cdInfo.Offset;
- res = TryReadCd(items, m_ArchiveInfo.Base + cdOffset, cdSize);
+ res = TryReadCd(items, m_ArchiveInfo.Base + cdOffset, cdSize, progress);
if (res == S_FALSE && m_ArchiveInfo.Base == 0)
{
- res = TryReadCd(items, cdInfo.Offset + m_ArchiveInfo.StartPosition, cdSize);
+ res = TryReadCd(items, cdInfo.Offset + m_ArchiveInfo.StartPosition, cdSize, progress);
if (res == S_OK)
m_ArchiveInfo.Base = m_ArchiveInfo.StartPosition;
}
@@ -616,23 +625,17 @@ HRESULT CInArchive::ReadLocalsAndCd(CObjectVector<CItemEx> &items, CProgressVirt
item.FromLocal = true;
ReadLocalItemDescriptor(item);
items.Add(item);
- if (progress != 0)
- {
- UInt64 numItems = items.Size();
- RINOK(progress->SetCompleted(&numItems));
- }
+ if (progress && items.Size() % 100 == 0)
+ RINOK(progress->SetCompleted(items.Size()));
if (!ReadUInt32(m_Signature))
break;
}
cdOffset = m_Position - 4;
- for(int i = 0; i < items.Size(); i++)
+ for (int i = 0; i < items.Size(); i++)
{
- if (progress != 0)
- {
- UInt64 numItems = items.Size();
- RINOK(progress->SetCompleted(&numItems));
- }
- if(m_Signature != NSignature::kCentralFileHeader)
+ if (progress && i % 1000 == 0)
+ RINOK(progress->SetCompleted(items.Size()));
+ if (m_Signature != NSignature::kCentralFileHeader)
return S_FALSE;
CItemEx cdItem;
@@ -688,6 +691,58 @@ HRESULT CInArchive::ReadLocalsAndCd(CObjectVector<CItemEx> &items, CProgressVirt
return S_OK;
}
+struct CEcd
+{
+ UInt16 thisDiskNumber;
+ UInt16 startCDDiskNumber;
+ UInt16 numEntriesInCDOnThisDisk;
+ UInt16 numEntriesInCD;
+ UInt32 cdSize;
+ UInt32 cdStartOffset;
+ UInt16 commentSize;
+ void Parse(const Byte *p);
+};
+
+void CEcd::Parse(const Byte *p)
+{
+ thisDiskNumber = Get16(p);
+ startCDDiskNumber = Get16(p + 2);
+ numEntriesInCDOnThisDisk = Get16(p + 4);
+ numEntriesInCD = Get16(p + 6);
+ cdSize = Get32(p + 8);
+ cdStartOffset = Get32(p + 12);
+ commentSize = Get16(p + 16);
+}
+
+struct CEcd64
+{
+ UInt16 versionMade;
+ UInt16 versionNeedExtract;
+ UInt32 thisDiskNumber;
+ UInt32 startCDDiskNumber;
+ UInt64 numEntriesInCDOnThisDisk;
+ UInt64 numEntriesInCD;
+ UInt64 cdSize;
+ UInt64 cdStartOffset;
+ void Parse(const Byte *p);
+ CEcd64() { memset(this, 0, sizeof(*this)); }
+};
+
+void CEcd64::Parse(const Byte *p)
+{
+ versionMade = Get16(p);
+ versionNeedExtract = Get16(p + 2);
+ thisDiskNumber = Get32(p + 4);
+ startCDDiskNumber = Get32(p + 8);
+ numEntriesInCDOnThisDisk = Get64(p + 12);
+ numEntriesInCD = Get64(p + 20);
+ cdSize = Get64(p + 28);
+ cdStartOffset = Get64(p + 36);
+}
+
+#define COPY_ECD_ITEM_16(n) if (!isZip64 || ecd. ## n != 0xFFFF) ecd64. ## n = ecd. ## n;
+#define COPY_ECD_ITEM_32(n) if (!isZip64 || ecd. ## n != 0xFFFFFFFF) ecd64. ## n = ecd. ## n;
+
HRESULT CInArchive::ReadHeaders(CObjectVector<CItemEx> &items, CProgressVirt *progress)
{
// m_Signature must be kLocalFileHeaderSignature or
@@ -696,14 +751,9 @@ HRESULT CInArchive::ReadHeaders(CObjectVector<CItemEx> &items, CProgressVirt *pr
IsZip64 = false;
items.Clear();
- if (progress != 0)
- {
- UInt64 numItems = items.Size();
- RINOK(progress->SetCompleted(&numItems));
- }
UInt64 cdSize, cdStartOffset;
- HRESULT res = ReadCd(items, cdStartOffset, cdSize);
+ HRESULT res = ReadCd(items, cdStartOffset, cdSize, progress);
if (res != S_FALSE && res != S_OK)
return res;
@@ -726,39 +776,32 @@ HRESULT CInArchive::ReadHeaders(CObjectVector<CItemEx> &items, CProgressVirt *pr
cdStartOffset -= m_ArchiveInfo.Base;
}
- UInt32 thisDiskNumber = 0;
- UInt32 startCDDiskNumber = 0;
- UInt64 numEntriesInCDOnThisDisk = 0;
- UInt64 numEntriesInCD = 0;
- UInt64 cdSizeFromRecord = 0;
- UInt64 cdStartOffsetFromRecord = 0;
+ CEcd64 ecd64;
bool isZip64 = false;
UInt64 zip64EcdStartOffset = m_Position - 4 - m_ArchiveInfo.Base;
- if(m_Signature == NSignature::kZip64EndOfCentralDir)
+ if (m_Signature == NSignature::kZip64EndOfCentralDir)
{
IsZip64 = isZip64 = true;
UInt64 recordSize = ReadUInt64();
- /* UInt16 versionMade = */ ReadUInt16();
- /* UInt16 versionNeedExtract = */ ReadUInt16();
- thisDiskNumber = ReadUInt32();
- startCDDiskNumber = ReadUInt32();
- numEntriesInCDOnThisDisk = ReadUInt64();
- numEntriesInCD = ReadUInt64();
- cdSizeFromRecord = ReadUInt64();
- cdStartOffsetFromRecord = ReadUInt64();
+
+ const int kBufSize = kZip64EcdSize;
+ Byte buf[kBufSize];
+ SafeReadBytes(buf, kBufSize);
+ ecd64.Parse(buf);
+
IncreaseRealPosition(recordSize - kZip64EcdSize);
if (!ReadUInt32(m_Signature))
return S_FALSE;
- if (thisDiskNumber != 0 || startCDDiskNumber != 0)
+ if (ecd64.thisDiskNumber != 0 || ecd64.startCDDiskNumber != 0)
throw CInArchiveException(CInArchiveException::kMultiVolumeArchiveAreNotSupported);
- if (numEntriesInCDOnThisDisk != items.Size() ||
- numEntriesInCD != items.Size() ||
- cdSizeFromRecord != cdSize ||
- (cdStartOffsetFromRecord != cdStartOffset &&
+ if (ecd64.numEntriesInCDOnThisDisk != items.Size() ||
+ ecd64.numEntriesInCD != items.Size() ||
+ ecd64.cdSize != cdSize ||
+ (ecd64.cdStartOffset != cdStartOffset &&
(!items.IsEmpty())))
return S_FALSE;
}
- if(m_Signature == NSignature::kZip64EndOfCentralDirLocator)
+ if (m_Signature == NSignature::kZip64EndOfCentralDirLocator)
{
/* UInt32 startEndCDDiskNumber = */ ReadUInt32();
UInt64 endCDStartOffset = ReadUInt64();
@@ -768,42 +811,30 @@ HRESULT CInArchive::ReadHeaders(CObjectVector<CItemEx> &items, CProgressVirt *pr
if (!ReadUInt32(m_Signature))
return S_FALSE;
}
- if(m_Signature != NSignature::kEndOfCentralDir)
+ if (m_Signature != NSignature::kEndOfCentralDir)
return S_FALSE;
- UInt16 thisDiskNumber16 = ReadUInt16();
- if (!isZip64 || thisDiskNumber16 != 0xFFFF)
- thisDiskNumber = thisDiskNumber16;
-
- UInt16 startCDDiskNumber16 = ReadUInt16();
- if (!isZip64 || startCDDiskNumber16 != 0xFFFF)
- startCDDiskNumber = startCDDiskNumber16;
-
- UInt16 numEntriesInCDOnThisDisk16 = ReadUInt16();
- if (!isZip64 || numEntriesInCDOnThisDisk16 != 0xFFFF)
- numEntriesInCDOnThisDisk = numEntriesInCDOnThisDisk16;
+ const int kBufSize = kEcdSize - 4;
+ Byte buf[kBufSize];
+ SafeReadBytes(buf, kBufSize);
+ CEcd ecd;
+ ecd.Parse(buf);
- UInt16 numEntriesInCD16 = ReadUInt16();
- if (!isZip64 || numEntriesInCD16 != 0xFFFF)
- numEntriesInCD = numEntriesInCD16;
+ COPY_ECD_ITEM_16(thisDiskNumber);
+ COPY_ECD_ITEM_16(startCDDiskNumber);
+ COPY_ECD_ITEM_16(numEntriesInCDOnThisDisk);
+ COPY_ECD_ITEM_16(numEntriesInCD);
+ COPY_ECD_ITEM_32(cdSize);
+ COPY_ECD_ITEM_32(cdStartOffset);
- UInt32 cdSizeFromRecord32 = ReadUInt32();
- if (!isZip64 || cdSizeFromRecord32 != 0xFFFFFFFF)
- cdSizeFromRecord = cdSizeFromRecord32;
+ ReadBuffer(m_ArchiveInfo.Comment, ecd.commentSize);
- UInt32 cdStartOffsetFromRecord32 = ReadUInt32();
- if (!isZip64 || cdStartOffsetFromRecord32 != 0xFFFFFFFF)
- cdStartOffsetFromRecord = cdStartOffsetFromRecord32;
-
- UInt16 commentSize = ReadUInt16();
- ReadBuffer(m_ArchiveInfo.Comment, commentSize);
-
- if (thisDiskNumber != 0 || startCDDiskNumber != 0)
+ if (ecd64.thisDiskNumber != 0 || ecd64.startCDDiskNumber != 0)
throw CInArchiveException(CInArchiveException::kMultiVolumeArchiveAreNotSupported);
- if ((UInt16)numEntriesInCDOnThisDisk != ((UInt16)items.Size()) ||
- (UInt16)numEntriesInCD != ((UInt16)items.Size()) ||
- (UInt32)cdSizeFromRecord != (UInt32)cdSize ||
- ((UInt32)(cdStartOffsetFromRecord) != (UInt32)cdStartOffset &&
+ if ((UInt16)ecd64.numEntriesInCDOnThisDisk != ((UInt16)items.Size()) ||
+ (UInt16)ecd64.numEntriesInCD != ((UInt16)items.Size()) ||
+ (UInt32)ecd64.cdSize != (UInt32)cdSize ||
+ ((UInt32)(ecd64.cdStartOffset) != (UInt32)cdStartOffset &&
(!items.IsEmpty())))
return S_FALSE;
@@ -813,26 +844,25 @@ HRESULT CInArchive::ReadHeaders(CObjectVector<CItemEx> &items, CProgressVirt *pr
ISequentialInStream* CInArchive::CreateLimitedStream(UInt64 position, UInt64 size)
{
CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
- CMyComPtr<ISequentialInStream> inStream(streamSpec);
+ CMyComPtr<ISequentialInStream> stream(streamSpec);
SeekInArchive(m_ArchiveInfo.Base + position);
streamSpec->SetStream(m_Stream);
streamSpec->Init(size);
- return inStream.Detach();
+ return stream.Detach();
}
IInStream* CInArchive::CreateStream()
{
- CMyComPtr<IInStream> inStream = m_Stream;
- return inStream.Detach();
+ CMyComPtr<IInStream> stream = m_Stream;
+ return stream.Detach();
}
bool CInArchive::SeekInArchive(UInt64 position)
{
UInt64 newPosition;
- if(m_Stream->Seek(position, STREAM_SEEK_SET, &newPosition) != S_OK)
+ if (m_Stream->Seek(position, STREAM_SEEK_SET, &newPosition) != S_OK)
return false;
return (newPosition == position);
}
}}
-
diff --git a/CPP/7zip/Archive/Zip/ZipIn.h b/CPP/7zip/Archive/Zip/ZipIn.h
index b5a5a3ef..750095d6 100755
--- a/CPP/7zip/Archive/Zip/ZipIn.h
+++ b/CPP/7zip/Archive/Zip/ZipIn.h
@@ -25,7 +25,7 @@ public:
kMultiVolumeArchiveAreNotSupported,
kReadStreamError,
kSeekStreamError
- }
+ }
Cause;
CInArchiveException(ECauseType cause): Cause(cause) {}
};
@@ -37,18 +37,19 @@ public:
UInt64 StartPosition;
CByteBuffer Comment;
CInArchiveInfo(): Base(0), StartPosition(0) {}
- void Clear()
- {
+ void Clear()
+ {
Base = 0;
StartPosition = 0;
- Comment.SetCapacity(0);
+ Comment.SetCapacity(0);
}
};
class CProgressVirt
{
public:
- STDMETHOD(SetCompleted)(const UInt64 *numFiles) PURE;
+ STDMETHOD(SetTotal)(UInt64 numFiles) PURE;
+ STDMETHOD(SetCompleted)(UInt64 numFiles) PURE;
};
struct CCdInfo
@@ -68,7 +69,7 @@ class CInArchive
HRESULT Seek(UInt64 offset);
- bool FindAndReadMarker(const UInt64 *searchHeaderSizeLimit);
+ HRESULT FindAndReadMarker(IInStream *stream, const UInt64 *searchHeaderSizeLimit);
bool ReadUInt32(UInt32 &signature);
AString ReadFileName(UInt32 nameSize);
@@ -83,15 +84,15 @@ class CInArchive
void IncreaseRealPosition(UInt64 addValue);
- void ReadExtra(UInt32 extraSize, CExtraBlock &extraBlock,
+ void ReadExtra(UInt32 extraSize, CExtraBlock &extraBlock,
UInt64 &unpackSize, UInt64 &packSize, UInt64 &localHeaderOffset, UInt32 &diskStartNumber);
HRESULT ReadLocalItem(CItemEx &item);
HRESULT ReadLocalItemDescriptor(CItemEx &item);
HRESULT ReadCdItem(CItemEx &item);
HRESULT TryEcd64(UInt64 offset, CCdInfo &cdInfo);
HRESULT FindCd(CCdInfo &cdInfo);
- HRESULT TryReadCd(CObjectVector<CItemEx> &items, UInt64 cdOffset, UInt64 cdSize);
- HRESULT ReadCd(CObjectVector<CItemEx> &items, UInt64 &cdOffset, UInt64 &cdSize);
+ HRESULT TryReadCd(CObjectVector<CItemEx> &items, UInt64 cdOffset, UInt64 cdSize, CProgressVirt *progress);
+ HRESULT ReadCd(CObjectVector<CItemEx> &items, UInt64 &cdOffset, UInt64 &cdSize, CProgressVirt *progress);
HRESULT ReadLocalsAndCd(CObjectVector<CItemEx> &items, CProgressVirt *progress, UInt64 &cdOffset);
public:
CInArchiveInfo m_ArchiveInfo;
@@ -100,12 +101,14 @@ public:
HRESULT ReadHeaders(CObjectVector<CItemEx> &items, CProgressVirt *progress);
HRESULT ReadLocalItemAfterCdItem(CItemEx &item);
HRESULT ReadLocalItemAfterCdItemFull(CItemEx &item);
- bool Open(IInStream *inStream, const UInt64 *searchHeaderSizeLimit);
+ HRESULT Open(IInStream *stream, const UInt64 *searchHeaderSizeLimit);
void Close();
void GetArchiveInfo(CInArchiveInfo &archiveInfo) const;
bool SeekInArchive(UInt64 position);
ISequentialInStream *CreateLimitedStream(UInt64 position, UInt64 size);
IInStream* CreateStream();
+
+ bool IsOpen() const { return m_Stream != NULL; }
};
}}
diff --git a/CPP/7zip/Archive/Zip/ZipItem.cpp b/CPP/7zip/Archive/Zip/ZipItem.cpp
index 484696f5..9bbf3882 100755
--- a/CPP/7zip/Archive/Zip/ZipItem.cpp
+++ b/CPP/7zip/Archive/Zip/ZipItem.cpp
@@ -18,7 +18,7 @@ bool operator==(const CVersion &v1, const CVersion &v2)
bool operator!=(const CVersion &v1, const CVersion &v2)
{
return !(v1 == v2);
-}
+}
bool CExtraSubBlock::ExtractNtfsTime(int index, FILETIME &ft) const
{
@@ -52,26 +52,26 @@ bool CExtraSubBlock::ExtractNtfsTime(int index, FILETIME &ft) const
}
bool CLocalItem::IsImplodeBigDictionary() const
-{
+{
if (CompressionMethod != NFileHeader::NCompressionMethod::kImploded)
throw 12312212;
- return (Flags & NFileHeader::NFlags::kImplodeDictionarySizeMask) != 0;
+ return (Flags & NFileHeader::NFlags::kImplodeDictionarySizeMask) != 0;
}
bool CLocalItem::IsImplodeLiteralsOn() const
{
if (CompressionMethod != NFileHeader::NCompressionMethod::kImploded)
throw 12312213;
- return (Flags & NFileHeader::NFlags::kImplodeLiteralsOnMask) != 0;
+ return (Flags & NFileHeader::NFlags::kImplodeLiteralsOnMask) != 0;
}
-bool CLocalItem::IsDirectory() const
-{
+bool CLocalItem::IsDir() const
+{
return NItemName::HasTailSlash(Name, GetCodePage());
}
-bool CItem::IsDirectory() const
-{
+bool CItem::IsDir() const
+{
if (NItemName::HasTailSlash(Name, GetCodePage()))
return true;
if (!FromCentral)
@@ -80,14 +80,11 @@ bool CItem::IsDirectory() const
switch(MadeByVersion.HostOS)
{
case NFileHeader::NHostOS::kAMIGA:
- switch (highAttributes & NFileHeader::NAmigaAttribute::kIFMT)
+ switch (highAttributes & NFileHeader::NAmigaAttribute::kIFMT)
{
- case NFileHeader::NAmigaAttribute::kIFDIR:
- return true;
- case NFileHeader::NAmigaAttribute::kIFREG:
- return false;
- default:
- return false; // change it throw kUnknownAttributes;
+ case NFileHeader::NAmigaAttribute::kIFDIR: return true;
+ case NFileHeader::NAmigaAttribute::kIFREG: return false;
+ default: return false; // change it throw kUnknownAttributes;
}
case NFileHeader::NHostOS::kFAT:
case NFileHeader::NHostOS::kNTFS:
@@ -103,7 +100,7 @@ bool CItem::IsDirectory() const
return false; // change it throw kUnknownAttributes;
default:
/*
- switch (highAttributes & NFileHeader::NUnixAttribute::kIFMT)
+ switch (highAttributes & NFileHeader::NUnixAttribute::kIFMT)
{
case NFileHeader::NUnixAttribute::kIFDIR:
return true;
@@ -118,7 +115,7 @@ bool CItem::IsDirectory() const
UInt32 CLocalItem::GetWinAttributes() const
{
DWORD winAttributes = 0;
- if (IsDirectory())
+ if (IsDir())
winAttributes |= FILE_ATTRIBUTE_DIRECTORY;
return winAttributes;
}
@@ -131,26 +128,26 @@ UInt32 CItem::GetWinAttributes() const
case NFileHeader::NHostOS::kFAT:
case NFileHeader::NHostOS::kNTFS:
if (FromCentral)
- winAttributes = ExternalAttributes;
+ winAttributes = ExternalAttributes;
break;
default:
winAttributes = 0; // must be converted from unix value;
}
- if (IsDirectory()) // test it;
+ if (IsDir()) // test it;
winAttributes |= FILE_ATTRIBUTE_DIRECTORY;
return winAttributes;
}
void CLocalItem::SetFlagBits(int startBitNumber, int numBits, int value)
-{
+{
UInt16 mask = (UInt16)(((1 << numBits) - 1) << startBitNumber);
Flags &= ~mask;
Flags |= value << startBitNumber;
}
void CLocalItem::SetBitMask(int bitMask, bool enable)
-{
- if(enable)
+{
+ if(enable)
Flags |= bitMask;
else
Flags &= ~bitMask;
diff --git a/CPP/7zip/Archive/Zip/ZipItem.h b/CPP/7zip/Archive/Zip/ZipItem.h
index 8d7cc3b4..bc1b27c0 100755
--- a/CPP/7zip/Archive/Zip/ZipItem.h
+++ b/CPP/7zip/Archive/Zip/ZipItem.h
@@ -32,8 +32,8 @@ struct CExtraSubBlock
struct CWzAesExtraField
{
- UInt16 VendorVersion; // 0x0001 - AE-1, 0x0002 - AE-2,
- // UInt16 VendorId; // "AE"
+ UInt16 VendorVersion; // 0x0001 - AE-1, 0x0002 - AE-2,
+ // UInt16 VendorId; // "AE"
Byte Strength; // 1 - 128-bit , 2 - 192-bit , 3 - 256-bit
UInt16 Method;
@@ -111,14 +111,14 @@ struct CExtraBlock
{
CObjectVector<CExtraSubBlock> SubBlocks;
void Clear() { SubBlocks.Clear(); }
- size_t GetSize() const
+ size_t GetSize() const
{
size_t res = 0;
for (int i = 0; i < SubBlocks.Size(); i++)
res += SubBlocks[i].Data.GetCapacity() + 2 + 2;
return res;
}
- bool GetWzAesField(CWzAesExtraField &aesField) const
+ bool GetWzAesField(CWzAesExtraField &aesField) const
{
for (int i = 0; i < SubBlocks.Size(); i++)
if (aesField.ParseFromSubBlock(SubBlocks[i]))
@@ -126,7 +126,7 @@ struct CExtraBlock
return false;
}
- bool GetStrongCryptoField(CStrongCryptoField &f) const
+ bool GetStrongCryptoField(CStrongCryptoField &f) const
{
for (int i = 0; i < SubBlocks.Size(); i++)
if (f.ParseFromSubBlock(SubBlocks[i]))
@@ -134,13 +134,13 @@ struct CExtraBlock
return false;
}
- bool HasWzAesField() const
+ bool HasWzAesField() const
{
CWzAesExtraField aesField;
return GetWzAesField(aesField);
}
- bool GetNtfsTime(int index, FILETIME &ft) const
+ bool GetNtfsTime(int index, FILETIME &ft) const
{
for (int i = 0; i < SubBlocks.Size(); i++)
{
@@ -152,7 +152,7 @@ struct CExtraBlock
}
/*
- bool HasStrongCryptoField() const
+ bool HasStrongCryptoField() const
{
CStrongCryptoField f;
return GetStrongCryptoField(f);
@@ -191,14 +191,14 @@ public:
bool IsImplodeBigDictionary() const;
bool IsImplodeLiteralsOn() const;
- bool IsDirectory() const;
+ bool IsDir() const;
bool IgnoreItem() const { return false; }
UInt32 GetWinAttributes() const;
bool HasDescriptor() const { return (Flags & NFileHeader::NFlags::kDescriptorUsedMask) != 0; }
- UString GetUnicodeString(const AString &s) const
- {
+ UString GetUnicodeString(const AString &s) const
+ {
UString res;
if (IsUtf8())
if (!ConvertUTF8ToUnicode(s, res))
@@ -239,10 +239,10 @@ public:
bool FromCentral;
bool NtfsTimeIsDefined;
- bool IsDirectory() const;
+ bool IsDir() const;
UInt32 GetWinAttributes() const;
- bool IsThereCrc() const
+ bool IsThereCrc() const
{
if (CompressionMethod == NFileHeader::NCompressionMethod::kWzAES)
{
@@ -250,12 +250,12 @@ public:
if (CentralExtra.GetWzAesField(aesField))
return aesField.NeedCrc();
}
- return (FileCRC != 0 || !IsDirectory());
+ return (FileCRC != 0 || !IsDir());
}
WORD GetCodePage() const
{
- return (WORD)((MadeByVersion.HostOS == NFileHeader::NHostOS::kFAT
+ return (WORD)((MadeByVersion.HostOS == NFileHeader::NHostOS::kFAT
|| MadeByVersion.HostOS == NFileHeader::NHostOS::kNTFS
) ? CP_OEMCP : CP_ACP);
}
diff --git a/CPP/7zip/Archive/Zip/ZipItemEx.h b/CPP/7zip/Archive/Zip/ZipItemEx.h
index 0c5ba0ca..ab62cdbb 100755
--- a/CPP/7zip/Archive/Zip/ZipItemEx.h
+++ b/CPP/7zip/Archive/Zip/ZipItemEx.h
@@ -15,17 +15,17 @@ public:
UInt32 FileHeaderWithNameSize;
UInt16 LocalExtraSize;
- UInt64 GetLocalFullSize() const
- { return FileHeaderWithNameSize + LocalExtraSize + PackSize +
+ UInt64 GetLocalFullSize() const
+ { return FileHeaderWithNameSize + LocalExtraSize + PackSize +
(HasDescriptor() ? NFileHeader::kDataDescriptorSize : 0); };
/*
- UInt64 GetLocalFullSize(bool isZip64) const
- { return FileHeaderWithNameSize + LocalExtraSize + PackSize +
+ UInt64 GetLocalFullSize(bool isZip64) const
+ { return FileHeaderWithNameSize + LocalExtraSize + PackSize +
(HasDescriptor() ? (isZip64 ? NFileHeader::kDataDescriptor64Size : NFileHeader::kDataDescriptorSize) : 0); };
*/
- UInt64 GetLocalExtraPosition() const
+ UInt64 GetLocalExtraPosition() const
{ return LocalHeaderPosition + FileHeaderWithNameSize; };
- UInt64 GetDataPosition() const
+ UInt64 GetDataPosition() const
{ return GetLocalExtraPosition() + LocalExtraSize; };
};
diff --git a/CPP/7zip/Archive/Zip/ZipOut.cpp b/CPP/7zip/Archive/Zip/ZipOut.cpp
index fd89b1e8..5b1bdeee 100755
--- a/CPP/7zip/Archive/Zip/ZipOut.cpp
+++ b/CPP/7zip/Archive/Zip/ZipOut.cpp
@@ -36,7 +36,7 @@ void COutArchive::PrepareWriteCompressedDataZip64(UInt16 fileNameLength, bool is
void COutArchive::PrepareWriteCompressedData(UInt16 fileNameLength, UInt64 unPackSize, bool aesEncryption)
{
- // We test it to 0xF8000000 to support case when compressed size
+ // We test it to 0xF8000000 to support case when compressed size
// can be larger than uncompressed size.
PrepareWriteCompressedDataZip64(fileNameLength, unPackSize >= 0xF8000000, aesEncryption);
}
diff --git a/CPP/7zip/Archive/Zip/ZipUpdate.cpp b/CPP/7zip/Archive/Zip/ZipUpdate.cpp
index 2ec08981..3294ad78 100755
--- a/CPP/7zip/Archive/Zip/ZipUpdate.cpp
+++ b/CPP/7zip/Archive/Zip/ZipUpdate.cpp
@@ -30,13 +30,20 @@ using namespace NSynchronization;
namespace NArchive {
namespace NZip {
-static const Byte kMadeByHostOS = NFileHeader::NHostOS::kFAT;
-static const Byte kExtractHostOS = NFileHeader::NHostOS::kFAT;
+static const Byte kHostOS =
+ #ifdef _WIN32
+ NFileHeader::NHostOS::kFAT;
+ #else
+ NFileHeader::NHostOS::kUnix;
+ #endif
+
+static const Byte kMadeByHostOS = kHostOS;
+static const Byte kExtractHostOS = kHostOS;
static const Byte kMethodForDirectory = NFileHeader::NCompressionMethod::kStored;
static const Byte kExtractVersionForDirectory = NFileHeader::NCompressionMethod::kStoreExtractVersion;
-static HRESULT CopyBlockToArchive(ISequentialInStream *inStream,
+static HRESULT CopyBlockToArchive(ISequentialInStream *inStream,
COutArchive &outArchive, ICompressProgressInfo *progress)
{
CMyComPtr<ISequentialOutStream> outStream;
@@ -45,7 +52,7 @@ static HRESULT CopyBlockToArchive(ISequentialInStream *inStream,
return copyCoder->Code(inStream, outStream, NULL, NULL, progress);
}
-static HRESULT WriteRange(IInStream *inStream, COutArchive &outArchive,
+static HRESULT WriteRange(IInStream *inStream, COutArchive &outArchive,
const CUpdateRange &range, ICompressProgressInfo *progress)
{
UInt64 position;
@@ -61,30 +68,30 @@ static HRESULT WriteRange(IInStream *inStream, COutArchive &outArchive,
}
static void SetFileHeader(
- COutArchive &archive,
+ COutArchive &archive,
const CCompressionMethodMode &options,
- const CUpdateItem &updateItem,
+ const CUpdateItem &ui,
CItem &item)
{
- item.UnPackSize = updateItem.Size;
- bool isDirectory;
+ item.UnPackSize = ui.Size;
+ bool isDir;
item.ClearFlags();
- if (updateItem.NewProperties)
+ if (ui.NewProperties)
{
- isDirectory = updateItem.IsDirectory;
- item.Name = updateItem.Name;
- item.SetUtf8(updateItem.IsUtf8);
- item.ExternalAttributes = updateItem.Attributes;
- item.Time = updateItem.Time;
- item.NtfsMTime = updateItem.NtfsMTime;
- item.NtfsATime = updateItem.NtfsATime;
- item.NtfsCTime = updateItem.NtfsCTime;
- item.NtfsTimeIsDefined = updateItem.NtfsTimeIsDefined;
+ isDir = ui.IsDir;
+ item.Name = ui.Name;
+ item.SetUtf8(ui.IsUtf8);
+ item.ExternalAttributes = ui.Attributes;
+ item.Time = ui.Time;
+ item.NtfsMTime = ui.NtfsMTime;
+ item.NtfsATime = ui.NtfsATime;
+ item.NtfsCTime = ui.NtfsCTime;
+ item.NtfsTimeIsDefined = ui.NtfsTimeIsDefined;
}
else
- isDirectory = item.IsDirectory();
+ isDir = item.IsDir();
item.LocalHeaderPosition = archive.GetCurrentPosition();
item.MadeByVersion.HostOS = kMadeByHostOS;
@@ -93,8 +100,8 @@ static void SetFileHeader(
item.ExtractVersion.HostOS = kExtractHostOS;
item.InternalAttributes = 0; // test it
- item.SetEncrypted(!isDirectory && options.PasswordIsDefined);
- if (isDirectory)
+ item.SetEncrypted(!isDir && options.PasswordIsDefined);
+ if (isDir)
{
item.ExtractVersion.Version = kExtractVersionForDirectory;
item.CompressionMethod = kMethodForDirectory;
@@ -103,7 +110,7 @@ static void SetFileHeader(
}
}
-static void SetItemInfoFromCompressingResult(const CCompressingResult &compressingResult,
+static void SetItemInfoFromCompressingResult(const CCompressingResult &compressingResult,
bool isAesMode, Byte aesKeyMode, CItem &item)
{
item.ExtractVersion.Version = compressingResult.ExtractVersion;
@@ -196,7 +203,7 @@ void CThreadInfo::WaitAndCode()
return;
Result = Coder.Compress(
#ifdef EXTERNAL_CODECS
- _codecsInfo, _externalCodecs,
+ _codecsInfo, _externalCodecs,
#endif
InStream, OutStream, Progress, CompressingResult);
if (Result == S_OK && Progress)
@@ -289,7 +296,7 @@ HRESULT CMtProgressMixer2::SetRatioInfo(int index, const UInt64 *inSize, const U
InSizes[index] = *inSize;
if (outSize != 0)
OutSizes[index] = *outSize;
- UInt64 v = ProgressOffset + (_inSizeIsMain ?
+ UInt64 v = ProgressOffset + (_inSizeIsMain ?
(InSizes[0] + InSizes[1]) :
(OutSizes[0] + OutSizes[1]));
return Progress->SetCompleted(&v);
@@ -300,7 +307,7 @@ STDMETHODIMP CMtProgressMixer2::SetRatioInfo(const UInt64 *inSize, const UInt64
return SetRatioInfo(0, inSize, outSize);
}
-class CMtProgressMixer:
+class CMtProgressMixer:
public ICompressProgressInfo,
public CMyUnknownImp
{
@@ -328,14 +335,14 @@ STDMETHODIMP CMtProgressMixer::SetRatioInfo(const UInt64 *inSize, const UInt64 *
#endif
-static HRESULT UpdateItemOldData(COutArchive &archive,
+static HRESULT UpdateItemOldData(COutArchive &archive,
IInStream *inStream,
- const CUpdateItem &updateItem, CItemEx &item,
+ const CUpdateItem &ui, CItemEx &item,
/* bool izZip64, */
ICompressProgressInfo *progress,
UInt64 &complexity)
{
- if (updateItem.NewProperties)
+ if (ui.NewProperties)
{
if (item.HasDescriptor())
return E_NOTIMPL;
@@ -344,15 +351,15 @@ static HRESULT UpdateItemOldData(COutArchive &archive,
// CUpdateRange range(item.GetLocalExtraPosition(), item.LocalExtraSize + item.PackSize);
CUpdateRange range(item.GetDataPosition(), item.PackSize);
- // item.ExternalAttributes = updateItem.Attributes;
+ // item.ExternalAttributes = ui.Attributes;
// Test it
- item.Name = updateItem.Name;
- item.SetUtf8(updateItem.IsUtf8);
- item.Time = updateItem.Time;
- item.NtfsMTime = updateItem.NtfsMTime;
- item.NtfsATime = updateItem.NtfsATime;
- item.NtfsCTime = updateItem.NtfsCTime;
- item.NtfsTimeIsDefined = updateItem.NtfsTimeIsDefined;
+ item.Name = ui.Name;
+ item.SetUtf8(ui.IsUtf8);
+ item.Time = ui.Time;
+ item.NtfsMTime = ui.NtfsMTime;
+ item.NtfsATime = ui.NtfsATime;
+ item.NtfsCTime = ui.NtfsCTime;
+ item.NtfsTimeIsDefined = ui.NtfsTimeIsDefined;
item.CentralExtra.RemoveUnknownSubBlocks();
item.LocalExtra.RemoveUnknownSubBlocks();
@@ -369,7 +376,7 @@ static HRESULT UpdateItemOldData(COutArchive &archive,
CUpdateRange range(item.LocalHeaderPosition, item.GetLocalFullSize());
// set new header position
- item.LocalHeaderPosition = archive.GetCurrentPosition();
+ item.LocalHeaderPosition = archive.GetCurrentPosition();
RINOK(WriteRange(inStream, archive, range, progress));
complexity += range.Size;
@@ -379,21 +386,21 @@ static HRESULT UpdateItemOldData(COutArchive &archive,
}
static void WriteDirHeader(COutArchive &archive, const CCompressionMethodMode *options,
- const CUpdateItem &updateItem, CItemEx &item)
+ const CUpdateItem &ui, CItemEx &item)
{
- SetFileHeader(archive, *options, updateItem, item);
- archive.PrepareWriteCompressedData((UInt16)item.Name.Length(), updateItem.Size, options->IsAesMode);
+ SetFileHeader(archive, *options, ui, item);
+ archive.PrepareWriteCompressedData((UInt16)item.Name.Length(), ui.Size, options->IsAesMode);
archive.WriteLocalHeader(item);
}
static HRESULT Update2St(
DECL_EXTERNAL_CODECS_LOC_VARS
- COutArchive &archive,
+ COutArchive &archive,
CInArchive *inArchive,
IInStream *inStream,
const CObjectVector<CItemEx> &inputItems,
const CObjectVector<CUpdateItem> &updateItems,
- const CCompressionMethodMode *options,
+ const CCompressionMethodMode *options,
const CByteBuffer &comment,
IArchiveUpdateCallback *updateCallback)
{
@@ -411,37 +418,37 @@ static HRESULT Update2St(
lps->InSize = unpackSizeTotal;
lps->OutSize = packSizeTotal;
RINOK(lps->SetCur());
- const CUpdateItem &updateItem = updateItems[itemIndex];
+ const CUpdateItem &ui = updateItems[itemIndex];
CItemEx item;
- if (!updateItem.NewProperties || !updateItem.NewData)
+ if (!ui.NewProperties || !ui.NewData)
{
- item = inputItems[updateItem.IndexInArchive];
+ item = inputItems[ui.IndexInArchive];
if (inArchive->ReadLocalItemAfterCdItemFull(item) != S_OK)
return E_NOTIMPL;
}
- if (updateItem.NewData)
+ if (ui.NewData)
{
- bool isDirectory = ((updateItem.NewProperties) ? updateItem.IsDirectory : item.IsDirectory());
- if (isDirectory)
+ bool isDir = ((ui.NewProperties) ? ui.IsDir : item.IsDir());
+ if (isDir)
{
- WriteDirHeader(archive, options, updateItem, item);
+ WriteDirHeader(archive, options, ui, item);
}
else
{
CMyComPtr<ISequentialInStream> fileInStream;
- HRESULT res = updateCallback->GetStream(updateItem.IndexInClient, &fileInStream);
+ HRESULT res = updateCallback->GetStream(ui.IndexInClient, &fileInStream);
if (res == S_FALSE)
{
- lps->ProgressOffset += updateItem.Size;
+ lps->ProgressOffset += ui.Size;
RINOK(updateCallback->SetOperationResult(NArchive::NUpdate::NOperationResult::kOK));
continue;
}
RINOK(res);
// file Size can be 64-bit !!!
- SetFileHeader(archive, *options, updateItem, item);
- archive.PrepareWriteCompressedData((UInt16)item.Name.Length(), updateItem.Size, options->IsAesMode);
+ SetFileHeader(archive, *options, ui, item);
+ archive.PrepareWriteCompressedData((UInt16)item.Name.Length(), ui.Size, options->IsAesMode);
CCompressingResult compressingResult;
CMyComPtr<IOutStream> outStream;
archive.CreateStreamForCompressing(&outStream);
@@ -459,7 +466,7 @@ static HRESULT Update2St(
{
UInt64 complexity = 0;
lps->SendRatio = false;
- RINOK(UpdateItemOldData(archive, inStream, updateItem, item, progress, complexity));
+ RINOK(UpdateItemOldData(archive, inStream, ui, item, progress, complexity));
lps->SendRatio = true;
lps->ProgressOffset += complexity;
}
@@ -472,12 +479,12 @@ static HRESULT Update2St(
static HRESULT Update2(
DECL_EXTERNAL_CODECS_LOC_VARS
- COutArchive &archive,
+ COutArchive &archive,
CInArchive *inArchive,
IInStream *inStream,
const CObjectVector<CItemEx> &inputItems,
const CObjectVector<CUpdateItem> &updateItems,
- const CCompressionMethodMode *options,
+ const CCompressionMethodMode *options,
const CByteBuffer &comment,
IArchiveUpdateCallback *updateCallback)
{
@@ -488,20 +495,20 @@ static HRESULT Update2(
int i;
for(i = 0; i < updateItems.Size(); i++)
{
- const CUpdateItem &updateItem = updateItems[i];
- if (updateItem.NewData)
+ const CUpdateItem &ui = updateItems[i];
+ if (ui.NewData)
{
- complexity += updateItem.Size;
- numBytesToCompress += updateItem.Size;
+ complexity += ui.Size;
+ numBytesToCompress += ui.Size;
numFilesToCompress++;
/*
- if (updateItem.Commented)
- complexity += updateItem.CommentRange.Size;
+ if (ui.Commented)
+ complexity += ui.CommentRange.Size;
*/
}
else
{
- CItemEx inputItem = inputItems[updateItem.IndexInArchive];
+ CItemEx inputItem = inputItems[ui.IndexInArchive];
if (inArchive->ReadLocalItemAfterCdItemFull(inputItem) != S_OK)
return E_NOTIMPL;
complexity += inputItem.GetLocalFullSize();
@@ -580,7 +587,7 @@ static HRESULT Update2(
mtProgressMixerSpec->Create(updateCallback, true);
CMtCompressProgressMixer mtCompressProgressMixer;
- mtCompressProgressMixer.Init(numThreads, mtProgressMixerSpec->RatioProgress);
+ mtCompressProgressMixer.Init(numThreads, mtProgressMixerSpec->RatioProgress);
CMemBlockManagerMt memManager(kBlockSize);
CMemRefs refs(&memManager);
@@ -625,30 +632,30 @@ static HRESULT Update2(
{
if ((UInt32)threadIndices.Size() < numThreads && mtItemIndex < updateItems.Size())
{
- const CUpdateItem &updateItem = updateItems[mtItemIndex++];
- if (!updateItem.NewData)
+ const CUpdateItem &ui = updateItems[mtItemIndex++];
+ if (!ui.NewData)
continue;
CItemEx item;
- if (updateItem.NewProperties)
+ if (ui.NewProperties)
{
- if (updateItem.IsDirectory)
+ if (ui.IsDir)
continue;
}
else
{
- item = inputItems[updateItem.IndexInArchive];
+ item = inputItems[ui.IndexInArchive];
if (inArchive->ReadLocalItemAfterCdItemFull(item) != S_OK)
return E_NOTIMPL;
- if (item.IsDirectory())
+ if (item.IsDir())
continue;
}
CMyComPtr<ISequentialInStream> fileInStream;
{
NWindows::NSynchronization::CCriticalSectionLock lock(mtProgressMixerSpec->Mixer2->CriticalSection);
- HRESULT res = updateCallback->GetStream(updateItem.IndexInClient, &fileInStream);
+ HRESULT res = updateCallback->GetStream(ui.IndexInClient, &fileInStream);
if (res == S_FALSE)
{
- complexity += updateItem.Size;
+ complexity += ui.Size;
complexity += NFileHeader::kLocalBlockSize;
mtProgressMixerSpec->Mixer2->SetProgressOffset(complexity);
RINOK(updateCallback->SetOperationResult(NArchive::NUpdate::NOperationResult::kOK));
@@ -667,9 +674,9 @@ static HRESULT Update2(
threadInfo.IsFree = false;
threadInfo.InStream = fileInStream;
- // !!!!! we must release ref before sending event
+ // !!!!! we must release ref before sending event
// BUG was here in v4.43 and v4.44. It could change ref counter in two threads in same time
- fileInStream.Release();
+ fileInStream.Release();
threadInfo.OutStreamSpec->Init();
threadInfo.ProgressSpec->Reinit();
@@ -690,31 +697,31 @@ static HRESULT Update2(
continue;
}
- const CUpdateItem &updateItem = updateItems[itemIndex];
+ const CUpdateItem &ui = updateItems[itemIndex];
CItemEx item;
- if (!updateItem.NewProperties || !updateItem.NewData)
+ if (!ui.NewProperties || !ui.NewData)
{
- item = inputItems[updateItem.IndexInArchive];
+ item = inputItems[ui.IndexInArchive];
if (inArchive->ReadLocalItemAfterCdItemFull(item) != S_OK)
return E_NOTIMPL;
}
- if (updateItem.NewData)
+ if (ui.NewData)
{
- bool isDirectory = ((updateItem.NewProperties) ? updateItem.IsDirectory : item.IsDirectory());
- if (isDirectory)
+ bool isDir = ((ui.NewProperties) ? ui.IsDir : item.IsDir());
+ if (isDir)
{
- WriteDirHeader(archive, options, updateItem, item);
+ WriteDirHeader(archive, options, ui, item);
}
else
{
if (lastRealStreamItemIndex < itemIndex)
{
lastRealStreamItemIndex = itemIndex;
- SetFileHeader(archive, *options, updateItem, item);
+ SetFileHeader(archive, *options, ui, item);
// file Size can be 64-bit !!!
- archive.PrepareWriteCompressedData((UInt16)item.Name.Length(), updateItem.Size, options->IsAesMode);
+ archive.PrepareWriteCompressedData((UInt16)item.Name.Length(), ui.Size, options->IsAesMode);
}
CMemBlocks2 &memRef = refs.Refs[itemIndex];
@@ -725,7 +732,7 @@ static HRESULT Update2(
memRef.WriteToStream(memManager.GetBlockSize(), outStream);
SetItemInfoFromCompressingResult(memRef.CompressingResult,
options->IsAesMode, options->AesKeyMode, item);
- SetFileHeader(archive, *options, updateItem, item);
+ SetFileHeader(archive, *options, ui, item);
archive.WriteLocalHeader(item);
// RINOK(updateCallback->SetOperationResult(NArchive::NUpdate::NOperationResult::kOK));
memRef.FreeOpt(&memManager);
@@ -743,7 +750,7 @@ static HRESULT Update2(
}
}
- DWORD result = ::WaitForMultipleObjects(compressingCompletedEvents.Size(),
+ DWORD result = ::WaitForMultipleObjects(compressingCompletedEvents.Size(),
&compressingCompletedEvents.Front(), FALSE, INFINITE);
int t = (int)(result - WAIT_OBJECT_0);
CThreadInfo &threadInfo = threads.Threads[threadIndices[t]];
@@ -756,9 +763,9 @@ static HRESULT Update2(
{
RINOK(threadInfo.OutStreamSpec->WriteToRealStream());
threadInfo.OutStreamSpec->ReleaseOutStream();
- SetItemInfoFromCompressingResult(threadInfo.CompressingResult,
+ SetItemInfoFromCompressingResult(threadInfo.CompressingResult,
options->IsAesMode, options->AesKeyMode, item);
- SetFileHeader(archive, *options, updateItem, item);
+ SetFileHeader(archive, *options, ui, item);
archive.WriteLocalHeader(item);
}
else
@@ -774,7 +781,7 @@ static HRESULT Update2(
}
else
{
- RINOK(UpdateItemOldData(archive, inStream, updateItem, item, progress, complexity));
+ RINOK(UpdateItemOldData(archive, inStream, ui, item, progress, complexity));
}
items.Add(item);
complexity += NFileHeader::kLocalBlockSize;
@@ -783,10 +790,10 @@ static HRESULT Update2(
}
archive.WriteCentralDir(items, comment);
return S_OK;
- #endif
+ #endif
}
-HRESULT Update(
+HRESULT Update(
DECL_EXTERNAL_CODECS_LOC_VARS
const CObjectVector<CItemEx> &inputItems,
const CObjectVector<CUpdateItem> &updateItems,
@@ -825,9 +832,9 @@ HRESULT Update(
return Update2(
EXTERNAL_CODECS_LOC_VARS
- outArchive, inArchive, inStream,
- inputItems, updateItems,
- compressionMethodMode,
+ outArchive, inArchive, inStream,
+ inputItems, updateItems,
+ compressionMethodMode,
archiveInfo.Comment, updateCallback);
}
diff --git a/CPP/7zip/Archive/Zip/ZipUpdate.h b/CPP/7zip/Archive/Zip/ZipUpdate.h
index 5e67bead..eee16738 100755
--- a/CPP/7zip/Archive/Zip/ZipUpdate.h
+++ b/CPP/7zip/Archive/Zip/ZipUpdate.h
@@ -16,7 +16,7 @@ namespace NZip {
struct CUpdateRange
{
- UInt64 Position;
+ UInt64 Position;
UInt64 Size;
CUpdateRange() {};
CUpdateRange(UInt64 position, UInt64 size): Position(position), Size(size) {};
@@ -26,7 +26,7 @@ struct CUpdateItem
{
bool NewData;
bool NewProperties;
- bool IsDirectory;
+ bool IsDir;
bool NtfsTimeIsDefined;
bool IsUtf8;
int IndexInArchive;
diff --git a/CPP/7zip/Bundles/Alone/Alone.dsp b/CPP/7zip/Bundles/Alone/Alone.dsp
index d50fb15e..22930d9e 100755
--- a/CPP/7zip/Bundles/Alone/Alone.dsp
+++ b/CPP/7zip/Bundles/Alone/Alone.dsp
@@ -505,6 +505,10 @@ SOURCE=..\..\..\Windows\Thread.h
# End Source File
# Begin Source File
+SOURCE=..\..\..\Windows\Time.cpp
+# End Source File
+# Begin Source File
+
SOURCE=..\..\..\Windows\Time.h
# End Source File
# End Group
@@ -1672,6 +1676,14 @@ SOURCE=..\..\Archive\Common\DummyOutStream.h
# End Source File
# Begin Source File
+SOURCE=..\..\Archive\Common\FindSignature.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\FindSignature.h
+# End Source File
+# Begin Source File
+
SOURCE=..\..\Archive\Common\HandlerOut.cpp
# End Source File
# Begin Source File
@@ -1735,22 +1747,6 @@ SOURCE=..\..\Archive\Split\SplitHandler.h
SOURCE=..\..\Archive\Split\SplitRegister.cpp
# End Source File
# End Group
-# Begin Group "Z Format"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Archive\Z\ZHandler.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Z\ZHandler.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Z\ZRegister.cpp
-# End Source File
-# End Group
# Begin Group "cab"
# PROP Default_Filter ""
@@ -1831,6 +1827,10 @@ SOURCE=..\..\Archive\Lzma\LzmaIn.h
SOURCE=..\..\Archive\Lzma\LzmaItem.h
# End Source File
# End Group
+# Begin Source File
+
+SOURCE=..\..\Archive\ZHandler.cpp
+# End Source File
# End Group
# Begin Group "UI Common"
diff --git a/CPP/7zip/Bundles/Alone/makefile b/CPP/7zip/Bundles/Alone/makefile
index e3dc8e5e..234153b3 100755
--- a/CPP/7zip/Bundles/Alone/makefile
+++ b/CPP/7zip/Bundles/Alone/makefile
@@ -47,6 +47,7 @@ WIN_OBJS = \
$O\PropVariantConversions.obj \
$O\Synchronization.obj \
$O\System.obj \
+ $O\Time.obj \
7ZIP_COMMON_OBJS = \
$O\CreateCoder.obj \
@@ -93,11 +94,15 @@ UI_COMMON_OBJS = \
$O\UpdateProduce.obj \
$O\WorkDir.obj \
+AR_OBJS = \
+ $O\ZHandler.obj \
+
AR_COMMON_OBJS = \
$O\CoderMixer2.obj \
$O\CoderMixer2MT.obj \
$O\CrossThreadProgress.obj \
$O\DummyOutStream.obj \
+ $O\FindSignature.obj \
$O\HandlerOut.obj \
$O\InStreamWithCRC.obj \
$O\ItemNameUtils.obj \
@@ -165,10 +170,6 @@ TAR_OBJS = \
$O\TarUpdate.obj \
$O\TarRegister.obj \
-Z_OBJS = \
- $O\ZHandler.obj \
- $O\ZRegister.obj \
-
ZIP_OBJS = \
$O\ZipAddCommon.obj \
$O\ZipHandler.obj \
@@ -290,6 +291,7 @@ OBJS = \
$(WIN_OBJS) \
$(7ZIP_COMMON_OBJS) \
$(UI_COMMON_OBJS) \
+ $(AR_OBJS) \
$(AR_COMMON_OBJS) \
$(7Z_OBJS) \
$(BZ2_OBJS) \
@@ -298,7 +300,6 @@ OBJS = \
$(LZM_OBJS) \
$(SPLIT_OBJS) \
$(TAR_OBJS) \
- $(Z_OBJS) \
$(ZIP_OBJS) \
$(BZIP2_OBJS) \
$(BZIP2_OPT_OBJS) \
@@ -339,6 +340,8 @@ $(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp
$(COMPL)
$(UI_COMMON_OBJS): ../../UI/Common/$(*B).cpp
$(COMPL)
+$(AR_OBJS): ../../Archive/$(*B).cpp
+ $(COMPL)
$(AR_COMMON_OBJS): ../../Archive/Common/$(*B).cpp
$(COMPL)
@@ -356,8 +359,6 @@ $(SPLIT_OBJS): ../../Archive/Split/$(*B).cpp
$(COMPL)
$(TAR_OBJS): ../../Archive/Tar/$(*B).cpp
$(COMPL)
-$(Z_OBJS): ../../Archive/Z/$(*B).cpp
- $(COMPL)
$(ZIP_OBJS): ../../Archive/Zip/$(*B).cpp
$(COMPL)
diff --git a/CPP/7zip/Bundles/Alone7z/makefile b/CPP/7zip/Bundles/Alone7z/makefile
index 53b94c1d..404c813d 100755
--- a/CPP/7zip/Bundles/Alone7z/makefile
+++ b/CPP/7zip/Bundles/Alone7z/makefile
@@ -49,6 +49,7 @@ WIN_OBJS = \
$O\PropVariantConversions.obj \
$O\Synchronization.obj \
$O\System.obj \
+ $O\Time.obj \
7ZIP_COMMON_OBJS = \
$O\CreateCoder.obj \
diff --git a/CPP/7zip/Bundles/Format7z/resource.rc b/CPP/7zip/Bundles/Format7z/resource.rc
index 5b3f363e..2f2b42ae 100755
--- a/CPP/7zip/Bundles/Format7z/resource.rc
+++ b/CPP/7zip/Bundles/Format7z/resource.rc
@@ -2,4 +2,4 @@
MY_VERSION_INFO_DLL("7z Standalone Plugin", "7za")
-101 ICON "../../Archive/7z/7z.ico"
+101 ICON "../../Archive/Icons/7z.ico"
diff --git a/CPP/7zip/Bundles/Format7zExtract/resource.rc b/CPP/7zip/Bundles/Format7zExtract/resource.rc
index 56e6b5d7..6a654615 100755
--- a/CPP/7zip/Bundles/Format7zExtract/resource.rc
+++ b/CPP/7zip/Bundles/Format7zExtract/resource.rc
@@ -2,4 +2,4 @@
MY_VERSION_INFO_DLL("7z Standalone Extracting Plugin", "7zxa")
-101 ICON "../../Archive/7z/7z.ico"
+101 ICON "../../Archive/Icons/7z.ico"
diff --git a/CPP/7zip/Bundles/Format7zExtractR/resource.rc b/CPP/7zip/Bundles/Format7zExtractR/resource.rc
index 09708cff..eb636986 100755
--- a/CPP/7zip/Bundles/Format7zExtractR/resource.rc
+++ b/CPP/7zip/Bundles/Format7zExtractR/resource.rc
@@ -2,4 +2,4 @@
MY_VERSION_INFO_DLL("7z Standalone Extracting Plugin", "7zxr")
-101 ICON "../../Archive/7z/7z.ico"
+101 ICON "../../Archive/Icons/7z.ico"
diff --git a/CPP/7zip/Bundles/Format7zF/Format7z.dsp b/CPP/7zip/Bundles/Format7zF/Format7z.dsp
index 7a41a82a..16d89635 100755
--- a/CPP/7zip/Bundles/Format7zF/Format7z.dsp
+++ b/CPP/7zip/Bundles/Format7zF/Format7z.dsp
@@ -91,102 +91,118 @@ LINK32=link.exe
# Begin Group "Spec"
# PROP Default_Filter ""
+# Begin Group "Icons"
+
+# PROP Default_Filter ""
# Begin Source File
-SOURCE=..\..\Archive\7z\7z.ico
+SOURCE=..\..\Archive\Icons\7z.ico
# End Source File
# Begin Source File
-SOURCE=..\..\Archive\Archive2.def
+SOURCE=..\..\Archive\Icons\arj.ico
# End Source File
# Begin Source File
-SOURCE=..\..\Archive\ArchiveExports.cpp
+SOURCE=..\..\Archive\Icons\bz2.ico
# End Source File
# Begin Source File
-SOURCE=..\..\Archive\Arj\arj.ico
+SOURCE=..\..\Archive\Icons\cab.ico
# End Source File
# Begin Source File
-SOURCE=..\..\Archive\BZip2\bz2.ico
+SOURCE=..\..\Archive\Icons\cpio.ico
# End Source File
# Begin Source File
-SOURCE=..\..\Archive\Cab\cab.ico
+SOURCE=..\..\Archive\Icons\deb.ico
# End Source File
# Begin Source File
-SOURCE=..\..\Compress\CodecExports.cpp
+SOURCE=..\..\Archive\Icons\dmg.ico
# End Source File
# Begin Source File
-SOURCE=..\..\Archive\Cpio\cpio.ico
+SOURCE=..\..\Archive\Icons\gz.ico
# End Source File
# Begin Source File
-SOURCE=..\..\Archive\Deb\deb.ico
+SOURCE=..\..\Archive\Icons\hfs.ico
# End Source File
# Begin Source File
-SOURCE=..\..\Archive\DllExports2.cpp
+SOURCE=..\..\Archive\Icons\iso.ico
# End Source File
# Begin Source File
-SOURCE=..\..\Archive\GZip\gz.ico
+SOURCE=..\..\Archive\Icons\lzh.ico
# End Source File
# Begin Source File
-SOURCE=..\..\Archive\Iso\Iso.ico
+SOURCE=..\..\Archive\Icons\lzma.ico
# End Source File
# Begin Source File
-SOURCE=..\..\Archive\Lzh\lzh.ico
+SOURCE=..\..\Archive\Icons\rar.ico
# End Source File
# Begin Source File
-SOURCE=..\..\Archive\Lzma\lzma.ico
+SOURCE=..\..\Archive\Icons\rpm.ico
# End Source File
# Begin Source File
-SOURCE=..\..\Archive\Rar\rar.ico
+SOURCE=..\..\Archive\Icons\split.ico
# End Source File
# Begin Source File
-SOURCE=.\resource.rc
+SOURCE=..\..\Archive\Icons\tar.ico
# End Source File
# Begin Source File
-SOURCE=..\..\Archive\RPM\rpm.ico
+SOURCE=..\..\Archive\Icons\wim.ico
# End Source File
# Begin Source File
-SOURCE=..\..\Archive\Split\Split.ico
+SOURCE=..\..\Archive\Icons\xar.ico
# End Source File
# Begin Source File
-SOURCE=.\StdAfx.cpp
-# ADD CPP /Yc"StdAfx.h"
+SOURCE=..\..\Archive\Icons\z.ico
# End Source File
# Begin Source File
-SOURCE=.\StdAfx.h
+SOURCE=..\..\Archive\Icons\zip.ico
# End Source File
+# End Group
# Begin Source File
-SOURCE=..\..\Archive\Tar\tar.ico
+SOURCE=..\..\Archive\Archive2.def
# End Source File
# Begin Source File
-SOURCE=..\..\Archive\Wim\wim.ico
+SOURCE=..\..\Archive\ArchiveExports.cpp
# End Source File
# Begin Source File
-SOURCE=..\..\Archive\Z\Z.ico
+SOURCE=..\..\Compress\CodecExports.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\DllExports2.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\resource.rc
+# End Source File
+# Begin Source File
+
+SOURCE=.\StdAfx.cpp
+# ADD CPP /Yc"StdAfx.h"
# End Source File
# Begin Source File
-SOURCE=..\..\Archive\Zip\zip.ico
+SOURCE=.\StdAfx.h
# End Source File
# End Group
# Begin Group "Common"
@@ -222,6 +238,14 @@ SOURCE=..\..\..\Common\MyInitGuid.h
# End Source File
# Begin Source File
+SOURCE=..\..\..\Common\MyMap.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\MyMap.h
+# End Source File
+# Begin Source File
+
SOURCE=..\..\..\Common\MyString.cpp
# End Source File
# Begin Source File
@@ -246,6 +270,14 @@ SOURCE=..\..\..\Common\MyWindows.h
# End Source File
# Begin Source File
+SOURCE=..\..\..\Common\MyXml.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\MyXml.h
+# End Source File
+# Begin Source File
+
SOURCE=..\..\..\Common\NewHandler.cpp
# End Source File
# Begin Source File
@@ -591,6 +623,14 @@ SOURCE=..\..\Compress\Deflate\DeflateNsisRegister.cpp
SOURCE=..\..\Compress\Deflate\DeflateRegister.cpp
# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\Deflate\ZlibDecoder.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Compress\Deflate\ZlibDecoder.h
+# End Source File
# End Group
# Begin Group "BZip2"
@@ -1670,38 +1710,6 @@ SOURCE=..\..\Archive\Rar\RarVolumeInStream.cpp
SOURCE=..\..\Archive\Rar\RarVolumeInStream.h
# End Source File
# End Group
-# Begin Group "Arj"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Archive\Arj\ArjHandler.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Arj\ArjHandler.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Arj\ArjHeader.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Arj\ArjIn.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Arj\ArjIn.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Arj\ArjItem.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Arj\ArjRegister.cpp
-# End Source File
-# End Group
# Begin Group "bz2"
# PROP Default_Filter ""
@@ -1839,6 +1847,14 @@ SOURCE=..\..\Archive\Common\DummyOutStream.h
# End Source File
# Begin Source File
+SOURCE=..\..\Archive\Common\FindSignature.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Common\FindSignature.h
+# End Source File
+# Begin Source File
+
SOURCE=..\..\Archive\Common\HandlerOut.cpp
# End Source File
# Begin Source File
@@ -1930,42 +1946,6 @@ SOURCE=..\..\Archive\Cpio\CpioItem.h
SOURCE=..\..\Archive\Cpio\CpioRegister.cpp
# End Source File
# End Group
-# Begin Group "Deb"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Archive\Deb\DebHandler.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Deb\DebHandler.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Deb\DebHeader.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Deb\DebHeader.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Deb\DebIn.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Deb\DebIn.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Deb\DebItem.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Deb\DebRegister.cpp
-# End Source File
-# End Group
# Begin Group "GZip"
# PROP Default_Filter ""
@@ -2141,30 +2121,6 @@ SOURCE=..\..\Archive\Nsis\NsisRegister.cpp
# Begin Group "RPM"
# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Archive\RPM\RpmHandler.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\RPM\RpmHandler.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\RPM\RpmHeader.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\RPM\RpmIn.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\RPM\RpmIn.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\RPM\RpmRegister.cpp
-# End Source File
# End Group
# Begin Group "Split"
@@ -2242,22 +2198,6 @@ SOURCE=..\..\Archive\Tar\TarUpdate.cpp
SOURCE=..\..\Archive\Tar\TarUpdate.h
# End Source File
# End Group
-# Begin Group "Z"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\Archive\Z\ZHandler.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Z\ZHandler.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\Archive\Z\ZRegister.cpp
-# End Source File
-# End Group
# Begin Group "Zip"
# PROP Default_Filter ""
@@ -2418,10 +2358,98 @@ SOURCE=..\..\Archive\Lzma\LzmaIn.h
SOURCE=..\..\Archive\Lzma\LzmaItem.h
# End Source File
# End Group
+# Begin Group "Hfs"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Archive\Hfs\HfsHandler.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Hfs\HfsHandler.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Hfs\HfsIn.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Hfs\HfsIn.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Hfs\HfsRegister.cpp
+# End Source File
+# End Group
+# Begin Group "Udf"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Archive\Udf\UdfHandler.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Udf\UdfHandler.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Udf\UdfIn.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Udf\UdfIn.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\Udf\UdfRegister.cpp
+# End Source File
+# End Group
+# Begin Source File
+
+SOURCE=..\..\Archive\ArjHandler.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\DebHandler.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\DmgHandler.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\ElfHandler.cpp
+# End Source File
# Begin Source File
SOURCE=..\..\Archive\IArchive.h
# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\MachoHandler.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\MubHandler.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\PeHandler.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\RpmHandler.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\XarHandler.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Archive\ZHandler.cpp
+# End Source File
# End Group
# Begin Group "7zip"
@@ -2446,6 +2474,10 @@ SOURCE=..\..\IProgress.h
SOURCE=..\..\IStream.h
# End Source File
+# Begin Source File
+
+SOURCE=..\..\PropID.h
+# End Source File
# End Group
# Begin Group "Windows"
@@ -2484,6 +2516,14 @@ SOURCE=..\..\..\Windows\PropVariant.h
# End Source File
# Begin Source File
+SOURCE=..\..\..\Windows\PropVariantUtils.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\PropVariantUtils.h
+# End Source File
+# Begin Source File
+
SOURCE=..\..\..\Windows\Synchronization.cpp
# End Source File
# Begin Source File
@@ -2502,6 +2542,14 @@ SOURCE=..\..\..\Windows\System.h
SOURCE=..\..\..\Windows\Thread.h
# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\Time.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\Time.h
+# End Source File
# End Group
# End Target
# End Project
diff --git a/CPP/7zip/Bundles/Format7zF/makefile b/CPP/7zip/Bundles/Format7zF/makefile
index 328f8ab6..fb2a1f91 100755
--- a/CPP/7zip/Bundles/Format7zF/makefile
+++ b/CPP/7zip/Bundles/Format7zF/makefile
@@ -12,7 +12,9 @@ COMMON_OBJS = \
$O\CRC.obj \
$O\IntToString.obj \
$O\NewHandler.obj \
+ $O\MyMap.obj \
$O\MyString.obj \
+ $O\MyXml.obj \
$O\StringConvert.obj \
$O\StringToInt.obj \
$O\MyVector.obj \
@@ -24,8 +26,10 @@ WIN_OBJS = \
$O\FileFind.obj \
$O\FileIO.obj \
$O\PropVariant.obj \
+ $O\PropVariantUtils.obj \
$O\Synchronization.obj \
$O\System.obj \
+ $O\Time.obj \
7ZIP_COMMON_OBJS = \
$O\InBuffer.obj \
@@ -52,12 +56,23 @@ WIN_OBJS = \
AR_OBJS = \
$O\ArchiveExports.obj \
$O\DllExports2.obj \
+ $O\ArjHandler.obj \
+ $O\DebHandler.obj \
+ $O\DmgHandler.obj \
+ $O\ElfHandler.obj \
+ $O\MachoHandler.obj \
+ $O\MubHandler.obj \
+ $O\PeHandler.obj \
+ $O\RpmHandler.obj \
+ $O\XarHandler.obj \
+ $O\ZHandler.obj \
AR_COMMON_OBJS = \
$O\CoderMixer2.obj \
$O\CoderMixer2MT.obj \
$O\CrossThreadProgress.obj \
$O\DummyOutStream.obj \
+ $O\FindSignature.obj \
$O\InStreamWithCRC.obj \
$O\ItemNameUtils.obj \
$O\MultiStream.obj \
@@ -84,11 +99,6 @@ AR_COMMON_OBJS = \
$O\7zUpdate.obj \
$O\7zRegister.obj \
-ARJ_OBJS = \
- $O\ArjHandler.obj \
- $O\ArjIn.obj \
- $O\ArjRegister.obj \
-
BZ2_OBJS = \
$O\BZip2Handler.obj \
$O\BZip2HandlerOut.obj \
@@ -119,12 +129,6 @@ CPIO_OBJS = \
$O\CpioIn.obj \
$O\CpioRegister.obj \
-DEB_OBJS = \
- $O\DebHandler.obj \
- $O\DebHeader.obj \
- $O\DebIn.obj \
- $O\DebRegister.obj \
-
GZ_OBJS = \
$O\GZipHandler.obj \
$O\GZipHandlerOut.obj \
@@ -134,6 +138,11 @@ GZ_OBJS = \
$O\GZipUpdate.obj \
$O\GZipRegister.obj \
+HFS_OBJS = \
+ $O\HfsHandler.obj \
+ $O\HfsIn.obj \
+ $O\HfsRegister.obj \
+
ISO_OBJS = \
$O\IsoHandler.obj \
$O\IsoHeader.obj \
@@ -167,11 +176,6 @@ RAR_OBJS = \
$O\RarVolumeInStream.obj \
$O\RarRegister.obj \
-RPM_OBJS = \
- $O\RpmHandler.obj \
- $O\RpmIn.obj \
- $O\RpmRegister.obj \
-
SPLIT_OBJS = \
$O\SplitHandler.obj \
$O\SplitHandlerOut.obj \
@@ -186,15 +190,16 @@ TAR_OBJS = \
$O\TarUpdate.obj \
$O\TarRegister.obj \
+UDF_OBJS = \
+ $O\UdfHandler.obj \
+ $O\UdfIn.obj \
+ $O\UdfRegister.obj \
+
WIM_OBJS = \
$O\WimHandler.obj \
$O\WimIn.obj \
$O\WimRegister.obj \
-Z_OBJS = \
- $O\ZHandler.obj \
- $O\ZRegister.obj \
-
ZIP_OBJS = \
$O\ZipAddCommon.obj \
$O\ZipHandler.obj \
@@ -240,6 +245,7 @@ DEFLATE_OPT_OBJS = \
$O\DeflateRegister.obj \
$O\Deflate64Register.obj \
$O\DeflateNsisRegister.obj \
+ $O\ZlibDecoder.obj \
IMPLODE_OBJS = \
$O\ImplodeDecoder.obj \
@@ -337,24 +343,22 @@ OBJS = \
$(AR_OBJS) \
$(AR_COMMON_OBJS) \
$(7Z_OBJS) \
- $(ARJ_OBJS) \
$(BZ2_OBJS) \
$(CAB_OBJS) \
$(CHM_OBJS) \
$(COM_OBJS) \
$(CPIO_OBJS) \
- $(DEB_OBJS) \
$(GZ_OBJS) \
+ $(HFS_OBJS) \
$(ISO_OBJS) \
$(LZH_OBJS) \
$(LZM_OBJS) \
$(NSIS_OBJS) \
$(RAR_OBJS) \
- $(RPM_OBJS) \
$(SPLIT_OBJS) \
$(TAR_OBJS) \
+ $(UDF_OBJS) \
$(WIM_OBJS) \
- $(Z_OBJS) \
$(ZIP_OBJS) \
$(BZIP2_OBJS) \
$(BZIP2_OPT_OBJS) \
@@ -402,8 +406,6 @@ $(AR_COMMON_OBJS): ../../Archive/Common/$(*B).cpp
$(7Z_OBJS): ../../Archive/7z/$(*B).cpp
$(COMPL)
-$(ARJ_OBJS): ../../Archive/Arj/$(*B).cpp
- $(COMPL)
$(BZ2_OBJS): ../../Archive/BZip2/$(*B).cpp
$(COMPL)
$(CAB_OBJS): ../../Archive/Cab/$(*B).cpp
@@ -414,10 +416,10 @@ $(COM_OBJS): ../../Archive/Com/$(*B).cpp
$(COMPL)
$(CPIO_OBJS): ../../Archive/Cpio/$(*B).cpp
$(COMPL)
-$(DEB_OBJS): ../../Archive/Deb/$(*B).cpp
- $(COMPL)
$(GZ_OBJS): ../../Archive/GZip/$(*B).cpp
$(COMPL)
+$(HFS_OBJS): ../../Archive/Hfs/$(*B).cpp
+ $(COMPL)
$(ISO_OBJS): ../../Archive/Iso/$(*B).cpp
$(COMPL)
$(LZH_OBJS): ../../Archive/Lzh/$(*B).cpp
@@ -428,15 +430,13 @@ $(NSIS_OBJS): ../../Archive/Nsis/$(*B).cpp
$(COMPL)
$(RAR_OBJS): ../../Archive/Rar/$(*B).cpp
$(COMPL)
-$(RPM_OBJS): ../../Archive/Rpm/$(*B).cpp
- $(COMPL)
$(SPLIT_OBJS): ../../Archive/Split/$(*B).cpp
$(COMPL)
$(TAR_OBJS): ../../Archive/Tar/$(*B).cpp
$(COMPL)
-$(WIM_OBJS): ../../Archive/Wim/$(*B).cpp
+$(UDF_OBJS): ../../Archive/Udf/$(*B).cpp
$(COMPL)
-$(Z_OBJS): ../../Archive/Z/$(*B).cpp
+$(WIM_OBJS): ../../Archive/Wim/$(*B).cpp
$(COMPL)
$(ZIP_OBJS): ../../Archive/Zip/$(*B).cpp
$(COMPL)
diff --git a/CPP/7zip/Bundles/Format7zF/resource.rc b/CPP/7zip/Bundles/Format7zF/resource.rc
index 18ec9549..79ef2950 100755
--- a/CPP/7zip/Bundles/Format7zF/resource.rc
+++ b/CPP/7zip/Bundles/Format7zF/resource.rc
@@ -3,26 +3,30 @@
MY_VERSION_INFO_DLL("7z Standalone Plugin", "7za")
-0 ICON "../../Archive/7z/7z.ico"
-1 ICON "../../Archive/Zip/zip.ico"
-2 ICON "../../Archive/BZip2/bz2.ico"
-3 ICON "../../Archive/Rar/rar.ico"
-4 ICON "../../Archive/Arj/arj.ico"
-5 ICON "../../Archive/Z/z.ico"
-6 ICON "../../Archive/Lzh/lzh.ico"
-7 ICON "../../Archive/Cab/cab.ico"
-8 ICON "../../Archive/Iso/iso.ico"
-9 ICON "../../Archive/Split/split.ico"
-10 ICON "../../Archive/RPM/rpm.ico"
-11 ICON "../../Archive/Deb/deb.ico"
-12 ICON "../../Archive/Cpio/cpio.ico"
-13 ICON "../../Archive/Tar/tar.ico"
-14 ICON "../../Archive/GZip/gz.ico"
-15 ICON "../../Archive/Wim/wim.ico"
-16 ICON "../../Archive/Lzma/lzma.ico"
+0 ICON "../../Archive/Icons/7z.ico"
+1 ICON "../../Archive/Icons/zip.ico"
+2 ICON "../../Archive/Icons/bz2.ico"
+3 ICON "../../Archive/Icons/rar.ico"
+4 ICON "../../Archive/Icons/arj.ico"
+5 ICON "../../Archive/Icons/z.ico"
+6 ICON "../../Archive/Icons/lzh.ico"
+7 ICON "../../Archive/Icons/cab.ico"
+8 ICON "../../Archive/Icons/iso.ico"
+9 ICON "../../Archive/Icons/split.ico"
+10 ICON "../../Archive/Icons/rpm.ico"
+11 ICON "../../Archive/Icons/deb.ico"
+12 ICON "../../Archive/Icons/cpio.ico"
+13 ICON "../../Archive/Icons/tar.ico"
+14 ICON "../../Archive/Icons/gz.ico"
+15 ICON "../../Archive/Icons/wim.ico"
+16 ICON "../../Archive/Icons/lzma.ico"
+17 ICON "../../Archive/Icons/dmg.ico"
+18 ICON "../../Archive/Icons/hfs.ico"
+19 ICON "../../Archive/Icons/xar.ico"
-STRINGTABLE
+
+STRINGTABLE
BEGIN
- 100 "7z:0 zip:1 bz2:2 bzip2:2 tbz2:2 tbz:2 rar:3 arj:4 z:5 taz:5 lzh:6 lha:6 cab:7 iso:8 split:9 rpm:10 deb:11 cpio:12 tar:13 gz:14 gzip:14 tgz:14 tpz:14 wim:15 swm:15 lzma:16"
+ 100 "7z:0 zip:1 bz2:2 bzip2:2 tbz2:2 tbz:2 rar:3 arj:4 z:5 taz:5 lzh:6 lha:6 cab:7 iso:8 split:9 rpm:10 deb:11 cpio:12 tar:13 gz:14 gzip:14 tgz:14 tpz:14 wim:15 swm:15 lzma:16 dmg:17 hfs:18 xar:19"
END
diff --git a/CPP/7zip/Bundles/Format7zR/resource.rc b/CPP/7zip/Bundles/Format7zR/resource.rc
index 60a17fe8..f9c17683 100755
--- a/CPP/7zip/Bundles/Format7zR/resource.rc
+++ b/CPP/7zip/Bundles/Format7zR/resource.rc
@@ -2,4 +2,4 @@
MY_VERSION_INFO_DLL("7z Standalone Plugin", "7zr")
-101 ICON "../../Archive/7z/7z.ico"
+101 ICON "../../Archive/Icons/7z.ico"
diff --git a/CPP/7zip/Bundles/SFXCon/Main.cpp b/CPP/7zip/Bundles/SFXCon/Main.cpp
index 79dabdec..5ae6878d 100755
--- a/CPP/7zip/Bundles/SFXCon/Main.cpp
+++ b/CPP/7zip/Bundles/SFXCon/Main.cpp
@@ -35,7 +35,7 @@ using namespace NCommandLineParser;
extern CStdOutStream *g_StdStream;
-static const char *kCopyrightString =
+static const char *kCopyrightString =
"\n7-Zip SFX " MY_VERSION_COPYRIGHT_DATE "\n";
static const int kNumSwitches = 6;
@@ -63,17 +63,17 @@ enum EEnum
{
kRecursed,
kWildCardOnlyRecursed,
- kNonRecursed,
+ kNonRecursed
};
}
-/*
+/*
static const char kRecursedIDChar = 'R';
static const wchar_t *kRecursedPostCharSet = L"0-";
namespace NRecursedPostCharIndex {
- enum EEnum
+ enum EEnum
{
- kWildCardRecursionOnly = 0,
+ kWildCardRecursionOnly = 0,
kNoRecursion = 1
};
}
@@ -84,7 +84,7 @@ static const char kImmediateNameID = '!';
static const char kSomeCludePostStringMinSize = 2; // at least <@|!><N>ame must be
static const char kSomeCludeAfterRecursedPostStringMinSize = 2; // at least <@|!><N>ame must be
*/
-static const CSwitchForm kSwitchForms[kNumSwitches] =
+static const CSwitchForm kSwitchForms[kNumSwitches] =
{
{ L"?", NSwitchType::kSimple, false },
{ L"H", NSwitchType::kSimple, false },
@@ -107,7 +107,7 @@ enum EEnum
}
-static const CCommandForm commandForms[kNumCommandForms] =
+static const CCommandForm commandForms[kNumCommandForms] =
{
{ L"T", false },
// { "E", false },
@@ -115,7 +115,7 @@ static const CCommandForm commandForms[kNumCommandForms] =
{ L"L", false }
};
-static const NRecursedType::EEnum kCommandRecursedDefault[kNumCommandForms] =
+static const NRecursedType::EEnum kCommandRecursedDefault[kNumCommandForms] =
{
NRecursedType::kRecursed
};
@@ -126,7 +126,7 @@ static const NRecursedType::EEnum kCommandRecursedDefault[kNumCommandForms] =
static const wchar_t *kUniversalWildcard = L"*";
static const int kCommandIndex = 0;
-static const char *kHelpString =
+static const char *kHelpString =
"\nUsage: 7zSFX [<command>] [<switches>...]\n"
"\n"
"<Commands>\n"
@@ -188,7 +188,7 @@ bool ParseArchiveCommand(const UString &commandString, CArchiveCommand &command)
UString commandStringUpper = commandString;
commandStringUpper.MakeUpper();
UString postString;
- int commandIndex = ParseCommand(kNumCommandForms, commandForms, commandStringUpper,
+ int commandIndex = ParseCommand(kNumCommandForms, commandForms, commandStringUpper,
postString) ;
if (commandIndex < 0)
return false;
@@ -199,7 +199,7 @@ bool ParseArchiveCommand(const UString &commandString, CArchiveCommand &command)
// ------------------------------------------------------------------
// filenames functions
-static bool AddNameToCensor(NWildcard::CCensor &wildcardCensor,
+static bool AddNameToCensor(NWildcard::CCensor &wildcardCensor,
const UString &name, bool include, NRecursedType::EEnum type)
{
/*
@@ -225,15 +225,15 @@ static bool AddNameToCensor(NWildcard::CCensor &wildcardCensor,
return true;
}
-void AddCommandLineWildCardToCensor(NWildcard::CCensor &wildcardCensor,
+void AddCommandLineWildCardToCensor(NWildcard::CCensor &wildcardCensor,
const UString &name, bool include, NRecursedType::EEnum type)
{
if (!AddNameToCensor(wildcardCensor, name, include, type))
ShowMessageAndThrowException(kIncorrectWildCardInCommandLine, NExitCode::kUserError);
}
-void AddToCensorFromNonSwitchesStrings(NWildcard::CCensor &wildcardCensor,
- const UStringVector & /* nonSwitchStrings */, NRecursedType::EEnum type,
+void AddToCensorFromNonSwitchesStrings(NWildcard::CCensor &wildcardCensor,
+ const UStringVector & /* nonSwitchStrings */, NRecursedType::EEnum type,
bool /* thereAreSwitchIncludeWildCards */)
{
AddCommandLineWildCardToCensor(wildcardCensor, kUniversalWildcard, true, type);
@@ -253,19 +253,19 @@ static void GetArguments(int numArguments, const char *arguments[], UStringVecto
#endif
int Main2(
- #ifndef _WIN32
+ #ifndef _WIN32
int numArguments, const char *arguments[]
#endif
)
{
- #ifdef _WIN32
+ #ifdef _WIN32
SetFileApisToOEM();
#endif
g_StdOut << kCopyrightString;
UStringVector commandStrings;
- #ifdef _WIN32
+ #ifdef _WIN32
NCommandLineParser::SplitCommandLine(GetCommandLineW(), commandStrings);
#else
GetArguments(numArguments, arguments, commandStrings);
@@ -280,7 +280,7 @@ int Main2(
{
parser.ParseStrings(kSwitchForms, commandStrings);
}
- catch(...)
+ catch(...)
{
PrintHelpAndExit();
}
@@ -297,7 +297,7 @@ int Main2(
CArchiveCommand command;
if (numNonSwitchStrings == 0)
command.CommandType = NCommandType::kFullExtract;
- else
+ else
{
if (numNonSwitchStrings > 1)
PrintHelpAndExit();
@@ -335,7 +335,7 @@ int Main2(
NFind::CFileInfoW archiveFileInfo;
if (!NFind::FindFile(archiveName, archiveFileInfo))
throw kCantFindSFX;
- if (archiveFileInfo.IsDirectory())
+ if (archiveFileInfo.IsDir())
throw kCantFindSFX;
UString outputDir;
@@ -349,7 +349,7 @@ int Main2(
UStringVector v1, v2;
v1.Add(archiveName);
v2.Add(archiveName);
- const NWildcard::CCensorNode &wildcardCensorHead =
+ const NWildcard::CCensorNode &wildcardCensorHead =
wildcardCensor.Pairs.Front().Head;
CCodecs *codecs = new CCodecs;
@@ -382,8 +382,8 @@ int Main2(
eo.StdOutMode = false;
eo.PathMode = NExtract::NPathMode::kFullPathnames;
eo.TestMode = command.CommandType == NCommandType::kTest;
- eo.OverwriteMode = yesToAll ?
- NExtract::NOverwriteMode::kWithoutPrompt :
+ eo.OverwriteMode = yesToAll ?
+ NExtract::NOverwriteMode::kWithoutPrompt :
NExtract::NOverwriteMode::kAskBefore;
eo.OutputDir = outputDir;
eo.YesToAll = yesToAll;
@@ -391,9 +391,9 @@ int Main2(
UString errorMessage;
CDecompressStat stat;
HRESULT result = DecompressArchives(
- codecs,
+ codecs, CIntVector(),
v1, v2,
- wildcardCensorHead,
+ wildcardCensorHead,
eo, &openCallback, ecs, errorMessage, stat);
if (!errorMessage.IsEmpty())
{
@@ -417,11 +417,11 @@ int Main2(
{
UInt64 numErrors = 0;
HRESULT result = ListArchives(
- codecs,
+ codecs, CIntVector(),
v1, v2,
- wildcardCensorHead,
- true, false,
- passwordEnabled,
+ wildcardCensorHead,
+ true, false,
+ passwordEnabled,
password, numErrors);
if (numErrors > 0)
{
diff --git a/CPP/7zip/Bundles/SFXSetup/ExtractCallback.cpp b/CPP/7zip/Bundles/SFXSetup/ExtractCallback.cpp
index 5d56a9e7..f2af88e6 100755
--- a/CPP/7zip/Bundles/SFXSetup/ExtractCallback.cpp
+++ b/CPP/7zip/Bundles/SFXSetup/ExtractCallback.cpp
@@ -5,44 +5,57 @@
#include "ExtractCallback.h"
#include "Common/Wildcard.h"
-#include "Common/StringConvert.h"
-#include "Windows/COM.h"
#include "Windows/FileDir.h"
#include "Windows/FileFind.h"
-#include "Windows/Time.h"
-#include "Windows/Defs.h"
#include "Windows/PropVariant.h"
-#include "Windows/PropVariantConversions.h"
-
using namespace NWindows;
using namespace NFile;
-// static LPCWSTR kErrorTitle = L"7-Zip";
static LPCWSTR kCantDeleteFile = L"Can not delete output file";
static LPCWSTR kCantOpenFile = L"Can not open output file";
static LPCWSTR kUnsupportedMethod = L"Unsupported Method";
-// static LPCWSTR kCRCFailed = L"CRC Failed";
-// static LPCWSTR kDataError = L"Data Error";
-// static LPCWSTR kUnknownError = L""Unknown Error";
void CExtractCallbackImp::Init(IInArchive *archiveHandler,
- const UString &directoryPath,
+ const UString &directoryPath,
const UString &itemDefaultName,
- const FILETIME &utcLastWriteTimeDefault,
- UInt32 attributesDefault)
+ const FILETIME &defaultMTime,
+ UInt32 defaultAttributes)
{
_message.Empty();
_isCorrupt = false;
_itemDefaultName = itemDefaultName;
- _utcLastWriteTimeDefault = utcLastWriteTimeDefault;
- _attributesDefault = attributesDefault;
+ _defaultMTime = defaultMTime;
+ _defaultAttributes = defaultAttributes;
_archiveHandler = archiveHandler;
_directoryPath = directoryPath;
NName::NormalizeDirPathPrefix(_directoryPath);
}
+HRESULT CExtractCallbackImp::Open_CheckBreak()
+{
+ #ifndef _NO_PROGRESS
+ return ProgressDialog.ProgressSynch.ProcessStopAndPause();
+ #else
+ return S_OK;
+ #endif
+}
+
+HRESULT CExtractCallbackImp::Open_SetTotal(const UInt64 * /* numFiles */, const UInt64 * /* numBytes */)
+{
+ return S_OK;
+}
+
+HRESULT CExtractCallbackImp::Open_SetCompleted(const UInt64 * /* numFiles */, const UInt64 * /* numBytes */)
+{
+ #ifndef _NO_PROGRESS
+ return ProgressDialog.ProgressSynch.ProcessStopAndPause();
+ #else
+ return S_OK;
+ #endif
+}
+
STDMETHODIMP CExtractCallbackImp::SetTotal(UInt64 size)
{
#ifndef _NO_PROGRESS
@@ -54,14 +67,7 @@ STDMETHODIMP CExtractCallbackImp::SetTotal(UInt64 size)
STDMETHODIMP CExtractCallbackImp::SetCompleted(const UInt64 *completeValue)
{
#ifndef _NO_PROGRESS
- for (;;)
- {
- if(ProgressDialog.ProgressSynch.GetStopped())
- return E_ABORT;
- if(!ProgressDialog.ProgressSynch.GetPaused())
- break;
- ::Sleep(100);
- }
+ RINOK(ProgressDialog.ProgressSynch.ProcessStopAndPause());
if (completeValue != NULL)
ProgressDialog.ProgressSynch.SetPos(*completeValue);
#endif
@@ -83,18 +89,18 @@ STDMETHODIMP CExtractCallbackImp::GetStream(UInt32 index,
ISequentialOutStream **outStream, Int32 askExtractMode)
{
#ifndef _NO_PROGRESS
- if(ProgressDialog.ProgressSynch.GetStopped())
+ if (ProgressDialog.ProgressSynch.GetStopped())
return E_ABORT;
#endif
_outFileStream.Release();
NCOM::CPropVariant propVariantName;
RINOK(_archiveHandler->GetProperty(index, kpidPath, &propVariantName));
UString fullPath;
- if(propVariantName.vt == VT_EMPTY)
+ if (propVariantName.vt == VT_EMPTY)
fullPath = _itemDefaultName;
- else
+ else
{
- if(propVariantName.vt != VT_BSTR)
+ if (propVariantName.vt != VT_BSTR)
return E_FAIL;
fullPath = propVariantName.bstrVal;
}
@@ -102,52 +108,51 @@ STDMETHODIMP CExtractCallbackImp::GetStream(UInt32 index,
// m_CurrentFilePath = GetSystemString(fullPath, _codePage);
- if(askExtractMode == NArchive::NExtract::NAskMode::kExtract)
+ if (askExtractMode == NArchive::NExtract::NAskMode::kExtract)
{
- NCOM::CPropVariant propVariant;
- RINOK(_archiveHandler->GetProperty(index, kpidAttributes, &propVariant));
- if (propVariant.vt == VT_EMPTY)
- _processedFileInfo.Attributes = _attributesDefault;
+ NCOM::CPropVariant prop;
+ RINOK(_archiveHandler->GetProperty(index, kpidAttrib, &prop));
+ if (prop.vt == VT_EMPTY)
+ _processedFileInfo.Attributes = _defaultAttributes;
else
{
- if (propVariant.vt != VT_UI4)
+ if (prop.vt != VT_UI4)
return E_FAIL;
- _processedFileInfo.Attributes = propVariant.ulVal;
+ _processedFileInfo.Attributes = prop.ulVal;
}
- RINOK(_archiveHandler->GetProperty(index, kpidIsFolder, &propVariant));
- _processedFileInfo.IsDirectory = VARIANT_BOOLToBool(propVariant.boolVal);
+ RINOK(_archiveHandler->GetProperty(index, kpidIsDir, &prop));
+ _processedFileInfo.IsDir = VARIANT_BOOLToBool(prop.boolVal);
bool isAnti = false;
{
- NCOM::CPropVariant propVariantTemp;
- RINOK(_archiveHandler->GetProperty(index, kpidIsAnti,
- &propVariantTemp));
- if (propVariantTemp.vt == VT_BOOL)
- isAnti = VARIANT_BOOLToBool(propVariantTemp.boolVal);
+ NCOM::CPropVariant propTemp;
+ RINOK(_archiveHandler->GetProperty(index, kpidIsAnti, &propTemp));
+ if (propTemp.vt == VT_BOOL)
+ isAnti = VARIANT_BOOLToBool(propTemp.boolVal);
}
- RINOK(_archiveHandler->GetProperty(index, kpidLastWriteTime, &propVariant));
- switch(propVariant.vt)
+ RINOK(_archiveHandler->GetProperty(index, kpidMTime, &prop));
+ switch(prop.vt)
{
case VT_EMPTY:
- _processedFileInfo.UTCLastWriteTime = _utcLastWriteTimeDefault;
+ _processedFileInfo.MTime = _defaultMTime;
break;
case VT_FILETIME:
- _processedFileInfo.UTCLastWriteTime = propVariant.filetime;
+ _processedFileInfo.MTime = prop.filetime;
break;
default:
return E_FAIL;
}
- UStringVector pathParts;
+ UStringVector pathParts;
SplitPathToParts(fullPath, pathParts);
- if(pathParts.IsEmpty())
+ if (pathParts.IsEmpty())
return E_FAIL;
UString processedPath = fullPath;
- if(!_processedFileInfo.IsDirectory)
+ if (!_processedFileInfo.IsDir)
pathParts.DeleteBack();
if (!pathParts.IsEmpty())
{
@@ -157,7 +162,7 @@ STDMETHODIMP CExtractCallbackImp::GetStream(UInt32 index,
UString fullProcessedPath = _directoryPath + processedPath;
- if(_processedFileInfo.IsDirectory)
+ if (_processedFileInfo.IsDir)
{
_diskFilePath = fullProcessedPath;
@@ -167,7 +172,7 @@ STDMETHODIMP CExtractCallbackImp::GetStream(UInt32 index,
}
NFind::CFileInfoW fileInfo;
- if(NFind::FindFile(fullProcessedPath, fileInfo))
+ if (NFind::FindFile(fullProcessedPath, fileInfo))
{
if (!NDirectory::DeleteFileAlways(fullProcessedPath))
{
@@ -214,9 +219,8 @@ STDMETHODIMP CExtractCallbackImp::SetOperationResult(Int32 resultEOperationResul
switch(resultEOperationResult)
{
case NArchive::NExtract::NOperationResult::kOK:
- {
break;
- }
+
default:
{
_outFileStream.Release();
@@ -225,23 +229,15 @@ STDMETHODIMP CExtractCallbackImp::SetOperationResult(Int32 resultEOperationResul
case NArchive::NExtract::NOperationResult::kUnSupportedMethod:
_message = kUnsupportedMethod;
break;
- case NArchive::NExtract::NOperationResult::kCRCError:
- _isCorrupt = true;
- // _message = kCRCFailed;
- break;
- case NArchive::NExtract::NOperationResult::kDataError:
- _isCorrupt = true;
- // _message = kDataError;
- break;
default:
_isCorrupt = true;
}
return E_FAIL;
}
}
- if(_outFileStream != NULL)
+ if (_outFileStream != NULL)
{
- _outFileStreamSpec->SetLastWriteTime(&_processedFileInfo.UTCLastWriteTime);
+ _outFileStreamSpec->SetMTime(&_processedFileInfo.MTime);
RINOK(_outFileStreamSpec->Close());
}
_outFileStream.Release();
@@ -249,4 +245,3 @@ STDMETHODIMP CExtractCallbackImp::SetOperationResult(Int32 resultEOperationResul
NDirectory::MySetFileAttributes(_diskFilePath, _processedFileInfo.Attributes);
return S_OK;
}
-
diff --git a/CPP/7zip/Bundles/SFXSetup/ExtractCallback.h b/CPP/7zip/Bundles/SFXSetup/ExtractCallback.h
index 01427394..4f4258bc 100755
--- a/CPP/7zip/Bundles/SFXSetup/ExtractCallback.h
+++ b/CPP/7zip/Bundles/SFXSetup/ExtractCallback.h
@@ -15,38 +15,31 @@
#ifndef _NO_PROGRESS
#include "../../UI/FileManager/ProgressDialog.h"
#endif
+#include "../../UI/Common/ArchiveOpenCallback.h"
-class CExtractCallbackImp:
+class CExtractCallbackImp:
public IArchiveExtractCallback,
+ public IOpenCallbackUI,
public CMyUnknownImp
{
public:
MY_UNKNOWN_IMP
- // IProgress
- STDMETHOD(SetTotal)(UInt64 size);
- STDMETHOD(SetCompleted)(const UInt64 *completeValue);
-
- // IExtractCallback
- STDMETHOD(GetStream)(UInt32 index, ISequentialOutStream **outStream,
- Int32 askExtractMode);
- STDMETHOD(PrepareOperation)(Int32 askExtractMode);
- STDMETHOD(SetOperationResult)(Int32 resultEOperationResult);
+ INTERFACE_IArchiveExtractCallback(;)
+ INTERFACE_IOpenCallbackUI(;)
private:
CMyComPtr<IInArchive> _archiveHandler;
UString _directoryPath;
-
UString _filePath;
-
UString _diskFilePath;
bool _extractMode;
struct CProcessedFileInfo
{
- FILETIME UTCLastWriteTime;
- bool IsDirectory;
+ FILETIME MTime;
+ bool IsDir;
UInt32 Attributes;
} _processedFileInfo;
@@ -54,8 +47,8 @@ private:
CMyComPtr<ISequentialOutStream> _outFileStream;
UString _itemDefaultName;
- FILETIME _utcLastWriteTimeDefault;
- UInt32 _attributesDefault;
+ FILETIME _defaultMTime;
+ UInt32 _defaultAttributes;
void CreateComplexDirectory(const UStringVector &dirPathParts);
public:
@@ -66,25 +59,25 @@ public:
bool _isCorrupt;
UString _message;
- void Init(IInArchive *archiveHandler,
- const UString &directoryPath,
+ void Init(IInArchive *archiveHandler,
+ const UString &directoryPath,
const UString &itemDefaultName,
- const FILETIME &utcLastWriteTimeDefault,
- UInt32 attributesDefault);
+ const FILETIME &defaultMTime,
+ UInt32 defaultAttributes);
#ifndef _NO_PROGRESS
HRESULT StartProgressDialog(const UString &title)
{
ProgressDialog.Create(title, 0);
{
- #ifdef LANG
+ #ifdef LANG
ProgressDialog.SetText(LangLoadString(IDS_PROGRESS_EXTRACTING, 0x02000890));
#else
ProgressDialog.SetText(NWindows::MyLoadStringW(IDS_PROGRESS_EXTRACTING));
#endif
}
- ProgressDialog.Show(SW_SHOWNORMAL);
+ ProgressDialog.Show(SW_SHOWNORMAL);
return S_OK;
}
virtual ~CExtractCallbackImp() { ProgressDialog.Destroy(); }
diff --git a/CPP/7zip/Bundles/SFXSetup/ExtractEngine.cpp b/CPP/7zip/Bundles/SFXSetup/ExtractEngine.cpp
index 04c9af18..d867b74a 100755
--- a/CPP/7zip/Bundles/SFXSetup/ExtractEngine.cpp
+++ b/CPP/7zip/Bundles/SFXSetup/ExtractEngine.cpp
@@ -12,128 +12,122 @@
#include "../../UI/Common/OpenArchive.h"
-#include "../../UI/Explorer/MyMessages.h"
#include "../../UI/FileManager/FormatUtils.h"
#include "ExtractCallback.h"
using namespace NWindows;
+static LPCWSTR kCantFindArchive = L"Can not find archive file";
+static LPCWSTR kCantOpenArchive = L"Can not open the file as archive";
+
struct CThreadExtracting
{
- CArchiveLink ArchiveLink;
+ #ifndef _NO_PROGRESS
+ bool ShowProgress;
+ #endif
+ CCodecs *Codecs;
+ UString FileName;
+ UString DestFolder;
CExtractCallbackImp *ExtractCallbackSpec;
CMyComPtr<IArchiveExtractCallback> ExtractCallback;
- #ifndef _NO_PROGRESS
+ CArchiveLink ArchiveLink;
HRESULT Result;
+ UString ErrorMessage;
- HRESULT Extract()
+ void Process()
{
- return ArchiveLink.GetArchive()->Extract(0, (UInt32)-1 , BoolToInt(false), ExtractCallback);
- }
- DWORD Process()
- {
- ExtractCallbackSpec->ProgressDialog.WaitCreating();
- Result = Extract();
- ExtractCallbackSpec->ProgressDialog.MyClose();
- return 0;
+ NFile::NFind::CFileInfoW fi;
+ if (!NFile::NFind::FindFile(FileName, fi))
+ {
+ ErrorMessage = kCantFindArchive;
+ Result = E_FAIL;
+ return;
+ }
+
+ Result = MyOpenArchive(Codecs, CIntVector(), FileName, ArchiveLink, ExtractCallbackSpec);
+ if (Result != S_OK)
+ {
+ if (Result != S_OK)
+ ErrorMessage = kCantOpenArchive;
+ return;
+ }
+
+ UString dirPath = DestFolder;
+ NFile::NName::NormalizeDirPathPrefix(dirPath);
+
+ if (!NFile::NDirectory::CreateComplexDirectory(dirPath))
+ {
+ ErrorMessage = MyFormatNew(IDS_CANNOT_CREATE_FOLDER,
+ #ifdef LANG
+ 0x02000603,
+ #endif
+ dirPath);
+ Result = E_FAIL;
+ return;
+ }
+
+ ExtractCallbackSpec->Init(ArchiveLink.GetArchive(), dirPath, L"Default", fi.MTime, 0);
+
+ #ifndef _NO_PROGRESS
+ if (ShowProgress)
+ ExtractCallbackSpec->ProgressDialog.WaitCreating();
+ #endif
+ Result = ArchiveLink.GetArchive()->Extract(0, (UInt32)-1 , BoolToInt(false), ExtractCallback);
+ #ifndef _NO_PROGRESS
+ if (ShowProgress)
+ ExtractCallbackSpec->ProgressDialog.MyClose();
+ #endif
}
+
static THREAD_FUNC_DECL MyThreadFunction(void *param)
{
- return ((CThreadExtracting *)param)->Process();
+ ((CThreadExtracting *)param)->Process();
+ return 0;
}
- #endif
};
-static const LPCWSTR kCantFindArchive = L"Can not find archive file";
-static const LPCWSTR kCantOpenArchive = L"File is not correct archive";
-
-HRESULT ExtractArchive(
- CCodecs *codecs,
- const UString &fileName,
- const UString &folderName,
- COpenCallbackGUI *openCallback,
- bool showProgress,
- bool &isCorrupt,
- UString &errorMessage)
+HRESULT ExtractArchive(CCodecs *codecs,const UString &fileName, const UString &destFolder,
+ bool showProgress, bool &isCorrupt, UString &errorMessage)
{
isCorrupt = false;
- NFile::NFind::CFileInfoW archiveFileInfo;
- if (!NFile::NFind::FindFile(fileName, archiveFileInfo))
- {
- errorMessage = kCantFindArchive;
- return E_FAIL;
- }
-
- CThreadExtracting extracter;
-
- HRESULT result = MyOpenArchive(codecs, fileName, extracter.ArchiveLink, openCallback);
-
- if (result != S_OK)
- {
- errorMessage = kCantOpenArchive;
- return result;
- }
+ CThreadExtracting t;
- UString directoryPath = folderName;
- NFile::NName::NormalizeDirPathPrefix(directoryPath);
+ t.Codecs = codecs;
+ t.FileName = fileName;
+ t.DestFolder = destFolder;
- /*
- UString directoryPath;
- {
- UString fullPath;
- int fileNamePartStartIndex;
- if (!NWindows::NFile::NDirectory::MyGetFullPathName(fileName, fullPath, fileNamePartStartIndex))
- {
- MessageBox(NULL, "Error 1329484", "7-Zip", 0);
- return E_FAIL;
- }
- directoryPath = fullPath.Left(fileNamePartStartIndex);
- }
- */
-
- if(!NFile::NDirectory::CreateComplexDirectory(directoryPath))
- {
- errorMessage = MyFormatNew(IDS_CANNOT_CREATE_FOLDER,
- #ifdef LANG
- 0x02000603,
- #endif
- directoryPath);
- return E_FAIL;
- }
-
- extracter.ExtractCallbackSpec = new CExtractCallbackImp;
- extracter.ExtractCallback = extracter.ExtractCallbackSpec;
+ t.ExtractCallbackSpec = new CExtractCallbackImp;
+ t.ExtractCallback = t.ExtractCallbackSpec;
- extracter.ExtractCallbackSpec->Init(
- extracter.ArchiveLink.GetArchive(),
- directoryPath, L"Default", archiveFileInfo.LastWriteTime, 0);
-
#ifndef _NO_PROGRESS
+ t.ShowProgress = showProgress;
if (showProgress)
{
NWindows::CThread thread;
- RINOK(thread.Create(CThreadExtracting::MyThreadFunction, &extracter));
+ RINOK(thread.Create(CThreadExtracting::MyThreadFunction, &t));
UString title;
- #ifdef LANG
+ #ifdef LANG
title = LangLoadString(IDS_PROGRESS_EXTRACTING, 0x02000890);
#else
title = NWindows::MyLoadStringW(IDS_PROGRESS_EXTRACTING);
#endif
- extracter.ExtractCallbackSpec->StartProgressDialog(title);
- result = extracter.Result;
+ t.ExtractCallbackSpec->StartProgressDialog(title);
}
else
#endif
{
- result = extracter.Extract();
+ t.Process();
}
- errorMessage = extracter.ExtractCallbackSpec->_message;
- isCorrupt = extracter.ExtractCallbackSpec->_isCorrupt;
- return result;
+
+ errorMessage = t.ErrorMessage;
+ if (errorMessage.IsEmpty())
+ errorMessage = t.ExtractCallbackSpec->_message;
+ isCorrupt = t.ExtractCallbackSpec->_isCorrupt;
+ return t.Result;
}
diff --git a/CPP/7zip/Bundles/SFXSetup/ExtractEngine.h b/CPP/7zip/Bundles/SFXSetup/ExtractEngine.h
index e2f7518b..56d69686 100755
--- a/CPP/7zip/Bundles/SFXSetup/ExtractEngine.h
+++ b/CPP/7zip/Bundles/SFXSetup/ExtractEngine.h
@@ -3,16 +3,9 @@
#ifndef __EXTRACTENGINE_H
#define __EXTRACTENGINE_H
-#include "../../UI/GUI/OpenCallbackGUI.h"
#include "../../UI/Common/LoadCodecs.h"
-HRESULT ExtractArchive(
- CCodecs *codecs,
- const UString &fileName,
- const UString &folderName,
- COpenCallbackGUI *openCallback,
- bool showProgress,
- bool &isCorrupt,
- UString &errorMessage);
+HRESULT ExtractArchive(CCodecs *codecs, const UString &fileName, const UString &destFolder,
+ bool showProgress, bool &isCorrupt, UString &errorMessage);
#endif
diff --git a/CPP/7zip/Bundles/SFXSetup/Main.cpp b/CPP/7zip/Bundles/SFXSetup/Main.cpp
index ff20b304..64f0eab1 100755
--- a/CPP/7zip/Bundles/SFXSetup/Main.cpp
+++ b/CPP/7zip/Bundles/SFXSetup/Main.cpp
@@ -31,11 +31,11 @@ using namespace NWindows;
HINSTANCE g_hInstance;
-static LPCTSTR kTempDirPrefix = TEXT("7zS");
+static LPCTSTR kTempDirPrefix = TEXT("7zS");
#define _SHELL_EXECUTE
-static bool ReadDataString(LPCWSTR fileName, LPCSTR startID,
+static bool ReadDataString(LPCWSTR fileName, LPCSTR startID,
LPCSTR endID, AString &stringResult)
{
stringResult.Empty();
@@ -64,7 +64,7 @@ static bool ReadDataString(LPCWSTR fileName, LPCSTR startID,
UInt32 numBytesInBuffer = numBytesPrev + processedSize;
UInt32 pos = 0;
for (;;)
- {
+ {
if (writeMode)
{
if (pos > numBytesInBuffer - signatureEndSize)
@@ -128,7 +128,7 @@ static inline bool IsItWindowsNT()
{
OSVERSIONINFO versionInfo;
versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
- if (!::GetVersionEx(&versionInfo))
+ if (!::GetVersionEx(&versionInfo))
return false;
return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
}
@@ -164,7 +164,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /
if (!ReadDataString(fullPath, kStartID, kEndID, config))
{
if (!assumeYes)
- MyMessageBox(L"Can't load config info");
+ ShowErrorMessage(L"Can't load config info");
return 1;
}
@@ -177,7 +177,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /
if (!GetTextConfig(config, pairs))
{
if (!assumeYes)
- MyMessageBox(L"Config failed");
+ ShowErrorMessage(L"Config failed");
return 1;
}
UString friendlyName = GetTextConfigValue(pairs, L"Title");
@@ -190,7 +190,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /
dirPrefix = pairs[index].String;
if (!installPrompt.IsEmpty() && !assumeYes)
{
- if (MessageBoxW(0, installPrompt, friendlyName, MB_YESNO |
+ if (MessageBoxW(0, installPrompt, friendlyName, MB_YESNO |
MB_ICONQUESTION) != IDYES)
return 0;
}
@@ -206,7 +206,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /
if (!tempDir.Create(kTempDirPrefix))
{
if (!assumeYes)
- MyMessageBox(L"Can not create temp folder archive");
+ ShowErrorMessage(L"Can not create temp folder archive");
return 1;
}
@@ -215,17 +215,15 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /
HRESULT result = codecs->Load();
if (result != S_OK)
{
- MyMessageBox(L"Can not load codecs");
+ ShowErrorMessage(L"Can not load codecs");
return 1;
}
- COpenCallbackGUI openCallback;
-
UString tempDirPath = GetUnicodeString(tempDir.GetPath());
{
bool isCorrupt = false;
UString errorMessage;
- HRESULT result = ExtractArchive(codecs, fullPath, tempDirPath, &openCallback, showProgress,
+ HRESULT result = ExtractArchive(codecs, fullPath, tempDirPath, showProgress,
isCorrupt, errorMessage);
if (result != S_OK)
@@ -278,7 +276,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /
if(result <= 32)
{
if (!assumeYes)
- MyMessageBox(L"Can not open file");
+ ShowErrorMessage(L"Can not open file");
return 1;
}
hProcess = execInfo.hProcess;
@@ -292,7 +290,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /
if (!NFile::NFind::DoesFileExist(GetSystemString(appLaunched)))
{
if (!assumeYes)
- MyMessageBox(L"Can not find setup.exe");
+ ShowErrorMessage(L"Can not find setup.exe");
return 1;
}
}
@@ -323,8 +321,8 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /
CSysString appLaunchedSys = GetSystemString(dirPrefix + appLaunched);
- BOOL createResult = CreateProcess(NULL, (LPTSTR)(LPCTSTR)appLaunchedSys,
- NULL, NULL, FALSE, 0, NULL, NULL /*tempDir.GetPath() */,
+ BOOL createResult = CreateProcess(NULL, (LPTSTR)(LPCTSTR)appLaunchedSys,
+ NULL, NULL, FALSE, 0, NULL, NULL /*tempDir.GetPath() */,
&startupInfo, &processInformation);
if (createResult == 0)
{
diff --git a/CPP/7zip/Bundles/SFXSetup/SFXSetup.dsp b/CPP/7zip/Bundles/SFXSetup/SFXSetup.dsp
index 3b0117a1..6a493519 100755
--- a/CPP/7zip/Bundles/SFXSetup/SFXSetup.dsp
+++ b/CPP/7zip/Bundles/SFXSetup/SFXSetup.dsp
@@ -647,18 +647,6 @@ SOURCE=..\..\UI\Common\OpenArchive.cpp
SOURCE=..\..\UI\Common\OpenArchive.h
# End Source File
# End Group
-# Begin Group "GUI"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=..\..\UI\GUI\OpenCallbackGUI.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\GUI\OpenCallbackGUI.h
-# End Source File
-# End Group
# End Group
# Begin Group "File Manager"
diff --git a/CPP/7zip/Bundles/SFXSetup/makefile b/CPP/7zip/Bundles/SFXSetup/makefile
index 274730cd..0d4255d1 100755
--- a/CPP/7zip/Bundles/SFXSetup/makefile
+++ b/CPP/7zip/Bundles/SFXSetup/makefile
@@ -12,9 +12,6 @@ SFX_WIN_OBJS = \
$O\ExtractCallback.obj \
$O\ExtractEngine.obj \
-GUI_OBJS = \
- $O\OpenCallbackGUI.obj \
-
COMMON_OBJS = \
$O\CommandLineParser.obj \
$O\CRC.obj \
@@ -111,7 +108,6 @@ C_OBJS = \
OBJS = \
$O\StdAfx.obj \
$(SFX_WIN_OBJS) \
- $(GUI_OBJS) \
$(COMMON_OBJS) \
$(WIN_OBJS) \
$(WIN_CTRL_OBJS) \
@@ -135,8 +131,6 @@ OBJS = \
$(SFX_WIN_OBJS): $(*B).cpp
$(COMPL)
-$(GUI_OBJS): ../../UI/GUI/$(*B).cpp
- $(COMPL)
$(COMMON_OBJS): ../../../Common/$(*B).cpp
$(COMPL)
$(WIN_OBJS): ../../../Windows/$(*B).cpp
diff --git a/CPP/7zip/Bundles/SFXWin/Main.cpp b/CPP/7zip/Bundles/SFXWin/Main.cpp
index 44f37560..7cc70882 100755
--- a/CPP/7zip/Bundles/SFXWin/Main.cpp
+++ b/CPP/7zip/Bundles/SFXWin/Main.cpp
@@ -4,12 +4,14 @@
#include <initguid.h>
-#include "Common/StringConvert.h"
#include "Common/CommandLineParser.h"
+#include "Common/StringConvert.h"
+#include "Windows/DLL.h"
+#include "Windows/Error.h"
#include "Windows/FileDir.h"
#include "Windows/FileName.h"
-#include "Windows/DLL.h"
+#include "Windows/ResourceString.h"
#include "../../ICoder.h"
#include "../../IPassword.h"
@@ -18,6 +20,7 @@
#include "../../UI/Common/ExitCode.h"
#include "../../UI/Explorer/MyMessages.h"
#include "../../UI/GUI/ExtractGUI.h"
+#include "../../UI/GUI/ExtractRes.h"
HINSTANCE g_hInstance;
#ifndef _UNICODE
@@ -26,15 +29,24 @@ static inline bool IsItWindowsNT()
{
OSVERSIONINFO versionInfo;
versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
- if (!::GetVersionEx(&versionInfo))
+ if (!::GetVersionEx(&versionInfo))
return false;
return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
}
#endif
-static const wchar_t *kMemoryExceptionMessage = L"ERROR: Can't allocate required memory!";
static const wchar_t *kUnknownExceptionMessage = L"ERROR: Unknown Error!";
+void ErrorMessageForHRESULT(HRESULT res)
+{
+ UString s;
+ if (res == E_OUTOFMEMORY)
+ s = NWindows::MyLoadStringW(IDS_MEM_ERROR);
+ else
+ s = NWindows::NError::MyFormatMessageW(res);
+ ShowErrorMessage(s);
+}
+
int APIENTRY WinMain2()
{
UString password;
@@ -67,7 +79,7 @@ int APIENTRY WinMain2()
int fileNamePartStartIndex;
if (!NWindows::NFile::NDirectory::MyGetFullPathName(path, fullPath, fileNamePartStartIndex))
{
- MyMessageBox(L"Error 1329484");
+ ShowErrorMessage(L"Error 1329484");
return 1;
}
@@ -76,14 +88,14 @@ int APIENTRY WinMain2()
HRESULT result = codecs->Load();
if (result != S_OK)
{
- ShowErrorMessage(0, result);
- return S_OK;
+ ErrorMessageForHRESULT(result);
+ return 1;
}
- COpenCallbackGUI openCallback;
+ // COpenCallbackGUI openCallback;
- openCallback.PasswordIsDefined = !password.IsEmpty();
- openCallback.Password = password;
+ // openCallback.PasswordIsDefined = !password.IsEmpty();
+ // openCallback.Password = password;
CExtractCallbackImp *ecs = new CExtractCallbackImp;
CMyComPtr<IFolderArchiveExtractCallback> extractCallback = ecs;
@@ -92,11 +104,11 @@ int APIENTRY WinMain2()
ecs->Password = password;
CExtractOptions eo;
- eo.OutputDir = outputFolderDefined ? outputFolder :
+ eo.OutputDir = outputFolderDefined ? outputFolder :
fullPath.Left(fileNamePartStartIndex);
eo.YesToAll = assumeYes;
- eo.OverwriteMode = assumeYes ?
- NExtract::NOverwriteMode::kWithoutPrompt :
+ eo.OverwriteMode = assumeYes ?
+ NExtract::NOverwriteMode::kWithoutPrompt :
NExtract::NOverwriteMode::kAskBefore;
eo.PathMode = NExtract::NPathMode::kFullPathnames;
eo.TestMode = false;
@@ -107,26 +119,23 @@ int APIENTRY WinMain2()
NWildcard::CCensorNode wildcardCensor;
wildcardCensor.AddItem(true, L"*", true, true, true);
- result = ExtractGUI(codecs, v1, v2,
- wildcardCensor, eo, (assumeYes ? false: true), &openCallback, ecs);
+ result = ExtractGUI(codecs, CIntVector(), v1, v2,
+ wildcardCensor, eo, (assumeYes ? false: true), ecs);
- /*
- HRESULT result = ExtractArchive(NULL, path, assumeYes, !assumeYes,
- outputFolderDefined ? outputFolder :
- fullPath.Left(fileNamePartStartIndex));
- */
if (result == S_OK)
{
if (ecs->Messages.Size() > 0 || ecs->NumArchiveErrors != 0)
- return NExitCode::kFatalError;
+ return NExitCode::kFatalError;
return 0;
}
if (result == E_ABORT)
return NExitCode::kUserBreak;
if (result == S_FALSE)
- MyMessageBox(L"Error in archive");
+ ShowErrorMessage(L"Error in archive");
else
- ShowErrorMessage(0, result);
+ ErrorMessageForHRESULT(result);
+ if (result == E_OUTOFMEMORY)
+ return NExitCode::kMemoryError;
return NExitCode::kFatalError;
}
@@ -142,12 +151,12 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /
}
catch(const CNewException &)
{
- MyMessageBox(kMemoryExceptionMessage);
- return (NExitCode::kMemoryError);
+ ErrorMessageForHRESULT(E_OUTOFMEMORY);
+ return NExitCode::kMemoryError;
}
catch(...)
{
- MyMessageBox(kUnknownExceptionMessage);
+ ShowErrorMessage(kUnknownExceptionMessage);
return NExitCode::kFatalError;
}
}
diff --git a/CPP/7zip/Bundles/SFXWin/SFXWin.dsp b/CPP/7zip/Bundles/SFXWin/SFXWin.dsp
index 0a78fe4d..a6c7a6fd 100755
--- a/CPP/7zip/Bundles/SFXWin/SFXWin.dsp
+++ b/CPP/7zip/Bundles/SFXWin/SFXWin.dsp
@@ -554,6 +554,14 @@ SOURCE=..\..\..\Windows\Control\Dialog.cpp
SOURCE=..\..\..\Windows\Control\Dialog.h
# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\Control\ListView.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\Control\ListView.h
+# End Source File
# End Group
# Begin Source File
@@ -802,14 +810,6 @@ SOURCE=..\..\UI\GUI\ExtractGUI.cpp
SOURCE=..\..\UI\GUI\ExtractGUI.h
# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\GUI\OpenCallbackGUI.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\..\UI\GUI\OpenCallbackGUI.h
-# End Source File
# End Group
# Begin Group "Explorer"
diff --git a/CPP/7zip/Bundles/SFXWin/makefile b/CPP/7zip/Bundles/SFXWin/makefile
index a5f39559..80c7528e 100755
--- a/CPP/7zip/Bundles/SFXWin/makefile
+++ b/CPP/7zip/Bundles/SFXWin/makefile
@@ -12,7 +12,6 @@ SFX_WIN_OBJS = \
GUI_OBJS = \
$O\ExtractDialog.obj \
$O\ExtractGUI.obj \
- $O\OpenCallbackGUI.obj \
COMMON_OBJS = \
$O\CRC.obj \
@@ -40,6 +39,7 @@ WIN_OBJS = \
WIN_CTRL_OBJS = \
$O\Dialog.obj \
+ $O\ListView.obj \
7ZIP_COMMON_OBJS = \
$O\CreateCoder.obj \
diff --git a/CPP/7zip/Common/CreateCoder.cpp b/CPP/7zip/Common/CreateCoder.cpp
index ae0f98fd..2742495d 100755
--- a/CPP/7zip/Common/CreateCoder.cpp
+++ b/CPP/7zip/Common/CreateCoder.cpp
@@ -11,11 +11,11 @@
static const unsigned int kNumCodecsMax = 64;
unsigned int g_NumCodecs = 0;
-const CCodecInfo *g_Codecs[kNumCodecsMax];
-void RegisterCodec(const CCodecInfo *codecInfo)
-{
+const CCodecInfo *g_Codecs[kNumCodecsMax];
+void RegisterCodec(const CCodecInfo *codecInfo)
+{
if (g_NumCodecs < kNumCodecsMax)
- g_Codecs[g_NumCodecs++] = codecInfo;
+ g_Codecs[g_NumCodecs++] = codecInfo;
}
#ifdef EXTERNAL_CODECS
@@ -59,7 +59,7 @@ HRESULT LoadExternalCodecs(ICompressCodecsInfo *codecsInfo, CObjectVector<CCodec
// memmove(info.Id.ID, prop.bstrVal, info.Id.IDSize);
if (prop.vt != VT_UI8)
{
- continue; // old Interface
+ continue; // old Interface
// return E_INVALIDARG;
}
info.Id = prop.uhVal.QuadPart;
@@ -93,7 +93,7 @@ bool FindMethod(
UInt32 i;
for (i = 0; i < g_NumCodecs; i++)
{
- const CCodecInfo &codec = *g_Codecs[i];
+ const CCodecInfo &codec = *g_Codecs[i];
if (name.CompareNoCase(codec.Name) == 0)
{
methodId = codec.Id;
@@ -106,7 +106,7 @@ bool FindMethod(
if (externalCodecs)
for (i = 0; i < (UInt32)externalCodecs->Size(); i++)
{
- const CCodecInfoEx &codec = (*externalCodecs)[i];
+ const CCodecInfoEx &codec = (*externalCodecs)[i];
if (codec.Name.CompareNoCase(name) == 0)
{
methodId = codec.Id;
@@ -128,7 +128,7 @@ bool FindMethod(
UInt32 i;
for (i = 0; i < g_NumCodecs; i++)
{
- const CCodecInfo &codec = *g_Codecs[i];
+ const CCodecInfo &codec = *g_Codecs[i];
if (methodId == codec.Id)
{
name = codec.Name;
@@ -139,7 +139,7 @@ bool FindMethod(
if (externalCodecs)
for (i = 0; i < (UInt32)externalCodecs->Size(); i++)
{
- const CCodecInfoEx &codec = (*externalCodecs)[i];
+ const CCodecInfoEx &codec = (*externalCodecs)[i];
if (methodId == codec.Id)
{
name = codec.Name;
@@ -162,7 +162,7 @@ HRESULT CreateCoder(
UInt32 i;
for (i = 0; i < g_NumCodecs; i++)
{
- const CCodecInfo &codec = *g_Codecs[i];
+ const CCodecInfo &codec = *g_Codecs[i];
if (codec.Id == methodId)
{
if (encode)
@@ -194,7 +194,7 @@ HRESULT CreateCoder(
if (!created && externalCodecs)
for (i = 0; i < (UInt32)externalCodecs->Size(); i++)
{
- const CCodecInfoEx &codec = (*externalCodecs)[i];
+ const CCodecInfoEx &codec = (*externalCodecs)[i];
if (codec.Id == methodId)
{
if (encode)
@@ -204,7 +204,7 @@ HRESULT CreateCoder(
if (codec.IsSimpleCodec())
{
HRESULT result = codecsInfo->CreateEncoder(i, &IID_ICompressCoder, (void **)&coder);
- if (result != S_OK && result != E_NOINTERFACE && result != CLASS_E_CLASSNOTAVAILABLE)
+ if (result != S_OK && result != E_NOINTERFACE && result != CLASS_E_CLASSNOTAVAILABLE)
return result;
if (!coder)
{
@@ -224,7 +224,7 @@ HRESULT CreateCoder(
if (codec.IsSimpleCodec())
{
HRESULT result = codecsInfo->CreateDecoder(i, &IID_ICompressCoder, (void **)&coder);
- if (result != S_OK && result != E_NOINTERFACE && result != CLASS_E_CLASSNOTAVAILABLE)
+ if (result != S_OK && result != E_NOINTERFACE && result != CLASS_E_CLASSNOTAVAILABLE)
return result;
if (!coder)
{
@@ -253,7 +253,7 @@ HRESULT CreateCoder(
HRESULT CreateCoder(
DECL_EXTERNAL_CODECS_LOC_VARS
CMethodId methodId,
- CMyComPtr<ICompressCoder> &coder,
+ CMyComPtr<ICompressCoder> &coder,
CMyComPtr<ICompressCoder2> &coder2,
bool encode)
{
diff --git a/CPP/7zip/Common/CreateCoder.h b/CPP/7zip/Common/CreateCoder.h
index 4d86ae70..1fcc1343 100755
--- a/CPP/7zip/Common/CreateCoder.h
+++ b/CPP/7zip/Common/CreateCoder.h
@@ -86,7 +86,7 @@ HRESULT CreateCoder(
HRESULT CreateCoder(
DECL_EXTERNAL_CODECS_LOC_VARS
- CMethodId methodId,
+ CMethodId methodId,
CMyComPtr<ICompressCoder> &coder, bool encode);
HRESULT CreateFilter(
diff --git a/CPP/7zip/Common/FilePathAutoRename.cpp b/CPP/7zip/Common/FilePathAutoRename.cpp
index 3c5b910f..bf69fc79 100755
--- a/CPP/7zip/Common/FilePathAutoRename.cpp
+++ b/CPP/7zip/Common/FilePathAutoRename.cpp
@@ -11,7 +11,7 @@
using namespace NWindows;
-static bool MakeAutoName(const UString &name,
+static bool MakeAutoName(const UString &name,
const UString &extension, int value, UString &path)
{
wchar_t number[32];
diff --git a/CPP/7zip/Common/FileStreams.cpp b/CPP/7zip/Common/FileStreams.cpp
index f1fa419f..eb7ad3a2 100755
--- a/CPP/7zip/Common/FileStreams.cpp
+++ b/CPP/7zip/Common/FileStreams.cpp
@@ -81,7 +81,7 @@ STDMETHODIMP CStdInFileStream::Read(void *data, UInt32 size, UInt32 *processedSi
{
#ifdef _WIN32
UInt32 realProcessedSize;
- BOOL res = ::ReadFile(GetStdHandle(STD_INPUT_HANDLE),
+ BOOL res = ::ReadFile(GetStdHandle(STD_INPUT_HANDLE),
data, size, (DWORD *)&realProcessedSize, NULL);
if(processedSize != NULL)
*processedSize = realProcessedSize;
@@ -94,10 +94,10 @@ STDMETHODIMP CStdInFileStream::Read(void *data, UInt32 size, UInt32 *processedSi
if(processedSize != NULL)
*processedSize = 0;
ssize_t res;
- do
+ do
{
res = read(0, data, (size_t)size);
- }
+ }
while (res < 0 && (errno == EINTR));
if (res == -1)
return E_FAIL;
@@ -110,7 +110,7 @@ STDMETHODIMP CStdInFileStream::Read(void *data, UInt32 size, UInt32 *processedSi
#endif
-STDMETHODIMP CInFileStream::Seek(Int64 offset, UInt32 seekOrigin,
+STDMETHODIMP CInFileStream::Seek(Int64 offset, UInt32 seekOrigin,
UInt64 *newPosition)
{
if(seekOrigin >= 3)
@@ -228,10 +228,10 @@ STDMETHODIMP CStdOutFileStream::Write(const void *data, UInt32 size, UInt32 *pro
{
// Seems that Windows doesn't like big amounts writing to stdout.
// So we limit portions by 32KB.
- UInt32 sizeTemp = (1 << 15);
+ UInt32 sizeTemp = (1 << 15);
if (sizeTemp > size)
sizeTemp = size;
- res = ::WriteFile(GetStdHandle(STD_OUTPUT_HANDLE),
+ res = ::WriteFile(GetStdHandle(STD_OUTPUT_HANDLE),
data, sizeTemp, (DWORD *)&realProcessedSize, NULL);
size -= realProcessedSize;
data = (const void *)((const Byte *)data + realProcessedSize);
@@ -243,10 +243,10 @@ STDMETHODIMP CStdOutFileStream::Write(const void *data, UInt32 size, UInt32 *pro
#else
ssize_t res;
- do
+ do
{
res = write(1, data, (size_t)size);
- }
+ }
while (res < 0 && (errno == EINTR));
if (res == -1)
return E_FAIL;
diff --git a/CPP/7zip/Common/FileStreams.h b/CPP/7zip/Common/FileStreams.h
index 715801d8..361c2199 100755
--- a/CPP/7zip/Common/FileStreams.h
+++ b/CPP/7zip/Common/FileStreams.h
@@ -16,7 +16,7 @@
#include "../IStream.h"
#include "../../Common/MyCom.h"
-class CInFileStream:
+class CInFileStream:
public IInStream,
public IStreamGetSize,
public CMyUnknownImp
@@ -53,7 +53,7 @@ public:
};
#ifndef _WIN32_WCE
-class CStdInFileStream:
+class CStdInFileStream:
public ISequentialInStream,
public CMyUnknownImp
{
@@ -68,7 +68,7 @@ public:
};
#endif
-class COutFileStream:
+class COutFileStream:
public IOutStream,
public CMyUnknownImp
{
@@ -109,14 +109,11 @@ public:
UInt64 ProcessedSize;
#ifdef USE_WIN_FILE
- bool SetTime(const FILETIME *creationTime, const FILETIME *lastAccessTime, const FILETIME *lastWriteTime)
+ bool SetTime(const FILETIME *cTime, const FILETIME *aTime, const FILETIME *mTime)
{
- return File.SetTime(creationTime, lastAccessTime, lastWriteTime);
- }
- bool SetLastWriteTime(const FILETIME *lastWriteTime)
- {
- return File.SetLastWriteTime(lastWriteTime);
+ return File.SetTime(cTime, aTime, mTime);
}
+ bool SetMTime(const FILETIME *mTime) { return File.SetMTime(mTime); }
#endif
@@ -128,7 +125,7 @@ public:
};
#ifndef _WIN32_WCE
-class CStdOutFileStream:
+class CStdOutFileStream:
public ISequentialOutStream,
public CMyUnknownImp
{
diff --git a/CPP/7zip/Common/FilterCoder.cpp b/CPP/7zip/Common/FilterCoder.cpp
index 58690c3d..6b34260c 100755
--- a/CPP/7zip/Common/FilterCoder.cpp
+++ b/CPP/7zip/Common/FilterCoder.cpp
@@ -3,8 +3,8 @@
#include "StdAfx.h"
#include "FilterCoder.h"
-extern "C"
-{
+extern "C"
+{
#include "../../../C/Alloc.h"
}
#include "../../Common/Defs.h"
@@ -13,13 +13,13 @@ extern "C"
static const UInt32 kBufferSize = 1 << 17;
CFilterCoder::CFilterCoder()
-{
- _buffer = (Byte *)::MidAlloc(kBufferSize);
+{
+ _buffer = (Byte *)::MidAlloc(kBufferSize);
}
-CFilterCoder::~CFilterCoder()
-{
- ::MidFree(_buffer);
+CFilterCoder::~CFilterCoder()
+{
+ ::MidFree(_buffer);
}
HRESULT CFilterCoder::WriteWithLimit(ISequentialOutStream *outStream, UInt32 size)
@@ -226,7 +226,7 @@ STDMETHODIMP CFilterCoder::CryptoSetPassword(const Byte *data, UInt32 size)
#endif
#ifndef EXTRACT_ONLY
-STDMETHODIMP CFilterCoder::SetCoderProperties(const PROPID *propIDs,
+STDMETHODIMP CFilterCoder::SetCoderProperties(const PROPID *propIDs,
const PROPVARIANT *properties, UInt32 numProperties)
{
return _SetCoderProperties->SetCoderProperties(propIDs, properties, numProperties);
diff --git a/CPP/7zip/Common/FilterCoder.h b/CPP/7zip/Common/FilterCoder.h
index f654ae3f..a0ec08ca 100755
--- a/CPP/7zip/Common/FilterCoder.h
+++ b/CPP/7zip/Common/FilterCoder.h
@@ -9,7 +9,7 @@
#define MY_QUERYINTERFACE_ENTRY_AG(i, sub0, sub) if (iid == IID_ ## i) \
{ if (!sub) RINOK(sub0->QueryInterface(IID_ ## i, (void **)&sub)) \
-*outObject = (void *)(i *)this; AddRef(); return S_OK; }
+*outObject = (void *)(i *)this; AddRef(); return S_OK; }
class CFilterCoder:
public ICompressCoder,
@@ -46,11 +46,11 @@ protected:
UInt64 _outSize;
UInt64 _nowPos64;
- HRESULT Init()
- {
+ HRESULT Init()
+ {
_nowPos64 = 0;
_outSizeIsDefined = false;
- return Filter->Init();
+ return Filter->Init();
}
CMyComPtr<ICryptoSetPassword> _setPassword;
@@ -67,7 +67,7 @@ public:
CFilterCoder();
~CFilterCoder();
HRESULT WriteWithLimit(ISequentialOutStream *outStream, UInt32 size);
- bool NeedMore() const
+ bool NeedMore() const
{ return (!_outSizeIsDefined || (_nowPos64 < _outSize)); }
public:
@@ -113,7 +113,7 @@ public:
STDMETHOD(CryptoSetPassword)(const Byte *data, UInt32 size);
#endif
#ifndef EXTRACT_ONLY
- STDMETHOD(SetCoderProperties)(const PROPID *propIDs,
+ STDMETHOD(SetCoderProperties)(const PROPID *propIDs,
const PROPVARIANT *properties, UInt32 numProperties);
STDMETHOD(WriteCoderProperties)(ISequentialOutStream *outStream);
// STDMETHOD(ResetSalt)();
diff --git a/CPP/7zip/Common/InBuffer.cpp b/CPP/7zip/Common/InBuffer.cpp
index 5c4361a3..29e3ea16 100755
--- a/CPP/7zip/Common/InBuffer.cpp
+++ b/CPP/7zip/Common/InBuffer.cpp
@@ -9,10 +9,10 @@ extern "C"
#include "../../../C/Alloc.h"
}
-CInBuffer::CInBuffer():
- _buffer(0),
- _bufferLimit(0),
- _bufferBase(0),
+CInBuffer::CInBuffer():
+ _buffer(0),
+ _bufferLimit(0),
+ _bufferBase(0),
_stream(0),
_bufferSize(0)
{}
diff --git a/CPP/7zip/Common/InBuffer.h b/CPP/7zip/Common/InBuffer.h
index 05fc77e5..75625bfd 100755
--- a/CPP/7zip/Common/InBuffer.h
+++ b/CPP/7zip/Common/InBuffer.h
@@ -8,9 +8,9 @@
#include "../../Common/MyException.h"
#ifndef _NO_EXCEPTIONS
-struct CInBufferException: public CSystemException
+struct CInBufferException: public CSystemException
{
- CInBufferException(HRESULT errorCode): CSystemException(errorCode) {}
+ CInBufferException(HRESULT errorCode): CSystemException(errorCode) {}
};
#endif
@@ -44,29 +44,35 @@ public:
bool ReadByte(Byte &b)
{
- if(_buffer >= _bufferLimit)
- if(!ReadBlock())
+ if (_buffer >= _bufferLimit)
+ if (!ReadBlock())
return false;
b = *_buffer++;
return true;
}
Byte ReadByte()
{
- if(_buffer >= _bufferLimit)
+ if (_buffer >= _bufferLimit)
return ReadBlock2();
return *_buffer++;
}
- void ReadBytes(void *data, UInt32 size, UInt32 &processedSize)
+ UInt32 ReadBytes(Byte *buf, UInt32 size)
{
- for(processedSize = 0; processedSize < size; processedSize++)
- if (!ReadByte(((Byte *)data)[processedSize]))
- return;
- }
- bool ReadBytes(void *data, UInt32 size)
- {
- UInt32 processedSize;
- ReadBytes(data, size, processedSize);
- return (processedSize == size);
+ if ((UInt32)(_bufferLimit - _buffer) >= size)
+ {
+ for (UInt32 i = 0; i < size; i++)
+ buf[i] = _buffer[i];
+ _buffer += size;
+ return size;
+ }
+ for (UInt32 i = 0; i < size; i++)
+ {
+ if (_buffer >= _bufferLimit)
+ if (!ReadBlock())
+ return i;
+ buf[i] = *_buffer++;
+ }
+ return size;
}
UInt64 GetProcessedSize() const { return _processedSize + (_buffer - _bufferBase); }
bool WasFinished() const { return _wasFinished; }
diff --git a/CPP/7zip/Common/InMemStream.cpp b/CPP/7zip/Common/InMemStream.cpp
index 7deef250..38c5c92c 100755
--- a/CPP/7zip/Common/InMemStream.cpp
+++ b/CPP/7zip/Common/InMemStream.cpp
@@ -191,8 +191,8 @@ HRESULT CInMemStreamMt::ReadSubStream(int subStreamIndex, void *data, UInt32 siz
if (curPos == Callback->GetBlockSize())
needFree = true;
blocks.Cs->Enter();
- if (blocks.CurBlockIndex == blocks.LastBlockIndex &&
- blocks.CurBlockPos == blocks.LastBlockPos &&
+ if (blocks.CurBlockIndex == blocks.LastBlockIndex &&
+ blocks.CurBlockPos == blocks.LastBlockPos &&
blocks.StreamWasFinished)
needFree = true;
blocks.Cs->Leave();
diff --git a/CPP/7zip/Common/InMemStream.h b/CPP/7zip/Common/InMemStream.h
index 636718c6..adc5aadd 100755
--- a/CPP/7zip/Common/InMemStream.h
+++ b/CPP/7zip/Common/InMemStream.h
@@ -162,7 +162,7 @@ struct IInMemStreamMtCallback
// must be same for all calls
virtual size_t GetBlockSize() = 0;
- // Out:
+ // Out:
// result != S_OK stops Reading
// if *p = 0, result must be != S_OK;
// Locking is allowed
@@ -249,7 +249,7 @@ public:
~CInMemStreamMt() { Free(); }
void SetStream(ISequentialInStream *stream) { _stream = stream; }
- // to stop reading you must implement
+ // to stop reading you must implement
// returning Error in IInMemStreamMtCallback::AllocateBlock
// and then you must free at least one substream
HRes StartReadThread();
@@ -260,7 +260,7 @@ public:
// void StopReading() { _stopReading = true; }
};
-class CInMemStream:
+class CInMemStream:
public ISequentialInStream,
public CMyUnknownImp
{
@@ -269,8 +269,8 @@ class CInMemStream:
public:
int Index;
CInMemStreamMt *mtStream;
- void Init(bool keepData = false)
- {
+ void Init(bool keepData = false)
+ {
_size = 0; _keepData = keepData ;
}
MY_UNKNOWN_IMP
diff --git a/CPP/7zip/Common/InOutTempBuffer.h b/CPP/7zip/Common/InOutTempBuffer.h
index 3abe76ec..e1e0e971 100755
--- a/CPP/7zip/Common/InOutTempBuffer.h
+++ b/CPP/7zip/Common/InOutTempBuffer.h
@@ -36,7 +36,7 @@ public:
HRESULT WriteToStream(ISequentialOutStream *stream);
};
-class CSequentialOutTempBufferImp:
+class CSequentialOutTempBufferImp:
public ISequentialOutStream,
public CMyUnknownImp
{
diff --git a/CPP/7zip/Common/LSBFDecoder.h b/CPP/7zip/Common/LSBFDecoder.h
index 75458452..730636aa 100755
--- a/CPP/7zip/Common/LSBFDecoder.h
+++ b/CPP/7zip/Common/LSBFDecoder.h
@@ -33,13 +33,13 @@ public:
void Init()
{
m_Stream.Init();
- m_BitPos = kNumBigValueBits;
+ m_BitPos = kNumBigValueBits;
m_Value = 0;
NumExtraBytes = 0;
}
- UInt64 GetProcessedSize() const
+ UInt64 GetProcessedSize() const
{ return m_Stream.GetProcessedSize() - (kNumBigValueBits - m_BitPos) / 8; }
- UInt64 GetProcessedBitsSize() const
+ UInt64 GetProcessedBitsSize() const
{ return (m_Stream.GetProcessedSize() << 3) - (kNumBigValueBits - m_BitPos); }
int GetBitPosition() const { return (m_BitPos & 7); }
diff --git a/CPP/7zip/Common/LSBFEncoder.h b/CPP/7zip/Common/LSBFEncoder.h
index d50aef0b..c6455475 100755
--- a/CPP/7zip/Common/LSBFEncoder.h
+++ b/CPP/7zip/Common/LSBFEncoder.h
@@ -21,7 +21,7 @@ public:
void Init()
{
m_Stream.Init();
- m_BitPos = 8;
+ m_BitPos = 8;
m_CurByte = 0;
}
HRESULT Flush()
@@ -34,7 +34,7 @@ public:
{
if(m_BitPos < 8)
m_Stream.WriteByte(m_CurByte);
- m_BitPos = 8;
+ m_BitPos = 8;
m_CurByte = 0;
}
@@ -56,7 +56,7 @@ public:
}
}
UInt32 GetBitPosition() const { return (8 - m_BitPos); }
- UInt64 GetProcessedSize() const {
+ UInt64 GetProcessedSize() const {
return m_Stream.GetProcessedSize() + (8 - m_BitPos + 7) /8; }
void WriteByte(Byte b) { m_Stream.WriteByte(b);}
};
diff --git a/CPP/7zip/Common/LimitedStreams.cpp b/CPP/7zip/Common/LimitedStreams.cpp
index af721146..490aa37b 100755
--- a/CPP/7zip/Common/LimitedStreams.cpp
+++ b/CPP/7zip/Common/LimitedStreams.cpp
@@ -22,3 +22,24 @@ STDMETHODIMP CLimitedSequentialInStream::Read(void *data, UInt32 size, UInt32 *p
return result;
}
+STDMETHODIMP CLimitedSequentialOutStream::Write(const void *data, UInt32 size, UInt32 *processedSize)
+{
+ HRESULT result = S_OK;
+ if (processedSize != NULL)
+ *processedSize = 0;
+ if (size > _size)
+ {
+ size = (UInt32)_size;
+ if (size == 0)
+ {
+ _overflow = true;
+ return E_FAIL;
+ }
+ }
+ if (_stream)
+ result = _stream->Write(data, size, &size);
+ _size -= size;
+ if (processedSize != NULL)
+ *processedSize = size;
+ return result;
+}
diff --git a/CPP/7zip/Common/LimitedStreams.h b/CPP/7zip/Common/LimitedStreams.h
index ec4a3a70..9bfdc8eb 100755
--- a/CPP/7zip/Common/LimitedStreams.h
+++ b/CPP/7zip/Common/LimitedStreams.h
@@ -6,7 +6,7 @@
#include "../../Common/MyCom.h"
#include "../IStream.h"
-class CLimitedSequentialInStream:
+class CLimitedSequentialInStream:
public ISequentialInStream,
public CMyUnknownImp
{
@@ -16,11 +16,11 @@ class CLimitedSequentialInStream:
bool _wasFinished;
public:
void SetStream(ISequentialInStream *stream) { _stream = stream; }
- void Init(UInt64 streamSize)
- {
- _size = streamSize;
- _pos = 0;
- _wasFinished = false;
+ void Init(UInt64 streamSize)
+ {
+ _size = streamSize;
+ _pos = 0;
+ _wasFinished = false;
}
MY_UNKNOWN_IMP
@@ -30,4 +30,25 @@ public:
bool WasFinished() const { return _wasFinished; }
};
+class CLimitedSequentialOutStream:
+ public ISequentialOutStream,
+ public CMyUnknownImp
+{
+ CMyComPtr<ISequentialOutStream> _stream;
+ UInt64 _size;
+ bool _overflow;
+public:
+ MY_UNKNOWN_IMP
+ STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
+ void SetStream(ISequentialOutStream *stream) { _stream = stream; }
+ void ReleaseStream() { _stream.Release(); }
+ void Init(UInt64 size)
+ {
+ _size = size;
+ _overflow = false;
+ }
+ bool IsFinishedOK() const { return (_size == 0 && !_overflow); }
+ UInt64 GetRem() const { return _size; }
+};
+
#endif
diff --git a/CPP/7zip/Common/LockedStream.cpp b/CPP/7zip/Common/LockedStream.cpp
index 36be1ceb..f05601cb 100755
--- a/CPP/7zip/Common/LockedStream.cpp
+++ b/CPP/7zip/Common/LockedStream.cpp
@@ -4,7 +4,7 @@
#include "LockedStream.h"
-HRESULT CLockedInStream::Read(UInt64 startPos, void *data, UInt32 size,
+HRESULT CLockedInStream::Read(UInt64 startPos, void *data, UInt32 size,
UInt32 *processedSize)
{
NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
diff --git a/CPP/7zip/Common/LockedStream.h b/CPP/7zip/Common/LockedStream.h
index 1c1e1793..486e4220 100755
--- a/CPP/7zip/Common/LockedStream.h
+++ b/CPP/7zip/Common/LockedStream.h
@@ -17,7 +17,7 @@ public:
HRESULT Read(UInt64 startPos, void *data, UInt32 size, UInt32 *processedSize);
};
-class CLockedSequentialInStreamImp:
+class CLockedSequentialInStreamImp:
public ISequentialInStream,
public CMyUnknownImp
{
diff --git a/CPP/7zip/Common/MSBFDecoder.h b/CPP/7zip/Common/MSBFDecoder.h
index dc80c0f7..1894ca40 100755
--- a/CPP/7zip/Common/MSBFDecoder.h
+++ b/CPP/7zip/Common/MSBFDecoder.h
@@ -30,11 +30,11 @@ public:
void Init()
{
m_Stream.Init();
- m_BitPos = kNumBigValueBits;
+ m_BitPos = kNumBigValueBits;
Normalize();
}
- UInt64 GetProcessedSize() const
+ UInt64 GetProcessedSize() const
{ return m_Stream.GetProcessedSize() - (kNumBigValueBits - m_BitPos) / 8; }
UInt32 GetBitPosition() const { return (m_BitPos & 7); }
diff --git a/CPP/7zip/Common/MSBFEncoder.h b/CPP/7zip/Common/MSBFEncoder.h
index 767a0e57..da92799b 100755
--- a/CPP/7zip/Common/MSBFEncoder.h
+++ b/CPP/7zip/Common/MSBFEncoder.h
@@ -23,7 +23,7 @@ public:
void Init()
{
m_Stream.Init();
- m_BitPos = 8;
+ m_BitPos = 8;
m_CurByte = 0;
}
HRESULT Flush()
@@ -50,7 +50,7 @@ public:
m_CurByte = 0;
}
}
- UInt64 GetProcessedSize() const {
+ UInt64 GetProcessedSize() const {
return m_Stream.GetProcessedSize() + (8 - m_BitPos + 7) / 8; }
};
diff --git a/CPP/7zip/Common/MemBlocks.cpp b/CPP/7zip/Common/MemBlocks.cpp
index 53f55242..baceb163 100755
--- a/CPP/7zip/Common/MemBlocks.cpp
+++ b/CPP/7zip/Common/MemBlocks.cpp
@@ -13,7 +13,7 @@ bool CMemBlockManager::AllocateSpace(size_t numBlocks)
if (_blockSize < sizeof(void *) || numBlocks < 1)
return false;
size_t totalSize = numBlocks * _blockSize;
- if (totalSize / _blockSize != numBlocks)
+ if (totalSize / _blockSize != numBlocks)
return false;
_data = ::MidAlloc(totalSize);
if (_data == 0)
@@ -36,7 +36,7 @@ void CMemBlockManager::FreeSpace()
void *CMemBlockManager::AllocateBlock()
{
if (_headFree == 0)
- return 0;
+ return 0;
void *p = _headFree;
_headFree = *(void **)_headFree;
return p;
@@ -114,7 +114,7 @@ void CMemBlocks::Free(CMemBlockManagerMt *manager)
void CMemBlocks::FreeOpt(CMemBlockManagerMt *manager)
{
Free(manager);
- Blocks.Free(); // to reduce memory usage
+ Blocks.ClearAndFree();
}
HRESULT CMemBlocks::WriteToStream(size_t blockSize, ISequentialOutStream *outStream) const
@@ -150,8 +150,8 @@ void CMemLockBlocks::Free(CMemBlockManagerMt *memManager)
TotalSize = 0;
}
-HRes CMemLockBlocks::SwitchToNoLockMode(CMemBlockManagerMt *memManager)
-{
+HRes CMemLockBlocks::SwitchToNoLockMode(CMemBlockManagerMt *memManager)
+{
if (LockMode)
{
if (Blocks.Size() > 0)
diff --git a/CPP/7zip/Common/MemBlocks.h b/CPP/7zip/Common/MemBlocks.h
index de7138ed..dcdc0d82 100755
--- a/CPP/7zip/Common/MemBlocks.h
+++ b/CPP/7zip/Common/MemBlocks.h
@@ -3,8 +3,8 @@
#ifndef __MEMBLOCKS_H
#define __MEMBLOCKS_H
-extern "C"
-{
+extern "C"
+{
#include "../../../C/Alloc.h"
}
@@ -46,7 +46,7 @@ public:
void FreeSpace();
void *AllocateBlock();
void FreeBlock(void *p, bool lockMode = true);
- HRes ReleaseLockedBlocks(int number) { return Semaphore.Release(number); }
+ HRes ReleaseLockedBlocks(int number) { return Semaphore.Release(number); }
};
@@ -70,7 +70,7 @@ struct CMemLockBlocks: public CMemBlocks
CMemLockBlocks(): LockMode(true) {};
void Free(CMemBlockManagerMt *memManager);
void FreeBlock(int index, CMemBlockManagerMt *memManager);
- HRes SwitchToNoLockMode(CMemBlockManagerMt *memManager);
+ HRes SwitchToNoLockMode(CMemBlockManagerMt *memManager);
void Detach(CMemLockBlocks &blocks, CMemBlockManagerMt *memManager);
};
diff --git a/CPP/7zip/Common/MethodProps.h b/CPP/7zip/Common/MethodProps.h
index 7ffa8e4a..7978c551 100755
--- a/CPP/7zip/Common/MethodProps.h
+++ b/CPP/7zip/Common/MethodProps.h
@@ -30,7 +30,7 @@ struct CMethodsMode
CMethodsMode()
#ifdef COMPRESS_MT
- : NumThreads(1)
+ : NumThreads(1)
#endif
{}
bool IsEmpty() const { return Methods.IsEmpty() ; }
diff --git a/CPP/7zip/Common/OffsetStream.cpp b/CPP/7zip/Common/OffsetStream.cpp
index 997ccae2..24fcf161 100755
--- a/CPP/7zip/Common/OffsetStream.cpp
+++ b/CPP/7zip/Common/OffsetStream.cpp
@@ -17,7 +17,7 @@ STDMETHODIMP COffsetOutStream::Write(const void *data, UInt32 size, UInt32 *proc
return _stream->Write(data, size, processedSize);
}
-STDMETHODIMP COffsetOutStream::Seek(Int64 offset, UInt32 seekOrigin,
+STDMETHODIMP COffsetOutStream::Seek(Int64 offset, UInt32 seekOrigin,
UInt64 *newPosition)
{
UInt64 absoluteNewPosition;
diff --git a/CPP/7zip/Common/OffsetStream.h b/CPP/7zip/Common/OffsetStream.h
index 57a055cc..5a69404f 100755
--- a/CPP/7zip/Common/OffsetStream.h
+++ b/CPP/7zip/Common/OffsetStream.h
@@ -6,7 +6,7 @@
#include "Common/MyCom.h"
#include "../IStream.h"
-class COffsetOutStream:
+class COffsetOutStream:
public IOutStream,
public CMyUnknownImp
{
diff --git a/CPP/7zip/Common/OutBuffer.cpp b/CPP/7zip/Common/OutBuffer.cpp
index 31d17c5a..998525c3 100755
--- a/CPP/7zip/Common/OutBuffer.cpp
+++ b/CPP/7zip/Common/OutBuffer.cpp
@@ -46,9 +46,9 @@ void COutBuffer::Init()
}
UInt64 COutBuffer::GetProcessedSize() const
-{
+{
UInt64 res = _processedSize + _pos - _streamPos;
- if (_streamPos > _pos)
+ if (_streamPos > _pos)
res += _bufferSize;
return res;
}
diff --git a/CPP/7zip/Common/OutBuffer.h b/CPP/7zip/Common/OutBuffer.h
index e99dbf2a..62e77caa 100755
--- a/CPP/7zip/Common/OutBuffer.h
+++ b/CPP/7zip/Common/OutBuffer.h
@@ -8,9 +8,9 @@
#include "../../Common/MyException.h"
#ifndef _NO_EXCEPTIONS
-struct COutBufferException: public CSystemException
-{
- COutBufferException(HRESULT errorCode): CSystemException(errorCode) {}
+struct COutBufferException: public CSystemException
+{
+ COutBufferException(HRESULT errorCode): CSystemException(errorCode) {}
};
#endif
diff --git a/CPP/7zip/Common/ProgressMt.h b/CPP/7zip/Common/ProgressMt.h
index e57f1167..26079d4e 100755
--- a/CPP/7zip/Common/ProgressMt.h
+++ b/CPP/7zip/Common/ProgressMt.h
@@ -24,7 +24,7 @@ public:
HRESULT SetRatioInfo(int index, const UInt64 *inSize, const UInt64 *outSize);
};
-class CMtCompressProgress:
+class CMtCompressProgress:
public ICompressProgressInfo,
public CMyUnknownImp
{
diff --git a/CPP/7zip/Common/ProgressUtils.h b/CPP/7zip/Common/ProgressUtils.h
index 831c7366..bae5395c 100755
--- a/CPP/7zip/Common/ProgressUtils.h
+++ b/CPP/7zip/Common/ProgressUtils.h
@@ -8,7 +8,7 @@
#include "../ICoder.h"
#include "../IProgress.h"
-class CLocalProgress:
+class CLocalProgress:
public ICompressProgressInfo,
public CMyUnknownImp
{
diff --git a/CPP/7zip/Common/RegisterArc.h b/CPP/7zip/Common/RegisterArc.h
index 57730214..ba5ed7c3 100755
--- a/CPP/7zip/Common/RegisterArc.h
+++ b/CPP/7zip/Common/RegisterArc.h
@@ -23,7 +23,7 @@ struct CArcInfo
void RegisterArc(const CArcInfo *arcInfo);
-#define REGISTER_ARC_NAME(x) CRegister ## x
+#define REGISTER_ARC_NAME(x) CRegister ## x
#define REGISTER_ARC_DEC_SIG(x) struct REGISTER_ARC_NAME(x) { \
REGISTER_ARC_NAME(x)() { g_ArcInfo.Signature[0]--; RegisterArc(&g_ArcInfo); }}; \
diff --git a/CPP/7zip/Common/RegisterCodec.h b/CPP/7zip/Common/RegisterCodec.h
index 1f1cd4df..786b4a4c 100755
--- a/CPP/7zip/Common/RegisterCodec.h
+++ b/CPP/7zip/Common/RegisterCodec.h
@@ -18,13 +18,13 @@ struct CCodecInfo
void RegisterCodec(const CCodecInfo *codecInfo);
-#define REGISTER_CODEC_NAME(x) CRegisterCodec ## x
+#define REGISTER_CODEC_NAME(x) CRegisterCodec ## x
#define REGISTER_CODEC(x) struct REGISTER_CODEC_NAME(x) { \
REGISTER_CODEC_NAME(x)() { RegisterCodec(&g_CodecInfo); }}; \
static REGISTER_CODEC_NAME(x) g_RegisterCodec;
-#define REGISTER_CODECS_NAME(x) CRegisterCodecs ## x
+#define REGISTER_CODECS_NAME(x) CRegisterCodecs ## x
#define REGISTER_CODECS(x) struct REGISTER_CODECS_NAME(x) { \
REGISTER_CODECS_NAME(x)() { for (int i = 0; i < sizeof(g_CodecsInfo) / sizeof(g_CodecsInfo[0]); i++) \
RegisterCodec(&g_CodecsInfo[i]); }}; \
diff --git a/CPP/7zip/Common/StdAfx.h b/CPP/7zip/Common/StdAfx.h
index 27a77b10..ef555ec1 100755
--- a/CPP/7zip/Common/StdAfx.h
+++ b/CPP/7zip/Common/StdAfx.h
@@ -6,4 +6,4 @@
#include "../../Common/MyWindows.h"
#include "../../Common/NewHandler.h"
-#endif
+#endif
diff --git a/CPP/7zip/Common/StreamBinder.cpp b/CPP/7zip/Common/StreamBinder.cpp
index 5db9d01f..03f88625 100755
--- a/CPP/7zip/Common/StreamBinder.cpp
+++ b/CPP/7zip/Common/StreamBinder.cpp
@@ -9,7 +9,7 @@
using namespace NWindows;
using namespace NSynchronization;
-class CSequentialInStreamForBinder:
+class CSequentialInStreamForBinder:
public ISequentialInStream,
public CMyUnknownImp
{
@@ -27,7 +27,7 @@ public:
STDMETHODIMP CSequentialInStreamForBinder::Read(void *data, UInt32 size, UInt32 *processedSize)
{ return m_StreamBinder->Read(data, size, processedSize); }
-class CSequentialOutStreamForBinder:
+class CSequentialOutStreamForBinder:
public ISequentialOutStream,
public CMyUnknownImp
{
@@ -67,16 +67,16 @@ void CStreamBinder::ReInit()
-void CStreamBinder::CreateStreams(ISequentialInStream **inStream,
+void CStreamBinder::CreateStreams(ISequentialInStream **inStream,
ISequentialOutStream **outStream)
{
- CSequentialInStreamForBinder *inStreamSpec = new
+ CSequentialInStreamForBinder *inStreamSpec = new
CSequentialInStreamForBinder;
CMyComPtr<ISequentialInStream> inStreamLoc(inStreamSpec);
inStreamSpec->SetBinder(this);
*inStream = inStreamLoc.Detach();
- CSequentialOutStreamForBinder *outStreamSpec = new
+ CSequentialOutStreamForBinder *outStreamSpec = new
CSequentialOutStreamForBinder;
CMyComPtr<ISequentialOutStream> outStreamLoc(outStreamSpec);
outStreamSpec->SetBinder(this);
@@ -96,7 +96,7 @@ HRESULT CStreamBinder::Read(void *data, UInt32 size, UInt32 *processedSize)
sizeToRead = MyMin(_bufferSize, size);
if (_bufferSize > 0)
{
- MoveMemory(data, _buffer, sizeToRead);
+ memcpy(data, _buffer, sizeToRead);
_buffer = ((const Byte *)_buffer) + sizeToRead;
_bufferSize -= sizeToRead;
if (_bufferSize == 0)
@@ -126,9 +126,9 @@ HRESULT CStreamBinder::Write(const void *data, UInt32 size, UInt32 *processedSiz
_allBytesAreWritenEvent.Reset();
_thereAreBytesToReadEvent.Set();
- HANDLE events[2];
+ HANDLE events[2];
events[0] = _allBytesAreWritenEvent;
- events[1] = _readStreamIsClosedEvent;
+ events[1] = _readStreamIsClosedEvent;
DWORD waitResult = ::WaitForMultipleObjects(2, events, FALSE, INFINITE);
if (waitResult != WAIT_OBJECT_0 + 0)
{
diff --git a/CPP/7zip/Common/StreamBinder.h b/CPP/7zip/Common/StreamBinder.h
index 1de2372a..48f68e60 100755
--- a/CPP/7zip/Common/StreamBinder.h
+++ b/CPP/7zip/Common/StreamBinder.h
@@ -19,7 +19,7 @@ public:
CStreamBinder() {}
HRes CreateEvents();
- void CreateStreams(ISequentialInStream **inStream,
+ void CreateStreams(ISequentialInStream **inStream,
ISequentialOutStream **outStream);
HRESULT Read(void *data, UInt32 size, UInt32 *processedSize);
void CloseRead();
diff --git a/CPP/7zip/Common/StreamObjects.cpp b/CPP/7zip/Common/StreamObjects.cpp
index 95d1c878..e043e565 100755
--- a/CPP/7zip/Common/StreamObjects.cpp
+++ b/CPP/7zip/Common/StreamObjects.cpp
@@ -32,7 +32,7 @@ STDMETHODIMP CSequentialOutStreamImp::Write(const void *data, UInt32 size, UInt3
_writeBuffer.Write(data, (size_t)size);
if(processedSize != NULL)
*processedSize = size;
- return S_OK;
+ return S_OK;
}
STDMETHODIMP CSequentialOutStreamImp2::Write(const void *data, UInt32 size, UInt32 *processedSize)
@@ -54,7 +54,7 @@ STDMETHODIMP CSequentialInStreamSizeCount::Read(void *data, UInt32 size, UInt32
_size += realProcessedSize;
if (processedSize != 0)
*processedSize = realProcessedSize;
- return result;
+ return result;
}
STDMETHODIMP CSequentialOutStreamSizeCount::Write(const void *data, UInt32 size, UInt32 *processedSize)
@@ -64,5 +64,5 @@ STDMETHODIMP CSequentialOutStreamSizeCount::Write(const void *data, UInt32 size,
_size += realProcessedSize;
if (processedSize != 0)
*processedSize = realProcessedSize;
- return result;
+ return result;
}
diff --git a/CPP/7zip/Common/StreamObjects.h b/CPP/7zip/Common/StreamObjects.h
index 6f670f59..a21089cb 100755
--- a/CPP/7zip/Common/StreamObjects.h
+++ b/CPP/7zip/Common/StreamObjects.h
@@ -7,7 +7,7 @@
#include "../../Common/MyCom.h"
#include "../IStream.h"
-class CSequentialInStreamImp:
+class CSequentialInStreamImp:
public ISequentialInStream,
public CMyUnknownImp
{
@@ -41,7 +41,7 @@ public:
const CByteDynamicBuffer& GetBuffer() const { return _buffer; }
};
-class CSequentialOutStreamImp:
+class CSequentialOutStreamImp:
public ISequentialOutStream,
public CMyUnknownImp
{
@@ -56,7 +56,7 @@ public:
STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
};
-class CSequentialOutStreamImp2:
+class CSequentialOutStreamImp2:
public ISequentialOutStream,
public CMyUnknownImp
{
@@ -65,11 +65,11 @@ class CSequentialOutStreamImp2:
size_t _pos;
public:
- void Init(Byte *buffer, size_t size)
- {
+ void Init(Byte *buffer, size_t size)
+ {
_buffer = buffer;
_pos = 0;
- _size = size;
+ _size = size;
}
size_t GetPos() const { return _pos; }
@@ -79,7 +79,7 @@ public:
STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
};
-class CSequentialInStreamSizeCount:
+class CSequentialInStreamSizeCount:
public ISequentialInStream,
public CMyUnknownImp
{
@@ -98,7 +98,7 @@ public:
STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
};
-class CSequentialOutStreamSizeCount:
+class CSequentialOutStreamSizeCount:
public ISequentialOutStream,
public CMyUnknownImp
{
diff --git a/CPP/7zip/Common/StreamUtils.cpp b/CPP/7zip/Common/StreamUtils.cpp
index 9cde2c40..049e4aa1 100755
--- a/CPP/7zip/Common/StreamUtils.cpp
+++ b/CPP/7zip/Common/StreamUtils.cpp
@@ -13,7 +13,7 @@ HRESULT ReadStream(ISequentialInStream *stream, void *data, size_t *processedSiz
while (size != 0)
{
UInt32 curSize = (size < kBlockSize) ? (UInt32)size : kBlockSize;
- UInt32 processedSizeLoc;
+ UInt32 processedSizeLoc;
HRESULT res = stream->Read(data, curSize, &processedSizeLoc);
*processedSize += processedSizeLoc;
data = (void *)((Byte *)data + processedSizeLoc);
@@ -27,14 +27,14 @@ HRESULT ReadStream(ISequentialInStream *stream, void *data, size_t *processedSiz
HRESULT ReadStream_FALSE(ISequentialInStream *stream, void *data, size_t size)
{
- size_t processedSize = size;
+ size_t processedSize = size;
RINOK(ReadStream(stream, data, &processedSize));
return (size == processedSize) ? S_OK : S_FALSE;
}
HRESULT ReadStream_FAIL(ISequentialInStream *stream, void *data, size_t size)
{
- size_t processedSize = size;
+ size_t processedSize = size;
RINOK(ReadStream(stream, data, &processedSize));
return (size == processedSize) ? S_OK : E_FAIL;
}
@@ -44,7 +44,7 @@ HRESULT WriteStream(ISequentialOutStream *stream, const void *data, size_t size)
while (size != 0)
{
UInt32 curSize = (size < kBlockSize) ? (UInt32)size : kBlockSize;
- UInt32 processedSizeLoc;
+ UInt32 processedSizeLoc;
HRESULT res = stream->Write(data, curSize, &processedSizeLoc);
data = (const void *)((const Byte *)data + processedSizeLoc);
size -= processedSizeLoc;
diff --git a/CPP/7zip/Common/VirtThread.h b/CPP/7zip/Common/VirtThread.h
index 604b090b..f14a1f22 100755
--- a/CPP/7zip/Common/VirtThread.h
+++ b/CPP/7zip/Common/VirtThread.h
@@ -16,7 +16,7 @@ struct CVirtThread
~CVirtThread();
WRes Create();
void Start();
- void WaitFinish() { FinishedEvent.Lock(); }
+ void WaitFinish() { FinishedEvent.Lock(); }
virtual void Execute() = 0;
};
diff --git a/CPP/7zip/Compress/Arj/ArjDecoder1.cpp b/CPP/7zip/Compress/Arj/ArjDecoder1.cpp
index df859971..964b2aea 100755
--- a/CPP/7zip/Compress/Arj/ArjDecoder1.cpp
+++ b/CPP/7zip/Compress/Arj/ArjDecoder1.cpp
@@ -16,7 +16,7 @@ static const UInt32 kMatchMinLen = 3;
// static const UInt32 kNC = 255 + kMatchMaxLen + 2 - kMatchMinLen;
-void CCoder::MakeTable(int nchar, Byte *bitlen, int tablebits,
+void CCoder::MakeTable(int nchar, Byte *bitlen, int tablebits,
UInt32 *table, int tablesize)
{
UInt32 count[17], weight[17], start[18], *p;
diff --git a/CPP/7zip/Compress/Arj/ArjDecoder1.h b/CPP/7zip/Compress/Arj/ArjDecoder1.h
index b337ec72..cecc9573 100755
--- a/CPP/7zip/Compress/Arj/ArjDecoder1.h
+++ b/CPP/7zip/Compress/Arj/ArjDecoder1.h
@@ -11,7 +11,7 @@
/*
// {23170F69-40C1-278B-0404-010000000000}
-DEFINE_GUID(CLSID_CCompressArjDecoder,
+DEFINE_GUID(CLSID_CCompressArjDecoder,
0x23170F69, 0x40C1, 0x278B, 0x04, 0x04, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00);
*/
diff --git a/CPP/7zip/Compress/Arj/ArjDecoder2.cpp b/CPP/7zip/Compress/Arj/ArjDecoder2.cpp
index a0eca445..5d7bf2ee 100755
--- a/CPP/7zip/Compress/Arj/ArjDecoder2.cpp
+++ b/CPP/7zip/Compress/Arj/ArjDecoder2.cpp
@@ -20,7 +20,7 @@ HRESULT CCoder::CodeReal(ISequentialInStream *inStream,
return E_INVALIDARG;
if (!m_OutWindowStream.Create(kHistorySize))
- return E_OUTOFMEMORY;
+ return E_OUTOFMEMORY;
if (!m_InBitStream.Create(1 << 20))
return E_OUTOFMEMORY;
diff --git a/CPP/7zip/Compress/Arj/ArjDecoder2.h b/CPP/7zip/Compress/Arj/ArjDecoder2.h
index 67a54eba..9d17ee91 100755
--- a/CPP/7zip/Compress/Arj/ArjDecoder2.h
+++ b/CPP/7zip/Compress/Arj/ArjDecoder2.h
@@ -11,7 +11,7 @@
/*
// {23170F69-40C1-278B-0404-020000000000}
-DEFINE_GUID(CLSID_CCompressArj2Decoder,
+DEFINE_GUID(CLSID_CCompressArj2Decoder,
0x23170F69, 0x40C1, 0x278B, 0x04, 0x04, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00);
*/
diff --git a/CPP/7zip/Compress/BWT/Mtf8.h b/CPP/7zip/Compress/BWT/Mtf8.h
index 92e4df20..470fd044 100755
--- a/CPP/7zip/Compress/BWT/Mtf8.h
+++ b/CPP/7zip/Compress/BWT/Mtf8.h
@@ -70,7 +70,7 @@ public:
#ifdef MODE_64BIT
typedef UInt64 CMtfVar;
#define MTF_MOVS 3
-#else
+#else
typedef UInt32 CMtfVar;
#define MTF_MOVS 2
#endif
@@ -127,17 +127,17 @@ class CMtf8Decoder
public:
Byte Buffer[256];
- Byte GetHead() const
- {
+ Byte GetHead() const
+ {
if (SmallSize > 0)
return SmallBuffer[kSmallSize - SmallSize];
return Buffer[0];
}
- void Init(int size)
- {
- Size = size;
- SmallSize = 0;
+ void Init(int size)
+ {
+ Size = size;
+ SmallSize = 0;
for (int i = 0; i < 16; i++)
{
Counts[i] = ((size >= 16) ? 16 : size);
diff --git a/CPP/7zip/Compress/BWT/StdAfx.h b/CPP/7zip/Compress/BWT/StdAfx.h
deleted file mode 100755
index b637fd40..00000000
--- a/CPP/7zip/Compress/BWT/StdAfx.h
+++ /dev/null
@@ -1,6 +0,0 @@
-// StdAfx.h
-
-#ifndef __STDAFX_H
-#define __STDAFX_H
-
-#endif
diff --git a/CPP/7zip/Compress/BZip2/BZip2CRC.h b/CPP/7zip/Compress/BZip2/BZip2CRC.h
index 8ac2a504..981fe837 100755
--- a/CPP/7zip/Compress/BZip2/BZip2CRC.h
+++ b/CPP/7zip/Compress/BZip2/BZip2CRC.h
@@ -15,7 +15,7 @@ public:
void Init() { _value = 0xFFFFFFFF; }
void UpdateByte(Byte b) { _value = Table[(_value >> 24) ^ b] ^ (_value << 8); }
void UpdateByte(unsigned int b) { _value = Table[(_value >> 24) ^ b] ^ (_value << 8); }
- UInt32 GetDigest() const { return _value ^ 0xFFFFFFFF; }
+ UInt32 GetDigest() const { return _value ^ 0xFFFFFFFF; }
};
class CBZip2CombinedCRC
@@ -25,7 +25,7 @@ public:
CBZip2CombinedCRC(): _value(0){};
void Init() { _value = 0; }
void Update(UInt32 v) { _value = ((_value << 1) | (_value >> 31)) ^ v; }
- UInt32 GetDigest() const { return _value ; }
+ UInt32 GetDigest() const { return _value ; }
};
#endif
diff --git a/CPP/7zip/Compress/BZip2/BZip2Decoder.cpp b/CPP/7zip/Compress/BZip2/BZip2Decoder.cpp
index 47ffa7c8..6ec40ffa 100755
--- a/CPP/7zip/Compress/BZip2/BZip2Decoder.cpp
+++ b/CPP/7zip/Compress/BZip2/BZip2Decoder.cpp
@@ -4,8 +4,8 @@
#include "BZip2Decoder.h"
-extern "C"
-{
+extern "C"
+{
#include "../../../../C/Alloc.h"
}
@@ -20,58 +20,58 @@ const UInt32 kNumThreadsMax = 4;
static const UInt32 kBufferSize = (1 << 17);
-static Int16 kRandNums[512] = {
- 619, 720, 127, 481, 931, 816, 813, 233, 566, 247,
- 985, 724, 205, 454, 863, 491, 741, 242, 949, 214,
- 733, 859, 335, 708, 621, 574, 73, 654, 730, 472,
- 419, 436, 278, 496, 867, 210, 399, 680, 480, 51,
- 878, 465, 811, 169, 869, 675, 611, 697, 867, 561,
- 862, 687, 507, 283, 482, 129, 807, 591, 733, 623,
- 150, 238, 59, 379, 684, 877, 625, 169, 643, 105,
- 170, 607, 520, 932, 727, 476, 693, 425, 174, 647,
- 73, 122, 335, 530, 442, 853, 695, 249, 445, 515,
- 909, 545, 703, 919, 874, 474, 882, 500, 594, 612,
- 641, 801, 220, 162, 819, 984, 589, 513, 495, 799,
- 161, 604, 958, 533, 221, 400, 386, 867, 600, 782,
- 382, 596, 414, 171, 516, 375, 682, 485, 911, 276,
- 98, 553, 163, 354, 666, 933, 424, 341, 533, 870,
- 227, 730, 475, 186, 263, 647, 537, 686, 600, 224,
- 469, 68, 770, 919, 190, 373, 294, 822, 808, 206,
- 184, 943, 795, 384, 383, 461, 404, 758, 839, 887,
- 715, 67, 618, 276, 204, 918, 873, 777, 604, 560,
- 951, 160, 578, 722, 79, 804, 96, 409, 713, 940,
- 652, 934, 970, 447, 318, 353, 859, 672, 112, 785,
- 645, 863, 803, 350, 139, 93, 354, 99, 820, 908,
- 609, 772, 154, 274, 580, 184, 79, 626, 630, 742,
- 653, 282, 762, 623, 680, 81, 927, 626, 789, 125,
- 411, 521, 938, 300, 821, 78, 343, 175, 128, 250,
- 170, 774, 972, 275, 999, 639, 495, 78, 352, 126,
- 857, 956, 358, 619, 580, 124, 737, 594, 701, 612,
- 669, 112, 134, 694, 363, 992, 809, 743, 168, 974,
- 944, 375, 748, 52, 600, 747, 642, 182, 862, 81,
- 344, 805, 988, 739, 511, 655, 814, 334, 249, 515,
- 897, 955, 664, 981, 649, 113, 974, 459, 893, 228,
- 433, 837, 553, 268, 926, 240, 102, 654, 459, 51,
- 686, 754, 806, 760, 493, 403, 415, 394, 687, 700,
- 946, 670, 656, 610, 738, 392, 760, 799, 887, 653,
- 978, 321, 576, 617, 626, 502, 894, 679, 243, 440,
- 680, 879, 194, 572, 640, 724, 926, 56, 204, 700,
- 707, 151, 457, 449, 797, 195, 791, 558, 945, 679,
- 297, 59, 87, 824, 713, 663, 412, 693, 342, 606,
- 134, 108, 571, 364, 631, 212, 174, 643, 304, 329,
- 343, 97, 430, 751, 497, 314, 983, 374, 822, 928,
- 140, 206, 73, 263, 980, 736, 876, 478, 430, 305,
- 170, 514, 364, 692, 829, 82, 855, 953, 676, 246,
- 369, 970, 294, 750, 807, 827, 150, 790, 288, 923,
- 804, 378, 215, 828, 592, 281, 565, 555, 710, 82,
- 896, 831, 547, 261, 524, 462, 293, 465, 502, 56,
- 661, 821, 976, 991, 658, 869, 905, 758, 745, 193,
- 768, 550, 608, 933, 378, 286, 215, 979, 792, 961,
- 61, 688, 793, 644, 986, 403, 106, 366, 905, 644,
- 372, 567, 466, 434, 645, 210, 389, 550, 919, 135,
- 780, 773, 635, 389, 707, 100, 626, 958, 165, 504,
- 920, 176, 193, 713, 857, 265, 203, 50, 668, 108,
- 645, 990, 626, 197, 510, 357, 358, 850, 858, 364,
+static Int16 kRandNums[512] = {
+ 619, 720, 127, 481, 931, 816, 813, 233, 566, 247,
+ 985, 724, 205, 454, 863, 491, 741, 242, 949, 214,
+ 733, 859, 335, 708, 621, 574, 73, 654, 730, 472,
+ 419, 436, 278, 496, 867, 210, 399, 680, 480, 51,
+ 878, 465, 811, 169, 869, 675, 611, 697, 867, 561,
+ 862, 687, 507, 283, 482, 129, 807, 591, 733, 623,
+ 150, 238, 59, 379, 684, 877, 625, 169, 643, 105,
+ 170, 607, 520, 932, 727, 476, 693, 425, 174, 647,
+ 73, 122, 335, 530, 442, 853, 695, 249, 445, 515,
+ 909, 545, 703, 919, 874, 474, 882, 500, 594, 612,
+ 641, 801, 220, 162, 819, 984, 589, 513, 495, 799,
+ 161, 604, 958, 533, 221, 400, 386, 867, 600, 782,
+ 382, 596, 414, 171, 516, 375, 682, 485, 911, 276,
+ 98, 553, 163, 354, 666, 933, 424, 341, 533, 870,
+ 227, 730, 475, 186, 263, 647, 537, 686, 600, 224,
+ 469, 68, 770, 919, 190, 373, 294, 822, 808, 206,
+ 184, 943, 795, 384, 383, 461, 404, 758, 839, 887,
+ 715, 67, 618, 276, 204, 918, 873, 777, 604, 560,
+ 951, 160, 578, 722, 79, 804, 96, 409, 713, 940,
+ 652, 934, 970, 447, 318, 353, 859, 672, 112, 785,
+ 645, 863, 803, 350, 139, 93, 354, 99, 820, 908,
+ 609, 772, 154, 274, 580, 184, 79, 626, 630, 742,
+ 653, 282, 762, 623, 680, 81, 927, 626, 789, 125,
+ 411, 521, 938, 300, 821, 78, 343, 175, 128, 250,
+ 170, 774, 972, 275, 999, 639, 495, 78, 352, 126,
+ 857, 956, 358, 619, 580, 124, 737, 594, 701, 612,
+ 669, 112, 134, 694, 363, 992, 809, 743, 168, 974,
+ 944, 375, 748, 52, 600, 747, 642, 182, 862, 81,
+ 344, 805, 988, 739, 511, 655, 814, 334, 249, 515,
+ 897, 955, 664, 981, 649, 113, 974, 459, 893, 228,
+ 433, 837, 553, 268, 926, 240, 102, 654, 459, 51,
+ 686, 754, 806, 760, 493, 403, 415, 394, 687, 700,
+ 946, 670, 656, 610, 738, 392, 760, 799, 887, 653,
+ 978, 321, 576, 617, 626, 502, 894, 679, 243, 440,
+ 680, 879, 194, 572, 640, 724, 926, 56, 204, 700,
+ 707, 151, 457, 449, 797, 195, 791, 558, 945, 679,
+ 297, 59, 87, 824, 713, 663, 412, 693, 342, 606,
+ 134, 108, 571, 364, 631, 212, 174, 643, 304, 329,
+ 343, 97, 430, 751, 497, 314, 983, 374, 822, 928,
+ 140, 206, 73, 263, 980, 736, 876, 478, 430, 305,
+ 170, 514, 364, 692, 829, 82, 855, 953, 676, 246,
+ 369, 970, 294, 750, 807, 827, 150, 790, 288, 923,
+ 804, 378, 215, 828, 592, 281, 565, 555, 710, 82,
+ 896, 831, 547, 261, 524, 462, 293, 465, 502, 56,
+ 661, 821, 976, 991, 658, 869, 905, 758, 745, 193,
+ 768, 550, 608, 933, 378, 286, 215, 979, 792, 961,
+ 61, 688, 793, 644, 986, 403, 106, 366, 905, 644,
+ 372, 567, 466, 434, 645, 210, 389, 550, 919, 135,
+ 780, 773, 635, 389, 707, 100, 626, 958, 165, 504,
+ 920, 176, 193, 713, 857, 265, 203, 50, 668, 108,
+ 645, 990, 626, 197, 510, 357, 358, 850, 858, 364,
936, 638
};
@@ -113,15 +113,15 @@ UInt32 NO_INLINE ReadBit(NStream::NMSBF::CDecoder<CInBuffer> *m_InStream)
return m_InStream->ReadBits(1);
}
-static HRESULT NO_INLINE ReadBlock(NStream::NMSBF::CDecoder<CInBuffer> *m_InStream,
- UInt32 *CharCounters, UInt32 blockSizeMax, Byte *m_Selectors, CHuffmanDecoder *m_HuffmanDecoders,
+static HRESULT NO_INLINE ReadBlock(NStream::NMSBF::CDecoder<CInBuffer> *m_InStream,
+ UInt32 *CharCounters, UInt32 blockSizeMax, Byte *m_Selectors, CHuffmanDecoder *m_HuffmanDecoders,
UInt32 *blockSizeRes, UInt32 *origPtrRes, bool *randRes)
{
*randRes = ReadBit(m_InStream) ? true : false;
*origPtrRes = ReadBits(m_InStream, kNumOrigBits);
// in original code it compares OrigPtr to (UInt32)(10 + blockSizeMax)) : why ?
- if (*origPtrRes >= blockSizeMax)
+ if (*origPtrRes >= blockSizeMax)
return S_FALSE;
CMtf8Decoder mtf;
@@ -131,7 +131,7 @@ static HRESULT NO_INLINE ReadBlock(NStream::NMSBF::CDecoder<CInBuffer> *m_InStre
{
Byte inUse16[16];
int i;
- for (i = 0; i < 16; i++)
+ for (i = 0; i < 16; i++)
inUse16[i] = (Byte)ReadBit(m_InStream);
for (i = 0; i < 256; i++)
if (inUse16[i >> 4])
@@ -139,7 +139,7 @@ static HRESULT NO_INLINE ReadBlock(NStream::NMSBF::CDecoder<CInBuffer> *m_InStre
if (ReadBit(m_InStream))
mtf.Add(numInUse++, (Byte)i);
}
- if (numInUse == 0)
+ if (numInUse == 0)
return S_FALSE;
// mtf.Init(numInUse);
}
@@ -164,11 +164,11 @@ static HRESULT NO_INLINE ReadBlock(NStream::NMSBF::CDecoder<CInBuffer> *m_InStre
{
int j = 0;
while (ReadBit(m_InStream))
- if (++j >= numTables)
+ if (++j >= numTables)
return S_FALSE;
Byte tmp = mtfPos[j];
- for (;j > 0; j--)
- mtfPos[j] = mtfPos[j - 1];
+ for (;j > 0; j--)
+ mtfPos[j] = mtfPos[j - 1];
m_Selectors[i] = mtfPos[0] = tmp;
}
while(++i < numSelectors);
@@ -180,19 +180,19 @@ static HRESULT NO_INLINE ReadBlock(NStream::NMSBF::CDecoder<CInBuffer> *m_InStre
Byte lens[kMaxAlphaSize];
int len = (int)ReadBits(m_InStream, kNumLevelsBits);
int i;
- for (i = 0; i < alphaSize; i++)
+ for (i = 0; i < alphaSize; i++)
{
for (;;)
{
- if (len < 1 || len > kMaxHuffmanLen)
+ if (len < 1 || len > kMaxHuffmanLen)
return S_FALSE;
- if (!ReadBit(m_InStream))
+ if (!ReadBit(m_InStream))
break;
len += 1 - (int)(ReadBit(m_InStream) << 1);
}
lens[i] = (Byte)len;
}
- for (; i < kMaxAlphaSize; i++)
+ for (; i < kMaxAlphaSize; i++)
lens[i] = 0;
if(!m_HuffmanDecoders[t].SetCodeLengths(lens))
return S_FALSE;
@@ -200,7 +200,7 @@ static HRESULT NO_INLINE ReadBlock(NStream::NMSBF::CDecoder<CInBuffer> *m_InStre
while(++t < numTables);
{
- for (int i = 0; i < 256; i++)
+ for (int i = 0; i < 256; i++)
CharCounters[i] = 0;
}
@@ -214,7 +214,7 @@ static HRESULT NO_INLINE ReadBlock(NStream::NMSBF::CDecoder<CInBuffer> *m_InStre
for (;;)
{
- if (groupSize == 0)
+ if (groupSize == 0)
{
if (groupIndex >= numSelectors)
return S_FALSE;
@@ -225,9 +225,9 @@ static HRESULT NO_INLINE ReadBlock(NStream::NMSBF::CDecoder<CInBuffer> *m_InStre
UInt32 nextSym = huffmanDecoder->DecodeSymbol(m_InStream);
- if (nextSym < 2)
+ if (nextSym < 2)
{
- runCounter += ((UInt32)(nextSym + 1) << runPower++);
+ runCounter += ((UInt32)(nextSym + 1) << runPower++);
if (blockSizeMax - blockSize < runCounter)
return S_FALSE;
continue;
@@ -236,22 +236,22 @@ static HRESULT NO_INLINE ReadBlock(NStream::NMSBF::CDecoder<CInBuffer> *m_InStre
{
UInt32 b = (UInt32)mtf.GetHead();
CharCounters[b] += runCounter;
- do
+ do
CharCounters[256 + blockSize++] = b;
while(--runCounter != 0);
runPower = 0;
- }
- if (nextSym <= (UInt32)numInUse)
+ }
+ if (nextSym <= (UInt32)numInUse)
{
UInt32 b = (UInt32)mtf.GetAndMove((int)nextSym - 1);
- if (blockSize >= blockSizeMax)
+ if (blockSize >= blockSizeMax)
return S_FALSE;
CharCounters[b]++;
CharCounters[256 + blockSize++] = b;
}
- else if (nextSym == (UInt32)numInUse + 1)
+ else if (nextSym == (UInt32)numInUse + 1)
break;
- else
+ else
return S_FALSE;
}
}
@@ -263,7 +263,7 @@ void NO_INLINE DecodeBlock1(UInt32 *charCounters, UInt32 blockSize)
{
{
UInt32 sum = 0;
- for (UInt32 i = 0; i < 256; i++)
+ for (UInt32 i = 0; i < 256; i++)
{
sum += charCounters[i];
charCounters[i] = sum - charCounters[i];
@@ -388,7 +388,7 @@ static UInt32 NO_INLINE DecodeBlock2Rand(const UInt32 *tt, UInt32 blockSize, UIn
tPos = tt[tPos >> 8];
{
- if (randToGo == 0)
+ if (randToGo == 0)
{
b ^= 1;
randToGo = kRandNums[randIndex++];
@@ -443,8 +443,8 @@ HRESULT CDecoder::Create()
Free();
MtMode = (NumThreads > 1);
m_NumThreadsPrev = NumThreads;
- try
- {
+ try
+ {
m_States = new CState[NumThreads];
if (m_States == 0)
return E_OUTOFMEMORY;
@@ -461,7 +461,7 @@ HRESULT CDecoder::Create()
{
NumThreads = t;
Free();
- return res;
+ return res;
}
}
}
@@ -495,21 +495,21 @@ HRESULT CDecoder::ReadSignatures(bool &wasFinished, UInt32 &crc)
crc = ReadCRC();
if (s[0] == kFinSig0)
{
- if (s[1] != kFinSig1 ||
- s[2] != kFinSig2 ||
- s[3] != kFinSig3 ||
- s[4] != kFinSig4 ||
+ if (s[1] != kFinSig1 ||
+ s[2] != kFinSig2 ||
+ s[3] != kFinSig3 ||
+ s[4] != kFinSig4 ||
s[5] != kFinSig5)
return S_FALSE;
wasFinished = true;
return (crc == CombinedCRC.GetDigest()) ? S_OK : S_FALSE;
}
- if (s[0] != kBlockSig0 ||
- s[1] != kBlockSig1 ||
- s[2] != kBlockSig2 ||
- s[3] != kBlockSig3 ||
- s[4] != kBlockSig4 ||
+ if (s[0] != kBlockSig0 ||
+ s[1] != kBlockSig1 ||
+ s[2] != kBlockSig2 ||
+ s[3] != kBlockSig3 ||
+ s[4] != kBlockSig4 ||
s[5] != kBlockSig5)
return S_FALSE;
CombinedCRC.Update(crc);
@@ -543,10 +543,10 @@ HRESULT CDecoder::DecodeFile(bool &isBZ, ICompressProgressInfo *progress)
int i;
for (i = 0; i < 4; i++)
s[i] = ReadByte();
- if (s[0] != kArSig0 ||
- s[1] != kArSig1 ||
- s[2] != kArSig2 ||
- s[3] <= kArSig3 ||
+ if (s[0] != kArSig0 ||
+ s[1] != kArSig1 ||
+ s[2] != kArSig2 ||
+ s[3] <= kArSig3 ||
s[3] > kArSig3 + kBlockSizeMultMax)
return S_OK;
isBZ = true;
@@ -595,11 +595,11 @@ HRESULT CDecoder::DecodeFile(bool &isBZ, ICompressProgressInfo *progress)
UInt32 blockSize, origPtr;
bool randMode;
- RINOK(ReadBlock(&m_InStream, state.Counters, dicSize,
- m_Selectors, m_HuffmanDecoders,
+ RINOK(ReadBlock(&m_InStream, state.Counters, dicSize,
+ m_Selectors, m_HuffmanDecoders,
&blockSize, &origPtr, &randMode));
DecodeBlock1(state.Counters, blockSize);
- if ((randMode ?
+ if ((randMode ?
DecodeBlock2Rand(state.Counters + 256, blockSize, origPtr, m_OutStream) :
DecodeBlock2(state.Counters + 256, blockSize, origPtr, m_OutStream)) != crc)
return S_FALSE;
@@ -698,7 +698,7 @@ void CState::ThreadFunc()
UInt32 blockSize = 0, origPtr = 0;
bool randMode = false;
- try
+ try
{
bool wasFinished;
res = Decoder->ReadSignatures(wasFinished, crc);
@@ -715,8 +715,8 @@ void CState::ThreadFunc()
continue;
}
- res = ReadBlock(&Decoder->m_InStream, Counters, Decoder->BlockSizeMax,
- Decoder->m_Selectors, Decoder->m_HuffmanDecoders,
+ res = ReadBlock(&Decoder->m_InStream, Counters, Decoder->BlockSizeMax,
+ Decoder->m_Selectors, Decoder->m_HuffmanDecoders,
&blockSize, &origPtr, &randMode);
if (res != S_OK)
{
@@ -746,7 +746,7 @@ void CState::ThreadFunc()
needFinish = Decoder->StreamWasFinished2;
if (!needFinish)
{
- if ((randMode ?
+ if ((randMode ?
DecodeBlock2Rand(Counters + 256, blockSize, origPtr, Decoder->m_OutStream) :
DecodeBlock2(Counters + 256, blockSize, origPtr, Decoder->m_OutStream)) == crc)
{
diff --git a/CPP/7zip/Compress/BZip2/BZip2Decoder.h b/CPP/7zip/Compress/BZip2/BZip2Decoder.h
index 511302d5..f6058841 100755
--- a/CPP/7zip/Compress/BZip2/BZip2Decoder.h
+++ b/CPP/7zip/Compress/BZip2/BZip2Decoder.h
@@ -89,11 +89,11 @@ private:
public:
bool NeedFlush;
CDecoderFlusher(CDecoder *decoder): _decoder(decoder), NeedFlush(true) {}
- ~CDecoderFlusher()
- {
+ ~CDecoderFlusher()
+ {
if (NeedFlush)
_decoder->Flush();
- _decoder->ReleaseStreams();
+ _decoder->ReleaseStreams();
}
};
diff --git a/CPP/7zip/Compress/BZip2/BZip2Encoder.cpp b/CPP/7zip/Compress/BZip2/BZip2Encoder.cpp
index 2491ef17..5ac9e50b 100755
--- a/CPP/7zip/Compress/BZip2/BZip2Encoder.cpp
+++ b/CPP/7zip/Compress/BZip2/BZip2Encoder.cpp
@@ -2,8 +2,8 @@
#include "StdAfx.h"
-extern "C"
-{
+extern "C"
+{
#include "../../../../C/Alloc.h"
#include "../../../../C/BwtSort.h"
#include "../../../../C/HuffEnc.h"
@@ -96,7 +96,7 @@ DWORD CThreadInfo::ThreadFunc()
}
HRESULT res = S_OK;
bool needLeave = true;
- try
+ try
{
UInt32 blockSize = Encoder->ReadRleBlock(m_Block);
m_PackSize = Encoder->m_InStream.GetProcessedSize();
@@ -127,7 +127,7 @@ DWORD CThreadInfo::ThreadFunc()
#endif
CEncoder::CEncoder():
- NumPasses(1),
+ NumPasses(1),
m_OptimizeNumTables(false),
m_BlockSizeMult(kBlockSizeMultMax)
{
@@ -150,8 +150,8 @@ HRESULT CEncoder::Create()
RINOK_THREAD(CanStartWaitingEvent.CreateIfNotCreated());
if (ThreadsInfo != 0 && m_NumThreadsPrev == NumThreads)
return S_OK;
- try
- {
+ try
+ {
Free();
MtMode = (NumThreads > 1);
m_NumThreadsPrev = NumThreads;
@@ -171,7 +171,7 @@ HRESULT CEncoder::Create()
{
NumThreads = t;
Free();
- return res;
+ return res;
}
}
}
@@ -239,8 +239,8 @@ void CThreadInfo::WriteBits2(UInt32 value, UInt32 numBits)
{ m_OutStreamCurrent->WriteBits(value, numBits); }
void CThreadInfo::WriteByte2(Byte b) { WriteBits2(b , 8); }
void CThreadInfo::WriteBit2(bool v) { WriteBits2((v ? 1 : 0), 1); }
-void CThreadInfo::WriteCRC2(UInt32 v)
-{
+void CThreadInfo::WriteCRC2(UInt32 v)
+{
for (int i = 0; i < 4; i++)
WriteByte2(((Byte)(v >> (24 - i * 8))));
}
@@ -249,8 +249,8 @@ void CEncoder::WriteBits(UInt32 value, UInt32 numBits)
{ m_OutStream.WriteBits(value, numBits); }
void CEncoder::WriteByte(Byte b) { WriteBits(b , 8); }
void CEncoder::WriteBit(bool v) { WriteBits((v ? 1 : 0), 1); }
-void CEncoder::WriteCRC(UInt32 v)
-{
+void CEncoder::WriteCRC(UInt32 v)
+{
for (int i = 0; i < 4; i++)
WriteByte(((Byte)(v >> (24 - i * 8))));
}
@@ -274,21 +274,21 @@ void CThreadInfo::EncodeBlock(const Byte *block, UInt32 blockSize)
bool inUse[256];
bool inUse16[16];
UInt32 i;
- for (i = 0; i < 256; i++)
+ for (i = 0; i < 256; i++)
inUse[i] = false;
- for (i = 0; i < 16; i++)
+ for (i = 0; i < 16; i++)
inUse16[i] = false;
for (i = 0; i < blockSize; i++)
inUse[block[i]] = true;
- for (i = 0; i < 256; i++)
+ for (i = 0; i < 256; i++)
if (inUse[i])
{
inUse16[i >> 4] = true;
mtf.Buffer[numInUse++] = (Byte)i;
}
- for (i = 0; i < 16; i++)
+ for (i = 0; i < 16; i++)
WriteBit2(inUse16[i]);
- for (i = 0; i < 256; i++)
+ for (i = 0; i < 256; i++)
if (inUse16[i >> 4])
WriteBit2(inUse[i]);
}
@@ -307,7 +307,7 @@ void CThreadInfo::EncodeBlock(const Byte *block, UInt32 blockSize)
UInt32 i = 0;
const UInt32 *bsIndex = m_BlockSorterIndex;
block--;
- do
+ do
{
int pos = mtf.FindAndMove(block[bsIndex[i]]);
if (pos == 0)
@@ -376,10 +376,10 @@ void CThreadInfo::EncodeBlock(const Byte *block, UInt32 blockSize)
}
else
{
- if (numSymbols < 200) numTables = 2;
- else if (numSymbols < 600) numTables = 3;
- else if (numSymbols < 1200) numTables = 4;
- else if (numSymbols < 2400) numTables = 5;
+ if (numSymbols < 200) numTables = 2;
+ else if (numSymbols < 600) numTables = 3;
+ else if (numSymbols < 1200) numTables = 4;
+ else if (numSymbols < 2400) numTables = 5;
else numTables = 6;
}
@@ -397,10 +397,10 @@ void CThreadInfo::EncodeBlock(const Byte *block, UInt32 blockSize)
UInt32 tFreq = remFreq / t;
int ge = gs;
UInt32 aFreq = 0;
- while (aFreq < tFreq) // && ge < alphaSize)
+ while (aFreq < tFreq) // && ge < alphaSize)
aFreq += symbolCounts[ge++];
- if (ge - 1 > gs && t != numTables && t != 1 && (((numTables - t) & 1) == 1))
+ if (ge - 1 > gs && t != numTables && t != 1 && (((numTables - t) & 1) == 1))
aFreq -= symbolCounts[--ge];
Byte *lens = Lens[t - 1];
@@ -427,7 +427,7 @@ void CThreadInfo::EncodeBlock(const Byte *block, UInt32 blockSize)
{
UInt32 mtfPos = 0;
UInt32 g = 0;
- do
+ do
{
UInt32 symbols[kGroupSize];
int i = 0;
@@ -523,7 +523,7 @@ void CThreadInfo::EncodeBlock(const Byte *block, UInt32 blockSize)
WriteBit2(false);
len++;
}
- else
+ else
{
WriteBit2(true);
len--;
@@ -547,7 +547,7 @@ void CThreadInfo::EncodeBlock(const Byte *block, UInt32 blockSize)
UInt32 symbol = mtfs[mtfPos++];
if (symbol >= 0xFF)
symbol += mtfs[mtfPos++];
- if (groupSize == 0)
+ if (groupSize == 0)
{
groupSize = kGroupSize;
int t = m_Selectors[groupIndex++];
@@ -587,7 +587,7 @@ UInt32 CThreadInfo::EncodeBlockWithHeaders(const Byte *block, UInt32 blockSize)
int numReps = 0;
Byte prevByte = block[0];
UInt32 i = 0;
- do
+ do
{
Byte b = block[i];
if (numReps == kRleModeRepSize)
@@ -627,7 +627,7 @@ void CThreadInfo::EncodeBlock2(const Byte *block, UInt32 blockSize, UInt32 numPa
{
UInt32 blockSize0 = blockSize / 2;
for (;(block[blockSize0] == block[blockSize0 - 1] ||
- block[blockSize0 - 1] == block[blockSize0 - 2]) &&
+ block[blockSize0 - 1] == block[blockSize0 - 2]) &&
blockSize0 < blockSize; blockSize0++);
if (blockSize0 < blockSize)
{
@@ -651,7 +651,7 @@ void CThreadInfo::EncodeBlock2(const Byte *block, UInt32 blockSize, UInt32 numPa
{
UInt32 size2 = endPos2 - startPos2;
if (size2 < endPos - startPos)
- {
+ {
UInt32 numBytes = m_OutStreamCurrent->GetBytePos() - startBytePos2;
Byte *buffer = m_OutStreamCurrent->GetStream();
for (UInt32 i = 0; i < numBytes; i++)
@@ -799,7 +799,7 @@ HRESULT CEncoder::CodeReal(ISequentialInStream *inStream,
{
for (;;)
{
- CThreadInfo &ti =
+ CThreadInfo &ti =
#ifdef COMPRESS_BZIP2_MT
ThreadsInfo[0];
#else
@@ -838,12 +838,12 @@ STDMETHODIMP CEncoder::Code(ISequentialInStream *inStream,
catch(...) { return S_FALSE; }
}
-HRESULT CEncoder::SetCoderProperties(const PROPID *propIDs,
+HRESULT CEncoder::SetCoderProperties(const PROPID *propIDs,
const PROPVARIANT *properties, UInt32 numProperties)
{
for(UInt32 i = 0; i < numProperties; i++)
{
- const PROPVARIANT &property = properties[i];
+ const PROPVARIANT &property = properties[i];
switch(propIDs[i])
{
case NCoderPropID::kNumPasses:
diff --git a/CPP/7zip/Compress/BZip2/BZip2Encoder.h b/CPP/7zip/Compress/BZip2/BZip2Encoder.h
index 98cd20d6..a7adc587 100755
--- a/CPP/7zip/Compress/BZip2/BZip2Encoder.h
+++ b/CPP/7zip/Compress/BZip2/BZip2Encoder.h
@@ -32,7 +32,7 @@ public:
void Init()
{
m_Pos = 0;
- m_BitPos = 8;
+ m_BitPos = 8;
m_CurByte = 0;
}
@@ -68,14 +68,14 @@ public:
UInt32 GetPos() const { return m_Pos * 8 + (8 - m_BitPos); }
Byte GetCurByte() const { return m_CurByte; }
void SetPos(UInt32 bitPos)
- {
+ {
m_Pos = bitPos / 8;
- m_BitPos = 8 - ((int)bitPos & 7);
+ m_BitPos = 8 - ((int)bitPos & 7);
}
void SetCurState(int bitPos, Byte curByte)
- {
- m_BitPos = 8 - bitPos;
- m_CurByte = curByte;
+ {
+ m_BitPos = 8 - bitPos;
+ m_CurByte = curByte;
}
};
@@ -143,7 +143,7 @@ public:
class CEncoder :
public ICompressCoder,
- public ICompressSetCoderProperties,
+ public ICompressSetCoderProperties,
#ifdef COMPRESS_BZIP2_MT
public ICompressSetCoderMt,
#endif
@@ -213,11 +213,11 @@ public:
public:
bool NeedFlush;
CFlusher(CEncoder *coder): _coder(coder), NeedFlush(true) {}
- ~CFlusher()
- {
+ ~CFlusher()
+ {
if (NeedFlush)
_coder->Flush();
- _coder->ReleaseStreams();
+ _coder->ReleaseStreams();
}
};
@@ -234,7 +234,7 @@ public:
STDMETHOD(Code)(ISequentialInStream *inStream,
ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress);
- STDMETHOD(SetCoderProperties)(const PROPID *propIDs,
+ STDMETHOD(SetCoderProperties)(const PROPID *propIDs,
const PROPVARIANT *properties, UInt32 numProperties);
#ifdef COMPRESS_BZIP2_MT
diff --git a/CPP/7zip/Compress/BZip2/StdAfx.cpp b/CPP/7zip/Compress/BZip2/StdAfx.cpp
deleted file mode 100755
index d0feea85..00000000
--- a/CPP/7zip/Compress/BZip2/StdAfx.cpp
+++ /dev/null
@@ -1,3 +0,0 @@
-// StdAfx.cpp
-
-#include "StdAfx.h"
diff --git a/CPP/7zip/Compress/Branch/BranchCoder.h b/CPP/7zip/Compress/Branch/BranchCoder.h
index 102f0dab..8ea84761 100755
--- a/CPP/7zip/Compress/Branch/BranchCoder.h
+++ b/CPP/7zip/Compress/Branch/BranchCoder.h
@@ -23,16 +23,16 @@ public:
};
#define MyClassEncoderA(Name) class C ## Name: public CBranchConverter \
- { public: UInt32 SubFilter(Byte *data, UInt32 size); };
+ { public: UInt32 SubFilter(Byte *data, UInt32 size); };
#define MyClassDecoderA(Name) class C ## Name: public CBranchConverter \
- { public: UInt32 SubFilter(Byte *data, UInt32 size); };
+ { public: UInt32 SubFilter(Byte *data, UInt32 size); };
#define MyClassEncoderB(Name, ADD_ITEMS, ADD_INIT) class C ## Name: public CBranchConverter, public ADD_ITEMS \
- { public: UInt32 SubFilter(Byte *data, UInt32 size); ADD_INIT};
+ { public: UInt32 SubFilter(Byte *data, UInt32 size); ADD_INIT};
#define MyClassDecoderB(Name, ADD_ITEMS, ADD_INIT) class C ## Name: public CBranchConverter, public ADD_ITEMS \
- { public: UInt32 SubFilter(Byte *data, UInt32 size); ADD_INIT};
+ { public: UInt32 SubFilter(Byte *data, UInt32 size); ADD_INIT};
#define MyClassA(Name, id, subId) \
MyClassEncoderA(Name ## _Encoder) \
diff --git a/CPP/7zip/Compress/Branch/BranchMisc.cpp b/CPP/7zip/Compress/Branch/BranchMisc.cpp
index ff4eafbe..956bafaf 100755
--- a/CPP/7zip/Compress/Branch/BranchMisc.cpp
+++ b/CPP/7zip/Compress/Branch/BranchMisc.cpp
@@ -3,8 +3,8 @@
#include "StdAfx.h"
#include "BranchMisc.h"
-extern "C"
-{
+extern "C"
+{
#include "../../../../C/Bra.h"
}
diff --git a/CPP/7zip/Compress/Branch/StdAfx.cpp b/CPP/7zip/Compress/Branch/StdAfx.cpp
deleted file mode 100755
index d0feea85..00000000
--- a/CPP/7zip/Compress/Branch/StdAfx.cpp
+++ /dev/null
@@ -1,3 +0,0 @@
-// StdAfx.cpp
-
-#include "StdAfx.h"
diff --git a/CPP/7zip/Compress/Branch/x86.h b/CPP/7zip/Compress/Branch/x86.h
index e898cb7e..960791c4 100755
--- a/CPP/7zip/Compress/Branch/x86.h
+++ b/CPP/7zip/Compress/Branch/x86.h
@@ -4,8 +4,8 @@
#define __X86_H
#include "BranchCoder.h"
-extern "C"
-{
+extern "C"
+{
#include "../../../../C/Bra.h"
}
@@ -15,7 +15,7 @@ struct CBranch86
void x86Init() { x86_Convert_Init(_prevMask); }
};
-MyClassB(BCJ_x86, 0x01, 3, CBranch86 ,
+MyClassB(BCJ_x86, 0x01, 3, CBranch86 ,
virtual void SubInit() { x86Init(); })
#endif
diff --git a/CPP/7zip/Compress/Branch/x86_2.cpp b/CPP/7zip/Compress/Branch/x86_2.cpp
index 51176c98..87203195 100755
--- a/CPP/7zip/Compress/Branch/x86_2.cpp
+++ b/CPP/7zip/Compress/Branch/x86_2.cpp
@@ -3,8 +3,8 @@
#include "StdAfx.h"
#include "x86_2.h"
-extern "C"
-{
+extern "C"
+{
#include "../../../../C/Alloc.h"
}
@@ -130,7 +130,7 @@ HRESULT CEncoder::CodeReal(ISequentialInStream **inStreams,
if (endPos < 5)
{
- // change it
+ // change it
for (bufferPos = 0; bufferPos < endPos; bufferPos++)
{
Byte b = _buffer[bufferPos];
@@ -167,7 +167,7 @@ HRESULT CEncoder::CodeReal(ISequentialInStream **inStreams,
continue;
}
Byte nextByte = _buffer[bufferPos + 4];
- UInt32 src =
+ UInt32 src =
(UInt32(nextByte) << 24) |
(UInt32(_buffer[bufferPos + 3]) << 16) |
(UInt32(_buffer[bufferPos + 2]) << 8) |
@@ -185,14 +185,14 @@ HRESULT CEncoder::CodeReal(ISequentialInStream **inStreams,
if (result == S_OK)
{
subStreamStartPos = subStreamEndPos;
- subStreamEndPos += subStreamSize;
+ subStreamEndPos += subStreamSize;
subStreamIndex++;
}
else if (result == S_FALSE || result == E_NOTIMPL)
{
getSubStreamSize.Release();
subStreamStartPos = 0;
- subStreamEndPos = subStreamStartPos - 1;
+ subStreamEndPos = subStreamStartPos - 1;
}
else
return result;
@@ -239,8 +239,8 @@ HRESULT CEncoder::CodeReal(ISequentialInStream **inStreams,
if (progress != NULL)
{
/*
- const UInt64 compressedSize =
- _mainStream.GetProcessedSize() +
+ const UInt64 compressedSize =
+ _mainStream.GetProcessedSize() +
_callStream.GetProcessedSize() +
_jumpStream.GetProcessedSize() +
_rangeEncoder.GetProcessedSize();
@@ -320,8 +320,8 @@ HRESULT CDecoder::CodeReal(ISequentialInStream **inStreams,
if (processedBytes >= (1 << 20) && progress != NULL)
{
/*
- const UInt64 compressedSize =
- _mainInStream.GetProcessedSize() +
+ const UInt64 compressedSize =
+ _mainInStream.GetProcessedSize() +
_callStream.GetProcessedSize() +
_jumpStream.GetProcessedSize() +
_rangeDecoder.GetProcessedSize();
diff --git a/CPP/7zip/Compress/Branch/x86_2.h b/CPP/7zip/Compress/Branch/x86_2.h
index 2e4a5267..8c5d754b 100755
--- a/CPP/7zip/Compress/Branch/x86_2.h
+++ b/CPP/7zip/Compress/Branch/x86_2.h
@@ -47,7 +47,7 @@ public:
~CCoderReleaser() { _coder->ReleaseStreams(); }
};
-public:
+public:
MY_UNKNOWN_IMP
@@ -65,14 +65,14 @@ public:
const UInt64 **outSizes,
UInt32 numOutStreams,
ICompressProgressInfo *progress);
-};
+};
#endif
class CDecoder:
public ICompressCoder2,
public CMyUnknownImp
-{
+{
public:
CInBuffer _mainInStream;
CInBuffer _callStream;
@@ -100,7 +100,7 @@ public:
~CCoderReleaser() { _coder->ReleaseStreams(); }
};
-public:
+public:
MY_UNKNOWN_IMP
HRESULT CodeReal(ISequentialInStream **inStreams,
const UInt64 **inSizes,
@@ -116,7 +116,7 @@ public:
const UInt64 **outSizes,
UInt32 numOutStreams,
ICompressProgressInfo *progress);
-};
+};
}}
diff --git a/CPP/7zip/Compress/ByteSwap/ByteSwap.h b/CPP/7zip/Compress/ByteSwap/ByteSwap.h
index 00303063..4d223d4c 100755
--- a/CPP/7zip/Compress/ByteSwap/ByteSwap.h
+++ b/CPP/7zip/Compress/ByteSwap/ByteSwap.h
@@ -7,14 +7,14 @@
#include "Common/MyCom.h"
// {23170F69-40C1-278B-0203-020000000000}
-DEFINE_GUID(CLSID_CCompressConvertByteSwap2,
+DEFINE_GUID(CLSID_CCompressConvertByteSwap2,
0x23170F69, 0x40C1, 0x278B, 0x02, 0x03, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00);
// {23170F69-40C1-278B-0203-040000000000}
-DEFINE_GUID(CLSID_CCompressConvertByteSwap4,
+DEFINE_GUID(CLSID_CCompressConvertByteSwap4,
0x23170F69, 0x40C1, 0x278B, 0x02, 0x03, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00);
-class CByteSwap2:
+class CByteSwap2:
public ICompressFilter,
public CMyUnknownImp
{
@@ -24,7 +24,7 @@ public:
STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);
};
-class CByteSwap4:
+class CByteSwap4:
public ICompressFilter,
public CMyUnknownImp
{
diff --git a/CPP/7zip/Compress/ByteSwap/StdAfx.cpp b/CPP/7zip/Compress/ByteSwap/StdAfx.cpp
deleted file mode 100755
index d0feea85..00000000
--- a/CPP/7zip/Compress/ByteSwap/StdAfx.cpp
+++ /dev/null
@@ -1,3 +0,0 @@
-// StdAfx.cpp
-
-#include "StdAfx.h"
diff --git a/CPP/7zip/Compress/CodecExports.cpp b/CPP/7zip/Compress/CodecExports.cpp
index 7500d923..cd7a209c 100755
--- a/CPP/7zip/Compress/CodecExports.cpp
+++ b/CPP/7zip/Compress/CodecExports.cpp
@@ -8,11 +8,11 @@
#include "../ICoder.h"
extern unsigned int g_NumCodecs;
-extern const CCodecInfo *g_Codecs[];
+extern const CCodecInfo *g_Codecs[];
static const UInt16 kDecodeId = 0x2790;
-DEFINE_GUID(CLSID_CCodec,
+DEFINE_GUID(CLSID_CCodec,
0x23170F69, 0x40C1, kDecodeId, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
static inline HRESULT SetPropString(const char *s, unsigned int size, PROPVARIANT *value)
@@ -40,7 +40,7 @@ static HRESULT SetClassID(CMethodId id, bool encode, PROPVARIANT *value)
static HRESULT FindCodecClassId(const GUID *clsID, UInt32 isCoder2, bool isFilter, bool &encode, int &index)
{
index = -1;
- if (clsID->Data1 != CLSID_CCodec.Data1 ||
+ if (clsID->Data1 != CLSID_CCodec.Data1 ||
clsID->Data2 != CLSID_CCodec.Data2 ||
(clsID->Data3 & ~1) != kDecodeId)
return S_OK;
diff --git a/CPP/7zip/Compress/Copy/CopyCoder.cpp b/CPP/7zip/Compress/Copy/CopyCoder.cpp
index d5285185..be4fee36 100755
--- a/CPP/7zip/Compress/Copy/CopyCoder.cpp
+++ b/CPP/7zip/Compress/Copy/CopyCoder.cpp
@@ -2,8 +2,8 @@
#include "StdAfx.h"
-extern "C"
-{
+extern "C"
+{
#include "../../../../C/Alloc.h"
}
@@ -20,7 +20,7 @@ CCopyCoder::~CCopyCoder()
}
STDMETHODIMP CCopyCoder::Code(ISequentialInStream *inStream,
- ISequentialOutStream *outStream,
+ ISequentialOutStream *outStream,
const UInt64 * /* inSize */, const UInt64 *outSize,
ICompressProgressInfo *progress)
{
diff --git a/CPP/7zip/Compress/Copy/CopyCoder.h b/CPP/7zip/Compress/Copy/CopyCoder.h
index d4530697..7de13992 100755
--- a/CPP/7zip/Compress/Copy/CopyCoder.h
+++ b/CPP/7zip/Compress/Copy/CopyCoder.h
@@ -8,7 +8,7 @@
namespace NCompress {
-class CCopyCoder:
+class CCopyCoder:
public ICompressCoder,
public ICompressGetInStreamProcessedSize,
public CMyUnknownImp
@@ -22,7 +22,7 @@ public:
MY_UNKNOWN_IMP1(ICompressGetInStreamProcessedSize)
STDMETHOD(Code)(ISequentialInStream *inStream,
- ISequentialOutStream *outStream,
+ ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress);
STDMETHOD(GetInStreamProcessedSize)(UInt64 *value);
diff --git a/CPP/7zip/Compress/Copy/StdAfx.cpp b/CPP/7zip/Compress/Copy/StdAfx.cpp
deleted file mode 100755
index d0feea85..00000000
--- a/CPP/7zip/Compress/Copy/StdAfx.cpp
+++ /dev/null
@@ -1,3 +0,0 @@
-// StdAfx.cpp
-
-#include "StdAfx.h"
diff --git a/CPP/7zip/Compress/Copy/StdAfx.h b/CPP/7zip/Compress/Copy/StdAfx.h
index 92239aeb..e7fb6986 100755
--- a/CPP/7zip/Compress/Copy/StdAfx.h
+++ b/CPP/7zip/Compress/Copy/StdAfx.h
@@ -5,4 +5,4 @@
#include "../../../Common/MyWindows.h"
-#endif
+#endif
diff --git a/CPP/7zip/Compress/Deflate/DeflateConst.h b/CPP/7zip/Compress/Deflate/DeflateConst.h
index 766b589a..00e5ab8b 100755
--- a/CPP/7zip/Compress/Deflate/DeflateConst.h
+++ b/CPP/7zip/Compress/Deflate/DeflateConst.h
@@ -38,30 +38,30 @@ const UInt32 kTableLevel0Number2 = kTableLevel0Number + 1;
const UInt32 kLevelMask = 0xF;
-const Byte kLenStart32[kFixedLenTableSize] =
+const Byte kLenStart32[kFixedLenTableSize] =
{0,1,2,3,4,5,6,7,8,10,12,14,16,20,24,28,32,40,48,56,64,80,96,112,128,160,192,224, 255, 0, 0};
-const Byte kLenStart64[kFixedLenTableSize] =
+const Byte kLenStart64[kFixedLenTableSize] =
{0,1,2,3,4,5,6,7,8,10,12,14,16,20,24,28,32,40,48,56,64,80,96,112,128,160,192,224, 0, 0, 0};
-const Byte kLenDirectBits32[kFixedLenTableSize] =
+const Byte kLenDirectBits32[kFixedLenTableSize] =
{0,0,0,0,0,0,0,0,1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 0, 0};
-const Byte kLenDirectBits64[kFixedLenTableSize] =
+const Byte kLenDirectBits64[kFixedLenTableSize] =
{0,0,0,0,0,0,0,0,1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 16, 0, 0};
-const UInt32 kDistStart[kDistTableSize64] =
+const UInt32 kDistStart[kDistTableSize64] =
{0,1,2,3,4,6,8,12,16,24,32,48,64,96,128,192,256,384,512,768,
1024,1536,2048,3072,4096,6144,8192,12288,16384,24576,32768,49152};
-const Byte kDistDirectBits[kDistTableSize64] =
+const Byte kDistDirectBits[kDistTableSize64] =
{0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,14,14};
const Byte kLevelDirectBits[3] = {2, 3, 7};
const Byte kCodeLengthAlphabetOrder[kLevelTableSize] = {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
-const UInt32 kMatchMinLen = 3;
+const UInt32 kMatchMinLen = 3;
const UInt32 kMatchMaxLen32 = kNumLenSymbols32 + kMatchMinLen - 1; //256 + 2
const UInt32 kMatchMaxLen64 = kNumLenSymbols64 + kMatchMinLen - 1; //255 + 2
-const UInt32 kMatchMaxLen = kMatchMaxLen32;
+const UInt32 kMatchMaxLen = kMatchMaxLen32;
const int kFinalBlockFieldSize = 1;
@@ -124,7 +124,7 @@ struct CLevels
litLenLevels[i] = 7;
for (; i < 288; i++)
litLenLevels[i] = 8;
- for (i = 0; i < kFixedDistTableSize; i++) // test it: InfoZip only uses kDistTableSize
+ for (i = 0; i < kFixedDistTableSize; i++) // test it: InfoZip only uses kDistTableSize
distLevels[i] = 5;
}
};
diff --git a/CPP/7zip/Compress/Deflate/DeflateDecoder.cpp b/CPP/7zip/Compress/Deflate/DeflateDecoder.cpp
index 7569df38..b5382912 100755
--- a/CPP/7zip/Compress/Deflate/DeflateDecoder.cpp
+++ b/CPP/7zip/Compress/Deflate/DeflateDecoder.cpp
@@ -11,10 +11,11 @@ namespace NDecoder {
static const int kLenIdFinished = -1;
static const int kLenIdNeedInit = -2;
-CCoder::CCoder(bool deflate64Mode, bool deflateNSIS):
- _deflate64Mode(deflate64Mode),
- _deflateNSIS(deflateNSIS),
- _keepHistory(false) {}
+CCoder::CCoder(bool deflate64Mode, bool deflateNSIS):
+ _deflate64Mode(deflate64Mode),
+ _deflateNSIS(deflateNSIS),
+ _keepHistory(false),
+ ZlibMode(false) {}
UInt32 CCoder::ReadBits(int numBits)
{
@@ -99,7 +100,7 @@ bool CCoder::ReadTables(void)
Byte levelLevels[kLevelTableSize];
for (int i = 0; i < kLevelTableSize; i++)
{
- int position = kCodeLengthAlphabetOrder[i];
+ int position = kCodeLengthAlphabetOrder[i];
if(i < numLevelCodes)
levelLevels[position] = (Byte)ReadBits(kLevelFieldSize);
else
@@ -231,7 +232,7 @@ HRESULT CCoder::CodeSpec(UInt32 curSize)
}
HRESULT CCoder::CodeReal(ISequentialInStream *inStream,
- ISequentialOutStream *outStream,
+ ISequentialOutStream *outStream,
const UInt64 *, const UInt64 *outSize,
ICompressProgressInfo *progress)
{
@@ -261,7 +262,15 @@ HRESULT CCoder::CodeReal(ISequentialInStream *inStream,
const UInt64 nowPos64 = m_OutWindowStream.GetProcessedSize() - start;
RINOK(progress->SetRatioInfo(&inSize, &nowPos64));
}
- }
+ }
+ if (_remainLen == kLenIdFinished && ZlibMode)
+ {
+ UInt32 currentBitPosition = m_InBitStream.GetBitPosition();
+ int numBitsForAlign = (int)(currentBitPosition > 0 ? (8 - currentBitPosition): 0);
+ ReadBits(numBitsForAlign);
+ for (int i = 0; i < 4; i++)
+ ZlibFooter[i] = (Byte)m_InBitStream.ReadBits(8);
+ }
flusher.NeedFlush = false;
return Flush();
}
@@ -274,7 +283,7 @@ HRESULT CCoder::CodeReal(ISequentialInStream *inStream,
#else
-#define DEFLATE_TRY_BEGIN try {
+#define DEFLATE_TRY_BEGIN try {
#define DEFLATE_TRY_END } \
catch(const CInBufferException &e) { return e.ErrorCode; } \
catch(const CLZOutWindowException &e) { return e.ErrorCode; } \
diff --git a/CPP/7zip/Compress/Deflate/DeflateDecoder.h b/CPP/7zip/Compress/Deflate/DeflateDecoder.h
index eebe52f0..add02ba6 100755
--- a/CPP/7zip/Compress/Deflate/DeflateDecoder.h
+++ b/CPP/7zip/Compress/Deflate/DeflateDecoder.h
@@ -76,6 +76,9 @@ class CCoder:
HRESULT CodeSpec(UInt32 curSize);
public:
+ bool ZlibMode;
+ Byte ZlibFooter[4];
+
CCoder(bool deflate64Mode, bool deflateNSIS = false);
void SetKeepHistory(bool keepHistory) { _keepHistory = keepHistory; }
@@ -86,7 +89,7 @@ public:
#ifndef NO_READ_FROM_CODER
MY_UNKNOWN_IMP4(
ICompressGetInStreamProcessedSize,
- ICompressSetInStream,
+ ICompressSetInStream,
ICompressSetOutStreamSize,
ISequentialInStream
)
diff --git a/CPP/7zip/Compress/Deflate/DeflateEncoder.cpp b/CPP/7zip/Compress/Deflate/DeflateEncoder.cpp
index 44ff42b4..14c7cb00 100755
--- a/CPP/7zip/Compress/Deflate/DeflateEncoder.cpp
+++ b/CPP/7zip/Compress/Deflate/DeflateEncoder.cpp
@@ -8,16 +8,16 @@
#include "Windows/Defs.h"
#include "Common/ComTry.h"
-extern "C"
-{
+extern "C"
+{
#include "../../../../C/Alloc.h"
#include "../../../../C/HuffEnc.h"
}
#if _MSC_VER >= 1300
-#define NO_INLINE __declspec(noinline)
+#define NO_INLINE __declspec(noinline)
#else
-#define NO_INLINE
+#define NO_INLINE
#endif
namespace NCompress {
@@ -34,7 +34,7 @@ static UInt32 kDivideBlockSizeMin = (1 << 6); // [1, (1 << 32)); ratio/speed tra
static const UInt32 kMaxUncompressedBlockSize = ((1 << 16) - 1) * 1; // [1, (1 << 32))
static const UInt32 kMatchArraySize = kMaxUncompressedBlockSize * 10; // [kMatchMaxLen * 2, (1 << 32))
static const UInt32 kMatchArrayLimit = kMatchArraySize - kMatchMaxLen * 4 * sizeof(UInt16);
-static const UInt32 kBlockUncompressedSizeThreshold = kMaxUncompressedBlockSize -
+static const UInt32 kBlockUncompressedSizeThreshold = kMaxUncompressedBlockSize -
kMatchMaxLen - kNumOpts;
static const int kMaxCodeBitLength = 11;
@@ -148,9 +148,9 @@ HRESULT CCoder::Create()
{
_lzInWindow.btMode = _btMode ? 1 : 0;
_lzInWindow.numHashBytes = 3;
- if (!MatchFinder_Create(&_lzInWindow,
- m_Deflate64Mode ? kHistorySize64 : kHistorySize32,
- kNumOpts + kMaxUncompressedBlockSize,
+ if (!MatchFinder_Create(&_lzInWindow,
+ m_Deflate64Mode ? kHistorySize64 : kHistorySize32,
+ kNumOpts + kMaxUncompressedBlockSize,
m_NumFastBytes, m_MatchMaxLen - m_NumFastBytes, &g_Alloc))
return E_OUTOFMEMORY;
if (!m_OutStream.Create(1 << 20))
@@ -164,12 +164,12 @@ HRESULT CCoder::Create()
}
// ICompressSetEncoderProperties2
-HRESULT CCoder::BaseSetEncoderProperties2(const PROPID *propIDs,
+HRESULT CCoder::BaseSetEncoderProperties2(const PROPID *propIDs,
const PROPVARIANT *properties, UInt32 numProperties)
{
for(UInt32 i = 0; i < numProperties; i++)
{
- const PROPVARIANT &prop = properties[i];
+ const PROPVARIANT &prop = properties[i];
switch(propIDs[i])
{
case NCoderPropID::kNumPasses:
@@ -207,7 +207,7 @@ HRESULT CCoder::BaseSetEncoderProperties2(const PROPID *propIDs,
if (prop.vt != VT_UI4)
return E_INVALIDARG;
UInt32 maximize = prop.ulVal;
- _fastMode = (maximize == 0);
+ _fastMode = (maximize == 0);
_btMode = !_fastMode;
break;
}
@@ -314,7 +314,7 @@ NO_INLINE UInt32 CCoder::Backward(UInt32 &backRes, UInt32 cur)
while(cur > 0);
backRes = m_Optimum[0].BackPrev;
m_OptimumCurrentIndex = m_Optimum[0].PosPrev;
- return m_OptimumCurrentIndex;
+ return m_OptimumCurrentIndex;
}
NO_INLINE UInt32 CCoder::GetOptimal(UInt32 &backRes)
@@ -339,7 +339,7 @@ NO_INLINE UInt32 CCoder::GetOptimal(UInt32 &backRes)
if(lenMain > m_NumFastBytes)
{
- backRes = matchDistances[numDistancePairs - 1];
+ backRes = matchDistances[numDistancePairs - 1];
MovePos(lenMain - 1);
return lenMain;
}
@@ -366,7 +366,7 @@ NO_INLINE UInt32 CCoder::GetOptimal(UInt32 &backRes)
for (;;)
{
++cur;
- if(cur == lenEnd || cur == kNumOptsBase || m_Pos >= kMatchArrayLimit)
+ if(cur == lenEnd || cur == kNumOptsBase || m_Pos >= kMatchArrayLimit)
return Backward(backRes, cur);
GetMatches();
matchDistances = m_MatchDistances + 1;
@@ -374,7 +374,7 @@ NO_INLINE UInt32 CCoder::GetOptimal(UInt32 &backRes)
UInt32 numDistancePairs = m_MatchDistances[0];
UInt32 newLen = 0;
if(numDistancePairs != 0)
- {
+ {
newLen = matchDistances[numDistancePairs - 2];
if(newLen > m_NumFastBytes)
{
@@ -386,10 +386,10 @@ NO_INLINE UInt32 CCoder::GetOptimal(UInt32 &backRes)
return len;
}
}
- UInt32 curPrice = m_Optimum[cur].Price;
+ UInt32 curPrice = m_Optimum[cur].Price;
UInt32 curAnd1Price = curPrice + m_LiteralPrices[Inline_MatchFinder_GetIndexByte(&_lzInWindow, cur - m_AdditionalOffset)];
COptimal &optimum = m_Optimum[cur + 1];
- if (curAnd1Price < optimum.Price)
+ if (curAnd1Price < optimum.Price)
{
optimum.Price = curAnd1Price;
optimum.PosPrev = (UInt16)cur;
@@ -405,7 +405,7 @@ NO_INLINE UInt32 CCoder::GetOptimal(UInt32 &backRes)
{
UInt32 curAndLenPrice = curPrice + m_LenPrices[lenTest - kMatchMinLen];
COptimal &optimum = m_Optimum[cur + lenTest];
- if (curAndLenPrice < optimum.Price)
+ if (curAndLenPrice < optimum.Price)
{
optimum.Price = curAndLenPrice;
optimum.PosPrev = (UInt16)cur;
@@ -431,7 +431,7 @@ UInt32 CCoder::GetOptimalFast(UInt32 &backRes)
if (numDistancePairs == 0)
return 1;
UInt32 lenMain = m_MatchDistances[numDistancePairs - 1];
- backRes = m_MatchDistances[numDistancePairs];
+ backRes = m_MatchDistances[numDistancePairs];
MovePos(lenMain - 1);
return lenMain;
}
@@ -455,49 +455,49 @@ NO_INLINE void CCoder::LevelTableDummy(const Byte *levels, int numLevels, UInt32
int count = 0;
int maxCount = 7;
int minCount = 4;
- if (nextLen == 0)
+ if (nextLen == 0)
{
maxCount = 138;
minCount = 3;
}
- for (int n = 0; n < numLevels; n++)
+ for (int n = 0; n < numLevels; n++)
{
- int curLen = nextLen;
+ int curLen = nextLen;
nextLen = (n < numLevels - 1) ? levels[n + 1] : 0xFF;
count++;
- if (count < maxCount && curLen == nextLen)
+ if (count < maxCount && curLen == nextLen)
continue;
- if (count < minCount)
+ if (count < minCount)
freqs[curLen] += (UInt32)count;
- else if (curLen != 0)
+ else if (curLen != 0)
{
- if (curLen != prevLen)
+ if (curLen != prevLen)
{
freqs[curLen]++;
count--;
}
freqs[kTableLevelRepNumber]++;
- }
- else if (count <= 10)
+ }
+ else if (count <= 10)
freqs[kTableLevel0Number]++;
- else
+ else
freqs[kTableLevel0Number2]++;
- count = 0;
+ count = 0;
prevLen = curLen;
- if (nextLen == 0)
+ if (nextLen == 0)
{
maxCount = 138;
minCount = 3;
- }
- else if (curLen == nextLen)
+ }
+ else if (curLen == nextLen)
{
maxCount = 6;
minCount = 3;
- }
- else
+ }
+ else
{
maxCount = 7;
minCount = 4;
@@ -520,57 +520,57 @@ NO_INLINE void CCoder::LevelTableCode(const Byte *levels, int numLevels, const B
int count = 0;
int maxCount = 7;
int minCount = 4;
- if (nextLen == 0)
+ if (nextLen == 0)
{
maxCount = 138;
minCount = 3;
}
- for (int n = 0; n < numLevels; n++)
+ for (int n = 0; n < numLevels; n++)
{
- int curLen = nextLen;
+ int curLen = nextLen;
nextLen = (n < numLevels - 1) ? levels[n + 1] : 0xFF;
count++;
- if (count < maxCount && curLen == nextLen)
+ if (count < maxCount && curLen == nextLen)
continue;
- if (count < minCount)
- for(int i = 0; i < count; i++)
+ if (count < minCount)
+ for(int i = 0; i < count; i++)
WRITE_HF(curLen);
- else if (curLen != 0)
+ else if (curLen != 0)
{
- if (curLen != prevLen)
+ if (curLen != prevLen)
{
WRITE_HF(curLen);
count--;
}
WRITE_HF(kTableLevelRepNumber);
WriteBits(count - 3, 2);
- }
- else if (count <= 10)
+ }
+ else if (count <= 10)
{
WRITE_HF(kTableLevel0Number);
WriteBits(count - 3, 3);
}
- else
+ else
{
WRITE_HF(kTableLevel0Number2);
WriteBits(count - 11, 7);
}
- count = 0;
+ count = 0;
prevLen = curLen;
- if (nextLen == 0)
+ if (nextLen == 0)
{
maxCount = 138;
minCount = 3;
- }
- else if (curLen == nextLen)
+ }
+ else if (curLen == nextLen)
{
maxCount = 6;
minCount = 3;
- }
- else
+ }
+ else
{
maxCount = 7;
minCount = 4;
@@ -585,11 +585,11 @@ NO_INLINE void CCoder::MakeTables(unsigned maxHuffLen)
}
NO_INLINE UInt32 Huffman_GetPrice(const UInt32 *freqs, const Byte *lens, UInt32 num)
-{
+{
UInt32 price = 0;
UInt32 i;
for (i = 0; i < num; i++)
- price += lens[i] * freqs[i];
+ price += lens[i] * freqs[i];
return price;
};
@@ -601,8 +601,8 @@ NO_INLINE UInt32 Huffman_GetPrice_Spec(const UInt32 *freqs, const Byte *lens, UI
NO_INLINE UInt32 CCoder::GetLzBlockPrice() const
{
- return
- Huffman_GetPrice_Spec(mainFreqs, m_NewLevels.litLenLevels, kFixedMainTableSize, m_LenDirectBits, kSymbolMatch) +
+ return
+ Huffman_GetPrice_Spec(mainFreqs, m_NewLevels.litLenLevels, kFixedMainTableSize, m_LenDirectBits, kSymbolMatch) +
Huffman_GetPrice_Spec(distFreqs, m_NewLevels.distLevels, kDistTableSize64, kDistDirectBits, 0);
}
@@ -618,7 +618,7 @@ NO_INLINE void CCoder::TryBlock()
{
if (m_OptimumCurrentIndex == m_OptimumEndIndex)
{
- if (m_Pos >= kMatchArrayLimit || BlockSizeRes >= blockSize || !m_SecondPass &&
+ if (m_Pos >= kMatchArrayLimit || BlockSizeRes >= blockSize || !m_SecondPass &&
((Inline_MatchFinder_GetNumAvailableBytes(&_lzInWindow) == 0) || m_ValueIndex >= m_ValueBlockSize))
break;
}
@@ -678,7 +678,7 @@ NO_INLINE void CCoder::SetPrices(const CLevels &levels)
}
NO_INLINE void Huffman_ReverseBits(UInt32 *codes, const Byte *lens, UInt32 num)
-{
+{
for (UInt32 i = 0; i < num; i++)
{
UInt32 x = codes[i];
@@ -760,7 +760,7 @@ NO_INLINE UInt32 CCoder::TryDynBlock(int tableIndex, UInt32 numPasses)
{
m_Pos = posTemp;
TryBlock();
- unsigned numHuffBits =
+ unsigned numHuffBits =
(m_ValueIndex > 18000 ? 12 :
(m_ValueIndex > 7000 ? 11 :
(m_ValueIndex > 2000 ? 10 : 9)));
@@ -789,7 +789,7 @@ NO_INLINE UInt32 CCoder::TryDynBlock(int tableIndex, UInt32 numPasses)
m_NumLevelCodes = kNumLevelCodesMin;
for (UInt32 i = 0; i < kLevelTableSize; i++)
{
- Byte level = levelLens[kCodeLengthAlphabetOrder[i]];
+ Byte level = levelLens[kCodeLengthAlphabetOrder[i]];
if (level > 0 && i >= m_NumLevelCodes)
m_NumLevelCodes = i + 1;
m_LevelLevels[i] = level;
@@ -891,7 +891,7 @@ void CCoder::CodeBlock(int tableIndex, bool finalBlock)
distFreqs[i] = (UInt32)1 << (kMaxStaticHuffLen - m_NewLevels.distLevels[i]);
MakeTables(kMaxStaticHuffLen);
}
- else
+ else
{
if (m_NumDivPasses > 1 || m_CheckStatic)
TryDynBlock(tableIndex, 1);
@@ -915,7 +915,7 @@ void CCoder::CodeBlock(int tableIndex, bool finalBlock)
SRes Read(void *object, void *data, size_t *size)
{
- const UInt32 kStepSize = (UInt32)1 << 31;
+ const UInt32 kStepSize = (UInt32)1 << 31;
UInt32 curSize = ((*size < kStepSize) ? (UInt32)*size : kStepSize);
HRESULT res = ((CSeqInStream *)object)->RealStream->Read(data, curSize, &curSize);
*size = curSize;
@@ -985,7 +985,7 @@ STDMETHODIMP CCOMCoder::Code(ISequentialInStream *inStream,
ICompressProgressInfo *progress)
{ return BaseCode(inStream, outStream, inSize, outSize, progress); }
-STDMETHODIMP CCOMCoder::SetCoderProperties(const PROPID *propIDs,
+STDMETHODIMP CCOMCoder::SetCoderProperties(const PROPID *propIDs,
const PROPVARIANT *properties, UInt32 numProperties)
{ return BaseSetEncoderProperties2(propIDs, properties, numProperties); }
@@ -994,7 +994,7 @@ STDMETHODIMP CCOMCoder64::Code(ISequentialInStream *inStream,
ICompressProgressInfo *progress)
{ return BaseCode(inStream, outStream, inSize, outSize, progress); }
-STDMETHODIMP CCOMCoder64::SetCoderProperties(const PROPID *propIDs,
+STDMETHODIMP CCOMCoder64::SetCoderProperties(const PROPID *propIDs,
const PROPVARIANT *properties, UInt32 numProperties)
{ return BaseSetEncoderProperties2(propIDs, properties, numProperties); }
diff --git a/CPP/7zip/Compress/Deflate/DeflateEncoder.h b/CPP/7zip/Compress/Deflate/DeflateEncoder.h
index 4cdfa707..e16b074d 100755
--- a/CPP/7zip/Compress/Deflate/DeflateEncoder.h
+++ b/CPP/7zip/Compress/Deflate/DeflateEncoder.h
@@ -180,7 +180,7 @@ public:
ICompressProgressInfo *progress);
// ICompressSetCoderProperties
- HRESULT BaseSetEncoderProperties2(const PROPID *propIDs,
+ HRESULT BaseSetEncoderProperties2(const PROPID *propIDs,
const PROPVARIANT *properties, UInt32 numProperties);
};
@@ -188,7 +188,7 @@ public:
class CCOMCoder :
public ICompressCoder,
- public ICompressSetCoderProperties,
+ public ICompressSetCoderProperties,
public CMyUnknownImp,
public CCoder
{
@@ -199,7 +199,7 @@ public:
ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress);
// ICompressSetCoderProperties
- STDMETHOD(SetCoderProperties)(const PROPID *propIDs,
+ STDMETHOD(SetCoderProperties)(const PROPID *propIDs,
const PROPVARIANT *properties, UInt32 numProperties);
};
@@ -216,7 +216,7 @@ public:
ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress);
// ICompressSetCoderProperties
- STDMETHOD(SetCoderProperties)(const PROPID *propIDs,
+ STDMETHOD(SetCoderProperties)(const PROPID *propIDs,
const PROPVARIANT *properties, UInt32 numProperties);
};
diff --git a/CPP/7zip/Compress/Deflate/StdAfx.cpp b/CPP/7zip/Compress/Deflate/StdAfx.cpp
deleted file mode 100755
index d0feea85..00000000
--- a/CPP/7zip/Compress/Deflate/StdAfx.cpp
+++ /dev/null
@@ -1,3 +0,0 @@
-// StdAfx.cpp
-
-#include "StdAfx.h"
diff --git a/CPP/7zip/Compress/Deflate/ZlibDecoder.cpp b/CPP/7zip/Compress/Deflate/ZlibDecoder.cpp
new file mode 100755
index 00000000..6a55b717
--- /dev/null
+++ b/CPP/7zip/Compress/Deflate/ZlibDecoder.cpp
@@ -0,0 +1,94 @@
+// ZlibDecoder.cpp
+
+#include "StdAfx.h"
+
+#include "ZlibDecoder.h"
+#include "DeflateDecoder.h"
+#include "../../Common/StreamUtils.h"
+
+namespace NCompress {
+namespace NZlib {
+
+#define DEFLATE_TRY_BEGIN try {
+#define DEFLATE_TRY_END } \
+ catch(...) { return S_FALSE; }
+
+#define ADLER_MOD 65521
+#define ADLER_LOOP_MAX 5550
+
+static UInt32 Adler32_Update(UInt32 adler, const Byte *buf, size_t size)
+{
+ UInt32 a = adler & 0xFFFF;
+ UInt32 b = (adler >> 16) & 0xFFFF;
+ while (size > 0)
+ {
+ unsigned curSize = (size > ADLER_LOOP_MAX) ? ADLER_LOOP_MAX : (unsigned )size;
+ unsigned i;
+ for (i = 0; i < curSize; i++)
+ {
+ a += buf[i];
+ b += a;
+ }
+ buf += curSize;
+ size -= curSize;
+ a %= ADLER_MOD;
+ b %= ADLER_MOD;
+ }
+ return (b << 16) + a;
+}
+
+STDMETHODIMP COutStreamWithAdler::Write(const void *data, UInt32 size, UInt32 *processedSize)
+{
+ HRESULT result = _stream->Write(data, size, &size);
+ _adler = Adler32_Update(_adler, (const Byte *)data, size);
+ if (processedSize != NULL)
+ *processedSize = size;
+ return result;
+}
+
+HRESULT CDecoder::Code(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
+ ICompressProgressInfo *progress)
+{
+ DEFLATE_TRY_BEGIN
+ if (!AdlerStream)
+ {
+ AdlerSpec = new COutStreamWithAdler;
+ AdlerStream = AdlerSpec;
+ }
+ if (!DeflateDecoder)
+ {
+ DeflateDecoderSpec = new NCompress::NDeflate::NDecoder::CCOMCoder;
+ DeflateDecoderSpec->ZlibMode = true;
+ DeflateDecoder = DeflateDecoderSpec;
+ }
+
+ Byte buf[2];
+ RINOK(ReadStream_FALSE(inStream, buf, 2));
+ int method = buf[0] & 0xF;
+ if (method != 8)
+ return S_FALSE;
+ // int dicSize = buf[0] >> 4;
+ if ((((UInt32)buf[0] << 8) + buf[1]) % 31 != 0)
+ return S_FALSE;
+ if ((buf[1] & 0x20) != 0) // dictPresent
+ return S_FALSE;
+ // int level = (buf[1] >> 6);
+
+ AdlerSpec->SetStream(outStream);
+ AdlerSpec->Init();
+ HRESULT res = DeflateDecoder->Code(inStream, AdlerStream, inSize, outSize, progress);
+ AdlerSpec->ReleaseStream();
+
+ if (res == S_OK)
+ {
+ const Byte *p = DeflateDecoderSpec->ZlibFooter;
+ UInt32 adler = ((UInt32)p[0] << 24) | ((UInt32)p[1] << 16) | ((UInt32)p[2] << 8) | p[3];
+ if (adler != AdlerSpec->GetAdler())
+ return S_FALSE;
+ }
+ return res;
+ DEFLATE_TRY_END
+}
+
+}}
diff --git a/CPP/7zip/Compress/Deflate/ZlibDecoder.h b/CPP/7zip/Compress/Deflate/ZlibDecoder.h
new file mode 100755
index 00000000..cb0cb3cc
--- /dev/null
+++ b/CPP/7zip/Compress/Deflate/ZlibDecoder.h
@@ -0,0 +1,47 @@
+// ZlibDecoder.h
+
+#ifndef __ZLIB_DECODER_H
+#define __ZLIB_DECODER_H
+
+#include "DeflateDecoder.h"
+
+namespace NCompress {
+namespace NZlib {
+
+const UInt32 ADLER_INIT_VAL = 1;
+
+class COutStreamWithAdler:
+ public ISequentialOutStream,
+ public CMyUnknownImp
+{
+ CMyComPtr<ISequentialOutStream> _stream;
+ UInt32 _adler;
+public:
+ MY_UNKNOWN_IMP
+ STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
+ void SetStream(ISequentialOutStream *stream) { _stream = stream; }
+ void ReleaseStream() { _stream.Release(); }
+ void Init() { _adler = ADLER_INIT_VAL; }
+ UInt32 GetAdler() const { return _adler; }
+};
+
+class CDecoder:
+ public ICompressCoder,
+ public CMyUnknownImp
+{
+ COutStreamWithAdler *AdlerSpec;
+ CMyComPtr<ISequentialOutStream> AdlerStream;
+
+ NCompress::NDeflate::NDecoder::CCOMCoder *DeflateDecoderSpec;
+ CMyComPtr<ICompressCoder> DeflateDecoder;
+public:
+ STDMETHOD(Code)(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
+ ICompressProgressInfo *progress);
+
+ MY_UNKNOWN_IMP
+};
+
+}}
+
+#endif
diff --git a/CPP/7zip/Compress/DllExports.cpp b/CPP/7zip/Compress/DllExports.cpp
index 66f7a7f8..a7ec9027 100755
--- a/CPP/7zip/Compress/DllExports.cpp
+++ b/CPP/7zip/Compress/DllExports.cpp
@@ -10,22 +10,24 @@
static const unsigned int kNumCodecsMax = 32;
unsigned int g_NumCodecs = 0;
-const CCodecInfo *g_Codecs[kNumCodecsMax];
-void RegisterCodec(const CCodecInfo *codecInfo)
-{
+const CCodecInfo *g_Codecs[kNumCodecsMax];
+void RegisterCodec(const CCodecInfo *codecInfo)
+{
if (g_NumCodecs < kNumCodecsMax)
- g_Codecs[g_NumCodecs++] = codecInfo;
+ g_Codecs[g_NumCodecs++] = codecInfo;
}
+#ifdef _WIN32
extern "C"
BOOL WINAPI DllMain(HINSTANCE /* hInstance */, DWORD /* dwReason */, LPVOID /*lpReserved*/)
{
return TRUE;
}
+#endif
static const UInt16 kDecodeId = 0x2790;
-DEFINE_GUID(CLSID_CCodec,
+DEFINE_GUID(CLSID_CCodec,
0x23170F69, 0x40C1, kDecodeId, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
STDAPI CreateCoder(const GUID *clsid, const GUID *iid, void **outObject);
diff --git a/CPP/7zip/Compress/DllExports2.cpp b/CPP/7zip/Compress/DllExports2.cpp
index 8519d1cc..836f3fa4 100755
--- a/CPP/7zip/Compress/DllExports2.cpp
+++ b/CPP/7zip/Compress/DllExports2.cpp
@@ -16,7 +16,7 @@ BOOL WINAPI DllMain(HINSTANCE /* hInstance */, DWORD /* dwReason */, LPVOID /*lp
static const UInt16 kDecodeId = 0x2790;
-DEFINE_GUID(CLSID_CCodec,
+DEFINE_GUID(CLSID_CCodec,
0x23170F69, 0x40C1, kDecodeId, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
STDAPI CreateCoder(const GUID *clsid, const GUID *iid, void **outObject);
diff --git a/CPP/7zip/Compress/Huffman/HuffmanDecoder.h b/CPP/7zip/Compress/Huffman/HuffmanDecoder.h
index df67e8c9..76b35c3a 100755
--- a/CPP/7zip/Compress/Huffman/HuffmanDecoder.h
+++ b/CPP/7zip/Compress/Huffman/HuffmanDecoder.h
@@ -13,8 +13,8 @@ const int kNumTableBits = 9;
template <int kNumBitsMax, UInt32 m_NumSymbols>
class CDecoder
{
- UInt32 m_Limits[kNumBitsMax + 1]; // m_Limits[i] = value limit for symbols with length = i
- UInt32 m_Positions[kNumBitsMax + 1]; // m_Positions[i] = index in m_Symbols[] of first symbol with length = i
+ UInt32 m_Limits[kNumBitsMax + 1]; // m_Limits[i] = value limit for symbols with length = i
+ UInt32 m_Positions[kNumBitsMax + 1]; // m_Positions[i] = index in m_Symbols[] of first symbol with length = i
UInt32 m_Symbols[m_NumSymbols];
Byte m_Lengths[1 << kNumTableBits]; // Table oh length for short codes.
@@ -72,10 +72,10 @@ public:
UInt32 value = bitStream->GetValue(kNumBitsMax);
if (value < m_Limits[kNumTableBits])
numBits = m_Lengths[value >> (kNumBitsMax - kNumTableBits)];
- else
+ else
for (numBits = kNumTableBits + 1; value >= m_Limits[numBits]; numBits++);
bitStream->MovePos(numBits);
- UInt32 index = m_Positions[numBits] +
+ UInt32 index = m_Positions[numBits] +
((value - m_Limits[numBits - 1]) >> (kNumBitsMax - numBits));
if (index >= m_NumSymbols)
// throw CDecoderException(); // test it
diff --git a/CPP/7zip/Compress/Huffman/StdAfx.h b/CPP/7zip/Compress/Huffman/StdAfx.h
deleted file mode 100755
index b637fd40..00000000
--- a/CPP/7zip/Compress/Huffman/StdAfx.h
+++ /dev/null
@@ -1,6 +0,0 @@
-// StdAfx.h
-
-#ifndef __STDAFX_H
-#define __STDAFX_H
-
-#endif
diff --git a/CPP/7zip/Compress/Implode/ImplodeDecoder.cpp b/CPP/7zip/Compress/Implode/ImplodeDecoder.cpp
index 692f7c20..a641f53e 100755
--- a/CPP/7zip/Compress/Implode/ImplodeDecoder.cpp
+++ b/CPP/7zip/Compress/Implode/ImplodeDecoder.cpp
@@ -19,8 +19,8 @@ public:
CException(ECauseType cause): m_Cause(cause) {}
};
-static const int kNumDistanceLowDirectBitsForBigDict = 7;
-static const int kNumDistanceLowDirectBitsForSmallDict = 6;
+static const int kNumDistanceLowDirectBitsForBigDict = 7;
+static const int kNumDistanceLowDirectBitsForSmallDict = 6;
static const int kNumBitsInByte = 8;
@@ -38,14 +38,14 @@ static const int kLiteralTableSize = (1 << kNumBitsInByte);
static const int kDistanceTableSize = 64;
static const int kLengthTableSize = 64;
-static const UInt32 kHistorySize =
- (1 << MyMax(kNumDistanceLowDirectBitsForBigDict,
- kNumDistanceLowDirectBitsForSmallDict)) *
+static const UInt32 kHistorySize =
+ (1 << MyMax(kNumDistanceLowDirectBitsForBigDict,
+ kNumDistanceLowDirectBitsForSmallDict)) *
kDistanceTableSize; // = 8 KB;
static const int kNumAdditionalLengthBits = 8;
-static const UInt32 kMatchMinLenWhenLiteralsOn = 3;
+static const UInt32 kMatchMinLenWhenLiteralsOn = 3;
static const UInt32 kMatchMinLenWhenLiteralsOff = 2;
static const UInt32 kMatchMinLenMax = MyMax(kMatchMinLenWhenLiteralsOn,
@@ -73,17 +73,17 @@ void CCoder::ReleaseStreams()
m_InBitStream.ReleaseStream();
}
-bool CCoder::ReadLevelItems(NImplode::NHuffman::CDecoder &decoder,
+bool CCoder::ReadLevelItems(NImplode::NHuffman::CDecoder &decoder,
Byte *levels, int numLevelItems)
{
- int numCodedStructures = m_InBitStream.ReadBits(kNumBitsInByte) +
+ int numCodedStructures = m_InBitStream.ReadBits(kNumBitsInByte) +
kLevelStructuresNumberAdditionalValue;
int currentIndex = 0;
for(int i = 0; i < numCodedStructures; i++)
{
- int level = m_InBitStream.ReadBits(kNumLevelStructureLevelBits) +
+ int level = m_InBitStream.ReadBits(kNumLevelStructureLevelBits) +
kLevelStructureLevelAdditionalValue;
- int rep = m_InBitStream.ReadBits(kNumLevelStructureRepNumberBits) +
+ int rep = m_InBitStream.ReadBits(kNumLevelStructureRepNumberBits) +
kLevelStructureRepNumberAdditionalValue;
if (currentIndex + rep > numLevelItems)
throw CException(CException::kData);
@@ -208,12 +208,12 @@ STDMETHODIMP CCoder::SetDecoderProperties2(const Byte *data, UInt32 size)
return E_INVALIDARG;
Byte flag = data[0];
m_BigDictionaryOn = ((flag & 2) != 0);
- m_NumDistanceLowDirectBits = m_BigDictionaryOn ?
+ m_NumDistanceLowDirectBits = m_BigDictionaryOn ?
kNumDistanceLowDirectBitsForBigDict:
kNumDistanceLowDirectBitsForSmallDict;
m_LiteralsOn = ((flag & 4) != 0);
- m_MinMatchLength = m_LiteralsOn ?
- kMatchMinLenWhenLiteralsOn :
+ m_MinMatchLength = m_LiteralsOn ?
+ kMatchMinLenWhenLiteralsOn :
kMatchMinLenWhenLiteralsOff;
return S_OK;
}
diff --git a/CPP/7zip/Compress/Implode/ImplodeDecoder.h b/CPP/7zip/Compress/Implode/ImplodeDecoder.h
index 627edba4..9616edf9 100755
--- a/CPP/7zip/Compress/Implode/ImplodeDecoder.h
+++ b/CPP/7zip/Compress/Implode/ImplodeDecoder.h
@@ -29,7 +29,7 @@ class CCoder :
bool m_BigDictionaryOn;
bool m_LiteralsOn;
- int m_NumDistanceLowDirectBits;
+ int m_NumDistanceLowDirectBits;
UInt32 m_MinMatchLength;
bool ReadLevelItems(NImplode::NHuffman::CDecoder &table, Byte *levels, int numLevelItems);
@@ -43,11 +43,11 @@ public:
void ReleaseStreams();
HRESULT (Flush)() { return m_OutWindowStream.Flush(); }
- STDMETHOD(CodeReal)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ STDMETHOD(CodeReal)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress);
- STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress);
diff --git a/CPP/7zip/Compress/Implode/ImplodeHuffmanDecoder.cpp b/CPP/7zip/Compress/Implode/ImplodeHuffmanDecoder.cpp
index ad2061c3..64345e08 100755
--- a/CPP/7zip/Compress/Implode/ImplodeHuffmanDecoder.cpp
+++ b/CPP/7zip/Compress/Implode/ImplodeHuffmanDecoder.cpp
@@ -51,8 +51,8 @@ bool CDecoder::SetCodeLengths(const Byte *codeLengths)
}
- // if _ZIP_MODE do not throw exception for trees containing only one node
- // #ifndef _ZIP_MODE
+ // if _ZIP_MODE do not throw exception for trees containing only one node
+ // #ifndef _ZIP_MODE
if (startPos != kMaxValue)
return false;
// #endif
@@ -79,7 +79,7 @@ UInt32 CDecoder::DecodeSymbol(CInBit *inStream)
if (i == 0)
return 0xFFFFFFFF;
inStream->MovePos(numBits);
- UInt32 index = m_Positions[numBits] +
+ UInt32 index = m_Positions[numBits] +
((value - m_Limitits[numBits + 1]) >> (kNumBitsInLongestCode - numBits));
if (index >= m_NumSymbols)
return 0xFFFFFFFF;
diff --git a/CPP/7zip/Compress/Implode/ImplodeHuffmanDecoder.h b/CPP/7zip/Compress/Implode/ImplodeHuffmanDecoder.h
index 9f7aeca1..541ca59d 100755
--- a/CPP/7zip/Compress/Implode/ImplodeHuffmanDecoder.h
+++ b/CPP/7zip/Compress/Implode/ImplodeHuffmanDecoder.h
@@ -16,8 +16,8 @@ typedef NStream::NLSBF::CDecoder<CInBuffer> CInBit;
class CDecoder
{
- UInt32 m_Limitits[kNumBitsInLongestCode + 2]; // m_Limitits[i] = value limit for symbols with length = i
- UInt32 m_Positions[kNumBitsInLongestCode + 2]; // m_Positions[i] = index in m_Symbols[] of first symbol with length = i
+ UInt32 m_Limitits[kNumBitsInLongestCode + 2]; // m_Limitits[i] = value limit for symbols with length = i
+ UInt32 m_Positions[kNumBitsInLongestCode + 2]; // m_Positions[i] = index in m_Symbols[] of first symbol with length = i
UInt32 m_NumSymbols; // number of symbols in m_Symbols
UInt32 *m_Symbols; // symbols: at first with len=1 then 2, ... 15.
public:
diff --git a/CPP/7zip/Compress/Implode/StdAfx.cpp b/CPP/7zip/Compress/Implode/StdAfx.cpp
deleted file mode 100755
index d0feea85..00000000
--- a/CPP/7zip/Compress/Implode/StdAfx.cpp
+++ /dev/null
@@ -1,3 +0,0 @@
-// StdAfx.cpp
-
-#include "StdAfx.h"
diff --git a/CPP/7zip/Compress/LZ/LZOutWindow.h b/CPP/7zip/Compress/LZ/LZOutWindow.h
index 60b1b8af..747d49d1 100755
--- a/CPP/7zip/Compress/LZ/LZOutWindow.h
+++ b/CPP/7zip/Compress/LZ/LZOutWindow.h
@@ -15,7 +15,7 @@ class CLZOutWindow: public COutBuffer
public:
void Init(bool solid = false);
- // distance >= 0, len > 0,
+ // distance >= 0, len > 0,
bool CopyBlock(UInt32 distance, UInt32 len)
{
UInt32 pos = _pos - distance - 1;
@@ -40,7 +40,7 @@ public:
pos = 0;
_buffer[_pos++] = _buffer[pos++];
if (_pos == _limitPos)
- FlushWithCheck();
+ FlushWithCheck();
}
while(--len != 0);
return true;
@@ -50,7 +50,7 @@ public:
{
_buffer[_pos++] = b;
if (_pos == _limitPos)
- FlushWithCheck();
+ FlushWithCheck();
}
Byte GetByte(UInt32 distance) const
@@ -58,7 +58,7 @@ public:
UInt32 pos = _pos - distance - 1;
if (pos >= _bufferSize)
pos += _bufferSize;
- return _buffer[pos];
+ return _buffer[pos];
}
};
diff --git a/CPP/7zip/Compress/LZ/StdAfx.h b/CPP/7zip/Compress/LZ/StdAfx.h
index 3ff6d8a2..e7fb6986 100755
--- a/CPP/7zip/Compress/LZ/StdAfx.h
+++ b/CPP/7zip/Compress/LZ/StdAfx.h
@@ -3,4 +3,6 @@
#ifndef __STDAFX_H
#define __STDAFX_H
-#endif
+#include "../../../Common/MyWindows.h"
+
+#endif
diff --git a/CPP/7zip/Compress/LZMA/LZMA.dsp b/CPP/7zip/Compress/LZMA/LZMA.dsp
new file mode 100755
index 00000000..d7e130fd
--- /dev/null
+++ b/CPP/7zip/Compress/LZMA/LZMA.dsp
@@ -0,0 +1,403 @@
+# Microsoft Developer Studio Project File - Name="LZMA" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=LZMA - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "LZMA.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "LZMA.mak" CFG="LZMA - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "LZMA - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "LZMA - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "LZMA - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 1
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LZMA_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "../../../" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LZMA_EXPORTS" /D "COMPRESS_MF_MT" /D "_7ZIP_LARGE_PAGES" /Yu"StdAfx.h" /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x419 /d "NDEBUG"
+# ADD RSC /l 0x419 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"C:\Program Files\7-zip\Codecs\LZMA.dll" /opt:NOWIN98
+# SUBTRACT LINK32 /pdb:none /debug
+
+!ELSEIF "$(CFG)" == "LZMA - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 1
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LZMA_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "../../../" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LZMA_EXPORTS" /D "COMPRESS_MF_MT" /D "_7ZIP_LARGE_PAGES" /Yu"StdAfx.h" /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x419 /d "_DEBUG"
+# ADD RSC /l 0x419 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"C:\Program Files\7-zip\Codecs\LZMA.dll" /pdbtype:sept
+
+!ENDIF
+
+# Begin Target
+
+# Name "LZMA - Win32 Release"
+# Name "LZMA - Win32 Debug"
+# Begin Group "Spec"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\Codec.def
+# End Source File
+# Begin Source File
+
+SOURCE=..\CodecExports.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\DllExports.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\resource.rc
+# End Source File
+# Begin Source File
+
+SOURCE=.\StdAfx.cpp
+# ADD CPP /Yc"StdAfx.h"
+# End Source File
+# Begin Source File
+
+SOURCE=.\StdAfx.h
+# End Source File
+# End Group
+# Begin Group "7-zip Common"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\Common\InBuffer.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\InBuffer.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\OutBuffer.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\OutBuffer.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\StreamUtils.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\Common\StreamUtils.h
+# End Source File
+# End Group
+# Begin Group "RangeCoder"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\RangeCoder\RangeCoder.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\RangeCoder\RangeCoderBit.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\RangeCoder\RangeCoderBit.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\RangeCoder\RangeCoderBitTree.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\RangeCoder\RangeCoderOpt.h
+# End Source File
+# End Group
+# Begin Group "Interface"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\ICoder.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\IStream.h
+# End Source File
+# End Group
+# Begin Group "LZ"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\LZ\LZOutWindow.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\LZ\LZOutWindow.h
+# End Source File
+# End Group
+# Begin Group "Common"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\..\Common\ComTry.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\Defs.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\Exception.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\MyCom.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\MyUnknown.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Common\MyWindows.h
+# End Source File
+# End Group
+# Begin Group "C"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\..\..\C\7zCrc.c
+
+!IF "$(CFG)" == "LZMA - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "LZMA - Win32 Debug"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\7zCrc.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\Alloc.c
+# SUBTRACT CPP /YX /Yc /Yu
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\Alloc.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\IStream.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\LzFind.c
+
+!IF "$(CFG)" == "LZMA - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "LZMA - Win32 Debug"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\LzFind.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\LzFindMt.c
+
+!IF "$(CFG)" == "LZMA - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "LZMA - Win32 Debug"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\LzFindMt.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\LzHash.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\LzmaDec.c
+
+!IF "$(CFG)" == "LZMA - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "LZMA - Win32 Debug"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\LzmaDec.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\LzmaEnc.c
+
+!IF "$(CFG)" == "LZMA - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "LZMA - Win32 Debug"
+
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\LzmaEnc.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\Threads.c
+# SUBTRACT CPP /YX /Yc /Yu
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\Threads.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\C\Types.h
+# End Source File
+# End Group
+# Begin Source File
+
+SOURCE=.\LZMA.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\LZMADecoder.cpp
+
+!IF "$(CFG)" == "LZMA - Win32 Release"
+
+# ADD CPP /O2
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "LZMA - Win32 Debug"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\LZMADecoder.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\LZMAEncoder.cpp
+
+!IF "$(CFG)" == "LZMA - Win32 Release"
+
+# ADD CPP /O2 /FAs
+# SUBTRACT CPP /YX /Yc /Yu
+
+!ELSEIF "$(CFG)" == "LZMA - Win32 Debug"
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\LZMAEncoder.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\LZMARegister.cpp
+# End Source File
+# End Target
+# End Project
diff --git a/CPP/7zip/Compress/LZMA/LZMA.dsw b/CPP/7zip/Compress/LZMA/LZMA.dsw
new file mode 100755
index 00000000..f750e453
--- /dev/null
+++ b/CPP/7zip/Compress/LZMA/LZMA.dsw
@@ -0,0 +1,29 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "LZMA"=".\LZMA.dsp" - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/CPP/7zip/Compress/LZMA/LZMADecoder.cpp b/CPP/7zip/Compress/LZMA/LZMADecoder.cpp
index 1df7fe6c..545b8f1d 100755
--- a/CPP/7zip/Compress/LZMA/LZMADecoder.cpp
+++ b/CPP/7zip/Compress/LZMA/LZMADecoder.cpp
@@ -76,11 +76,11 @@ STDMETHODIMP CDecoder::SetOutStreamSize(const UInt64 *outSize)
}
STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream,
- ISequentialOutStream *outStream, const UInt64 * /* inSize */,
+ ISequentialOutStream *outStream, const UInt64 * /* inSize */,
const UInt64 *outSize, ICompressProgressInfo *progress)
{
if (_inBuf == 0)
- return S_FALSE;
+ return S_FALSE;
SetOutStreamSize(outSize);
for (;;)
@@ -104,7 +104,7 @@ STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream,
if (rem < curSize)
{
curSize = (SizeT)rem;
- /*
+ /*
// finishMode = LZMA_FINISH_END;
we can't use LZMA_FINISH_END here to allow partial decoding
*/
@@ -141,7 +141,7 @@ STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream,
{
RINOK(progress->SetRatioInfo(&_inSizeProcessed, &_outSizeProcessed));
}
- }
+ }
}
#ifndef NO_READ_FROM_CODER
@@ -169,7 +169,7 @@ STDMETHODIMP CDecoder::Read(void *data, UInt32 size, UInt32 *processedSize)
SizeT outProcessed = size;
ELzmaStatus status;
- SRes res = LzmaDec_DecodeToBuf(&_state, (Byte *)data, &outProcessed,
+ SRes res = LzmaDec_DecodeToBuf(&_state, (Byte *)data, &outProcessed,
_inBuf + _inPos, &inProcessed, LZMA_FINISH_ANY, &status);
_inPos += (UInt32)inProcessed;
_inSizeProcessed += inProcessed;
diff --git a/CPP/7zip/Compress/LZMA/LZMADecoder.h b/CPP/7zip/Compress/LZMA/LZMADecoder.h
index be5df30d..fa140e47 100755
--- a/CPP/7zip/Compress/LZMA/LZMADecoder.h
+++ b/CPP/7zip/Compress/LZMA/LZMADecoder.h
@@ -14,7 +14,7 @@ extern "C"
namespace NCompress {
namespace NLZMA {
-class CDecoder:
+class CDecoder:
public ICompressCoder,
public ICompressSetDecoderProperties2,
public ICompressGetInStreamProcessedSize,
@@ -38,10 +38,10 @@ public:
#ifndef NO_READ_FROM_CODER
MY_UNKNOWN_IMP5(
- ICompressSetDecoderProperties2,
+ ICompressSetDecoderProperties2,
ICompressGetInStreamProcessedSize,
- ICompressSetInStream,
- ICompressSetOutStreamSize,
+ ICompressSetInStream,
+ ICompressSetOutStreamSize,
ISequentialInStream)
#else
MY_UNKNOWN_IMP2(
diff --git a/CPP/7zip/Compress/LZMA/LZMAEncoder.cpp b/CPP/7zip/Compress/LZMA/LZMAEncoder.cpp
index 25faa730..43e1b772 100755
--- a/CPP/7zip/Compress/LZMA/LZMAEncoder.cpp
+++ b/CPP/7zip/Compress/LZMA/LZMAEncoder.cpp
@@ -20,9 +20,9 @@
#include "../../Common/StreamUtils.h"
-extern "C"
-{
-#include "../../../../C/Alloc.h"
+extern "C"
+{
+#include "../../../../C/Alloc.h"
}
static HRESULT SResToHRESULT(SRes res)
@@ -40,7 +40,7 @@ static HRESULT SResToHRESULT(SRes res)
namespace NCompress {
namespace NLZMA {
-static const UInt32 kStreamStepSize = (UInt32)1 << 31;
+static const UInt32 kStreamStepSize = (UInt32)1 << 31;
static SRes MyRead(void *object, void *data, size_t *size)
{
@@ -122,7 +122,7 @@ static int ParseMatchFinder(const wchar_t *s, int *btMode, int *numHashBytes)
return 1;
}
-STDMETHODIMP CEncoder::SetCoderProperties(const PROPID *propIDs,
+STDMETHODIMP CEncoder::SetCoderProperties(const PROPID *propIDs,
const PROPVARIANT *properties, UInt32 numProperties)
{
CLzmaEncProps props;
@@ -154,7 +154,7 @@ STDMETHODIMP CEncoder::SetCoderProperties(const PROPID *propIDs,
case NCoderPropID::kEndMarker:
if (prop.vt != VT_BOOL) return E_INVALIDARG; props.writeEndMark = (prop.boolVal == VARIANT_TRUE); break;
case NCoderPropID::kMatchFinder:
- if (prop.vt != VT_BSTR) return E_INVALIDARG;
+ if (prop.vt != VT_BSTR) return E_INVALIDARG;
if (!ParseMatchFinder(prop.bstrVal, &props.btMode, &props.numHashBytes /* , &_matchFinderBase.skipModeBits */))
return E_INVALIDARG; break;
default:
@@ -165,7 +165,7 @@ STDMETHODIMP CEncoder::SetCoderProperties(const PROPID *propIDs,
}
STDMETHODIMP CEncoder::WriteCoderProperties(ISequentialOutStream *outStream)
-{
+{
Byte props[LZMA_PROPS_SIZE];
size_t size = LZMA_PROPS_SIZE;
RINOK(LzmaEnc_WriteProperties(_encoder, props, &size));
@@ -204,7 +204,7 @@ SRes CompressProgress(void *pp, UInt64 inSize, UInt64 outSize)
}
STDMETHODIMP CEncoder::Code(ISequentialInStream *inStream,
- ISequentialOutStream *outStream, const UInt64 * /* inSize */,
+ ISequentialOutStream *outStream, const UInt64 * /* inSize */,
const UInt64 * /* outSize */,
ICompressProgressInfo *progress)
{
diff --git a/CPP/7zip/Compress/LZMA/LZMAEncoder.h b/CPP/7zip/Compress/LZMA/LZMAEncoder.h
index 711ac0b4..05583e74 100755
--- a/CPP/7zip/Compress/LZMA/LZMAEncoder.h
+++ b/CPP/7zip/Compress/LZMA/LZMAEncoder.h
@@ -27,7 +27,7 @@ struct CSeqOutStream
HRESULT Res;
};
-class CEncoder :
+class CEncoder :
public ICompressCoder,
public ICompressSetOutStream,
public ICompressSetCoderProperties,
@@ -50,12 +50,12 @@ public:
STDMETHOD(Code)(ISequentialInStream *inStream,
- ISequentialOutStream *outStream,
+ ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress);
// ICompressSetCoderProperties2
- STDMETHOD(SetCoderProperties)(const PROPID *propIDs,
+ STDMETHOD(SetCoderProperties)(const PROPID *propIDs,
const PROPVARIANT *properties, UInt32 numProperties);
// ICompressWriteCoderProperties
diff --git a/CPP/7zip/Compress/LZMA/makefile b/CPP/7zip/Compress/LZMA/makefile
new file mode 100755
index 00000000..e3b795e6
--- /dev/null
+++ b/CPP/7zip/Compress/LZMA/makefile
@@ -0,0 +1,61 @@
+PROG = LZMA.dll
+DEF_FILE = ../Codec.def
+CFLAGS = $(CFLAGS) -I ../../../ \
+ -DCOMPRESS_MF_MT \
+ -D_7ZIP_LARGE_PAGES \
+
+LIBS = $(LIBS) oleaut32.lib
+
+COMPRESS_OBJS = \
+ $O\CodecExports.obj \
+ $O\DllExports.obj \
+
+COMMON_OBJS = \
+ $O\CRC.obj \
+
+LZMA_OPT_OBJS = \
+ $O\LZMADecoder.obj \
+ $O\LZMAEncoder.obj \
+ $O\LZMARegister.obj \
+
+7ZIP_COMMON_OBJS = \
+ $O\InBuffer.obj \
+ $O\OutBuffer.obj \
+ $O\StreamUtils.obj \
+
+C_OBJS = \
+ $O\Alloc.obj \
+ $O\LzFind.obj \
+ $O\LzFindMt.obj \
+ $O\LzmaDec.obj \
+ $O\LzmaEnc.obj \
+ $O\Threads.obj \
+
+!include "../../Crc2.mak"
+
+OBJS = \
+ $O\StdAfx.obj \
+ $(COMPRESS_OBJS) \
+ $(COMMON_OBJS) \
+ $(LZMA_OPT_OBJS) \
+ $(7ZIP_COMMON_OBJS) \
+ $(C_OBJS) \
+ $(CRC_OBJS) \
+ $O\RangeCoderBit.obj \
+ $O\resource.res
+
+!include "../../../Build.mak"
+
+$(COMPRESS_OBJS): ../$(*B).cpp
+ $(COMPL)
+$(COMMON_OBJS): ../../../Common/$(*B).cpp
+ $(COMPL)
+$(LZMA_OPT_OBJS): $(*B).cpp
+ $(COMPL_O2)
+$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp
+ $(COMPL)
+$O\RangeCoderBit.obj: ../RangeCoder/$(*B).cpp
+ $(COMPL)
+$(C_OBJS): ../../../../C/$(*B).c
+ $(COMPL_O2)
+!include "../../Crc.mak"
diff --git a/CPP/7zip/Compress/LZMA/resource.rc b/CPP/7zip/Compress/LZMA/resource.rc
new file mode 100755
index 00000000..1b2b6abb
--- /dev/null
+++ b/CPP/7zip/Compress/LZMA/resource.rc
@@ -0,0 +1,3 @@
+#include "../../MyVersionInfo.rc"
+
+MY_VERSION_INFO_DLL("LZMA Codec", "LZMA")
diff --git a/CPP/7zip/Compress/LZMA_Alone/LzmaAlone.cpp b/CPP/7zip/Compress/LZMA_Alone/LzmaAlone.cpp
index 0d2800bd..1afbec97 100755
--- a/CPP/7zip/Compress/LZMA_Alone/LzmaAlone.cpp
+++ b/CPP/7zip/Compress/LZMA_Alone/LzmaAlone.cpp
@@ -49,7 +49,7 @@ static inline bool IsItWindowsNT()
{
OSVERSIONINFO versionInfo;
versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
- if (!::GetVersionEx(&versionInfo))
+ if (!::GetVersionEx(&versionInfo))
return false;
return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
}
@@ -80,7 +80,7 @@ enum Enum
};
}
-static const CSwitchForm kSwitchForms[] =
+static const CSwitchForm kSwitchForms[] =
{
{ L"?", NSwitchType::kSimple, false },
{ L"H", NSwitchType::kSimple, false },
@@ -135,7 +135,7 @@ static void IncorrectCommand()
PrintHelpAndExit("Incorrect command");
}
-static void WriteArgumentsToStringList(int numArguments, const char *arguments[],
+static void WriteArgumentsToStringList(int numArguments, const char *arguments[],
UStringVector &strings)
{
for(int i = 1; i < numArguments; i++)
@@ -176,7 +176,7 @@ int main2(int n, const char *args[])
{
fprintf(stderr, "Unsupported base types. Edit Common/Types.h and recompile");
return 1;
- }
+ }
UStringVector commandStrings;
WriteArgumentsToStringList(n, args, commandStrings);
@@ -185,7 +185,7 @@ int main2(int n, const char *args[])
{
parser.ParseStrings(kSwitchForms, commandStrings);
}
- catch(...)
+ catch(...)
{
IncorrectCommand();
}
@@ -200,7 +200,7 @@ int main2(int n, const char *args[])
int paramIndex = 0;
if (paramIndex >= nonSwitchStrings.Size())
IncorrectCommand();
- const UString &command = nonSwitchStrings[paramIndex++];
+ const UString &command = nonSwitchStrings[paramIndex++];
bool dictionaryIsDefined = false;
UInt32 dictionary = (UInt32)-1;
@@ -268,12 +268,12 @@ int main2(int n, const char *args[])
{
if (paramIndex >= nonSwitchStrings.Size())
IncorrectCommand();
- const UString &inputName = nonSwitchStrings[paramIndex++];
+ const UString &inputName = nonSwitchStrings[paramIndex++];
inStreamSpec = new CInFileStream;
inStream = inStreamSpec;
if (!inStreamSpec->Open(GetSystemString(inputName)))
{
- fprintf(stderr, "\nError: can not open input file %s\n",
+ fprintf(stderr, "\nError: can not open input file %s\n",
(const char *)GetOemString(inputName));
return 1;
}
@@ -290,12 +290,12 @@ int main2(int n, const char *args[])
{
if (paramIndex >= nonSwitchStrings.Size())
IncorrectCommand();
- const UString &outputName = nonSwitchStrings[paramIndex++];
+ const UString &outputName = nonSwitchStrings[paramIndex++];
outStreamSpec = new COutFileStream;
outStream = outStreamSpec;
if (!outStreamSpec->Create(GetSystemString(outputName), true))
{
- fprintf(stderr, "\nError: can not open output file %s\n",
+ fprintf(stderr, "\nError: can not open output file %s\n",
(const char *)GetOemString(outputName));
return 1;
}
@@ -314,7 +314,7 @@ int main2(int n, const char *args[])
Byte *inBuffer = 0;
if (inSize != 0)
{
- inBuffer = (Byte *)MyAlloc((size_t)inSize);
+ inBuffer = (Byte *)MyAlloc((size_t)inSize);
if (inBuffer == 0)
throw kCantAllocate;
}
@@ -330,7 +330,7 @@ int main2(int n, const char *args[])
outSize = (size_t)fileSize / 20 * 21 + (1 << 16);
if (outSize != 0)
{
- outBuffer = (Byte *)MyAlloc((size_t)outSize);
+ outBuffer = (Byte *)MyAlloc((size_t)outSize);
if (outBuffer == 0)
throw kCantAllocate;
}
@@ -354,7 +354,7 @@ int main2(int n, const char *args[])
throw "too big";
if (outSize != 0)
{
- outBuffer = (Byte *)MyAlloc(outSize);
+ outBuffer = (Byte *)MyAlloc(outSize);
if (outBuffer == 0)
throw kCantAllocate;
}
@@ -414,7 +414,7 @@ int main2(int n, const char *args[])
if (!GetNumber(parser[NKey::kPosBits].PostStrings[0], posStateBits))
IncorrectCommand();
- PROPID propIDs[] =
+ PROPID propIDs[] =
{
NCoderPropID::kDictionarySize,
NCoderPropID::kPosStateBits,
@@ -480,12 +480,12 @@ int main2(int n, const char *args[])
{
fprintf(stderr, "\nError: Can not allocate memory\n");
return 1;
- }
+ }
else if (result != S_OK)
{
fprintf(stderr, "\nEncoder error = %X\n", (unsigned int)result);
return 1;
- }
+ }
}
else
{
@@ -511,7 +511,7 @@ int main2(int n, const char *args[])
{
fprintf(stderr, "Decoder error");
return 1;
- }
+ }
}
if (outStreamSpec != NULL)
{
@@ -527,14 +527,14 @@ int main2(int n, const char *args[])
int MY_CDECL main(int n, const char *args[])
{
try { return main2(n, args); }
- catch(const char *s)
- {
+ catch(const char *s)
+ {
fprintf(stderr, "\nError: %s\n", s);
- return 1;
+ return 1;
}
- catch(...)
- {
+ catch(...)
+ {
fprintf(stderr, "\nError\n");
- return 1;
+ return 1;
}
}
diff --git a/CPP/7zip/Compress/LZMA_Alone/LzmaBench.cpp b/CPP/7zip/Compress/LZMA_Alone/LzmaBench.cpp
index cbb0aa86..5d350d45 100755
--- a/CPP/7zip/Compress/LZMA_Alone/LzmaBench.cpp
+++ b/CPP/7zip/Compress/LZMA_Alone/LzmaBench.cpp
@@ -28,8 +28,8 @@
#endif
#endif
-extern "C"
-{
+extern "C"
+{
#include "../../../../C/Alloc.h"
#include "../../../../C/7zCrc.h"
}
@@ -60,9 +60,9 @@ class CBaseRandomGenerator
public:
CBaseRandomGenerator() { Init(); }
void Init() { A1 = 362436069; A2 = 521288629;}
- UInt32 GetRnd()
+ UInt32 GetRnd()
{
- return
+ return
((A1 = 36969 * (A1 & 0xffff) + (A1 >> 16)) << 16) +
((A2 = 18000 * (A2 & 0xffff) + (A2 >> 16)) );
}
@@ -73,14 +73,14 @@ class CBenchBuffer
public:
size_t BufferSize;
Byte *Buffer;
- CBenchBuffer(): Buffer(0) {}
+ CBenchBuffer(): Buffer(0) {}
virtual ~CBenchBuffer() { Free(); }
- void Free()
- {
+ void Free()
+ {
::MidFree(Buffer);
Buffer = 0;
}
- bool Alloc(size_t bufferSize)
+ bool Alloc(size_t bufferSize)
{
if (Buffer != 0 && BufferSize == bufferSize)
return true;
@@ -96,14 +96,14 @@ class CBenchRandomGenerator: public CBenchBuffer
CBaseRandomGenerator *RG;
public:
void Set(CBaseRandomGenerator *rg) { RG = rg; }
- UInt32 GetVal(UInt32 &res, int numBits)
+ UInt32 GetVal(UInt32 &res, int numBits)
{
UInt32 val = res & (((UInt32)1 << numBits) - 1);
res >>= numBits;
return val;
}
- UInt32 GetLen(UInt32 &res)
- {
+ UInt32 GetLen(UInt32 &res)
+ {
UInt32 len = GetVal(res, 2);
return GetVal(res, 1 + len);
}
@@ -145,7 +145,7 @@ public:
};
-class CBenchmarkInStream:
+class CBenchmarkInStream:
public ISequentialInStream,
public CMyUnknownImp
{
@@ -179,7 +179,7 @@ STDMETHODIMP CBenchmarkInStream::Read(void *data, UInt32 size, UInt32 *processed
return S_OK;
}
-class CBenchmarkOutStream:
+class CBenchmarkOutStream:
public ISequentialOutStream,
public CBenchBuffer,
public CMyUnknownImp
@@ -187,8 +187,8 @@ class CBenchmarkOutStream:
// bool _overflow;
public:
UInt32 Pos;
- // CBenchmarkOutStream(): _overflow(false) {}
- void Init()
+ // CBenchmarkOutStream(): _overflow(false) {}
+ void Init()
{
// _overflow = false;
Pos = 0;
@@ -214,7 +214,7 @@ STDMETHODIMP CBenchmarkOutStream::Write(const void *data, UInt32 size, UInt32 *p
return S_OK;
}
-class CCrcOutStream:
+class CCrcOutStream:
public ISequentialOutStream,
public CMyUnknownImp
{
@@ -251,7 +251,7 @@ static UInt64 GetTimeCount()
return value.QuadPart;
*/
return GetTickCount();
- #endif
+ #endif
}
static UInt64 GetFreq()
@@ -261,7 +261,7 @@ static UInt64 GetFreq()
return 1000000;
#else
return 1;
- #endif
+ #endif
#else
/*
LARGE_INTEGER value;
@@ -269,7 +269,7 @@ static UInt64 GetFreq()
return value.QuadPart;
*/
return 1000;
- #endif
+ #endif
}
#ifndef USE_POSIX_TIME
@@ -284,7 +284,7 @@ static UInt64 GetUserTime()
if (::GetProcessTimes(::GetCurrentProcess(), &creationTime, &exitTime, &kernelTime, &userTime) != 0)
return GetTime64(userTime) + GetTime64(kernelTime);
return (UInt64)GetTickCount() * 10000;
- #endif
+ #endif
}
static UInt64 GetUserFreq()
@@ -293,18 +293,18 @@ static UInt64 GetUserFreq()
return CLOCKS_PER_SEC;
#else
return 10000000;
- #endif
+ #endif
}
class CBenchProgressStatus
{
#ifdef BENCH_MT
- NWindows::NSynchronization::CCriticalSection CS;
+ NWindows::NSynchronization::CCriticalSection CS;
#endif
public:
HRESULT Res;
bool EncodeMode;
- void SetResult(HRESULT res)
+ void SetResult(HRESULT res)
{
#ifdef BENCH_MT
NWindows::NSynchronization::CCriticalSectionLock lock(CS);
@@ -450,7 +450,7 @@ UInt64 GetDecompressRating(UInt64 elapsedTime, UInt64 freq, UInt64 outSize, UInt
}
#ifdef EXTERNAL_LZMA
-typedef UInt32 (WINAPI * CreateObjectPointer)(const GUID *clsID,
+typedef UInt32 (WINAPI * CreateObjectPointer)(const GUID *clsID,
const GUID *interfaceID, void **outObject);
#endif
@@ -571,9 +571,9 @@ HRESULT CEncoderInfo::Init(UInt32 dictionarySize, UInt32 numThreads, CBaseRandom
return E_OUTOFMEMORY;
propStreamSpec->Init();
- PROPID propIDs[] =
- {
- NCoderPropID::kDictionarySize,
+ PROPID propIDs[] =
+ {
+ NCoderPropID::kDictionarySize,
NCoderPropID::kMultiThread
};
const int kNumProps = sizeof(propIDs) / sizeof(propIDs[0]);
@@ -664,13 +664,13 @@ HRESULT LzmaBench(
#endif
UInt32 numThreads, UInt32 dictionarySize, IBenchCallback *callback)
{
- UInt32 numEncoderThreads =
+ UInt32 numEncoderThreads =
#ifdef BENCH_MT
(numThreads > 1 ? numThreads / 2 : 1);
#else
1;
#endif
- UInt32 numSubDecoderThreads =
+ UInt32 numSubDecoderThreads =
#ifdef BENCH_MT
(numThreads > 1 ? 2 : 1);
#else
@@ -838,7 +838,7 @@ HRESULT LzmaBench(
inline UInt64 GetLZMAUsage(bool multiThread, UInt32 dictionary)
-{
+{
UInt32 hs = dictionary - 1;
hs |= (hs >> 1);
hs |= (hs >> 2);
@@ -849,7 +849,7 @@ inline UInt64 GetLZMAUsage(bool multiThread, UInt32 dictionary)
if (hs > (1 << 24))
hs >>= 1;
hs++;
- return ((hs + (1 << 16)) + (UInt64)dictionary * 2) * 4 + (UInt64)dictionary * 3 / 2 +
+ return ((hs + (1 << 16)) + (UInt64)dictionary * 2) * 4 + (UInt64)dictionary * 3 / 2 +
(1 << 20) + (multiThread ? (6 << 20) : 0);
}
@@ -905,10 +905,10 @@ struct CCrcThreads
Items[i].Wait();
NumThreads = 0;
}
- ~CCrcThreads()
- {
+ ~CCrcThreads()
+ {
WaitAll();
- delete []Items;
+ delete []Items;
}
};
#endif
diff --git a/CPP/7zip/Compress/LZMA_Alone/LzmaBench.h b/CPP/7zip/Compress/LZMA_Alone/LzmaBench.h
index d57e7977..f8aeb6be 100755
--- a/CPP/7zip/Compress/LZMA_Alone/LzmaBench.h
+++ b/CPP/7zip/Compress/LZMA_Alone/LzmaBench.h
@@ -12,8 +12,8 @@
struct CBenchInfo
{
UInt64 GlobalTime;
- UInt64 GlobalFreq;
- UInt64 UserTime;
+ UInt64 GlobalFreq;
+ UInt64 UserTime;
UInt64 UserFreq;
UInt64 UnpackSize;
UInt64 PackSize;
diff --git a/CPP/7zip/Compress/LZMA_Alone/LzmaBenchCon.cpp b/CPP/7zip/Compress/LZMA_Alone/LzmaBenchCon.cpp
index e55b4bc7..b1c455e9 100755
--- a/CPP/7zip/Compress/LZMA_Alone/LzmaBenchCon.cpp
+++ b/CPP/7zip/Compress/LZMA_Alone/LzmaBenchCon.cpp
@@ -24,18 +24,18 @@ struct CTotalBenchRes
UInt64 Usage;
UInt64 RPU;
void Init() { NumIterations = 0; Rating = 0; Usage = 0; RPU = 0; }
- void Normalize()
- {
- if (NumIterations == 0)
+ void Normalize()
+ {
+ if (NumIterations == 0)
return;
- Rating /= NumIterations;
- Usage /= NumIterations;
- RPU /= NumIterations;
+ Rating /= NumIterations;
+ Usage /= NumIterations;
+ RPU /= NumIterations;
NumIterations = 1;
}
- void SetMid(const CTotalBenchRes &r1, const CTotalBenchRes &r2)
- {
- Rating = (r1.Rating + r2.Rating) / 2;
+ void SetMid(const CTotalBenchRes &r1, const CTotalBenchRes &r2)
+ {
+ Rating = (r1.Rating + r2.Rating) / 2;
Usage = (r1.Usage + r2.Usage) / 2;
RPU = (r1.RPU + r2.RPU) / 2;
NumIterations = (r1.NumIterations + r2.NumIterations) / 2;
@@ -168,7 +168,7 @@ HRESULT LzmaBenchCon(
if (!CrcInternalTest())
return S_FALSE;
#ifdef BENCH_MT
- UInt64 ramSize = NWindows::NSystem::GetRamSize(); //
+ UInt64 ramSize = NWindows::NSystem::GetRamSize(); //
UInt32 numCPUs = NWindows::NSystem::GetNumberOfProcessors();
PrintRequirements(f, "size: ", ramSize, "CPU hardware threads:", numCPUs);
if (numThreads == (UInt32)-1)
diff --git a/CPP/7zip/Compress/LZMA_Alone/makefile.gcc b/CPP/7zip/Compress/LZMA_Alone/makefile.gcc
index b5a5f1d1..32ec28a3 100755
--- a/CPP/7zip/Compress/LZMA_Alone/makefile.gcc
+++ b/CPP/7zip/Compress/LZMA_Alone/makefile.gcc
@@ -12,7 +12,7 @@ endif
ifdef IS_MINGW
FILE_IO =FileIO
FILE_IO_2 =Windows/$(FILE_IO)
-LIB2 = -luuid
+LIB2 = -luuid
else
FILE_IO =C_FileIO
FILE_IO_2 =Common/$(FILE_IO)
diff --git a/CPP/7zip/Compress/Lzh/LzhDecoder.cpp b/CPP/7zip/Compress/Lzh/LzhDecoder.cpp
index 36adf657..ef1b718a 100755
--- a/CPP/7zip/Compress/Lzh/LzhDecoder.cpp
+++ b/CPP/7zip/Compress/Lzh/LzhDecoder.cpp
@@ -21,28 +21,28 @@ UInt32 CCoder::ReadBits(int numBits) { return m_InBitStream.ReadBits(numBits);
HRESULT CCoder::ReadLevelTable()
{
int n = ReadBits(kNumLevelBits);
- if (n == 0)
+ if (n == 0)
{
m_LevelHuffman.Symbol = ReadBits(kNumLevelBits);
if (m_LevelHuffman.Symbol >= kNumLevelSymbols)
return S_FALSE;
}
- else
+ else
{
if (n > kNumLevelSymbols)
return S_FALSE;
m_LevelHuffman.Symbol = -1;
Byte lens[kNumLevelSymbols];
int i = 0;
- while (i < n)
+ while (i < n)
{
int c = m_InBitStream.ReadBits(3);
- if (c == 7)
- while (ReadBits(1))
+ if (c == 7)
+ while (ReadBits(1))
if (c++ > kMaxHuffmanLen)
return S_FALSE;
lens[i++] = (Byte)c;
- if (i == kNumSpecLevelSymbols)
+ if (i == kNumSpecLevelSymbols)
{
c = ReadBits(2);
while (--c >= 0)
@@ -65,18 +65,18 @@ HRESULT CCoder::ReadPTable(int numBits)
if (m_PHuffmanDecoder.Symbol >= kNumDistanceSymbols)
return S_FALSE;
}
- else
+ else
{
if (n > kNumDistanceSymbols)
return S_FALSE;
m_PHuffmanDecoder.Symbol = -1;
Byte lens[kNumDistanceSymbols];
int i = 0;
- while (i < n)
+ while (i < n)
{
int c = m_InBitStream.ReadBits(3);
- if (c == 7)
- while (ReadBits(1))
+ if (c == 7)
+ while (ReadBits(1))
{
if (c > kMaxHuffmanLen)
return S_FALSE;
@@ -94,23 +94,23 @@ HRESULT CCoder::ReadPTable(int numBits)
HRESULT CCoder::ReadCTable()
{
int n = ReadBits(kNumCBits);
- if (n == 0)
+ if (n == 0)
{
m_CHuffmanDecoder.Symbol = ReadBits(kNumCBits);
if (m_CHuffmanDecoder.Symbol >= kNumCSymbols)
return S_FALSE;
}
- else
+ else
{
if (n > kNumCSymbols)
return S_FALSE;
m_CHuffmanDecoder.Symbol = -1;
Byte lens[kNumCSymbols];
int i = 0;
- while (i < n)
+ while (i < n)
{
int c = m_LevelHuffman.Decode(&m_InBitStream);
- if (c < kNumSpecLevelSymbols)
+ if (c < kNumSpecLevelSymbols)
{
if (c == 0)
c = 1;
@@ -156,9 +156,9 @@ STDMETHODIMP CCoder::CodeReal(ISequentialInStream *inStream,
CCoderReleaser coderReleaser(this);
int pbit;
- if (m_NumDictBits <= 13)
+ if (m_NumDictBits <= 13)
pbit = 4;
- else
+ else
pbit = 5;
UInt32 blockSize = 0;
@@ -167,7 +167,7 @@ STDMETHODIMP CCoder::CodeReal(ISequentialInStream *inStream,
{
// for (i = 0; i < dictSize; i++) dtext[i] = 0x20;
- if (blockSize == 0)
+ if (blockSize == 0)
{
if (progress != NULL)
{
@@ -181,7 +181,7 @@ STDMETHODIMP CCoder::CodeReal(ISequentialInStream *inStream,
}
blockSize--;
UInt32 c = m_CHuffmanDecoder.Decode(&m_InBitStream);
- if (c < 256)
+ if (c < 256)
{
m_OutWindowStream.PutByte((Byte)c);
pos++;
diff --git a/CPP/7zip/Compress/Lzh/LzhDecoder.h b/CPP/7zip/Compress/Lzh/LzhDecoder.h
index 79f71b88..c2f240e0 100755
--- a/CPP/7zip/Compress/Lzh/LzhDecoder.h
+++ b/CPP/7zip/Compress/Lzh/LzhDecoder.h
@@ -74,7 +74,7 @@ class CCoder :
};
friend class CCoderReleaser;
- void MakeTable(int nchar, Byte *bitlen, int tablebits,
+ void MakeTable(int nchar, Byte *bitlen, int tablebits,
UInt32 *table, int tablesize);
UInt32 ReadBits(int numBits);
diff --git a/CPP/7zip/Compress/Lzx/Lzx.h b/CPP/7zip/Compress/Lzx/Lzx.h
index 386a17c3..249cbe51 100755
--- a/CPP/7zip/Compress/Lzx/Lzx.h
+++ b/CPP/7zip/Compress/Lzx/Lzx.h
@@ -40,7 +40,7 @@ const int kLevelSymbolSame = 19;
const int kLevelSymbolZerosStartValue = 4;
const int kLevelSymbolZerosNumBits = 4;
-const int kLevelSymbolZerosBigStartValue = kLevelSymbolZerosStartValue +
+const int kLevelSymbolZerosBigStartValue = kLevelSymbolZerosStartValue +
(1 << kLevelSymbolZerosNumBits);
const int kLevelSymbolZerosBigNumBits = 5;
diff --git a/CPP/7zip/Compress/Lzx/Lzx86Converter.cpp b/CPP/7zip/Compress/Lzx/Lzx86Converter.cpp
index 1265dba0..0492b36c 100755
--- a/CPP/7zip/Compress/Lzx/Lzx86Converter.cpp
+++ b/CPP/7zip/Compress/Lzx/Lzx86Converter.cpp
@@ -28,7 +28,7 @@ void Cx86ConvertOutStream::MakeTranslation()
Int32 pos = (Int32)(m_ProcessedSize + i - 1);
if (absValue >= -pos && absValue < (Int32)m_TranslationSize)
{
- UInt32 offset = (absValue >= 0) ?
+ UInt32 offset = (absValue >= 0) ?
absValue - pos :
absValue + m_TranslationSize;
for(j = 0; j < 4; j++)
diff --git a/CPP/7zip/Compress/Lzx/Lzx86Converter.h b/CPP/7zip/Compress/Lzx/Lzx86Converter.h
index b507a612..c8757ad5 100755
--- a/CPP/7zip/Compress/Lzx/Lzx86Converter.h
+++ b/CPP/7zip/Compress/Lzx/Lzx86Converter.h
@@ -11,7 +11,7 @@ namespace NLzx {
const int kUncompressedBlockSize = 1 << 15;
-class Cx86ConvertOutStream:
+class Cx86ConvertOutStream:
public ISequentialOutStream,
public CMyUnknownImp
{
diff --git a/CPP/7zip/Compress/Lzx/LzxDecoder.cpp b/CPP/7zip/Compress/Lzx/LzxDecoder.cpp
index 94ce6fc9..ceeb25d3 100755
--- a/CPP/7zip/Compress/Lzx/LzxDecoder.cpp
+++ b/CPP/7zip/Compress/Lzx/LzxDecoder.cpp
@@ -1,12 +1,12 @@
- // LzxDecoder.cpp
+// LzxDecoder.cpp
#include "StdAfx.h"
#include "LzxDecoder.h"
#include "Common/Defs.h"
-extern "C"
-{
+extern "C"
+{
#include "../../../../C/Alloc.h"
}
#include "Windows/Defs.h"
@@ -307,7 +307,7 @@ HRESULT CDecoder::CodeSpec(UInt32 curSize)
}
HRESULT CDecoder::CodeReal(ISequentialInStream *inStream,
- ISequentialOutStream *outStream,
+ ISequentialOutStream *outStream,
const UInt64 *, const UInt64 *outSize,
ICompressProgressInfo *progress)
{
@@ -338,7 +338,7 @@ HRESULT CDecoder::CodeReal(ISequentialInStream *inStream,
UInt64 nowPos64 = m_OutWindowStream.GetProcessedSize() - start;
RINOK(progress->SetRatioInfo(&inSize, &nowPos64));
}
- }
+ }
flusher.NeedFlush = false;
return Flush();
}
@@ -374,7 +374,7 @@ STDMETHODIMP CDecoder::SetOutStreamSize(const UInt64 *outSize)
}
HRESULT CDecoder::SetParams(int numDictBits)
-{
+{
if (numDictBits < kNumDictionaryBitsMin || numDictBits > kNumDictionaryBitsMax)
return E_INVALIDARG;
UInt32 numPosSlots;
diff --git a/CPP/7zip/Compress/Lzx/LzxDecoder.h b/CPP/7zip/Compress/Lzx/LzxDecoder.h
index 4a577d38..a9b41570 100755
--- a/CPP/7zip/Compress/Lzx/LzxDecoder.h
+++ b/CPP/7zip/Compress/Lzx/LzxDecoder.h
@@ -36,10 +36,10 @@ public:
void Init()
{
m_Stream.Init();
- m_BitPos = kNumBigValueBits;
+ m_BitPos = kNumBigValueBits;
}
- UInt64 GetProcessedSize() const
+ UInt64 GetProcessedSize() const
{ return m_Stream.GetProcessedSize() - (kNumBigValueBits - m_BitPos) / 8; }
int GetBitPosition() const { return m_BitPos & 0xF; }
@@ -57,7 +57,7 @@ public:
UInt32 GetValue(int numBits) const
{
- return ((m_Value >> ((32 - kNumValueBits) - m_BitPos)) & kBitDecoderValueMask) >>
+ return ((m_Value >> ((32 - kNumValueBits) - m_BitPos)) & kBitDecoderValueMask) >>
(kNumValueBits - numBits);
}
@@ -96,7 +96,7 @@ public:
};
}
-class CDecoder :
+class CDecoder :
public ICompressCoder,
public CMyUnknownImp
{
@@ -135,8 +135,8 @@ class CDecoder :
HRESULT CodeSpec(UInt32 size);
- HRESULT CodeReal(ISequentialInStream *inStream,
- ISequentialOutStream *outStream,
+ HRESULT CodeReal(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress);
public:
@@ -148,8 +148,8 @@ public:
STDMETHOD(Flush)();
// ICompressCoder interface
- STDMETHOD(Code)(ISequentialInStream *inStream,
- ISequentialOutStream *outStream,
+ STDMETHOD(Code)(ISequentialInStream *inStream,
+ ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress);
diff --git a/CPP/7zip/Compress/PPMD/PPMDContext.h b/CPP/7zip/Compress/PPMD/PPMDContext.h
index 2e955d32..577d3b76 100755
--- a/CPP/7zip/Compress/PPMD/PPMDContext.h
+++ b/CPP/7zip/Compress/PPMD/PPMDContext.h
@@ -15,42 +15,42 @@ namespace NPPMD {
const int INT_BITS=7, PERIOD_BITS=7, TOT_BITS=INT_BITS+PERIOD_BITS,
INTERVAL=1 << INT_BITS, BIN_SCALE=1 << TOT_BITS, MAX_FREQ=124;
-struct SEE2_CONTEXT
-{
+struct SEE2_CONTEXT
+{
// SEE-contexts for PPM-contexts with masked symbols
UInt16 Summ;
Byte Shift, Count;
void init(int InitVal) { Summ = (UInt16)(InitVal << (Shift=PERIOD_BITS-4)); Count=4; }
- unsigned int getMean()
+ unsigned int getMean()
{
- unsigned int RetVal=(Summ >> Shift);
+ unsigned int RetVal=(Summ >> Shift);
Summ = (UInt16)(Summ - RetVal);
return RetVal+(RetVal == 0);
}
- void update()
+ void update()
{
- if (Shift < PERIOD_BITS && --Count == 0)
+ if (Shift < PERIOD_BITS && --Count == 0)
{
- Summ <<= 1;
+ Summ <<= 1;
Count = (Byte)(3 << Shift++);
}
}
};
-struct PPM_CONTEXT
+struct PPM_CONTEXT
{
- UInt16 NumStats; // sizeof(UInt16) > sizeof(Byte)
+ UInt16 NumStats; // sizeof(UInt16) > sizeof(Byte)
UInt16 SummFreq;
- struct STATE
- {
- Byte Symbol, Freq;
+ struct STATE
+ {
+ Byte Symbol, Freq;
UInt16 SuccessorLow;
UInt16 SuccessorHigh;
UInt32 GetSuccessor() const { return SuccessorLow | ((UInt32)SuccessorHigh << 16); }
- void SetSuccessor(UInt32 v)
- {
+ void SetSuccessor(UInt32 v)
+ {
SuccessorLow = (UInt16)(v & 0xFFFF);
SuccessorHigh = (UInt16)((v >> 16) & 0xFFFF);
}
@@ -62,11 +62,11 @@ struct PPM_CONTEXT
PPM_CONTEXT* createChild(CSubAllocator &subAllocator, STATE* pStats, STATE& FirstState)
{
PPM_CONTEXT* pc = (PPM_CONTEXT*) subAllocator.AllocContext();
- if (pc)
+ if (pc)
{
- pc->NumStats = 1;
+ pc->NumStats = 1;
pc->oneState() = FirstState;
- pc->Suffix = subAllocator.GetOffset(this);
+ pc->Suffix = subAllocator.GetOffset(this);
pStats->SetSuccessor(subAllocator.GetOffsetNoCheck(pc));
}
return pc;
@@ -97,7 +97,7 @@ struct CInfo
HiBitsFlag = HB2Flag[FoundState->Symbol];
return BinSumm[rs.Freq - 1][
PrevSuccess + NS2BSIndx[numStates - 1] +
- HiBitsFlag + 2 * HB2Flag[rs.Symbol] +
+ HiBitsFlag + 2 * HB2Flag[rs.Symbol] +
((RunLength >> 26) & 0x20)];
}
@@ -110,19 +110,19 @@ struct CInfo
{
int i, k, m;
memset(CharMask,0,sizeof(CharMask));
- SubAllocator.InitSubAllocator();
+ SubAllocator.InitSubAllocator();
InitRL = -((MaxOrder < 12) ? MaxOrder : 12) - 1;
MinContext = MaxContext = (PPM_CONTEXT*) SubAllocator.AllocContext();
- MinContext->Suffix = 0;
+ MinContext->Suffix = 0;
OrderFall = MaxOrder;
MinContext->SummFreq = (UInt16)((MinContext->NumStats = 256) + 1);
FoundState = (PPM_CONTEXT::STATE*)SubAllocator.AllocUnits(256 / 2);
MinContext->Stats = SubAllocator.GetOffsetNoCheck(FoundState);
PrevSuccess = 0;
- for (RunLength = InitRL, i = 0; i < 256; i++)
+ for (RunLength = InitRL, i = 0; i < 256; i++)
{
PPM_CONTEXT::STATE &state = FoundState[i];
- state.Symbol = (Byte)i;
+ state.Symbol = (Byte)i;
state.Freq = 1;
state.SetSuccessor(0);
}
@@ -131,7 +131,7 @@ struct CInfo
for ( m=0; m < 64; m += 8)
BinSumm[i][k + m] = (UInt16)(BIN_SCALE - InitBinEsc[k] / (i + 2));
for (i = 0; i < 25; i++)
- for (k = 0; k < 16; k++)
+ for (k = 0; k < 16; k++)
SEE2Cont[i][k].init(5*i+10);
}
@@ -139,39 +139,39 @@ struct CInfo
{
int i, k, m ,Step;
EscCount=PrintCount=1;
- if (maxOrder < 2)
+ if (maxOrder < 2)
{
memset(CharMask,0,sizeof(CharMask));
- OrderFall = MaxOrder;
+ OrderFall = MaxOrder;
MinContext = MaxContext;
- while (MinContext->Suffix != 0)
+ while (MinContext->Suffix != 0)
{
- MinContext = GetContextNoCheck(MinContext->Suffix);
+ MinContext = GetContextNoCheck(MinContext->Suffix);
OrderFall--;
}
FoundState = GetState(MinContext->Stats);
MinContext = MaxContext;
- }
- else
+ }
+ else
{
- MaxOrder = maxOrder;
+ MaxOrder = maxOrder;
RestartModelRare();
- NS2BSIndx[0] = 2 * 0;
+ NS2BSIndx[0] = 2 * 0;
NS2BSIndx[1] = 2 * 1;
- memset(NS2BSIndx + 2, 2 * 2, 9);
+ memset(NS2BSIndx + 2, 2 * 2, 9);
memset(NS2BSIndx + 11, 2 * 3, 256 - 11);
- for (i = 0; i < 3; i++)
+ for (i = 0; i < 3; i++)
NS2Indx[i] = (Byte)i;
- for (m = i, k = Step = 1; i < 256; i++)
+ for (m = i, k = Step = 1; i < 256; i++)
{
NS2Indx[i] = (Byte)m;
- if ( !--k )
- {
- k = ++Step;
- m++;
+ if ( !--k )
+ {
+ k = ++Step;
+ m++;
}
}
- memset(HB2Flag, 0, 0x40);
+ memset(HB2Flag, 0, 0x40);
memset(HB2Flag + 0x40, 0x08, 0x100 - 0x40);
DummySEE2Cont.Shift = PERIOD_BITS;
}
@@ -186,59 +186,59 @@ struct CInfo
PPM_CONTEXT *pc = MinContext;
PPM_CONTEXT *UpBranch = GetContext(FoundState->GetSuccessor());
PPM_CONTEXT::STATE * p, * ps[MAX_O], ** pps = ps;
- if ( !skip )
+ if ( !skip )
{
*pps++ = FoundState;
- if ( !pc->Suffix )
+ if ( !pc->Suffix )
goto NO_LOOP;
}
- if ( p1 )
+ if ( p1 )
{
- p = p1;
+ p = p1;
pc = GetContext(pc->Suffix);
goto LOOP_ENTRY;
}
- do
+ do
{
pc = GetContext(pc->Suffix);
- if (pc->NumStats != 1)
+ if (pc->NumStats != 1)
{
if ((p = GetStateNoCheck(pc->Stats))->Symbol != FoundState->Symbol)
do { p++; } while (p->Symbol != FoundState->Symbol);
- }
- else
+ }
+ else
p = &(pc->oneState());
LOOP_ENTRY:
- if (GetContext(p->GetSuccessor()) != UpBranch)
+ if (GetContext(p->GetSuccessor()) != UpBranch)
{
- pc = GetContext(p->GetSuccessor());
+ pc = GetContext(p->GetSuccessor());
break;
}
*pps++ = p;
- }
+ }
while ( pc->Suffix );
NO_LOOP:
- if (pps == ps)
+ if (pps == ps)
return pc;
UpState.Symbol = *(Byte*) UpBranch;
UpState.SetSuccessor(SubAllocator.GetOffset(UpBranch) + 1);
- if (pc->NumStats != 1)
+ if (pc->NumStats != 1)
{
if ((p = GetStateNoCheck(pc->Stats))->Symbol != UpState.Symbol)
do { p++; } while (p->Symbol != UpState.Symbol);
unsigned int cf = p->Freq-1;
unsigned int s0 = pc->SummFreq - pc->NumStats - cf;
- UpState.Freq = (Byte)(1 + ((2 * cf <= s0) ? (5 * cf > s0) :
+ UpState.Freq = (Byte)(1 + ((2 * cf <= s0) ? (5 * cf > s0) :
((2 * cf + 3 * s0 - 1) / (2 * s0))));
- }
- else
+ }
+ else
UpState.Freq = pc->oneState().Freq;
- do
+ do
{
pc = pc->createChild(SubAllocator, *--pps, UpState);
- if ( !pc )
+ if ( !pc )
return NULL;
- }
+ }
while (pps != ps);
return pc;
}
@@ -248,46 +248,46 @@ NO_LOOP:
PPM_CONTEXT::STATE fs = *FoundState, * p = NULL;
PPM_CONTEXT* pc, * Successor;
unsigned int ns1, ns, cf, sf, s0;
- if (fs.Freq < MAX_FREQ / 4 && MinContext->Suffix != 0)
+ if (fs.Freq < MAX_FREQ / 4 && MinContext->Suffix != 0)
{
pc = GetContextNoCheck(MinContext->Suffix);
- if (pc->NumStats != 1)
+ if (pc->NumStats != 1)
{
- if ((p = GetStateNoCheck(pc->Stats))->Symbol != fs.Symbol)
+ if ((p = GetStateNoCheck(pc->Stats))->Symbol != fs.Symbol)
{
do { p++; } while (p->Symbol != fs.Symbol);
- if (p[0].Freq >= p[-1].Freq)
+ if (p[0].Freq >= p[-1].Freq)
{
- _PPMD_SWAP(p[0],p[-1]);
+ _PPMD_SWAP(p[0],p[-1]);
p--;
}
}
- if (p->Freq < MAX_FREQ-9)
+ if (p->Freq < MAX_FREQ-9)
{
- p->Freq += 2;
+ p->Freq += 2;
pc->SummFreq += 2;
}
- }
- else
+ }
+ else
{
- p = &(pc->oneState());
+ p = &(pc->oneState());
p->Freq = (Byte)(p->Freq + ((p->Freq < 32) ? 1 : 0));
}
}
- if ( !OrderFall )
+ if ( !OrderFall )
{
MinContext = MaxContext = CreateSuccessors(true, p);
FoundState->SetSuccessor(SubAllocator.GetOffset(MinContext));
- if (MinContext == 0)
+ if (MinContext == 0)
goto RESTART_MODEL;
return;
}
- *SubAllocator.pText++ = fs.Symbol;
+ *SubAllocator.pText++ = fs.Symbol;
Successor = (PPM_CONTEXT*) SubAllocator.pText;
- if (SubAllocator.pText >= SubAllocator.UnitsStart)
+ if (SubAllocator.pText >= SubAllocator.UnitsStart)
goto RESTART_MODEL;
- if (fs.GetSuccessor() != 0)
+ if (fs.GetSuccessor() != 0)
{
if ((Byte *)GetContext(fs.GetSuccessor()) <= SubAllocator.pText)
{
@@ -296,60 +296,60 @@ NO_LOOP:
if (cs == NULL)
goto RESTART_MODEL;
}
- if ( !--OrderFall )
+ if ( !--OrderFall )
{
Successor = GetContext(fs.GetSuccessor());
SubAllocator.pText -= (MaxContext != MinContext);
}
- }
- else
+ }
+ else
{
- FoundState->SetSuccessor(SubAllocator.GetOffsetNoCheck(Successor));
+ FoundState->SetSuccessor(SubAllocator.GetOffsetNoCheck(Successor));
fs.SetSuccessor(SubAllocator.GetOffsetNoCheck(MinContext));
}
s0 = MinContext->SummFreq - (ns = MinContext->NumStats) - (fs.Freq - 1);
- for (pc = MaxContext; pc != MinContext; pc = GetContext(pc->Suffix))
+ for (pc = MaxContext; pc != MinContext; pc = GetContext(pc->Suffix))
{
- if ((ns1 = pc->NumStats) != 1)
+ if ((ns1 = pc->NumStats) != 1)
{
- if ((ns1 & 1) == 0)
+ if ((ns1 & 1) == 0)
{
void *ppp = SubAllocator.ExpandUnits(GetState(pc->Stats), ns1 >> 1);
pc->Stats = SubAllocator.GetOffset(ppp);
- if (!ppp)
+ if (!ppp)
goto RESTART_MODEL;
}
pc->SummFreq = (UInt16)(pc->SummFreq + (2 * ns1 < ns) + 2 * ((4 * ns1 <= ns) &
(pc->SummFreq <= 8 * ns1)));
- }
- else
+ }
+ else
{
p = (PPM_CONTEXT::STATE*) SubAllocator.AllocUnits(1);
- if ( !p )
+ if ( !p )
goto RESTART_MODEL;
- *p = pc->oneState();
+ *p = pc->oneState();
pc->Stats = SubAllocator.GetOffsetNoCheck(p);
- if (p->Freq < MAX_FREQ / 4 - 1)
+ if (p->Freq < MAX_FREQ / 4 - 1)
p->Freq <<= 1;
- else
+ else
p->Freq = MAX_FREQ - 4;
pc->SummFreq = (UInt16)(p->Freq + InitEsc + (ns > 3));
}
- cf = 2 * fs.Freq * (pc->SummFreq+6);
+ cf = 2 * fs.Freq * (pc->SummFreq+6);
sf = s0 + pc->SummFreq;
- if (cf < 6 * sf)
+ if (cf < 6 * sf)
{
cf = 1 + (cf > sf)+(cf >= 4 * sf);
pc->SummFreq += 3;
- }
- else
+ }
+ else
{
cf = 4 + (cf >= 9 * sf) + (cf >= 12 * sf) + (cf >= 15 * sf);
pc->SummFreq = (UInt16)(pc->SummFreq + cf);
}
- p = GetState(pc->Stats) + ns1;
+ p = GetState(pc->Stats) + ns1;
p->SetSuccessor(SubAllocator.GetOffset(Successor));
- p->Symbol = fs.Symbol;
+ p->Symbol = fs.Symbol;
p->Freq = (Byte)cf;
pc->NumStats = (UInt16)++ns1;
}
@@ -357,27 +357,27 @@ NO_LOOP:
return;
RESTART_MODEL:
RestartModelRare();
- EscCount = 0;
+ EscCount = 0;
PrintCount = 0xFF;
}
void ClearMask()
{
- EscCount = 1;
+ EscCount = 1;
memset(CharMask, 0, sizeof(CharMask));
- // if (++PrintCount == 0)
+ // if (++PrintCount == 0)
// PrintInfo(DecodedFile,EncodedFile);
}
void update1(PPM_CONTEXT::STATE* p)
{
- (FoundState = p)->Freq += 4;
+ (FoundState = p)->Freq += 4;
MinContext->SummFreq += 4;
- if (p[0].Freq > p[-1].Freq)
+ if (p[0].Freq > p[-1].Freq)
{
- _PPMD_SWAP(p[0],p[-1]);
+ _PPMD_SWAP(p[0],p[-1]);
FoundState = --p;
- if (p->Freq > MAX_FREQ)
+ if (p->Freq > MAX_FREQ)
rescale();
}
}
@@ -387,27 +387,27 @@ RESTART_MODEL:
{
(FoundState = p)->Freq += 4;
MinContext->SummFreq += 4;
- if (p->Freq > MAX_FREQ)
+ if (p->Freq > MAX_FREQ)
rescale();
- EscCount++;
+ EscCount++;
RunLength = InitRL;
}
SEE2_CONTEXT* makeEscFreq2(int Diff, UInt32 &scale)
{
SEE2_CONTEXT* psee2c;
- if (MinContext->NumStats != 256)
+ if (MinContext->NumStats != 256)
{
- psee2c = SEE2Cont[NS2Indx[Diff-1]] +
+ psee2c = SEE2Cont[NS2Indx[Diff-1]] +
(Diff < (GetContext(MinContext->Suffix))->NumStats - MinContext->NumStats) +
- 2 * (MinContext->SummFreq < 11 * MinContext->NumStats) +
- 4 * (NumMasked > Diff) +
+ 2 * (MinContext->SummFreq < 11 * MinContext->NumStats) +
+ 4 * (NumMasked > Diff) +
HiBitsFlag;
scale = psee2c->getMean();
- }
- else
+ }
+ else
{
- psee2c = &DummySEE2Cont;
+ psee2c = &DummySEE2Cont;
scale = 1;
}
return psee2c;
@@ -420,37 +420,37 @@ RESTART_MODEL:
int OldNS = MinContext->NumStats, i = MinContext->NumStats - 1, Adder, EscFreq;
PPM_CONTEXT::STATE* p1, * p;
PPM_CONTEXT::STATE *stats = GetStateNoCheck(MinContext->Stats);
- for (p = FoundState; p != stats; p--)
+ for (p = FoundState; p != stats; p--)
_PPMD_SWAP(p[0], p[-1]);
- stats->Freq += 4;
+ stats->Freq += 4;
MinContext->SummFreq += 4;
- EscFreq = MinContext->SummFreq - p->Freq;
+ EscFreq = MinContext->SummFreq - p->Freq;
Adder = (OrderFall != 0);
p->Freq = (Byte)((p->Freq + Adder) >> 1);
MinContext->SummFreq = p->Freq;
- do
+ do
{
EscFreq -= (++p)->Freq;
p->Freq = (Byte)((p->Freq + Adder) >> 1);
MinContext->SummFreq = (UInt16)(MinContext->SummFreq + p->Freq);
- if (p[0].Freq > p[-1].Freq)
+ if (p[0].Freq > p[-1].Freq)
{
PPM_CONTEXT::STATE tmp = *(p1 = p);
- do
- {
- p1[0] = p1[-1];
- }
+ do
+ {
+ p1[0] = p1[-1];
+ }
while (--p1 != stats && tmp.Freq > p1[-1].Freq);
*p1 = tmp;
}
- }
+ }
while ( --i );
- if (p->Freq == 0)
+ if (p->Freq == 0)
{
do { i++; } while ((--p)->Freq == 0);
EscFreq += i;
MinContext->NumStats = (UInt16)(MinContext->NumStats - i);
- if (MinContext->NumStats == 1)
+ if (MinContext->NumStats == 1)
{
PPM_CONTEXT::STATE tmp = *stats;
do { tmp.Freq = (Byte)(tmp.Freq - (tmp.Freq >> 1)); EscFreq >>= 1; } while (EscFreq > 1);
@@ -471,10 +471,10 @@ RESTART_MODEL:
PPM_CONTEXT *c = GetContext(FoundState->GetSuccessor());
if (!OrderFall && (Byte *)c > SubAllocator.pText)
MinContext = MaxContext = c;
- else
+ else
{
UpdateModel();
- if (EscCount == 0)
+ if (EscCount == 0)
ClearMask();
}
}
diff --git a/CPP/7zip/Compress/PPMD/PPMDDecode.h b/CPP/7zip/Compress/PPMD/PPMDDecode.h
index b05d8ee0..1df2c9cd 100755
--- a/CPP/7zip/Compress/PPMD/PPMDDecode.h
+++ b/CPP/7zip/Compress/PPMD/PPMDDecode.h
@@ -30,23 +30,23 @@ struct CDecodeInfo: public CInfo
{
void DecodeBinSymbol(CRangeDecoderVirt *rangeDecoder)
{
- PPM_CONTEXT::STATE& rs = MinContext->oneState();
+ PPM_CONTEXT::STATE& rs = MinContext->oneState();
UInt16& bs = GetBinSumm(rs, GetContextNoCheck(MinContext->Suffix)->NumStats);
- if (rangeDecoder->DecodeBit(bs, TOT_BITS) == 0)
+ if (rangeDecoder->DecodeBit(bs, TOT_BITS) == 0)
{
FoundState = &rs;
rs.Freq = (Byte)(rs.Freq + (rs.Freq < 128 ? 1: 0));
bs = (UInt16)(bs + INTERVAL - GET_MEAN(bs, PERIOD_BITS, 2));
PrevSuccess = 1;
RunLength++;
- }
- else
+ }
+ else
{
bs = (UInt16)(bs - GET_MEAN(bs, PERIOD_BITS, 2));
InitEsc = ExpEscape[bs >> 10];
- NumMasked = 1;
+ NumMasked = 1;
CharMask[rs.Symbol] = EscCount;
- PrevSuccess = 0;
+ PrevSuccess = 0;
FoundState = NULL;
}
}
@@ -55,12 +55,12 @@ struct CDecodeInfo: public CInfo
{
PPM_CONTEXT::STATE* p = GetStateNoCheck(MinContext->Stats);
int i, count, hiCnt;
- if ((count = rangeDecoder->GetThreshold(MinContext->SummFreq)) < (hiCnt = p->Freq))
+ if ((count = rangeDecoder->GetThreshold(MinContext->SummFreq)) < (hiCnt = p->Freq))
{
PrevSuccess = (2 * hiCnt > MinContext->SummFreq);
RunLength += PrevSuccess;
rangeDecoder->Decode(0, p->Freq); // MinContext->SummFreq);
- (FoundState = p)->Freq = (Byte)(hiCnt += 4);
+ (FoundState = p)->Freq = (Byte)(hiCnt += 4);
MinContext->SummFreq += 4;
if (hiCnt > MAX_FREQ)
rescale();
@@ -69,12 +69,12 @@ struct CDecodeInfo: public CInfo
PrevSuccess = 0;
i = MinContext->NumStats - 1;
while ((hiCnt += (++p)->Freq) <= count)
- if (--i == 0)
+ if (--i == 0)
{
HiBitsFlag = HB2Flag[FoundState->Symbol];
rangeDecoder->Decode(hiCnt, MinContext->SummFreq - hiCnt); // , MinContext->SummFreq);
CharMask[p->Symbol] = EscCount;
- i = (NumMasked = MinContext->NumStats)-1;
+ i = (NumMasked = MinContext->NumStats)-1;
FoundState = NULL;
do { CharMask[(--p)->Symbol] = EscCount; } while ( --i );
return;
@@ -91,57 +91,57 @@ struct CDecodeInfo: public CInfo
SEE2_CONTEXT* psee2c = makeEscFreq2(i, freqSum);
PPM_CONTEXT::STATE* ps[256], ** pps = ps, * p = GetStateNoCheck(MinContext->Stats)-1;
hiCnt = 0;
- do
+ do
{
do { p++; } while (CharMask[p->Symbol] == EscCount);
- hiCnt += p->Freq;
+ hiCnt += p->Freq;
*pps++ = p;
- }
+ }
while ( --i );
freqSum += hiCnt;
count = rangeDecoder->GetThreshold(freqSum);
p = *(pps = ps);
- if (count < hiCnt)
+ if (count < hiCnt)
{
hiCnt = 0;
- while ((hiCnt += p->Freq) <= count)
+ while ((hiCnt += p->Freq) <= count)
p=*++pps;
rangeDecoder->Decode(hiCnt - p->Freq, p->Freq); // , freqSum);
- psee2c->update();
+ psee2c->update();
update2(p);
- }
- else
+ }
+ else
{
rangeDecoder->Decode(hiCnt, freqSum - hiCnt); // , freqSum);
- i = MinContext->NumStats - NumMasked;
+ i = MinContext->NumStats - NumMasked;
pps--;
do { CharMask[(*++pps)->Symbol] = EscCount; } while ( --i );
- psee2c->Summ = (UInt16)(psee2c->Summ + freqSum);
+ psee2c->Summ = (UInt16)(psee2c->Summ + freqSum);
NumMasked = MinContext->NumStats;
}
}
int DecodeSymbol(CRangeDecoderVirt *rangeDecoder)
{
- if (MinContext->NumStats != 1)
+ if (MinContext->NumStats != 1)
DecodeSymbol1(rangeDecoder);
- else
+ else
DecodeBinSymbol(rangeDecoder);
- while ( !FoundState )
+ while ( !FoundState )
{
- do
+ do
{
- OrderFall++;
+ OrderFall++;
MinContext = GetContext(MinContext->Suffix);
- if (MinContext == 0)
+ if (MinContext == 0)
return -1;
- }
+ }
while (MinContext->NumStats == NumMasked);
- DecodeSymbol2(rangeDecoder);
+ DecodeSymbol2(rangeDecoder);
}
Byte symbol = FoundState->Symbol;
NextContext();
diff --git a/CPP/7zip/Compress/PPMD/PPMDDecoder.cpp b/CPP/7zip/Compress/PPMD/PPMDDecoder.cpp
index f24c2408..cbb7e786 100755
--- a/CPP/7zip/Compress/PPMD/PPMDDecoder.cpp
+++ b/CPP/7zip/Compress/PPMD/PPMDDecoder.cpp
@@ -27,7 +27,7 @@ STDMETHODIMP CDecoder::SetDecoderProperties2(const Byte *properties, UInt32 size
if (!_rangeDecoder.Create(1 << 20))
return E_OUTOFMEMORY;
- if (!_info.SubAllocator.StartSubAllocator(_usedMemorySize))
+ if (!_info.SubAllocator.StartSubAllocator(_usedMemorySize))
return E_OUTOFMEMORY;
return S_OK;
@@ -123,7 +123,7 @@ STDMETHODIMP CDecoder::CodeReal(ISequentialInStream *inStream,
#else
-#define PPMD_TRY_BEGIN try {
+#define PPMD_TRY_BEGIN try {
#define PPMD_TRY_END } \
catch(const CInBufferException &e) { return e.ErrorCode; } \
catch(const COutBufferException &e) { return e.ErrorCode; } \
diff --git a/CPP/7zip/Compress/PPMD/PPMDDecoder.h b/CPP/7zip/Compress/PPMD/PPMDDecoder.h
index cbb88ad5..7c7201bf 100755
--- a/CPP/7zip/Compress/PPMD/PPMDDecoder.h
+++ b/CPP/7zip/Compress/PPMD/PPMDDecoder.h
@@ -14,7 +14,7 @@
namespace NCompress {
namespace NPPMD {
-class CDecoder :
+class CDecoder :
public ICompressCoder,
public ICompressSetDecoderProperties2,
#ifndef NO_READ_FROM_CODER
@@ -43,9 +43,9 @@ public:
#ifndef NO_READ_FROM_CODER
MY_UNKNOWN_IMP4(
- ICompressSetDecoderProperties2,
- ICompressSetInStream,
- ICompressSetOutStreamSize,
+ ICompressSetDecoderProperties2,
+ ICompressSetInStream,
+ ICompressSetOutStreamSize,
ISequentialInStream)
#else
MY_UNKNOWN_IMP1(
@@ -61,7 +61,7 @@ public:
HRESULT Flush() { return _outStream.Flush(); }
STDMETHOD(CodeReal)(ISequentialInStream *inStream,
- ISequentialOutStream *outStream,
+ ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress);
diff --git a/CPP/7zip/Compress/PPMD/PPMDEncode.h b/CPP/7zip/Compress/PPMD/PPMDEncode.h
index 6a720cac..1e9d907c 100755
--- a/CPP/7zip/Compress/PPMD/PPMDEncode.h
+++ b/CPP/7zip/Compress/PPMD/PPMDEncode.h
@@ -14,9 +14,9 @@ struct CEncodeInfo: public CInfo
void EncodeBinSymbol(int symbol, NRangeCoder::CEncoder *rangeEncoder)
{
- PPM_CONTEXT::STATE& rs = MinContext->oneState();
+ PPM_CONTEXT::STATE& rs = MinContext->oneState();
UInt16 &bs = GetBinSumm(rs, GetContextNoCheck(MinContext->Suffix)->NumStats);
- if (rs.Symbol == symbol)
+ if (rs.Symbol == symbol)
{
FoundState = &rs;
rs.Freq = (Byte)(rs.Freq + (rs.Freq < 128 ? 1: 0));
@@ -24,15 +24,15 @@ struct CEncodeInfo: public CInfo
bs = (UInt16)(bs + INTERVAL - GET_MEAN(bs, PERIOD_BITS, 2));
PrevSuccess = 1;
RunLength++;
- }
- else
+ }
+ else
{
rangeEncoder->EncodeBit(bs, TOT_BITS, 1);
bs = (UInt16)(bs - GET_MEAN(bs, PERIOD_BITS, 2));
InitEsc = ExpEscape[bs >> 10];
- NumMasked = 1;
+ NumMasked = 1;
CharMask[rs.Symbol] = EscCount;
- PrevSuccess = 0;
+ PrevSuccess = 0;
FoundState = NULL;
}
}
@@ -40,27 +40,27 @@ struct CEncodeInfo: public CInfo
void EncodeSymbol1(int symbol, NRangeCoder::CEncoder *rangeEncoder)
{
PPM_CONTEXT::STATE* p = GetStateNoCheck(MinContext->Stats);
- if (p->Symbol == symbol)
+ if (p->Symbol == symbol)
{
PrevSuccess = (2 * (p->Freq) > MinContext->SummFreq);
RunLength += PrevSuccess;
rangeEncoder->Encode(0, p->Freq, MinContext->SummFreq);
- (FoundState = p)->Freq += 4;
+ (FoundState = p)->Freq += 4;
MinContext->SummFreq += 4;
- if (p->Freq > MAX_FREQ)
+ if (p->Freq > MAX_FREQ)
rescale();
return;
}
PrevSuccess = 0;
int LoCnt = p->Freq, i = MinContext->NumStats - 1;
- while ((++p)->Symbol != symbol)
+ while ((++p)->Symbol != symbol)
{
LoCnt += p->Freq;
- if (--i == 0)
+ if (--i == 0)
{
HiBitsFlag = HB2Flag[FoundState->Symbol];
CharMask[p->Symbol] = EscCount;
- i=(NumMasked = MinContext->NumStats)-1;
+ i=(NumMasked = MinContext->NumStats)-1;
FoundState = NULL;
do { CharMask[(--p)->Symbol] = EscCount; } while ( --i );
rangeEncoder->Encode(LoCnt, MinContext->SummFreq - LoCnt, MinContext->SummFreq);
@@ -76,16 +76,16 @@ struct CEncodeInfo: public CInfo
int hiCnt, i = MinContext->NumStats - NumMasked;
UInt32 scale;
SEE2_CONTEXT* psee2c = makeEscFreq2(i, scale);
- PPM_CONTEXT::STATE* p = GetStateNoCheck(MinContext->Stats) - 1;
+ PPM_CONTEXT::STATE* p = GetStateNoCheck(MinContext->Stats) - 1;
hiCnt = 0;
- do
+ do
{
do { p++; } while (CharMask[p->Symbol] == EscCount);
hiCnt += p->Freq;
- if (p->Symbol == symbol)
+ if (p->Symbol == symbol)
goto SYMBOL_FOUND;
CharMask[p->Symbol] = EscCount;
- }
+ }
while ( --i );
rangeEncoder->Encode(hiCnt, scale, hiCnt + scale);
@@ -98,40 +98,40 @@ SYMBOL_FOUND:
UInt32 highCount = hiCnt;
UInt32 lowCount = highCount - p->Freq;
- if ( --i )
+ if ( --i )
{
PPM_CONTEXT::STATE* p1 = p;
- do
+ do
{
do { p1++; } while (CharMask[p1->Symbol] == EscCount);
hiCnt += p1->Freq;
- }
+ }
while ( --i );
}
// SubRange.scale += hiCnt;
scale += hiCnt;
rangeEncoder->Encode(lowCount, highCount - lowCount, scale);
- psee2c->update();
+ psee2c->update();
update2(p);
}
void EncodeSymbol(int c, NRangeCoder::CEncoder *rangeEncoder)
{
- if (MinContext->NumStats != 1)
- EncodeSymbol1(c, rangeEncoder);
- else
- EncodeBinSymbol(c, rangeEncoder);
- while ( !FoundState )
+ if (MinContext->NumStats != 1)
+ EncodeSymbol1(c, rangeEncoder);
+ else
+ EncodeBinSymbol(c, rangeEncoder);
+ while ( !FoundState )
{
- do
+ do
{
- OrderFall++;
+ OrderFall++;
MinContext = GetContext(MinContext->Suffix);
- if (MinContext == 0)
+ if (MinContext == 0)
return; // S_OK;
- }
+ }
while (MinContext->NumStats == NumMasked);
- EncodeSymbol2(c, rangeEncoder);
+ EncodeSymbol2(c, rangeEncoder);
}
NextContext();
}
diff --git a/CPP/7zip/Compress/PPMD/PPMDEncoder.cpp b/CPP/7zip/Compress/PPMD/PPMDEncoder.cpp
index cefd2478..c4cd1df2 100755
--- a/CPP/7zip/Compress/PPMD/PPMDEncoder.cpp
+++ b/CPP/7zip/Compress/PPMD/PPMDEncoder.cpp
@@ -16,7 +16,7 @@
namespace NCompress {
namespace NPPMD {
-const UInt32 kMinMemSize = (1 << 11);
+const UInt32 kMinMemSize = (1 << 11);
const UInt32 kMinOrder = 2;
/*
@@ -31,7 +31,7 @@ class CCounter
{
public:
CCounter() {}
- ~CCounter()
+ ~CCounter()
{
ofstream ofs("Res.dat");
ofs << "innerEncode1 = " << setw(10) << g_NumInner << endl;
@@ -45,7 +45,7 @@ public:
CCounter g_Counter;
*/
-STDMETHODIMP CEncoder::SetCoderProperties(const PROPID *propIDs,
+STDMETHODIMP CEncoder::SetCoderProperties(const PROPID *propIDs,
const PROPVARIANT *properties, UInt32 numProperties)
{
for (UInt32 i = 0; i < numProperties; i++)
@@ -75,7 +75,7 @@ STDMETHODIMP CEncoder::SetCoderProperties(const PROPID *propIDs,
}
STDMETHODIMP CEncoder::WriteCoderProperties(ISequentialOutStream *outStream)
-{
+{
const UInt32 kPropSize = 5;
Byte properties[kPropSize];
properties[0] = _order;
@@ -95,7 +95,7 @@ CEncoder::CEncoder():
HRESULT CEncoder::CodeReal(ISequentialInStream *inStream,
- ISequentialOutStream *outStream,
+ ISequentialOutStream *outStream,
const UInt64 * /* inSize */, const UInt64 * /* outSize */,
ICompressProgressInfo *progress)
{
@@ -103,7 +103,7 @@ HRESULT CEncoder::CodeReal(ISequentialInStream *inStream,
return E_OUTOFMEMORY;
if (!_rangeEncoder.Create(1 << 20))
return E_OUTOFMEMORY;
- if (!_info.SubAllocator.StartSubAllocator(_usedMemorySize))
+ if (!_info.SubAllocator.StartSubAllocator(_usedMemorySize))
return E_OUTOFMEMORY;
_inStream.SetStream(inStream);
@@ -125,12 +125,12 @@ HRESULT CEncoder::CodeReal(ISequentialInStream *inStream,
Byte symbol;
if (!_inStream.ReadByte(symbol))
{
- // here we can write End Mark for stream version.
+ // here we can write End Mark for stream version.
// In current version this feature is not used.
- // _info.EncodeSymbol(-1, &_rangeEncoder);
+ // _info.EncodeSymbol(-1, &_rangeEncoder);
return S_OK;
}
- _info.EncodeSymbol(symbol, &_rangeEncoder);
+ _info.EncodeSymbol(symbol, &_rangeEncoder);
}
while (--size != 0);
if (progress != NULL)
diff --git a/CPP/7zip/Compress/PPMD/PPMDEncoder.h b/CPP/7zip/Compress/PPMD/PPMDEncoder.h
index 915180b9..0c027ff0 100755
--- a/CPP/7zip/Compress/PPMD/PPMDEncoder.h
+++ b/CPP/7zip/Compress/PPMD/PPMDEncoder.h
@@ -14,7 +14,7 @@
namespace NCompress {
namespace NPPMD {
-class CEncoder :
+class CEncoder :
public ICompressCoder,
public ICompressSetCoderProperties,
public ICompressWriteCoderProperties,
@@ -67,7 +67,7 @@ public:
ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress);
- STDMETHOD(SetCoderProperties)(const PROPID *propIDs,
+ STDMETHOD(SetCoderProperties)(const PROPID *propIDs,
const PROPVARIANT *properties, UInt32 numProperties);
STDMETHOD(WriteCoderProperties)(ISequentialOutStream *outStream);
diff --git a/CPP/7zip/Compress/PPMD/PPMDSubAlloc.h b/CPP/7zip/Compress/PPMD/PPMDSubAlloc.h
index 5162f0a1..480ffa13 100755
--- a/CPP/7zip/Compress/PPMD/PPMDSubAlloc.h
+++ b/CPP/7zip/Compress/PPMD/PPMDSubAlloc.h
@@ -6,8 +6,8 @@
#include "PPMDType.h"
-extern "C"
-{
+extern "C"
+{
#include "../../../../C/Alloc.h"
}
@@ -19,19 +19,19 @@ const UINT UNIT_SIZE=12, N_INDEXES=N1+N2+N3+N4;
const UInt32 kExtraSize = (UNIT_SIZE * 3);
const UInt32 kMaxMemBlockSize = 0xFFFFFFFF - kExtraSize;
-struct MEM_BLK
+struct MEM_BLK
{
UInt16 Stamp, NU;
UInt32 Next, Prev;
- void InsertAt(Byte *Base, UInt32 p)
+ void InsertAt(Byte *Base, UInt32 p)
{
Prev = p;
MEM_BLK *pp = (MEM_BLK *)(Base + p);
Next = pp->Next;
pp->Next = ((MEM_BLK *)(Base + Next))->Prev = (UInt32)((Byte *)this - Base);
}
- void Remove(Byte *Base)
- {
+ void Remove(Byte *Base)
+ {
((MEM_BLK *)(Base + Prev))->Next = Next;
((MEM_BLK *)(Base + Next))->Prev = Prev;
}
@@ -71,13 +71,13 @@ public:
MEM_BLK *GetBlk(UInt32 offset) const { return (MEM_BLK *)(Base + offset); }
UInt32 *GetNode(UInt32 offset) const { return (UInt32 *)(Base + offset); }
- void InsertNode(void* p, int indx)
+ void InsertNode(void* p, int indx)
{
*(UInt32 *)p = FreeList[indx];
FreeList[indx] = GetOffsetNoCheck(p);
}
- void* RemoveNode(int indx)
+ void* RemoveNode(int indx)
{
UInt32 offset = FreeList[indx];
UInt32 *p = GetNode(offset);
@@ -91,7 +91,7 @@ public:
{
int i, UDiff = Indx2Units[oldIndx] - Indx2Units[newIndx];
Byte* p = ((Byte*)pv) + U2B(Indx2Units[newIndx]);
- if (Indx2Units[i = Units2Indx[UDiff-1]] != UDiff)
+ if (Indx2Units[i = Units2Indx[UDiff-1]] != UDiff)
{
InsertNode(p, --i);
p += U2B(i = Indx2Units[i]);
@@ -103,7 +103,7 @@ public:
UInt32 GetUsedMemory() const
{
UInt32 RetVal = SubAllocatorSize - (UInt32)(HiUnit - LoUnit) - (UInt32)(UnitsStart - pText);
- for (UInt32 i = 0; i < N_INDEXES; i++)
+ for (UInt32 i = 0; i < N_INDEXES; i++)
for (UInt32 pn = FreeList[i]; pn != 0; RetVal -= (UInt32)Indx2Units[i] * UNIT_SIZE)
pn = *GetNode(pn);
return (RetVal >> 2);
@@ -111,9 +111,9 @@ public:
UInt32 GetSubAllocatorSize() const { return SubAllocatorSize; }
- void StopSubAllocator()
+ void StopSubAllocator()
{
- if (SubAllocatorSize != 0)
+ if (SubAllocatorSize != 0)
{
BigFree(Base);
SubAllocatorSize = 0;
@@ -123,7 +123,7 @@ public:
bool StartSubAllocator(UInt32 size)
{
- if (SubAllocatorSize == size)
+ if (SubAllocatorSize == size)
return true;
StopSubAllocator();
if (size == 0)
@@ -134,7 +134,7 @@ public:
return false;
HeapStart = Base + UNIT_SIZE; // we need such code to support NULL;
}
- SubAllocatorSize = size;
+ SubAllocatorSize = size;
return true;
}
@@ -150,7 +150,7 @@ public:
for (k++; i < N1 + N2 + N3 ;i++,k += 3) Indx2Units[i] = (Byte)k;
for (k++; i < N1 + N2 + N3 + N4; i++, k += 4) Indx2Units[i] = (Byte)k;
GlueCount = 0;
- for (k = i = 0; k < 128; k++)
+ for (k = i = 0; k < 128; k++)
{
i += (Indx2Units[i] < k+1);
Units2Indx[k] = (Byte)i;
@@ -173,7 +173,7 @@ public:
ps0->Next = ps0->Prev = s0;
for (i = 0; i < N_INDEXES; i++)
- while (FreeList[i] != 0)
+ while (FreeList[i] != 0)
{
MEM_BLK *pp = (MEM_BLK *)RemoveNode(i);
pp->InsertAt(Base, s0);
@@ -192,14 +192,14 @@ public:
pp->NU = (UInt16)(pp->NU + pp1->NU);
}
}
- while ((p = ps0->Next) != s0)
+ while ((p = ps0->Next) != s0)
{
MEM_BLK *pp = GetBlk(p);
pp->Remove(Base);
int sz;
for (sz = pp->NU; sz > 128; sz -= 128, p += 128 * UNIT_SIZE)
InsertNode(Base + p, N_INDEXES - 1);
- if (Indx2Units[i = Units2Indx[sz-1]] != sz)
+ if (Indx2Units[i = Units2Indx[sz-1]] != sz)
{
int k = sz - Indx2Units[--i];
InsertNode(Base + p + (sz - k) * UNIT_SIZE, k - 1);
@@ -209,7 +209,7 @@ public:
}
void* AllocUnitsRare(int indx)
{
- if ( !GlueCount )
+ if ( !GlueCount )
{
GlueCount = 255;
GlueFreeBlocks();
@@ -217,11 +217,11 @@ public:
return RemoveNode(indx);
}
int i = indx;
- do
+ do
{
- if (++i == N_INDEXES)
+ if (++i == N_INDEXES)
{
- GlueCount--;
+ GlueCount--;
i = U2B(Indx2Units[indx]);
return (UnitsStart - pText > i) ? (UnitsStart -= i) : (NULL);
}
@@ -259,9 +259,9 @@ public:
if (i0 == i1)
return oldPtr;
void* ptr = AllocUnits(oldNU + 1);
- if (ptr)
+ if (ptr)
{
- memcpy(ptr, oldPtr, U2B(oldNU));
+ memcpy(ptr, oldPtr, U2B(oldNU));
InsertNode(oldPtr, i0);
}
return ptr;
@@ -272,14 +272,14 @@ public:
int i0 = Units2Indx[oldNU - 1], i1 = Units2Indx[newNU - 1];
if (i0 == i1)
return oldPtr;
- if (FreeList[i1] != 0)
+ if (FreeList[i1] != 0)
{
void* ptr = RemoveNode(i1);
memcpy(ptr, oldPtr, U2B(newNU));
- InsertNode(oldPtr,i0);
+ InsertNode(oldPtr,i0);
return ptr;
- }
- else
+ }
+ else
{
SplitBlock(oldPtr, i0, i1);
return oldPtr;
diff --git a/CPP/7zip/Compress/PPMD/PPMDType.h b/CPP/7zip/Compress/PPMD/PPMDType.h
index 5200fa54..aec68095 100755
--- a/CPP/7zip/Compress/PPMD/PPMDType.h
+++ b/CPP/7zip/Compress/PPMD/PPMDType.h
@@ -3,7 +3,7 @@
* Written and distributed to public domain by Dmitry Shkarin 1997, *
* 1999-2001 *
* Contents: compilation parameters and miscelaneous definitions *
- * Comments: system & compiler dependent file
+ * Comments: system & compiler dependent file
* modified by Igor Pavlov (2004-08-29).
****************************************************************************/
diff --git a/CPP/7zip/Compress/PPMD/StdAfx.cpp b/CPP/7zip/Compress/PPMD/StdAfx.cpp
deleted file mode 100755
index d0feea85..00000000
--- a/CPP/7zip/Compress/PPMD/StdAfx.cpp
+++ /dev/null
@@ -1,3 +0,0 @@
-// StdAfx.cpp
-
-#include "StdAfx.h"
diff --git a/CPP/7zip/Compress/Quantum/QuantumDecoder.cpp b/CPP/7zip/Compress/Quantum/QuantumDecoder.cpp
index e870292d..03425578 100755
--- a/CPP/7zip/Compress/Quantum/QuantumDecoder.cpp
+++ b/CPP/7zip/Compress/Quantum/QuantumDecoder.cpp
@@ -62,7 +62,7 @@ HRESULT CDecoder::CodeSpec(UInt32 curSize)
_outWindowStream.PutByte(b);
curSize--;
}
- else
+ else
{
selector -= kNumLitSelectors;
unsigned int len = selector + kMatchMinLen;
@@ -105,7 +105,7 @@ HRESULT CDecoder::CodeSpec(UInt32 curSize)
}
HRESULT CDecoder::CodeReal(ISequentialInStream *inStream,
- ISequentialOutStream *outStream,
+ ISequentialOutStream *outStream,
const UInt64 *, const UInt64 *outSize,
ICompressProgressInfo *progress)
{
@@ -134,7 +134,7 @@ HRESULT CDecoder::CodeReal(ISequentialInStream *inStream,
UInt64 nowPos64 = _outWindowStream.GetProcessedSize() - start;
RINOK(progress->SetRatioInfo(&inSize, &nowPos64));
}
- }
+ }
flusher.NeedFlush = false;
return Flush();
}
diff --git a/CPP/7zip/Compress/Quantum/QuantumDecoder.h b/CPP/7zip/Compress/Quantum/QuantumDecoder.h
index 8b5aaaba..5871f536 100755
--- a/CPP/7zip/Compress/Quantum/QuantumDecoder.h
+++ b/CPP/7zip/Compress/Quantum/QuantumDecoder.h
@@ -26,7 +26,7 @@ public:
void Init()
{
m_Stream.Init();
- m_Value = 0x10000;
+ m_Value = 0x10000;
}
UInt64 GetProcessedSize() const { return m_Stream.GetProcessedSize(); }
@@ -45,7 +45,7 @@ public:
{
UInt32 res = 0;
do
- res = (res << 1) | ReadBit();
+ res = (res << 1) | ReadBit();
while(--numBits != 0);
return res;
}
@@ -98,7 +98,7 @@ public:
UInt64 GetProcessedSize() const { return Stream.GetProcessedSize(); }
- UInt32 GetThreshold(UInt32 total) const
+ UInt32 GetThreshold(UInt32 total) const
{
return ((Code + 1) * total - 1) / Range; // & 0xFFFF is not required;
}
@@ -111,9 +111,9 @@ public:
Low += offset;
for (;;)
{
- if ((Low & 0x8000) != (high & 0x8000))
+ if ((Low & 0x8000) != (high & 0x8000))
{
- if ((Low & 0x4000) == 0 || (high & 0x4000) != 0)
+ if ((Low & 0x4000) == 0 || (high & 0x4000) != 0)
break;
Low &= 0x3FFF;
high |= 0x4000;
@@ -156,7 +156,7 @@ public:
unsigned int i;
for (i = 1; Freqs[i] > threshold; i++);
rangeDecoder->Decode(Freqs[i], Freqs[i - 1], Freqs[0]);
- unsigned int res = Values[--i];
+ unsigned int res = Values[--i];
do
Freqs[i] += kUpdateStep;
while(i-- != 0);
@@ -201,7 +201,7 @@ public:
}
-class CDecoder:
+class CDecoder:
public ICompressCoder,
public ICompressSetInStream,
public ICompressSetOutStreamSize,
@@ -231,7 +231,7 @@ class CDecoder:
HRESULT CodeSpec(UInt32 size);
public:
MY_UNKNOWN_IMP2(
- ICompressSetInStream,
+ ICompressSetInStream,
ICompressSetOutStreamSize)
void ReleaseStreams()
@@ -246,15 +246,15 @@ public:
public:
bool NeedFlush;
CDecoderFlusher(CDecoder *decoder): _decoder(decoder), NeedFlush(true) {}
- ~CDecoderFlusher()
- {
+ ~CDecoderFlusher()
+ {
if (NeedFlush)
_decoder->Flush();
- _decoder->ReleaseStreams();
+ _decoder->ReleaseStreams();
}
};
- HRESULT Flush() { return _outWindowStream.Flush(); }
+ HRESULT Flush() { return _outWindowStream.Flush(); }
HRESULT CodeReal(ISequentialInStream *inStream,
ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
diff --git a/CPP/7zip/Compress/RangeCoder/RangeCoder.h b/CPP/7zip/Compress/RangeCoder/RangeCoder.h
index 0a6b4064..b79c0fc8 100755
--- a/CPP/7zip/Compress/RangeCoder/RangeCoder.h
+++ b/CPP/7zip/Compress/RangeCoder/RangeCoder.h
@@ -34,7 +34,7 @@ public:
void FlushData()
{
- // Low += 1;
+ // Low += 1;
for(int i = 0; i < 5; i++)
ShiftLow();
}
@@ -56,7 +56,7 @@ public:
void ShiftLow()
{
- if ((UInt32)Low < (UInt32)0xFF000000 || (int)(Low >> 32) != 0)
+ if ((UInt32)Low < (UInt32)0xFF000000 || (int)(Low >> 32) != 0)
{
Byte temp = _cache;
do
@@ -65,10 +65,10 @@ public:
temp = 0xFF;
}
while(--_cacheSize != 0);
- _cache = (Byte)((UInt32)Low >> 24);
- }
- _cacheSize++;
- Low = (UInt32)Low << 8;
+ _cache = (Byte)((UInt32)Low >> 24);
+ }
+ _cacheSize++;
+ Low = (UInt32)Low << 8;
}
void EncodeDirectBits(UInt32 value, int numBits)
@@ -149,7 +149,7 @@ public:
UInt32 DecodeDirectBits(int numTotalBits)
{
UInt32 range = Range;
- UInt32 code = Code;
+ UInt32 code = Code;
UInt32 result = 0;
for (int i = numTotalBits; i != 0; i--)
{
@@ -169,7 +169,7 @@ public:
if (range < kTopValue)
{
code = (code << 8) | Stream.ReadByte();
- range <<= 8;
+ range <<= 8;
}
}
Range = range;
diff --git a/CPP/7zip/Compress/RangeCoder/RangeCoderBit.cpp b/CPP/7zip/Compress/RangeCoder/RangeCoderBit.cpp
index 9a7c0a05..2bfae0b8 100755
--- a/CPP/7zip/Compress/RangeCoder/RangeCoderBit.cpp
+++ b/CPP/7zip/Compress/RangeCoder/RangeCoderBit.cpp
@@ -9,7 +9,7 @@ namespace NRangeCoder {
UInt32 ProbPrices[kBitModelTotal >> kNumMoveReducingBits];
-struct CPriceTables { CPriceTables()
+struct CPriceTables { CPriceTables()
{
for (UInt32 i = (1 << kNumMoveReducingBits) / 2; i < kBitModelTotal; i += (1 << kNumMoveReducingBits))
{
diff --git a/CPP/7zip/Compress/RangeCoder/RangeCoderBitTree.h b/CPP/7zip/Compress/RangeCoder/RangeCoderBitTree.h
index 97dd9b38..ee47eaad 100755
--- a/CPP/7zip/Compress/RangeCoder/RangeCoderBitTree.h
+++ b/CPP/7zip/Compress/RangeCoder/RangeCoderBitTree.h
@@ -108,7 +108,7 @@ public:
};
template <int numMoveBits>
-void ReverseBitTreeEncode(CBitEncoder<numMoveBits> *Models,
+void ReverseBitTreeEncode(CBitEncoder<numMoveBits> *Models,
CEncoder *rangeEncoder, int NumBitLevels, UInt32 symbol)
{
UInt32 modelIndex = 1;
@@ -122,7 +122,7 @@ void ReverseBitTreeEncode(CBitEncoder<numMoveBits> *Models,
}
template <int numMoveBits>
-UInt32 ReverseBitTreeGetPrice(CBitEncoder<numMoveBits> *Models,
+UInt32 ReverseBitTreeGetPrice(CBitEncoder<numMoveBits> *Models,
UInt32 NumBitLevels, UInt32 symbol)
{
UInt32 price = 0;
@@ -138,7 +138,7 @@ UInt32 ReverseBitTreeGetPrice(CBitEncoder<numMoveBits> *Models,
}
template <int numMoveBits>
-UInt32 ReverseBitTreeDecode(CBitDecoder<numMoveBits> *Models,
+UInt32 ReverseBitTreeDecode(CBitDecoder<numMoveBits> *Models,
CDecoder *rangeDecoder, int NumBitLevels)
{
UInt32 modelIndex = 1;
diff --git a/CPP/7zip/Compress/RangeCoder/RangeCoderOpt.h b/CPP/7zip/Compress/RangeCoder/RangeCoderOpt.h
index 668b9a5b..57792776 100755
--- a/CPP/7zip/Compress/RangeCoder/RangeCoderOpt.h
+++ b/CPP/7zip/Compress/RangeCoder/RangeCoderOpt.h
@@ -5,7 +5,7 @@
#define RC_INIT_VAR \
UInt32 range = rangeDecoder->Range; \
- UInt32 code = rangeDecoder->Code;
+ UInt32 code = rangeDecoder->Code;
#define RC_FLUSH_VAR \
rangeDecoder->Range = range; \
diff --git a/CPP/7zip/Compress/Rar/Rar1Decoder.cpp b/CPP/7zip/Compress/Rar/Rar1Decoder.cpp
index 0998a3f2..38d4f4a9 100755
--- a/CPP/7zip/Compress/Rar/Rar1Decoder.cpp
+++ b/CPP/7zip/Compress/Rar/Rar1Decoder.cpp
@@ -1,5 +1,5 @@
// Rar1Decoder.cpp
-// According to unRAR license, this code may not be used to develop
+// According to unRAR license, this code may not be used to develop
// a program that creates RAR archives
#include "StdAfx.h"
diff --git a/CPP/7zip/Compress/Rar/Rar1Decoder.h b/CPP/7zip/Compress/Rar/Rar1Decoder.h
index 840b466d..185ef10a 100755
--- a/CPP/7zip/Compress/Rar/Rar1Decoder.h
+++ b/CPP/7zip/Compress/Rar/Rar1Decoder.h
@@ -1,5 +1,5 @@
// Rar15Decoder.h
-// According to unRAR license, this code may not be used to develop
+// According to unRAR license, this code may not be used to develop
// a program that creates RAR archives
#ifndef __RAR10_DECODER_H
diff --git a/CPP/7zip/Compress/Rar/Rar2Decoder.cpp b/CPP/7zip/Compress/Rar/Rar2Decoder.cpp
index 28d50213..ed10a408 100755
--- a/CPP/7zip/Compress/Rar/Rar2Decoder.cpp
+++ b/CPP/7zip/Compress/Rar/Rar2Decoder.cpp
@@ -1,5 +1,5 @@
// Rar2Decoder.cpp
-// According to unRAR license, this code may not be used to develop
+// According to unRAR license, this code may not be used to develop
// a program that creates RAR archives
#include "StdAfx.h"
@@ -56,7 +56,7 @@ Byte CFilter::Decode(int &channelDelta, Byte deltaByte)
case 1: if (K1 >= -16) K1--; break;
case 2: if (K1 < 16) K1++; break;
case 3: if (K2 >= -16) K2--; break;
- case 4: if (K2 < 16) K2++; break;
+ case 4: if (K2 < 16) K2++; break;
case 5: if (K3 >= -16) K3--; break;
case 6: if (K3 < 16) K3++; break;
case 7: if (K4 >= -16) K4--; break;
@@ -143,7 +143,7 @@ bool CDecoder::ReadTables(void)
num = ReadBits(3) + 3;
else if (number == kTableLevel0Number2)
num = ReadBits(7) + 11;
- else
+ else
return false;
for (;num > 0 && i < numLevels; num--)
newLevels[i++] = 0;
@@ -170,8 +170,8 @@ bool CDecoder::ReadLastTables()
// it differs a little from pure RAR sources;
// UInt64 ttt = m_InBitStream.GetProcessedSize() + 2;
// + 2 works for: return 0xFF; in CInBuffer::ReadByte.
- if (m_InBitStream.GetProcessedSize() + 7 <= m_PackSize) // test it: probably incorrect;
- // if (m_InBitStream.GetProcessedSize() + 2 <= m_PackSize) // test it: probably incorrect;
+ if (m_InBitStream.GetProcessedSize() + 7 <= m_PackSize) // test it: probably incorrect;
+ // if (m_InBitStream.GetProcessedSize() + 2 <= m_PackSize) // test it: probably incorrect;
if (m_AudioMode)
{
UInt32 symbol = m_MMDecoders[m_MmFilter.CurrentChannel].DecodeSymbol(&m_InBitStream);
@@ -180,7 +180,7 @@ bool CDecoder::ReadLastTables()
if (symbol >= kMMTableSize)
return false;
}
- else
+ else
{
UInt32 number = m_MainDecoder.DecodeSymbol(&m_InBitStream);
if (number == kReadTableNumber)
@@ -239,7 +239,7 @@ bool CDecoder::DecodeLz(Int32 pos)
else if (number >= kMatchNumber)
{
number -= kMatchNumber;
- length = kNormalMatchMinLen + UInt32(kLenStart[number]) +
+ length = kNormalMatchMinLen + UInt32(kLenStart[number]) +
m_InBitStream.ReadBits(kLenDirectBits[number]);
number = m_DistDecoder.DecodeSymbol(&m_InBitStream);
if (number >= kDistTableSize)
@@ -280,7 +280,7 @@ bool CDecoder::DecodeLz(Int32 pos)
else if (number < kReadTableNumber)
{
number -= kLen2Number;
- distance = kLen2DistStarts[number] +
+ distance = kLen2DistStarts[number] +
m_InBitStream.ReadBits(kLen2DistDirectBits[number]);
length = 2;
}
@@ -324,7 +324,7 @@ HRESULT CDecoder::CodeReal(ISequentialInStream *inStream,
InitStructures();
if (unPackSize == 0)
{
- if (m_InBitStream.GetProcessedSize() + 2 <= m_PackSize) // test it: probably incorrect;
+ if (m_InBitStream.GetProcessedSize() + 2 <= m_PackSize) // test it: probably incorrect;
if (!ReadTables())
return S_FALSE;
return S_OK;
@@ -340,7 +340,7 @@ HRESULT CDecoder::CodeReal(ISequentialInStream *inStream,
if (blockSize > unPackSize - pos)
blockSize = (UInt32)(unPackSize - pos);
UInt64 blockStartPos = m_OutWindowStream.GetProcessedSize();
- if (m_AudioMode)
+ if (m_AudioMode)
{
if (!DecodeMm(blockSize))
return S_FALSE;
diff --git a/CPP/7zip/Compress/Rar/Rar2Decoder.h b/CPP/7zip/Compress/Rar/Rar2Decoder.h
index 7906b1fc..8626a7d9 100755
--- a/CPP/7zip/Compress/Rar/Rar2Decoder.h
+++ b/CPP/7zip/Compress/Rar/Rar2Decoder.h
@@ -1,5 +1,5 @@
// Rar2Decoder.h
-// According to unRAR license, this code may not be used to develop
+// According to unRAR license, this code may not be used to develop
// a program that creates RAR archives
#ifndef __RAR2DECODER_H
@@ -67,9 +67,9 @@ const UInt32 kDistLimit2 = 0x101 - 1;
const UInt32 kDistLimit3 = 0x2000 - 1;
const UInt32 kDistLimit4 = 0x40000 - 1;
-const UInt32 kMatchMaxLen = 255 + 2;
-const UInt32 kMatchMaxLenMax = 255 + 5;
-const UInt32 kNormalMatchMinLen = 3;
+const UInt32 kMatchMaxLen = 255 + 2;
+const UInt32 kMatchMaxLenMax = 255 + 5;
+const UInt32 kNormalMatchMinLen = 3;
namespace NMultimedia {
diff --git a/CPP/7zip/Compress/Rar/Rar3Decoder.cpp b/CPP/7zip/Compress/Rar/Rar3Decoder.cpp
index 5ba13646..c2b18fc9 100755
--- a/CPP/7zip/Compress/Rar/Rar3Decoder.cpp
+++ b/CPP/7zip/Compress/Rar/Rar3Decoder.cpp
@@ -1,5 +1,5 @@
// Rar3Decoder.cpp
-// According to unRAR license, this code may not be used to develop
+// According to unRAR license, this code may not be used to develop
// a program that creates RAR archives
#include "StdAfx.h"
@@ -19,7 +19,7 @@ static const UInt32 kSymbolLen2 = kSymbolRep + kNumReps;
static const Byte kLenStart[kLenTableSize] = {0,1,2,3,4,5,6,7,8,10,12,14,16,20,24,28,32,40,48,56,64,80,96,112,128,160,192,224};
static const Byte kLenDirectBits[kLenTableSize] = {0,0,0,0,0,0,0,0,1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5};
-static const Byte kDistDirectBits[kDistTableSize] =
+static const Byte kDistDirectBits[kDistTableSize] =
{0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,14,14,15,15,
16,16,16,16,16,16,16,16,16,16,16,16,16,16,
18,18,18,18,18,18,18,18,18,18,18,18};
@@ -32,12 +32,12 @@ static const Byte kLen2DistDirectBits[kNumLen2Symbols]={2,2,3, 4, 5, 6, 6, 6};
static const UInt32 kDistLimit3 = 0x2000 - 2;
static const UInt32 kDistLimit4 = 0x40000 - 2;
-static const UInt32 kNormalMatchMinLen = 3;
+static const UInt32 kNormalMatchMinLen = 3;
static const UInt32 kVmDataSizeMax = 1 << 16;
static const UInt32 kVmCodeSizeMax = 1 << 16;
-CDecoder::CDecoder():
+CDecoder::CDecoder():
_window(0),
_winPos(0),
_wrPtr(0),
@@ -382,7 +382,7 @@ HRESULT CDecoder::InitPPM()
// SubAlloc.StartSubAllocator(MaxMB+1);
// StartModelRare(maxOrder);
- if (!_ppm.SubAllocator.StartSubAllocator((maxMB + 1) << 20))
+ if (!_ppm.SubAllocator.StartSubAllocator((maxMB + 1) << 20))
return E_OUTOFMEMORY;
_ppm.MaxOrder = 0;
_ppm.StartModelRare(maxOrder);
@@ -667,7 +667,7 @@ HRESULT CDecoder::DecodeLZ(bool &keepDecompressing)
return S_FALSE;
length = 2 + kLenStart[number] + m_InBitStream.ReadBits(kLenDirectBits[number]);
}
- else
+ else
{
rep3 = rep2;
rep2 = rep1;
@@ -709,7 +709,7 @@ HRESULT CDecoder::DecodeLZ(bool &keepDecompressing)
PrevAlignCount = kNumAlignReps;
rep0 += PrevAlignBits;
}
- else
+ else
return S_FALSE;
}
}
@@ -784,8 +784,8 @@ STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream,
ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress)
{
- try
- {
+ try
+ {
if (inSize == NULL || outSize == NULL)
return E_INVALIDARG;
@@ -815,11 +815,11 @@ STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream,
CCoderReleaser coderReleaser(this);
_unpackSize = *outSize;
- return CodeReal(progress);
+ return CodeReal(progress);
}
catch(const CInBufferException &e) { return e.ErrorCode; }
catch(...) { return S_FALSE; }
- // CNewException is possible here. But probably CNewException is caused
+ // CNewException is possible here. But probably CNewException is caused
// by error in data stream.
}
diff --git a/CPP/7zip/Compress/Rar/Rar3Decoder.h b/CPP/7zip/Compress/Rar/Rar3Decoder.h
index 07008138..cac769bd 100755
--- a/CPP/7zip/Compress/Rar/Rar3Decoder.h
+++ b/CPP/7zip/Compress/Rar/Rar3Decoder.h
@@ -1,5 +1,5 @@
// Rar3Decoder.h
-// According to unRAR license, this code may not be used to develop
+// According to unRAR license, this code may not be used to develop
// a program that creates RAR archives
#ifndef __RAR3DECODER_H
@@ -50,11 +50,11 @@ public:
m_Stream.Init();
m_BitPos = 0;
m_Value = 0;
- // m_BitPos = kNumBigValueBits;
+ // m_BitPos = kNumBigValueBits;
// Normalize();
}
- UInt64 GetProcessedSize() const
+ UInt64 GetProcessedSize() const
{ return m_Stream.GetProcessedSize() - (m_BitPos) / 8; }
UInt32 GetBitPosition() const { return ((8 - m_BitPos) & 7); }
@@ -110,7 +110,7 @@ public:
void Normalize()
{
- while ((Low ^ (Low + Range)) < kTopValue ||
+ while ((Low ^ (Low + Range)) < kTopValue ||
Range < kBot && ((Range = (0 - Low) & (kBot - 1)), 1))
{
Code = (Code << 8) | m_Stream.ReadByte();
@@ -190,7 +190,7 @@ class CDecoder:
UInt32 _wrPtr;
UInt64 _lzSize;
UInt64 _unpackSize;
- UInt64 _writtenFileSize; // if it's > _unpackSize, then _unpackSize only written
+ UInt64 _writtenFileSize; // if it's > _unpackSize, then _unpackSize only written
CMyComPtr<ISequentialOutStream> _outStream;
NHuffman::CDecoder<kNumHuffmanBits, kMainTableSize> m_MainDecoder;
NHuffman::CDecoder<kNumHuffmanBits, kDistTableSize> m_DistDecoder;
diff --git a/CPP/7zip/Compress/Rar/Rar3Vm.cpp b/CPP/7zip/Compress/Rar/Rar3Vm.cpp
index 8222668b..daa083e4 100755
--- a/CPP/7zip/Compress/Rar/Rar3Vm.cpp
+++ b/CPP/7zip/Compress/Rar/Rar3Vm.cpp
@@ -1,11 +1,11 @@
// Rar3Vm.cpp
-// According to unRAR license, this code may not be used to develop
+// According to unRAR license, this code may not be used to develop
// a program that creates RAR archives
/*
Note:
- Due to performance considerations Rar VM may set Flags C incorrectly
- for some operands (SHL x, 0, ... ).
+ Due to performance considerations Rar VM may set Flags C incorrectly
+ for some operands (SHL x, 0, ... ).
Check implementation of concrete VM command
to see if it sets flags right.
*/
@@ -14,10 +14,10 @@ Note:
#include "Rar3Vm.h"
-extern "C"
-{
+extern "C"
+{
#include "../../../../C/Alloc.h"
-#include "../../../../C/7zCrc.h"
+#include "../../../../C/7zCrc.h"
}
namespace NCompress {
@@ -121,7 +121,7 @@ CVm::~CVm()
// CVm::Execute can change CProgram object: it clears progarm if VM returns error.
-bool CVm::Execute(CProgram *prg, const CProgramInitState *initState,
+bool CVm::Execute(CProgram *prg, const CProgramInitState *initState,
CBlockRef &outBlockRef, CRecordVector<Byte> &outGlobalData)
{
memcpy(R, initState->InitR, sizeof(initState->InitR));
@@ -762,14 +762,14 @@ void CVm::ReadVmProgram(const Byte *code, UInt32 codeSize, CProgram *prg)
#ifdef RARVM_STANDARD_FILTERS
-enum EStandardFilter
+enum EStandardFilter
{
- SF_E8,
- SF_E8E9,
- SF_ITANIUM,
- SF_RGB,
- SF_AUDIO,
- SF_DELTA,
+ SF_E8,
+ SF_E8E9,
+ SF_ITANIUM,
+ SF_RGB,
+ SF_AUDIO,
+ SF_DELTA,
SF_UPCASE
};
@@ -778,7 +778,7 @@ struct StandardFilterSignature
UInt32 Length;
UInt32 CRC;
EStandardFilter Type;
-}
+}
kStdFilters[]=
{
53, 0xad576887, SF_E8,
@@ -813,7 +813,7 @@ void CVm::PrepareProgram(const Byte *code, UInt32 codeSize, CProgram *prg)
prg->Commands.Clear();
#ifdef RARVM_STANDARD_FILTERS
prg->StandardFilterIndex = -1;
- #endif
+ #endif
if (xorSum == code[0] && codeSize > 0)
{
@@ -821,7 +821,7 @@ void CVm::PrepareProgram(const Byte *code, UInt32 codeSize, CProgram *prg)
prg->StandardFilterIndex = FindStandardFilter(code, codeSize);
if (prg->StandardFilterIndex >= 0)
return;
- #endif
+ #endif
// 1 byte for checksum
ReadVmProgram(code + 1, codeSize - 1, prg);
}
diff --git a/CPP/7zip/Compress/Rar/Rar3Vm.h b/CPP/7zip/Compress/Rar/Rar3Vm.h
index 8b2e01f1..f6cf11b4 100755
--- a/CPP/7zip/Compress/Rar/Rar3Vm.h
+++ b/CPP/7zip/Compress/Rar/Rar3Vm.h
@@ -1,5 +1,5 @@
// Rar3Vm.h
-// According to unRAR license, this code may not be used to develop
+// According to unRAR license, this code may not be used to develop
// a program that creates RAR archives
#ifndef __RAR3VM_H
@@ -65,7 +65,7 @@ enum ECommand
CMD_SHL, CMD_SHR, CMD_SAR, CMD_NEG, CMD_PUSHA,CMD_POPA, CMD_PUSHF,CMD_POPF,
CMD_MOVZX,CMD_MOVSX,CMD_XCHG, CMD_MUL, CMD_DIV, CMD_ADC, CMD_SBB, CMD_PRINT,
- CMD_MOVB, CMD_CMPB, CMD_ADDB, CMD_SUBB, CMD_INCB, CMD_DECB,
+ CMD_MOVB, CMD_CMPB, CMD_ADDB, CMD_SUBB, CMD_INCB, CMD_DECB,
CMD_XORB, CMD_ANDB, CMD_ORB, CMD_TESTB,CMD_NEGB,
CMD_SHLB, CMD_SHRB, CMD_SARB, CMD_MULB
};
@@ -168,7 +168,7 @@ public:
bool Create();
void PrepareProgram(const Byte *code, UInt32 codeSize, CProgram *prg);
void SetMemory(UInt32 pos, const Byte *data, UInt32 dataSize);
- bool Execute(CProgram *prg, const CProgramInitState *initState,
+ bool Execute(CProgram *prg, const CProgramInitState *initState,
CBlockRef &outBlockRef, CRecordVector<Byte> &outGlobalData);
const Byte *GetDataPointer(UInt32 offset) const { return Mem + offset; }
diff --git a/CPP/7zip/Compress/Shrink/ShrinkDecoder.cpp b/CPP/7zip/Compress/Shrink/ShrinkDecoder.cpp
index 187fa3a9..5079a51a 100755
--- a/CPP/7zip/Compress/Shrink/ShrinkDecoder.cpp
+++ b/CPP/7zip/Compress/Shrink/ShrinkDecoder.cpp
@@ -4,8 +4,8 @@
#include "ShrinkDecoder.h"
-extern "C"
-{
+extern "C"
+{
#include "../../../../C/Alloc.h"
}
#include "../../Common/InBuffer.h"
@@ -17,7 +17,7 @@ namespace NShrink {
static const UInt32 kBufferSize = (1 << 20);
-static const int kNumMinBits = 9;
+static const int kNumMinBits = 9;
STDMETHODIMP CDecoder ::CodeReal(ISequentialInStream *inStream,
ISequentialOutStream *outStream, const UInt64 * /* inSize */, const UInt64 * /* outSize */,
@@ -90,7 +90,7 @@ STDMETHODIMP CDecoder ::CodeReal(ISequentialInStream *inStream,
head++;
}
}
- else
+ else
return S_FALSE;
continue;
}
diff --git a/CPP/7zip/Compress/Shrink/ShrinkDecoder.h b/CPP/7zip/Compress/Shrink/ShrinkDecoder.h
index 1c15ea8a..0c1b8607 100755
--- a/CPP/7zip/Compress/Shrink/ShrinkDecoder.h
+++ b/CPP/7zip/Compress/Shrink/ShrinkDecoder.h
@@ -10,8 +10,8 @@
namespace NCompress {
namespace NShrink {
-const int kNumMaxBits = 13;
-const UInt32 kNumItems = 1 << kNumMaxBits;
+const int kNumMaxBits = 13;
+const UInt32 kNumItems = 1 << kNumMaxBits;
class CDecoder :
public ICompressCoder,
@@ -25,11 +25,11 @@ class CDecoder :
public:
MY_UNKNOWN_IMP
- STDMETHOD(CodeReal)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ STDMETHOD(CodeReal)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress);
- STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
+ STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream,
const UInt64 *inSize, const UInt64 *outSize,
ICompressProgressInfo *progress);
};
diff --git a/CPP/7zip/Compress/Shrink/StdAfx.cpp b/CPP/7zip/Compress/Shrink/StdAfx.cpp
deleted file mode 100755
index d0feea85..00000000
--- a/CPP/7zip/Compress/Shrink/StdAfx.cpp
+++ /dev/null
@@ -1,3 +0,0 @@
-// StdAfx.cpp
-
-#include "StdAfx.h"
diff --git a/CPP/7zip/Compress/Z/StdAfx.cpp b/CPP/7zip/Compress/Z/StdAfx.cpp
deleted file mode 100755
index d0feea85..00000000
--- a/CPP/7zip/Compress/Z/StdAfx.cpp
+++ /dev/null
@@ -1,3 +0,0 @@
-// StdAfx.cpp
-
-#include "StdAfx.h"
diff --git a/CPP/7zip/Compress/Z/ZDecoder.cpp b/CPP/7zip/Compress/Z/ZDecoder.cpp
index 144d0878..4d435b6c 100755
--- a/CPP/7zip/Compress/Z/ZDecoder.cpp
+++ b/CPP/7zip/Compress/Z/ZDecoder.cpp
@@ -4,57 +4,37 @@
#include "ZDecoder.h"
-extern "C"
-{
+extern "C"
+{
#include "../../../../C/Alloc.h"
}
#include "../../Common/InBuffer.h"
#include "../../Common/OutBuffer.h"
-#include "../../Common/LSBFDecoder.h"
namespace NCompress {
namespace NZ {
static const UInt32 kBufferSize = (1 << 20);
-static const Byte kNumBitsMask = 0x1F;
-static const Byte kBlockModeMask = 0x80;
-static const int kNumMinBits = 9;
-static const int kNumMaxBits = 16;
+static const Byte kNumBitsMask = 0x1F;
+static const Byte kBlockModeMask = 0x80;
+static const int kNumMinBits = 9;
+static const int kNumMaxBits = 16;
void CDecoder::Free()
{
- MyFree(_parents);
- _parents = 0;
- MyFree(_suffixes);
- _suffixes = 0;
- MyFree(_stack);
- _stack = 0;
+ MyFree(_parents); _parents = 0;
+ MyFree(_suffixes); _suffixes = 0;
+ MyFree(_stack); _stack = 0;
}
-bool CDecoder::Alloc(size_t numItems)
-{
- Free();
- _parents = (UInt16 *)MyAlloc(numItems * sizeof(UInt16));
- if (_parents == 0)
- return false;
- _suffixes = (Byte *)MyAlloc(numItems * sizeof(Byte));
- if (_suffixes == 0)
- return false;
- _stack = (Byte *)MyAlloc(numItems * sizeof(Byte));
- return _stack != 0;
-}
-
-CDecoder::~CDecoder()
-{
- Free();
-}
+CDecoder::~CDecoder() { Free(); }
STDMETHODIMP CDecoder::CodeReal(ISequentialInStream *inStream,
ISequentialOutStream *outStream, const UInt64 * /* inSize */, const UInt64 * /* outSize */,
ICompressProgressInfo *progress)
{
- NStream::NLSBF::CBaseDecoder<CInBuffer> inBuffer;
+ CInBuffer inBuffer;
COutBuffer outBuffer;
if (!inBuffer.Create(kBufferSize))
@@ -72,13 +52,13 @@ STDMETHODIMP CDecoder::CodeReal(ISequentialInStream *inStream,
return S_FALSE;
UInt32 numItems = 1 << maxbits;
bool blockMode = ((_properties & kBlockModeMask) != 0);
- if (!blockMode)
- return E_NOTIMPL;
if (maxbits != _numMaxBits || _parents == 0 || _suffixes == 0 || _stack == 0)
{
- if (!Alloc(numItems))
- return E_OUTOFMEMORY;
+ Free();
+ _parents = (UInt16 *)MyAlloc(numItems * sizeof(UInt16)); if (_parents == 0) return E_OUTOFMEMORY;
+ _suffixes = (Byte *)MyAlloc(numItems * sizeof(Byte)); if (_suffixes == 0) return E_OUTOFMEMORY;
+ _stack = (Byte *)MyAlloc(numItems * sizeof(Byte)); if (_stack == 0) return E_OUTOFMEMORY;
_numMaxBits = maxbits;
}
@@ -88,25 +68,40 @@ STDMETHODIMP CDecoder::CodeReal(ISequentialInStream *inStream,
bool needPrev = false;
- int keepBits = 0;
+ unsigned bitPos = 0;
+ unsigned numBufBits = 0;
+
+ Byte buf[kNumMaxBits + 4];
_parents[256] = 0; // virus protection
_suffixes[256] = 0;
for (;;)
{
- if (keepBits < numBits)
- keepBits = numBits * 8;
- UInt32 symbol = inBuffer.ReadBits(numBits);
- if (inBuffer.ExtraBitsWereRead())
+ if (numBufBits == bitPos)
+ {
+ numBufBits = (unsigned)inBuffer.ReadBytes(buf, numBits) * 8;
+ bitPos = 0;
+ UInt64 nowPos = outBuffer.GetProcessedSize();
+ if (progress != NULL && nowPos - prevPos >= (1 << 18))
+ {
+ prevPos = nowPos;
+ UInt64 packSize = inBuffer.GetProcessedSize();
+ RINOK(progress->SetRatioInfo(&packSize, &nowPos));
+ }
+ }
+ unsigned bytePos = bitPos >> 3;
+ UInt32 symbol = buf[bytePos] | ((UInt32)buf[bytePos + 1] << 8) | ((UInt32)buf[bytePos + 2] << 16);
+ symbol >>= (bitPos & 7);
+ symbol &= (1 << numBits) - 1;
+ bitPos += numBits;
+ if (bitPos > numBufBits)
break;
- keepBits -= numBits;
if (symbol >= head)
return S_FALSE;
if (blockMode && symbol == 256)
{
- for (;keepBits > 0; keepBits--)
- inBuffer.ReadBits(1);
+ numBufBits = bitPos = 0;
numBits = kNumMinBits;
head = 257;
needPrev = false;
@@ -126,8 +121,9 @@ STDMETHODIMP CDecoder::CodeReal(ISequentialInStream *inStream,
if (symbol == head - 1)
_stack[0] = (Byte)cur;
}
- while (i > 0)
+ do
outBuffer.WriteByte((_stack[--i]));
+ while (i > 0);
if (head < numItems)
{
needPrev = true;
@@ -136,21 +132,13 @@ STDMETHODIMP CDecoder::CodeReal(ISequentialInStream *inStream,
{
if (numBits < maxbits)
{
+ numBufBits = bitPos = 0;
numBits++;
- keepBits = numBits * 8;
}
}
}
else
needPrev = false;
-
- UInt64 nowPos = outBuffer.GetProcessedSize();
- if (progress != NULL && nowPos - prevPos > (1 << 18))
- {
- prevPos = nowPos;
- UInt64 packSize = inBuffer.GetProcessedSize();
- RINOK(progress->SetRatioInfo(&packSize, &nowPos));
- }
}
return outBuffer.Flush();
}
diff --git a/CPP/7zip/Compress/Z/ZDecoder.h b/CPP/7zip/Compress/Z/ZDecoder.h
index 1640c7f4..70e40c20 100755
--- a/CPP/7zip/Compress/Z/ZDecoder.h
+++ b/CPP/7zip/Compress/Z/ZDecoder.h
@@ -24,7 +24,6 @@ public:
CDecoder(): _properties(0), _numMaxBits(0), _parents(0), _suffixes(0), _stack(0) {};
~CDecoder();
void Free();
- bool Alloc(size_t numItems);
MY_UNKNOWN_IMP1(ICompressSetDecoderProperties2)
diff --git a/CPP/7zip/Crypto/7zAES/7zAES.cpp b/CPP/7zip/Crypto/7zAES/7zAES.cpp
index ce6b7aef..f8034fd2 100755
--- a/CPP/7zip/Crypto/7zAES/7zAES.cpp
+++ b/CPP/7zip/Crypto/7zAES/7zAES.cpp
@@ -9,8 +9,8 @@
#include "../AES/MyAES.h"
#include "7zAES.h"
-extern "C"
-{
+extern "C"
+{
#include "../../../../C/Sha256.h"
}
@@ -139,7 +139,7 @@ STDMETHODIMP CEncoder::ResetInitVector()
}
STDMETHODIMP CEncoder::WriteCoderProperties(ISequentialOutStream *outStream)
-{
+{
// _key.Init();
for (UInt32 i = _ivSize; i < sizeof(_iv); i++)
_iv[i] = 0;
@@ -149,7 +149,7 @@ STDMETHODIMP CEncoder::WriteCoderProperties(ISequentialOutStream *outStream)
// _key.NumCyclesPower = 0x3F;
_key.NumCyclesPower = 19;
- Byte firstByte = (Byte)(_key.NumCyclesPower |
+ Byte firstByte = (Byte)(_key.NumCyclesPower |
(((_key.SaltSize == 0) ? 0 : 1) << 7) |
(((ivSize == 0) ? 0 : 1) << 6));
RINOK(outStream->Write(&firstByte, 1, NULL));
diff --git a/CPP/7zip/Crypto/7zAES/7zAES.h b/CPP/7zip/Crypto/7zAES/7zAES.h
index ce14e2a1..ed2bb3cd 100755
--- a/CPP/7zip/Crypto/7zAES/7zAES.h
+++ b/CPP/7zip/Crypto/7zAES/7zAES.h
@@ -60,7 +60,7 @@ protected:
CBase();
};
-class CBaseCoder:
+class CBaseCoder:
public ICompressFilter,
public ICryptoSetPassword,
public CMyUnknownImp,
@@ -82,7 +82,7 @@ public:
#ifndef EXTRACT_ONLY
-class CEncoder:
+class CEncoder:
public CBaseCoder,
public ICompressWriteCoderProperties,
// public ICryptoResetSalt,
@@ -101,7 +101,7 @@ public:
};
#endif
-class CDecoder:
+class CDecoder:
public CBaseCoder,
public ICompressSetDecoderProperties2
{
diff --git a/CPP/7zip/Crypto/7zAES/DllExports.cpp b/CPP/7zip/Crypto/7zAES/DllExports.cpp
deleted file mode 100755
index 8766ded4..00000000
--- a/CPP/7zip/Crypto/7zAES/DllExports.cpp
+++ /dev/null
@@ -1,111 +0,0 @@
-// DLLExports.cpp
-
-#include "StdAfx.h"
-
-#include "Common/MyInitGuid.h"
-#include "Common/ComTry.h"
-#include "7zAES.h"
-
-/*
-// {23170F69-40C1-278B-0703-000000000000}
-DEFINE_GUID(CLSID_CCrypto_Hash_SHA256,
-0x23170F69, 0x40C1, 0x278B, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
-*/
-
-// {23170F69-40C1-278B-06F1-070100000100}
-DEFINE_GUID(CLSID_CCrypto7zAESEncoder,
-0x23170F69, 0x40C1, 0x278B, 0x06, 0xF1, 0x07, 0x01, 0x00, 0x00, 0x01, 0x00);
-
-// {23170F69-40C1-278B-06F1-070100000000}
-DEFINE_GUID(CLSID_CCrypto7zAESDecoder,
-0x23170F69, 0x40C1, 0x278B, 0x06, 0xF1, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00);
-
-HINSTANCE g_hInstance;
-#ifndef _UNICODE
-bool g_IsNT = false;
-static bool IsItWindowsNT()
-{
- OSVERSIONINFO versionInfo;
- versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
- if (!::GetVersionEx(&versionInfo))
- return false;
- return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
-}
-#endif
-
-extern "C"
-BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
-{
- if (dwReason == DLL_PROCESS_ATTACH)
- {
- g_hInstance = hInstance;
- #ifndef _UNICODE
- g_IsNT = IsItWindowsNT();
- #endif
- }
- return TRUE;
-}
-
-STDAPI CreateObject(const GUID *clsid, const GUID *iid, void **outObject)
-{
- COM_TRY_BEGIN
- *outObject = 0;
- int correctInterface = (*iid == IID_ICompressFilter);
- CMyComPtr<ICompressFilter> filter;
- if (*clsid == CLSID_CCrypto7zAESDecoder)
- {
- if (!correctInterface)
- return E_NOINTERFACE;
- filter = (ICompressFilter *)new NCrypto::NSevenZ::CDecoder();
- }
- else if (*clsid == CLSID_CCrypto7zAESEncoder)
- {
- if (!correctInterface)
- return E_NOINTERFACE;
- filter = (ICompressFilter *)new NCrypto::NSevenZ::CEncoder();
- }
- else
- return CLASS_E_CLASSNOTAVAILABLE;
- *outObject = filter.Detach();
- COM_TRY_END
- return S_OK;
-}
-
-STDAPI GetNumberOfMethods(UINT32 *numMethods)
-{
- *numMethods = 1;
- return S_OK;
-}
-
-STDAPI GetMethodProperty(UINT32 index, PROPID propID, PROPVARIANT *value)
-{
- if (index != 0)
- return E_INVALIDARG;
- ::VariantClear((tagVARIANT *)value);
- switch(propID)
- {
- case NMethodPropID::kID:
- {
- const char id[] = { 0x06, (char)(unsigned char)0xF1, 0x07, 0x01 };
- if ((value->bstrVal = ::SysAllocStringByteLen(id, sizeof(id))) != 0)
- value->vt = VT_BSTR;
- return S_OK;
- }
- case NMethodPropID::kName:
- if ((value->bstrVal = ::SysAllocString(L"7zAES")) != 0)
- value->vt = VT_BSTR;
- return S_OK;
- case NMethodPropID::kDecoder:
- if ((value->bstrVal = ::SysAllocStringByteLen(
- (const char *)&CLSID_CCrypto7zAESDecoder, sizeof(GUID))) != 0)
- value->vt = VT_BSTR;
- return S_OK;
- case NMethodPropID::kEncoder:
- if ((value->bstrVal = ::SysAllocStringByteLen(
- (const char *)&CLSID_CCrypto7zAESEncoder, sizeof(GUID))) != 0)
- value->vt = VT_BSTR;
- return S_OK;
- }
- return S_OK;
-}
-
diff --git a/CPP/7zip/Crypto/7zAES/StdAfx.cpp b/CPP/7zip/Crypto/7zAES/StdAfx.cpp
deleted file mode 100755
index d0feea85..00000000
--- a/CPP/7zip/Crypto/7zAES/StdAfx.cpp
+++ /dev/null
@@ -1,3 +0,0 @@
-// StdAfx.cpp
-
-#include "StdAfx.h"
diff --git a/CPP/7zip/Crypto/AES/MyAES.cpp b/CPP/7zip/Crypto/AES/MyAES.cpp
index 842a634e..286570a9 100755
--- a/CPP/7zip/Crypto/AES/MyAES.cpp
+++ b/CPP/7zip/Crypto/AES/MyAES.cpp
@@ -16,7 +16,7 @@ STDMETHODIMP_(UInt32) CAesCbcEncoder::Filter(Byte *data, UInt32 size)
}
STDMETHODIMP CAesCbcEncoder::SetKey(const Byte *data, UInt32 size)
-{
+{
if ((size & 0x7) != 0 || size < 16 || size > 32)
return E_INVALIDARG;
Aes_SetKeyEncode(&Aes.aes, data, size);
@@ -39,7 +39,7 @@ STDMETHODIMP_(UInt32) CAesCbcDecoder::Filter(Byte *data, UInt32 size)
}
STDMETHODIMP CAesCbcDecoder::SetKey(const Byte *data, UInt32 size)
-{
+{
if ((size & 0x7) != 0 || size < 16 || size > 32)
return E_INVALIDARG;
Aes_SetKeyDecode(&Aes.aes, data, size);
diff --git a/CPP/7zip/Crypto/AES/MyAES.h b/CPP/7zip/Crypto/AES/MyAES.h
index ee1d2828..2e99f158 100755
--- a/CPP/7zip/Crypto/AES/MyAES.h
+++ b/CPP/7zip/Crypto/AES/MyAES.h
@@ -8,8 +8,8 @@
#include "../../ICoder.h"
-extern "C"
-{
+extern "C"
+{
#include "../../../../C/Aes.h"
}
@@ -19,7 +19,7 @@ class CAesCbcEncoder:
public ICompressFilter,
public ICryptoProperties,
public CMyUnknownImp
-{
+{
CAesCbc Aes;
public:
MY_UNKNOWN_IMP1(ICryptoProperties)
@@ -33,7 +33,7 @@ class CAesCbcDecoder:
public ICompressFilter,
public ICryptoProperties,
public CMyUnknownImp
-{
+{
CAesCbc Aes;
public:
MY_UNKNOWN_IMP1(ICryptoProperties)
diff --git a/CPP/7zip/Crypto/AES/StdAfx.cpp b/CPP/7zip/Crypto/AES/StdAfx.cpp
deleted file mode 100755
index d0feea85..00000000
--- a/CPP/7zip/Crypto/AES/StdAfx.cpp
+++ /dev/null
@@ -1,3 +0,0 @@
-// StdAfx.cpp
-
-#include "StdAfx.h"
diff --git a/CPP/7zip/Crypto/Hash/HmacSha1.cpp b/CPP/7zip/Crypto/Hash/HmacSha1.cpp
index a5c20a75..a66d6271 100755
--- a/CPP/7zip/Crypto/Hash/HmacSha1.cpp
+++ b/CPP/7zip/Crypto/Hash/HmacSha1.cpp
@@ -20,7 +20,7 @@ void CHmac::SetKey(const Byte *key, size_t keySize)
_sha.Final(keyTemp);
keySize = kDigestSize;
}
- else
+ else
for (i = 0; i < keySize; i++)
keyTemp[i] = key[i];
for (i = 0; i < kBlockSize; i++)
@@ -34,7 +34,7 @@ void CHmac::SetKey(const Byte *key, size_t keySize)
}
void CHmac::Final(Byte *mac, size_t macSize)
-{
+{
Byte digest[kDigestSize];
_sha.Final(digest);
_sha2.Update(digest, kDigestSize);
@@ -59,14 +59,14 @@ void CHmac32::SetKey(const Byte *key, size_t keySize)
sha.Final(digest);
for (int i = 0 ; i < kDigestSizeInWords; i++)
- keyTemp[i] =
+ keyTemp[i] =
((UInt32)(digest[i * 4 + 0]) << 24) |
((UInt32)(digest[i * 4 + 1]) << 16) |
((UInt32)(digest[i * 4 + 2]) << 8) |
((UInt32)(digest[i * 4 + 3]));
keySize = kDigestSizeInWords;
}
- else
+ else
for (size_t i = 0; i < keySize; i++)
keyTemp[i / 4] |= (key[i] << (24 - 8 * (i & 3)));
for (i = 0; i < kBlockSizeInWords; i++)
@@ -80,7 +80,7 @@ void CHmac32::SetKey(const Byte *key, size_t keySize)
}
void CHmac32::Final(UInt32 *mac, size_t macSize)
-{
+{
UInt32 digest[kDigestSizeInWords];
_sha.Final(digest);
_sha2.Update(digest, kDigestSizeInWords);
diff --git a/CPP/7zip/Crypto/Hash/Pbkdf2HmacSha1.cpp b/CPP/7zip/Crypto/Hash/Pbkdf2HmacSha1.cpp
index b11881b7..cbbdec89 100755
--- a/CPP/7zip/Crypto/Hash/Pbkdf2HmacSha1.cpp
+++ b/CPP/7zip/Crypto/Hash/Pbkdf2HmacSha1.cpp
@@ -7,7 +7,7 @@
namespace NCrypto {
namespace NSha1 {
-void Pbkdf2Hmac(const Byte *pwd, size_t pwdSize, const Byte *salt, size_t saltSize,
+void Pbkdf2Hmac(const Byte *pwd, size_t pwdSize, const Byte *salt, size_t saltSize,
UInt32 numIterations, Byte *key, size_t keySize)
{
CHmac baseCtx;
@@ -39,7 +39,7 @@ void Pbkdf2Hmac(const Byte *pwd, size_t pwdSize, const Byte *salt, size_t saltSi
}
}
-void Pbkdf2Hmac32(const Byte *pwd, size_t pwdSize, const UInt32 *salt, size_t saltSize,
+void Pbkdf2Hmac32(const Byte *pwd, size_t pwdSize, const UInt32 *salt, size_t saltSize,
UInt32 numIterations, UInt32 *key, size_t keySize)
{
CHmac32 baseCtx;
diff --git a/CPP/7zip/Crypto/Hash/Pbkdf2HmacSha1.h b/CPP/7zip/Crypto/Hash/Pbkdf2HmacSha1.h
index 00a5e009..68e85ee3 100755
--- a/CPP/7zip/Crypto/Hash/Pbkdf2HmacSha1.h
+++ b/CPP/7zip/Crypto/Hash/Pbkdf2HmacSha1.h
@@ -10,10 +10,10 @@
namespace NCrypto {
namespace NSha1 {
-void Pbkdf2Hmac(const Byte *pwd, size_t pwdSize, const Byte *salt, size_t saltSize,
+void Pbkdf2Hmac(const Byte *pwd, size_t pwdSize, const Byte *salt, size_t saltSize,
UInt32 numIterations, Byte *key, size_t keySize);
-void Pbkdf2Hmac32(const Byte *pwd, size_t pwdSize, const UInt32 *salt, size_t saltSize,
+void Pbkdf2Hmac32(const Byte *pwd, size_t pwdSize, const UInt32 *salt, size_t saltSize,
UInt32 numIterations, UInt32 *key, size_t keySize);
}}
diff --git a/CPP/7zip/Crypto/Hash/RandGen.cpp b/CPP/7zip/Crypto/Hash/RandGen.cpp
index 9ae36155..a030a0d2 100755
--- a/CPP/7zip/Crypto/Hash/RandGen.cpp
+++ b/CPP/7zip/Crypto/Hash/RandGen.cpp
@@ -28,7 +28,7 @@
// Maybe it's possible to restore original timer value from generated value.
void CRandomGenerator::Init()
-{
+{
NCrypto::NSha1::CContext hash;
hash.Init();
@@ -82,7 +82,7 @@ void CRandomGenerator::Init()
static NWindows::NSynchronization::CCriticalSection g_CriticalSection;
void CRandomGenerator::Generate(Byte *data, unsigned int size)
-{
+{
g_CriticalSection.Enter();
if (_needInit)
Init();
diff --git a/CPP/7zip/Crypto/Hash/RandGen.h b/CPP/7zip/Crypto/Hash/RandGen.h
index 3b58a032..3f06b26b 100755
--- a/CPP/7zip/Crypto/Hash/RandGen.h
+++ b/CPP/7zip/Crypto/Hash/RandGen.h
@@ -13,7 +13,7 @@ class CRandomGenerator
void Init();
public:
CRandomGenerator(): _needInit(true) {};
- void Generate(Byte *data, unsigned int size);
+ void Generate(Byte *data, unsigned size);
};
extern CRandomGenerator g_RandomGenerator;
diff --git a/CPP/7zip/Crypto/Hash/Sha1.cpp b/CPP/7zip/Crypto/Hash/Sha1.cpp
index 8d56b3dc..2962c654 100755
--- a/CPP/7zip/Crypto/Hash/Sha1.cpp
+++ b/CPP/7zip/Crypto/Hash/Sha1.cpp
@@ -1,12 +1,12 @@
// Sha1.cpp
-// This file is based on public domain
+// This file is based on public domain
// Steve Reid and Wei Dai's code from Crypto++
#include "StdAfx.h"
#include "Sha1.h"
-extern "C"
-{
+extern "C"
+{
#include "../../../../C/RotateDefs.h"
}
@@ -16,7 +16,7 @@ namespace NSha1 {
// define it for speed optimization
// #define _SHA1_UNROLL
-static const unsigned int kNumW =
+static const unsigned int kNumW =
#ifdef _SHA1_UNROLL
16;
#else
@@ -79,9 +79,9 @@ void CContextBase::GetBlockDigest(UInt32 *data, UInt32 *destDigest, bool returnR
#ifdef _SHA1_UNROLL
- RX_5(R2, 20); RX_5(R2, 25); RX_5(R2, 30); RX_5(R2, 35);
- RX_5(R3, 40); RX_5(R3, 45); RX_5(R3, 50); RX_5(R3, 55);
- RX_5(R4, 60); RX_5(R4, 65); RX_5(R4, 70); RX_5(R4, 75);
+ RX_5(R2, 20); RX_5(R2, 25); RX_5(R2, 30); RX_5(R2, 35);
+ RX_5(R3, 40); RX_5(R3, 45); RX_5(R3, 50); RX_5(R3, 55);
+ RX_5(R4, 60); RX_5(R4, 65); RX_5(R4, 70); RX_5(R4, 75);
#else
i = 20;
for (; i < 40; i += 5) { RX_5(R2, i); }
@@ -101,7 +101,7 @@ void CContextBase::GetBlockDigest(UInt32 *data, UInt32 *destDigest, bool returnR
// Wipe variables
// a = b = c = d = e = 0;
-}
+}
void CContextBase::PrepareBlock(UInt32 *block, unsigned int size) const
{
@@ -165,7 +165,7 @@ void CContext::Final(Byte *digest)
UpdateBlock();
int i;
- for (i = 0; i < kDigestSizeInWords; i++)
+ for (i = 0; i < kDigestSizeInWords; i++)
{
UInt32 state = _state[i] & 0xFFFFFFFF;
*digest++ = (Byte)(state >> 24);
diff --git a/CPP/7zip/Crypto/Hash/Sha1.h b/CPP/7zip/Crypto/Hash/Sha1.h
index ebb11142..8ad8675b 100755
--- a/CPP/7zip/Crypto/Hash/Sha1.h
+++ b/CPP/7zip/Crypto/Hash/Sha1.h
@@ -1,5 +1,5 @@
// Sha1.h
-// This file is based on public domain
+// This file is based on public domain
// Steve Reid and Wei Dai's code from Crypto++
#ifndef __SHA1_H
@@ -26,9 +26,9 @@ class CContextBase
protected:
UInt32 _state[5];
UInt64 _count;
- void UpdateBlock(UInt32 *data, bool returnRes = false)
- {
- GetBlockDigest(data, _state, returnRes);
+ void UpdateBlock(UInt32 *data, bool returnRes = false)
+ {
+ GetBlockDigest(data, _state, returnRes);
_count++;
}
public:
diff --git a/CPP/7zip/Crypto/Rar20/Rar20Cipher.h b/CPP/7zip/Crypto/Rar20/Rar20Cipher.h
index e2091cda..465cc42a 100755
--- a/CPP/7zip/Crypto/Rar20/Rar20Cipher.h
+++ b/CPP/7zip/Crypto/Rar20/Rar20Cipher.h
@@ -13,7 +13,7 @@
namespace NCrypto {
namespace NRar20 {
-class CDecoder:
+class CDecoder:
public ICompressFilter,
public ICryptoSetPassword,
public CMyUnknownImp
diff --git a/CPP/7zip/Crypto/Rar20/Rar20Crypto.cpp b/CPP/7zip/Crypto/Rar20/Rar20Crypto.cpp
index 6cd2d450..d688644d 100755
--- a/CPP/7zip/Crypto/Rar20/Rar20Crypto.cpp
+++ b/CPP/7zip/Crypto/Rar20/Rar20Crypto.cpp
@@ -3,9 +3,9 @@
#include "StdAfx.h"
#include "Rar20Crypto.h"
-extern "C"
-{
- #include "../../../../C/7zCrc.h"
+extern "C"
+{
+ #include "../../../../C/7zCrc.h"
}
#define rol(x,n) (((x) << (n)) | ((x) >> (8 * sizeof(x) - (n))))
diff --git a/CPP/7zip/Crypto/Rar20/Rar20Crypto.h b/CPP/7zip/Crypto/Rar20/Rar20Crypto.h
index 071d01f1..572db3dd 100755
--- a/CPP/7zip/Crypto/Rar20/Rar20Crypto.h
+++ b/CPP/7zip/Crypto/Rar20/Rar20Crypto.h
@@ -14,9 +14,9 @@ class CData
UInt32 Keys[4];
UInt32 SubstLong(UInt32 t)
{
- return (UInt32)SubstTable[(int)t & 255] |
+ return (UInt32)SubstTable[(int)t & 255] |
((UInt32)SubstTable[(int)(t >> 8) & 255] << 8) |
- ((UInt32)SubstTable[(int)(t >> 16) & 255] << 16) |
+ ((UInt32)SubstTable[(int)(t >> 16) & 255] << 16) |
((UInt32)SubstTable[(int)(t >> 24) & 255] << 24);
}
diff --git a/CPP/7zip/Crypto/RarAES/RarAES.h b/CPP/7zip/Crypto/RarAES/RarAES.h
index a99ad531..d43b3889 100755
--- a/CPP/7zip/Crypto/RarAES/RarAES.h
+++ b/CPP/7zip/Crypto/RarAES/RarAES.h
@@ -10,8 +10,8 @@
#include "../../ICoder.h"
#include "../../IPassword.h"
-extern "C"
-{
+extern "C"
+{
#include "../../../../C/Aes.h"
}
@@ -20,7 +20,7 @@ namespace NRar29 {
const UInt32 kRarAesKeySize = 16;
-class CDecoder:
+class CDecoder:
public ICompressFilter,
public ICompressSetDecoderProperties2,
public ICryptoSetPassword,
diff --git a/CPP/7zip/Crypto/WzAES/StdAfx.cpp b/CPP/7zip/Crypto/WzAES/StdAfx.cpp
deleted file mode 100755
index d0feea85..00000000
--- a/CPP/7zip/Crypto/WzAES/StdAfx.cpp
+++ /dev/null
@@ -1,3 +0,0 @@
-// StdAfx.cpp
-
-#include "StdAfx.h"
diff --git a/CPP/7zip/Crypto/WzAES/WzAES.cpp b/CPP/7zip/Crypto/WzAES/WzAES.cpp
index 704ea9fc..ba213626 100755
--- a/CPP/7zip/Crypto/WzAES/WzAES.cpp
+++ b/CPP/7zip/Crypto/WzAES/WzAES.cpp
@@ -1,6 +1,6 @@
// WzAES.cpp
/*
-This code implements Brian Gladman's scheme
+This code implements Brian Gladman's scheme
specified in password Based File Encryption Utility.
Note: you must include Crypto/AES/MyAES.cpp to project to initialize AES tables
@@ -39,12 +39,12 @@ STDMETHODIMP CBaseCoder::CryptoSetPassword(const Byte *data, UInt32 size)
(p)[2] = (Byte)(x >> 16); (p)[3] = (Byte)(x >> 24); }
void CBaseCoder::EncryptData(Byte *data, UInt32 size)
-{
+{
unsigned int pos = _blockPos;
for (; size > 0; size--)
{
if (pos == AES_BLOCK_SIZE)
- {
+ {
if (++_counter[0] == 0)
_counter[1]++;
UInt32 temp[4];
@@ -65,7 +65,7 @@ void CBaseCoder::EncryptData(Byte *data, UInt32 size)
static void BytesToBeUInt32s(const Byte *src, UInt32 *dest, int destSize)
{
for (int i = 0 ; i < destSize; i++)
- dest[i] =
+ dest[i] =
((UInt32)(src[i * 4 + 0]) << 24) |
((UInt32)(src[i * 4 + 1]) << 16) |
((UInt32)(src[i * 4 + 2]) << 8) |
@@ -85,9 +85,9 @@ STDMETHODIMP CBaseCoder::Init()
#ifdef _NO_WZAES_OPTIMIZATIONS
NSha1::Pbkdf2Hmac(
- _key.Password, _key.Password.GetCapacity(),
+ _key.Password, _key.Password.GetCapacity(),
_key.Salt, _key.GetSaltSize(),
- kNumKeyGenIterations,
+ kNumKeyGenIterations,
buf, keysTotalSize);
#else
@@ -98,11 +98,11 @@ STDMETHODIMP CBaseCoder::Init()
UInt32 saltSizeInWords = _key.GetSaltSize() / 4;
BytesToBeUInt32s(_key.Salt, salt, saltSizeInWords);
NSha1::Pbkdf2Hmac32(
- _key.Password, _key.Password.GetCapacity(),
+ _key.Password, _key.Password.GetCapacity(),
salt, saltSizeInWords,
- kNumKeyGenIterations,
+ kNumKeyGenIterations,
buf32, key32SizeTotal);
- for (UInt32 j = 0; j < keysTotalSize; j++)
+ for (UInt32 j = 0; j < keysTotalSize; j++)
buf[j] = (Byte)(buf32[j / 4] >> (24 - 8 * (j & 3)));
#endif
@@ -121,7 +121,7 @@ STDMETHODIMP CBaseCoder::Init()
/*
STDMETHODIMP CEncoder::WriteCoderProperties(ISequentialOutStream *outStream)
-{
+{
Byte keySizeMode = 3;
return outStream->Write(&keySizeMode, 1, NULL);
}
diff --git a/CPP/7zip/Crypto/WzAES/WzAES.h b/CPP/7zip/Crypto/WzAES/WzAES.h
index fa14410a..ad35035c 100755
--- a/CPP/7zip/Crypto/WzAES/WzAES.h
+++ b/CPP/7zip/Crypto/WzAES/WzAES.h
@@ -1,10 +1,10 @@
// WzAES.h
/*
-This code implements Brian Gladman's scheme
+This code implements Brian Gladman's scheme
specified in password Based File Encryption Utility:
- AES encryption (128,192,256-bit) in Counter (CTR) mode.
- HMAC-SHA1 authentication for encrypted data (10 bytes)
- - Keys are derived by PPKDF2(RFC2898)-HMAC-SHA1 from ASCII password and
+ - Keys are derived by PPKDF2(RFC2898)-HMAC-SHA1 from ASCII password and
Salt (saltSize = aesKeySize / 2).
- 2 bytes contain Password Verifier's Code
*/
@@ -21,8 +21,8 @@ specified in password Based File Encryption Utility:
#include "../../ICoder.h"
#include "../../IPassword.h"
-extern "C"
-{
+extern "C"
+{
#include "../../../../C/Aes.h"
}
@@ -53,7 +53,7 @@ public:
void Init() { KeySizeMode = 3; }
};
-class CBaseCoder:
+class CBaseCoder:
public ICompressFilter,
public ICryptoSetPassword,
public CMyUnknownImp
@@ -79,7 +79,7 @@ public:
UInt32 GetHeaderSize() const { return _key.GetSaltSize() + kPwdVerifCodeSize; }
};
-class CEncoder:
+class CEncoder:
public CBaseCoder
// public ICompressWriteCoderProperties
{
@@ -99,7 +99,7 @@ public:
}
};
-class CDecoder:
+class CDecoder:
public CBaseCoder,
public ICompressSetDecoderProperties2
{
diff --git a/CPP/7zip/Crypto/Zip/ZipCipher.h b/CPP/7zip/Crypto/Zip/ZipCipher.h
index d750336c..83732a41 100755
--- a/CPP/7zip/Crypto/Zip/ZipCipher.h
+++ b/CPP/7zip/Crypto/Zip/ZipCipher.h
@@ -14,7 +14,7 @@
namespace NCrypto {
namespace NZip {
-class CEncoder :
+class CEncoder :
public ICompressFilter,
public ICryptoSetPassword,
public ICryptoSetCRC,
@@ -36,7 +36,7 @@ public:
};
-class CDecoder:
+class CDecoder:
public ICompressFilter,
public ICryptoSetPassword,
public CMyUnknownImp
diff --git a/CPP/7zip/Crypto/Zip/ZipCrypto.cpp b/CPP/7zip/Crypto/Zip/ZipCrypto.cpp
index 7389ba25..55ec8e54 100755
--- a/CPP/7zip/Crypto/Zip/ZipCrypto.cpp
+++ b/CPP/7zip/Crypto/Zip/ZipCrypto.cpp
@@ -3,8 +3,8 @@
#include "StdAfx.h"
#include "ZipCipher.h"
-extern "C"
-{
+extern "C"
+{
#include "../../../../C/7zCrc.h"
}
diff --git a/CPP/7zip/Guid.txt b/CPP/7zip/Guid.txt
index f97a61a7..387a74d7 100755
--- a/CPP/7zip/Guid.txt
+++ b/CPP/7zip/Guid.txt
@@ -1,6 +1,6 @@
{23170F69-40C1-278A-0000-00yy00xx0000}
-00 IProgress.h
+00 IProgress.h
05 IProgress
@@ -13,7 +13,7 @@
0B IFolderArchiveUpdateCallback
0Ñ Agent.h::IArchiveFolderInternal
-03 IStream.h
+03 IStream.h
01 ISequentialInStream
02 ISequentialOutStream
@@ -29,7 +29,7 @@
05 ICompressCoder
18 ICompressCoder2
20 ICompressSetCoderProperties
- 21 ICompressSetDecoderProperties //
+ 21 ICompressSetDecoderProperties //
22 ICompressSetDecoderProperties2
23 ICompressWriteCoderProperties
24 ICompressGetInStreamProcessedSize
@@ -55,7 +55,7 @@
11 ICryptoGetTextPassword2
-06 IArchive.h
+06 IArchive.h
03 ISetProperties
@@ -118,6 +118,14 @@ Handler GUIDs:
09 Nsis
0A Lzma
+ DD Pe
+ DE Elf
+ DF Mach-O
+ E0 Udf
+ E1 Xar
+ E2 Mub
+ E3 Hfs
+ E4 Dmg
E5 Compound
E6 Wim
E7 Iso
@@ -131,7 +139,7 @@ Handler GUIDs:
EF GZip
{23170F69-40C1-278A-1000-000100030000} CAgentArchiveHandle
-{23170F69-40C1-278A-1000-000100020000} ContextMenu.h::CZipContextMenu
+{23170F69-40C1-278A-1000-000100020000} ContextMenu.h::CZipContextMenu
{23170F69-40C1-278B- old codecs clsids
diff --git a/CPP/7zip/ICoder.h b/CPP/7zip/ICoder.h
index 7b0ace12..262dfdba 100755
--- a/CPP/7zip/ICoder.h
+++ b/CPP/7zip/ICoder.h
@@ -15,8 +15,8 @@ CODER_INTERFACE(ICompressProgressInfo, 0x04)
CODER_INTERFACE(ICompressCoder, 0x05)
{
STDMETHOD(Code)(ISequentialInStream *inStream,
- ISequentialOutStream *outStream,
- const UInt64 *inSize,
+ ISequentialOutStream *outStream,
+ const UInt64 *inSize,
const UInt64 *outSize,
ICompressProgressInfo *progress) PURE;
};
@@ -24,9 +24,9 @@ CODER_INTERFACE(ICompressCoder, 0x05)
CODER_INTERFACE(ICompressCoder2, 0x18)
{
STDMETHOD(Code)(ISequentialInStream **inStreams,
- const UInt64 **inSizes,
+ const UInt64 **inSizes,
UInt32 numInStreams,
- ISequentialOutStream **outStreams,
+ ISequentialOutStream **outStreams,
const UInt64 **outSizes,
UInt32 numOutStreams,
ICompressProgressInfo *progress) PURE;
@@ -46,7 +46,7 @@ namespace NCoderPropID
kNumFastBytes = 0x450,
kMatchFinder,
kMatchFinderCycles,
- kNumPasses = 0x460,
+ kNumPasses = 0x460,
kAlgorithm = 0x470,
kMultiThread = 0x480,
kNumThreads,
@@ -56,7 +56,7 @@ namespace NCoderPropID
CODER_INTERFACE(ICompressSetCoderProperties, 0x20)
{
- STDMETHOD(SetCoderProperties)(const PROPID *propIDs,
+ STDMETHOD(SetCoderProperties)(const PROPID *propIDs,
const PROPVARIANT *properties, UInt32 numProperties) PURE;
};
@@ -121,7 +121,7 @@ CODER_INTERFACE(ICompressFilter, 0x40)
// Filter return outSize (UInt32)
// if (outSize <= size): Filter have converted outSize bytes
// if (outSize > size): Filter have not converted anything.
- // and it needs at least outSize bytes to convert one block
+ // and it needs at least outSize bytes to convert one block
// (it's for crypto block algorithms).
};
diff --git a/CPP/7zip/IProgress.h b/CPP/7zip/IProgress.h
index f5f54b28..d6093f17 100755
--- a/CPP/7zip/IProgress.h
+++ b/CPP/7zip/IProgress.h
@@ -8,15 +8,18 @@
#include "IDecl.h"
+#define INTERFACE_IProgress(x) \
+ STDMETHOD(SetTotal)(UInt64 total) x; \
+ STDMETHOD(SetCompleted)(const UInt64 *completeValue) x; \
+
DECL_INTERFACE(IProgress, 0, 5)
{
- STDMETHOD(SetTotal)(UInt64 total) PURE;
- STDMETHOD(SetCompleted)(const UInt64 *completeValue) PURE;
+ INTERFACE_IProgress(PURE)
};
/*
// {23170F69-40C1-278A-0000-000000050002}
-DEFINE_GUID(IID_IProgress2,
+DEFINE_GUID(IID_IProgress2,
0x23170F69, 0x40C1, 0x278A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x02);
MIDL_INTERFACE("23170F69-40C1-278A-0000-000000050002")
IProgress2: public IUnknown
diff --git a/CPP/7zip/IStream.h b/CPP/7zip/IStream.h
index a19d04f9..a177a9cb 100755
--- a/CPP/7zip/IStream.h
+++ b/CPP/7zip/IStream.h
@@ -17,7 +17,7 @@ STREAM_INTERFACE(ISequentialInStream, 0x01)
/*
Out: if size != 0, return_value = S_OK and (*processedSize == 0),
then there are no more bytes in stream.
- if (size > 0) && there are bytes in stream,
+ if (size > 0) && there are bytes in stream,
this function must read at least 1 byte.
This function is allowed to read less than number of remaining bytes in stream.
You must call Read function in loop, if you need exact amount of data
diff --git a/CPP/7zip/MyVersion.h b/CPP/7zip/MyVersion.h
index 6e57dea3..cf6aa5d3 100755
--- a/CPP/7zip/MyVersion.h
+++ b/CPP/7zip/MyVersion.h
@@ -1,8 +1,8 @@
#define MY_VER_MAJOR 4
-#define MY_VER_MINOR 58
-#define MY_VER_BUILD 10
-#define MY_VERSION " 4.58 beta"
-#define MY_7ZIP_VERSION "7-Zip 4.58 beta"
-#define MY_DATE "2008-05-05"
+#define MY_VER_MINOR 59
+#define MY_VER_BUILD 7
+#define MY_VERSION " 4.59 beta"
+#define MY_7ZIP_VERSION "7-Zip 4.59 beta"
+#define MY_DATE "2008-08-13"
#define MY_COPYRIGHT "Copyright (c) 1999-2008 Igor Pavlov"
#define MY_VERSION_COPYRIGHT_DATE MY_VERSION " " MY_COPYRIGHT " " MY_DATE
diff --git a/CPP/7zip/PropID.h b/CPP/7zip/PropID.h
index 40450ee1..9de487e8 100755
--- a/CPP/7zip/PropID.h
+++ b/CPP/7zip/PropID.h
@@ -1,7 +1,7 @@
-// Interface/PropID.h
+// PropID.h
-#ifndef __INTERFACE_PROPID_H
-#define __INTERFACE_PROPID_H
+#ifndef __7ZIP_PROPID_H
+#define __7ZIP_PROPID_H
enum
{
@@ -11,20 +11,20 @@ enum
kpidPath,
kpidName,
kpidExtension,
- kpidIsFolder,
+ kpidIsDir,
kpidSize,
- kpidPackedSize,
- kpidAttributes,
- kpidCreationTime,
- kpidLastAccessTime,
- kpidLastWriteTime,
- kpidSolid,
- kpidCommented,
- kpidEncrypted,
- kpidSplitBefore,
- kpidSplitAfter,
- kpidDictionarySize,
- kpidCRC,
+ kpidPackSize,
+ kpidAttrib,
+ kpidCTime,
+ kpidATime,
+ kpidMTime,
+ kpidSolid,
+ kpidCommented,
+ kpidEncrypted,
+ kpidSplitBefore,
+ kpidSplitAfter,
+ kpidDictionarySize,
+ kpidCRC,
kpidType,
kpidIsAnti,
kpidMethod,
@@ -36,7 +36,7 @@ enum
kpidComment,
kpidPosition,
kpidPrefix,
- kpidNumSubFolders,
+ kpidNumSubDirs,
kpidNumSubFiles,
kpidUnpackVer,
kpidVolume,
@@ -46,9 +46,17 @@ enum
kpidNumBlocks,
kpidNumVolumes,
kpidTimeType,
+ kpidBit64,
+ kpidBigEndian,
+ kpidCpu,
+ kpidPhySize,
+ kpidHeadersSize,
+ kpidChecksum,
+ kpidCharacts,
+ kpidVa,
kpidTotalSize = 0x1100,
- kpidFreeSpace,
+ kpidFreeSpace,
kpidClusterSize,
kpidVolumeName,
diff --git a/CPP/7zip/UI/Agent/Agent.cpp b/CPP/7zip/UI/Agent/Agent.cpp
index 82ae33bc..b0cb559f 100755
--- a/CPP/7zip/UI/Agent/Agent.cpp
+++ b/CPP/7zip/UI/Agent/Agent.cpp
@@ -22,9 +22,9 @@ extern "C"
using namespace NWindows;
STDMETHODIMP CAgentFolder::GetAgentFolder(CAgentFolder **agentFolder)
-{
- *agentFolder = this;
- return S_OK;
+{
+ *agentFolder = this;
+ return S_OK;
}
void CAgentFolder::LoadFolder(CProxyFolder *folder)
@@ -137,13 +137,13 @@ STDMETHODIMP CAgentFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARI
const CProxyFolder &item = folder->Folders[realIndex];
if (!_flatMode && propID == kpidSize)
prop = item.Size;
- else if (!_flatMode && propID == kpidPackedSize)
+ else if (!_flatMode && propID == kpidPackSize)
prop = item.PackSize;
else
switch(propID)
{
- case kpidIsFolder: prop = true; break;
- case kpidNumSubFolders: prop = item.NumSubFolders; break;
+ case kpidIsDir: prop = true; break;
+ case kpidNumSubDirs: prop = item.NumSubFolders; break;
case kpidNumSubFiles: prop = item.NumSubFiles; break;
case kpidName: prop = item.Name; break;
case kpidCRC:
@@ -153,7 +153,7 @@ STDMETHODIMP CAgentFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARI
RINOK(_agentSpec->GetArchive()->GetProperty(item.Index, propID, value));
}
if (item.CrcIsDefined && value->vt == VT_EMPTY)
- prop = item.Crc;
+ prop = item.Crc;
break;
}
case kpidPrefix: GetPrefixIfAny(itemIndex, prop); break;
@@ -169,10 +169,10 @@ STDMETHODIMP CAgentFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARI
const CProxyFile &item = folder->Files[realIndex];
switch(propID)
{
- case kpidIsFolder: prop = false; break;
+ case kpidIsDir: prop = false; break;
case kpidName: prop = item.Name; break;
case kpidPrefix: GetPrefixIfAny(itemIndex, prop); break;
- default:
+ default:
return _agentSpec->GetArchive()->GetProperty(item.Index, propID, value);
}
}
@@ -238,9 +238,9 @@ STDMETHODIMP CAgentFolder::BindToParentFolder(IFolderFolder **resultFolder)
COM_TRY_END
}
-STATPROPSTG kProperties[] =
+STATPROPSTG kProperties[] =
{
- { NULL, kpidNumSubFolders, VT_UI4},
+ { NULL, kpidNumSubDirs, VT_UI4},
{ NULL, kpidNumSubFiles, VT_UI4},
{ NULL, kpidPrefix, VT_BSTR}
};
@@ -287,11 +287,11 @@ STDMETHODIMP CAgentFolder::GetPropertyInfo(UInt32 index, BSTR *name, PROPID *pro
COM_TRY_END
}
-STATPROPSTG kFolderProps[] =
+STATPROPSTG kFolderProps[] =
{
{ NULL, kpidSize, VT_UI8},
- { NULL, kpidPackedSize, VT_UI8},
- { NULL, kpidNumSubFolders, VT_UI4},
+ { NULL, kpidPackSize, VT_UI8},
+ { NULL, kpidNumSubDirs, VT_UI4},
{ NULL, kpidNumSubFiles, VT_UI4},
{ NULL, kpidCRC, VT_UI4}
};
@@ -304,12 +304,12 @@ STDMETHODIMP CAgentFolder::GetFolderProperty(PROPID propID, PROPVARIANT *value)
NWindows::NCOM::CPropVariant prop;
switch(propID)
{
- case kpidSize: prop = _proxyFolderItem->Size; break;
- case kpidPackedSize: prop = _proxyFolderItem->PackSize; break;
- case kpidNumSubFolders: prop = _proxyFolderItem->NumSubFolders; break;
- case kpidNumSubFiles: prop = _proxyFolderItem->NumSubFiles; break;
- case kpidName: prop = _proxyFolderItem->Name; break;
- case kpidPath: prop = _proxyFolderItem->GetFullPathPrefix(); break;
+ case kpidSize: prop = _proxyFolderItem->Size; break;
+ case kpidPackSize: prop = _proxyFolderItem->PackSize; break;
+ case kpidNumSubDirs: prop = _proxyFolderItem->NumSubFolders; break;
+ case kpidNumSubFiles: prop = _proxyFolderItem->NumSubFiles; break;
+ case kpidName: prop = _proxyFolderItem->Name; break;
+ case kpidPath: prop = _proxyFolderItem->GetFullPathPrefix(); break;
case kpidType: prop = UString(L"7-Zip.") + _agentSpec->ArchiveType; break;
case kpidCRC: if (_proxyFolderItem->CrcIsDefined) prop = _proxyFolderItem->Crc; break;
}
@@ -373,10 +373,10 @@ void CAgentFolder::GetRealIndices(const UInt32 *indices, UInt32 numItems, CUIntV
HeapSort(&realIndices.Front(), realIndices.Size());
}
-STDMETHODIMP CAgentFolder::Extract(const UInt32 *indices,
- UInt32 numItems,
- NExtract::NPathMode::EEnum pathMode,
- NExtract::NOverwriteMode::EEnum overwriteMode,
+STDMETHODIMP CAgentFolder::Extract(const UInt32 *indices,
+ UInt32 numItems,
+ NExtract::NPathMode::EEnum pathMode,
+ NExtract::NOverwriteMode::EEnum overwriteMode,
const wchar_t *path,
INT32 testMode,
IFolderArchiveExtractCallback *extractCallback2)
@@ -399,20 +399,20 @@ STDMETHODIMP CAgentFolder::Extract(const UInt32 *indices,
extractCallbackSpec->InitForMulti(false, pathMode, overwriteMode);
- extractCallbackSpec->Init(_agentSpec->GetArchive(),
- extractCallback2,
+ extractCallbackSpec->Init(_agentSpec->GetArchive(),
+ extractCallback2,
false,
(path ? path : L""),
- pathParts,
+ pathParts,
_agentSpec->DefaultName,
- _agentSpec->DefaultTime,
- _agentSpec->DefaultAttributes,
+ _agentSpec->DefaultTime,
+ _agentSpec->DefaultAttrib,
(UInt64)(Int64)-1
// ,_agentSpec->_srcDirectoryPrefix
);
CUIntVector realIndices;
GetRealIndices(indices, numItems, realIndices);
- return _agentSpec->GetArchive()->Extract(&realIndices.Front(),
+ return _agentSpec->GetArchive()->Extract(&realIndices.Front(),
realIndices.Size(), testMode, extractCallback);
COM_TRY_END
}
@@ -433,7 +433,7 @@ CAgent::~CAgent()
}
STDMETHODIMP CAgent::Open(
- const wchar_t *filePath,
+ const wchar_t *filePath,
BSTR *archiveType,
// CLSID *clsIDResult,
IArchiveOpenCallback *openArchiveCallback)
@@ -443,7 +443,7 @@ STDMETHODIMP CAgent::Open(
NFile::NFind::CFileInfoW fileInfo;
if (!NFile::NFind::FindFile(_archiveFilePath, fileInfo))
return ::GetLastError();
- if (fileInfo.IsDirectory())
+ if (fileInfo.IsDir())
return E_FAIL;
CArcInfoEx archiverInfo0, archiverInfo1;
@@ -452,14 +452,13 @@ STDMETHODIMP CAgent::Open(
_compressCodecsInfo = _codecs;
RINOK(_codecs->Load());
- HRESULT res = OpenArchive(_codecs, _archiveFilePath, _archiveLink, openArchiveCallback);
+ RINOK(OpenArchive(_codecs, CIntVector(), _archiveFilePath, _archiveLink, openArchiveCallback));
// _archive = _archiveLink.GetArchive();
DefaultName = _archiveLink.GetDefaultItemName();
const CArcInfoEx &ai = _codecs->Formats[_archiveLink.GetArchiverIndex()];
- RINOK(res);
- DefaultTime = fileInfo.LastWriteTime;
- DefaultAttributes = fileInfo.Attributes;
+ DefaultTime = fileInfo.MTime;
+ DefaultAttrib = fileInfo.Attrib;
ArchiveType = ai.Name;
if (archiveType != 0)
{
@@ -470,7 +469,7 @@ STDMETHODIMP CAgent::Open(
COM_TRY_END
}
-STDMETHODIMP CAgent::ReOpen(IArchiveOpenCallback * /* openArchiveCallback */)
+STDMETHODIMP CAgent::ReOpen(IArchiveOpenCallback *openArchiveCallback)
{
COM_TRY_BEGIN
if (_proxyArchive != NULL)
@@ -478,7 +477,7 @@ STDMETHODIMP CAgent::ReOpen(IArchiveOpenCallback * /* openArchiveCallback */)
delete _proxyArchive;
_proxyArchive = NULL;
}
- RINOK(ReOpenArchive(_codecs, _archiveLink, _archiveFilePath));
+ RINOK(ReOpenArchive(_codecs, _archiveLink, _archiveFilePath, openArchiveCallback));
return ReadItems();
COM_TRY_END
}
@@ -508,10 +507,10 @@ HRESULT CAgent::ReadItems()
if (_proxyArchive != NULL)
return S_OK;
_proxyArchive = new CProxyArchive();
- return _proxyArchive->Load(GetArchive(),
- DefaultName,
- // _defaultTime,
- // _defaultAttributes,
+ return _proxyArchive->Load(GetArchive(),
+ DefaultName,
+ // _defaultTime,
+ // _defaultAttrib,
NULL);
}
@@ -529,8 +528,8 @@ STDMETHODIMP CAgent::BindToRootFolder(IFolderFolder **resultFolder)
STDMETHODIMP CAgent::Extract(
- NExtract::NPathMode::EEnum pathMode,
- NExtract::NOverwriteMode::EEnum overwriteMode,
+ NExtract::NPathMode::EEnum pathMode,
+ NExtract::NOverwriteMode::EEnum overwriteMode,
const wchar_t *path,
INT32 testMode,
IFolderArchiveExtractCallback *extractCallback2)
@@ -539,14 +538,14 @@ STDMETHODIMP CAgent::Extract(
CArchiveExtractCallback *extractCallbackSpec = new CArchiveExtractCallback;
CMyComPtr<IArchiveExtractCallback> extractCallback = extractCallbackSpec;
extractCallbackSpec->InitForMulti(false, pathMode, overwriteMode);
- extractCallbackSpec->Init(GetArchive(),
- extractCallback2,
+ extractCallbackSpec->Init(GetArchive(),
+ extractCallback2,
false,
path,
- UStringVector(),
+ UStringVector(),
DefaultName,
- DefaultTime,
- DefaultAttributes,
+ DefaultTime,
+ DefaultAttrib,
(UInt64)(Int64)-1
// ,_srcDirectoryPrefix
);
@@ -561,7 +560,7 @@ STDMETHODIMP CAgent::GetNumberOfProperties(UInt32 *numProperties)
COM_TRY_END
}
-STDMETHODIMP CAgent::GetPropertyInfo(UInt32 index,
+STDMETHODIMP CAgent::GetPropertyInfo(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType)
{
COM_TRY_BEGIN
@@ -586,11 +585,11 @@ STDMETHODIMP CAgent::GetNumberOfArchiveProperties(UInt32 *numProperties)
COM_TRY_END
}
-STDMETHODIMP CAgent::GetArchivePropertyInfo(UInt32 index,
+STDMETHODIMP CAgent::GetArchivePropertyInfo(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType)
{
COM_TRY_BEGIN
- return GetArchive()->GetArchivePropertyInfo(index,
+ return GetArchive()->GetArchivePropertyInfo(index,
name, propID, varType);
COM_TRY_END
}
diff --git a/CPP/7zip/UI/Agent/Agent.h b/CPP/7zip/UI/Agent/Agent.h
index 0f2d7573..64fb31f6 100755
--- a/CPP/7zip/UI/Agent/Agent.h
+++ b/CPP/7zip/UI/Agent/Agent.h
@@ -21,7 +21,7 @@ class CAgentFolder;
DECL_INTERFACE(IArchiveFolderInternal, 0x01, 0xC)
{
- STDMETHOD(GetAgentFolder)(CAgentFolder **agentFolder) PURE;
+ STDMETHOD(GetAgentFolder)(CAgentFolder **agentFolder) PURE;
};
struct CProxyItem
@@ -32,7 +32,7 @@ struct CProxyItem
class CAgent;
-class CAgentFolder:
+class CAgentFolder:
public IFolderFolder,
public IFolderProperties,
public IGetFolderArchiveProperties,
@@ -46,7 +46,7 @@ class CAgentFolder:
{
public:
- MY_QUERYINTERFACE_BEGIN
+ MY_QUERYINTERFACE_BEGIN
MY_QUERYINTERFACE_ENTRY(IFolderFolder)
MY_QUERYINTERFACE_ENTRY(IFolderProperties)
MY_QUERYINTERFACE_ENTRY(IGetFolderArchiveProperties)
@@ -69,9 +69,9 @@ public:
STDMETHOD(GetFolderArchiveProperties)(IFolderArchiveProperties **object);
// IArchiveFolder
- STDMETHOD(Extract)(const UINT32 *indices, UINT32 numItems,
- NExtract::NPathMode::EEnum pathMode,
- NExtract::NOverwriteMode::EEnum overwriteMode,
+ STDMETHOD(Extract)(const UINT32 *indices, UINT32 numItems,
+ NExtract::NPathMode::EEnum pathMode,
+ NExtract::NOverwriteMode::EEnum overwriteMode,
const wchar_t *path,
INT32 testMode,
IFolderArchiveExtractCallback *extractCallback);
@@ -103,7 +103,7 @@ public:
bool deleteOperation,
bool createFolderOperation,
bool renameOperation,
- const wchar_t *newItemName,
+ const wchar_t *newItemName,
const NUpdateArchive::CActionSet *actionSet,
const UINT32 *indices, UINT32 numItems,
IFolderArchiveUpdateCallback *updateCallback100);
@@ -126,7 +126,7 @@ public:
private:
};
-class CAgent:
+class CAgent:
public IInFolderArchive,
public IFolderArchiveProperties,
#ifndef EXTRACT_ONLY
@@ -137,7 +137,7 @@ class CAgent:
{
public:
- MY_QUERYINTERFACE_BEGIN
+ MY_QUERYINTERFACE_BEGIN
MY_QUERYINTERFACE_ENTRY(IInFolderArchive)
MY_QUERYINTERFACE_ENTRY(IFolderArchiveProperties)
#ifndef EXTRACT_ONLY
@@ -154,19 +154,19 @@ public:
INTERFACE_IOutFolderArchive(;)
HRESULT CommonUpdate(
- const wchar_t *newArchiveName,
+ const wchar_t *newArchiveName,
int numUpdateItems,
IArchiveUpdateCallback *updateCallback);
HRESULT CreateFolder(
- const wchar_t *newArchiveName,
- const wchar_t *folderName,
+ const wchar_t *newArchiveName,
+ const wchar_t *folderName,
IFolderArchiveUpdateCallback *updateCallback100);
HRESULT RenameItem(
- const wchar_t *newArchiveName,
- const UINT32 *indices, UINT32 numItems,
- const wchar_t *newItemName,
+ const wchar_t *newArchiveName,
+ const UINT32 *indices, UINT32 numItems,
+ const wchar_t *newItemName,
IFolderArchiveUpdateCallback *updateCallback100);
// ISetProperties
@@ -189,7 +189,7 @@ public:
UString DefaultName;
FILETIME DefaultTime;
- UINT32 DefaultAttributes;
+ DWORD DefaultAttrib;
UString ArchiveType;
@@ -211,7 +211,7 @@ public:
};
#ifdef NEW_FOLDER_INTERFACE
-class CArchiveFolderManager:
+class CArchiveFolderManager:
public IFolderManager,
public CMyUnknownImp
{
@@ -223,7 +223,7 @@ public:
CArchiveFolderManager(): _codecs(0) {}
private:
void LoadFormats();
- int FindFormat(const UString &type);
+ int FindFormat(const UString &type);
CCodecs *_codecs;
CMyComPtr<ICompressCodecsInfo> _compressCodecsInfo;
};
diff --git a/CPP/7zip/UI/Agent/AgentOut.cpp b/CPP/7zip/UI/Agent/AgentOut.cpp
index 7976e1a2..2e953aed 100755
--- a/CPP/7zip/UI/Agent/AgentOut.cpp
+++ b/CPP/7zip/UI/Agent/AgentOut.cpp
@@ -2,13 +2,14 @@
#include "StdAfx.h"
-#include "Common/StringConvert.h"
#include "Common/IntToString.h"
+#include "Common/StringConvert.h"
#include "Windows/Defs.h"
+#include "Windows/FileDir.h"
#include "Windows/PropVariant.h"
#include "Windows/PropVariantConversions.h"
-#include "Windows/FileDir.h"
+#include "Windows/Time.h"
#include "../../Compress/Copy/CopyCoder.h"
#include "../../Common/FileStreams.h"
@@ -54,7 +55,7 @@ STDMETHODIMP CAgent::SetFolder(IFolderFolder *folder)
for (;;)
{
CMyComPtr<IFolderFolder> newFolder;
- folderItem->BindToParentFolder(&newFolder);
+ folderItem->BindToParentFolder(&newFolder);
if (newFolder == NULL)
break;
@@ -73,22 +74,22 @@ STDMETHODIMP CAgent::SetFolder(IFolderFolder *folder)
return S_OK;
}
-STDMETHODIMP CAgent::SetFiles(const wchar_t *folderPrefix,
- const wchar_t **names, UINT32 numNames)
+STDMETHODIMP CAgent::SetFiles(const wchar_t *folderPrefix,
+ const wchar_t **names, UInt32 numNames)
{
_folderPrefix = folderPrefix;
_names.Clear();
_names.Reserve(numNames);
- for (UINT32 i = 0; i < numNames; i++)
+ for (UInt32 i = 0; i < numNames; i++)
_names.Add(names[i]);
return S_OK;
}
-static HRESULT GetFileTime(CAgent *agent, UINT32 itemIndex, FILETIME &fileTime)
+static HRESULT GetFileTime(CAgent *agent, UInt32 itemIndex, FILETIME &fileTime)
{
CPropVariant property;
- RINOK(agent->GetArchive()->GetProperty(itemIndex, kpidLastWriteTime, &property));
+ RINOK(agent->GetArchive()->GetProperty(itemIndex, kpidMTime, &property));
if (property.vt == VT_FILETIME)
fileTime = property.filetime;
else if (property.vt == VT_EMPTY)
@@ -99,54 +100,54 @@ static HRESULT GetFileTime(CAgent *agent, UINT32 itemIndex, FILETIME &fileTime)
}
static HRESULT EnumerateArchiveItems(CAgent *agent,
- const CProxyFolder &item,
+ const CProxyFolder &item,
const UString &prefix,
- CObjectVector<CArchiveItem> &archiveItems)
+ CObjectVector<CArcItem> &arcItems)
{
int i;
- for(i = 0; i < item.Files.Size(); i++)
+ for (i = 0; i < item.Files.Size(); i++)
{
const CProxyFile &fileItem = item.Files[i];
- CArchiveItem archiveItem;
+ CArcItem ai;
- RINOK(::GetFileTime(agent, fileItem.Index, archiveItem.LastWriteTime));
+ RINOK(::GetFileTime(agent, fileItem.Index, ai.MTime));
CPropVariant property;
agent->GetArchive()->GetProperty(fileItem.Index, kpidSize, &property);
- archiveItem.SizeIsDefined = (property.vt != VT_EMPTY);
- if (archiveItem.SizeIsDefined)
- archiveItem.Size = ConvertPropVariantToUInt64(property);
- archiveItem.IsDirectory = false;
- archiveItem.Name = prefix + fileItem.Name;
- archiveItem.Censored = true; // test it
- archiveItem.IndexInServer = fileItem.Index;
- archiveItems.Add(archiveItem);
+ ai.SizeDefined = (property.vt != VT_EMPTY);
+ if (ai.SizeDefined)
+ ai.Size = ConvertPropVariantToUInt64(property);
+ ai.IsDir = false;
+ ai.Name = prefix + fileItem.Name;
+ ai.Censored = true; // test it
+ ai.IndexInServer = fileItem.Index;
+ arcItems.Add(ai);
}
- for(i = 0; i < item.Folders.Size(); i++)
+ for (i = 0; i < item.Folders.Size(); i++)
{
const CProxyFolder &dirItem = item.Folders[i];
UString fullName = prefix + dirItem.Name;
if(dirItem.IsLeaf)
{
- CArchiveItem archiveItem;
- RINOK(::GetFileTime(agent, dirItem.Index, archiveItem.LastWriteTime));
- archiveItem.IsDirectory = true;
- archiveItem.SizeIsDefined = false;
- archiveItem.Name = fullName;
- archiveItem.Censored = true; // test it
- archiveItem.IndexInServer = dirItem.Index;
- archiveItems.Add(archiveItem);
+ CArcItem ai;
+ RINOK(::GetFileTime(agent, dirItem.Index, ai.MTime));
+ ai.IsDir = true;
+ ai.SizeDefined = false;
+ ai.Name = fullName;
+ ai.Censored = true; // test it
+ ai.IndexInServer = dirItem.Index;
+ arcItems.Add(ai);
}
- RINOK(EnumerateArchiveItems(agent, dirItem, fullName + UString(L'\\'), archiveItems));
+ RINOK(EnumerateArchiveItems(agent, dirItem, fullName + UString(L'\\'), arcItems));
}
return S_OK;
}
STDMETHODIMP CAgent::DoOperation(
- CCodecs *codecs,
+ CCodecs *codecs,
int formatIndex,
- const wchar_t *newArchiveName,
- const Byte *stateActions,
+ const wchar_t *newArchiveName,
+ const Byte *stateActions,
const wchar_t *sfxModule,
IFolderArchiveUpdateCallback *updateCallback100)
{
@@ -157,16 +158,16 @@ STDMETHODIMP CAgent::DoOperation(
for (i = 0; i < NUpdateArchive::NPairState::kNumValues; i++)
actionSet.StateActions[i] = (NUpdateArchive::NPairAction::EEnum)stateActions[i];
- CObjectVector<CDirItem> dirItems;
+ CDirItems dirItems;
- UString folderPrefix = _folderPrefix;
- NFile::NName::NormalizeDirPathPrefix(folderPrefix);
- UStringVector errorPaths;
- CRecordVector<DWORD> errorCodes;
- ::EnumerateDirItems(folderPrefix, _names, _archiveNamePrefix, dirItems, errorPaths, errorCodes);
- if (errorCodes.Size() > 0)
{
- return errorCodes.Front();
+ UString folderPrefix = _folderPrefix;
+ NFile::NName::NormalizeDirPathPrefix(folderPrefix);
+ UStringVector errorPaths;
+ CRecordVector<DWORD> errorCodes;
+ dirItems.EnumerateDirItems2(folderPrefix, _archiveNamePrefix, _names, errorPaths, errorCodes);
+ if (errorCodes.Size() > 0)
+ return errorCodes.Front();
}
CMyComPtr<IOutArchive> outArchive;
@@ -193,7 +194,7 @@ STDMETHODIMP CAgent::DoOperation(
}
NFileTimeType::EEnum fileTimeType;
- UINT32 value;
+ UInt32 value;
RINOK(outArchive->GetFileTimeType(&value));
switch(value)
@@ -207,19 +208,21 @@ STDMETHODIMP CAgent::DoOperation(
return E_FAIL;
}
- CObjectVector<CUpdatePair> updatePairs;
- CObjectVector<CArchiveItem> archiveItems;
+ CObjectVector<CArcItem> arcItems;
if (GetArchive())
{
RINOK(ReadItems());
- EnumerateArchiveItems(this, _proxyArchive->RootFolder, L"", archiveItems);
+ EnumerateArchiveItems(this, _proxyArchive->RootFolder, L"", arcItems);
}
- GetUpdatePairInfoList(dirItems, archiveItems, fileTimeType, updatePairs);
-
- CObjectVector<CUpdatePair2> updatePairs2;
- UpdateProduce(updatePairs, actionSet, updatePairs2);
+ CRecordVector<CUpdatePair2> updatePairs2;
+
+ {
+ CRecordVector<CUpdatePair> updatePairs;
+ GetUpdatePairInfoList(dirItems, arcItems, fileTimeType, updatePairs);
+ UpdateProduce(updatePairs, actionSet, updatePairs2);
+ }
UInt32 numFiles = 0;
for (i = 0; i < updatePairs2.Size(); i++)
@@ -236,9 +239,8 @@ STDMETHODIMP CAgent::DoOperation(
CArchiveUpdateCallback *updateCallbackSpec = new CArchiveUpdateCallback;
CMyComPtr<IArchiveUpdateCallback> updateCallback(updateCallbackSpec );
- updateCallbackSpec->DirPrefix = folderPrefix;
updateCallbackSpec->DirItems = &dirItems;
- updateCallbackSpec->ArchiveItems = &archiveItems;
+ updateCallbackSpec->ArcItems = &arcItems;
updateCallbackSpec->UpdatePairs = &updatePairs2;
updateCallbackSpec->Archive = GetArchive();
updateCallbackSpec->Callback = &updateCallbackAgent;
@@ -305,12 +307,12 @@ STDMETHODIMP CAgent::DoOperation(
}
STDMETHODIMP CAgent::DoOperation2(
- const wchar_t *newArchiveName,
- const Byte *stateActions,
+ const wchar_t *newArchiveName,
+ const Byte *stateActions,
const wchar_t *sfxModule,
IFolderArchiveUpdateCallback *updateCallback100)
{
- return DoOperation(_codecs, -1, newArchiveName,
+ return DoOperation(_codecs, -1, newArchiveName,
stateActions, sfxModule, updateCallback100);
}
@@ -370,8 +372,8 @@ HRESULT CAgent::CommonUpdate(
STDMETHODIMP CAgent::DeleteItems(
- const wchar_t *newArchiveName,
- const UINT32 *indices, UINT32 numItems,
+ const wchar_t *newArchiveName,
+ const UInt32 *indices, UInt32 numItems,
IFolderArchiveUpdateCallback *updateCallback100)
{
if (!CanUpdate())
@@ -383,7 +385,7 @@ STDMETHODIMP CAgent::DeleteItems(
CUIntVector realIndices;
_agentFolder->GetRealIndices(indices, numItems, realIndices);
- CObjectVector<CUpdatePair2> updatePairs;
+ CRecordVector<CUpdatePair2> updatePairs;
int curIndex = 0;
UInt32 numItemsInArchive;
RINOK(GetArchive()->GetNumberOfItems(&numItemsInArchive));
@@ -395,13 +397,11 @@ STDMETHODIMP CAgent::DeleteItems(
curIndex++;
continue;
}
- CUpdatePair2 updatePair;
- updatePair.NewData = updatePair.NewProperties = false;
- updatePair.ExistInArchive = true;
- updatePair.ExistOnDisk = false;
- updatePair.IsAnti = false; // check it. Maybe it can be undefined
- updatePair.ArchiveItemIndex = i;
- updatePairs.Add(updatePair);
+ CUpdatePair2 up2;
+ up2.NewData = up2.NewProps = false;
+ up2.IsAnti = false; // check it. Maybe it can be undefined
+ up2.ArcIndex = i;
+ updatePairs.Add(up2);
}
updateCallbackSpec->UpdatePairs = &updatePairs;
updateCallbackSpec->Archive = GetArchive();
@@ -410,8 +410,8 @@ STDMETHODIMP CAgent::DeleteItems(
}
HRESULT CAgent::CreateFolder(
- const wchar_t *newArchiveName,
- const wchar_t *folderName,
+ const wchar_t *newArchiveName,
+ const wchar_t *folderName,
IFolderArchiveUpdateCallback *updateCallback100)
{
if (!CanUpdate())
@@ -421,44 +421,38 @@ HRESULT CAgent::CreateFolder(
CArchiveUpdateCallback *updateCallbackSpec = new CArchiveUpdateCallback;
CMyComPtr<IArchiveUpdateCallback> updateCallback(updateCallbackSpec);
- CObjectVector<CUpdatePair2> updatePairs;
- UINT32 numItemsInArchive;
+ CRecordVector<CUpdatePair2> updatePairs;
+ UInt32 numItemsInArchive;
RINOK(GetArchive()->GetNumberOfItems(&numItemsInArchive));
for (UInt32 i = 0; i < numItemsInArchive; i++)
{
- CUpdatePair2 updatePair;
- updatePair.NewData = updatePair.NewProperties = false;
- updatePair.ExistInArchive = true;
- updatePair.ExistOnDisk = false;
- updatePair.IsAnti = false; // check it.
- updatePair.ArchiveItemIndex = i;
- updatePairs.Add(updatePair);
+ CUpdatePair2 up2;
+ up2.NewData = up2.NewProps = false;
+ up2.IsAnti = false; // check it.
+ up2.ArcIndex = i;
+ updatePairs.Add(up2);
}
- CUpdatePair2 updatePair;
- updatePair.NewData = updatePair.NewProperties = true;
- updatePair.ExistInArchive = false;
- updatePair.ExistOnDisk = true;
- updatePair.IsAnti = false;
- updatePair.ArchiveItemIndex = -1;
- updatePair.DirItemIndex = 0;
+ CUpdatePair2 up2;
+ up2.NewData = up2.NewProps = true;
+ up2.IsAnti = false;
+ up2.DirIndex = 0;
+
+ updatePairs.Add(up2);
- updatePairs.Add(updatePair);
+ updatePairs.ReserveDown();
- CObjectVector<CDirItem> dirItems;
- CDirItem dirItem;
+ CDirItems dirItems;
+ CDirItem di;
- dirItem.Attributes = FILE_ATTRIBUTE_DIRECTORY;
- dirItem.Size = 0;
- dirItem.Name = _agentFolder->_proxyFolderItem->GetFullPathPrefix() + folderName;
+ di.Attrib = FILE_ATTRIBUTE_DIRECTORY;
+ di.Size = 0;
+ di.Name = _agentFolder->_proxyFolderItem->GetFullPathPrefix() + folderName;
- SYSTEMTIME systemTime;
- FILETIME fileTime;
- ::GetSystemTime(&systemTime);
- ::SystemTimeToFileTime(&systemTime, &fileTime);
- dirItem.LastAccessTime = dirItem.LastWriteTime =
- dirItem.CreationTime = fileTime;
+ FILETIME ft;
+ NTime::GetCurUtcFileTime(ft);
+ di.CTime = di.ATime = di.MTime = ft;
- dirItems.Add(dirItem);
+ dirItems.Items.Add(di);
updateCallbackSpec->Callback = &updateCallbackAgent;
updateCallbackSpec->DirItems = &dirItems;
@@ -469,9 +463,9 @@ HRESULT CAgent::CreateFolder(
HRESULT CAgent::RenameItem(
- const wchar_t *newArchiveName,
- const UINT32 *indices, UINT32 numItems,
- const wchar_t *newItemName,
+ const wchar_t *newArchiveName,
+ const UInt32 *indices, UInt32 numItems,
+ const wchar_t *newItemName,
IFolderArchiveUpdateCallback *updateCallback100)
{
if (!CanUpdate())
@@ -490,25 +484,22 @@ HRESULT CAgent::RenameItem(
UString oldItemPath = fullPrefix + _agentFolder->GetName(indices[0]);
UString newItemPath = fullPrefix + newItemName;
- CObjectVector<CUpdatePair2> updatePairs;
+ CRecordVector<CUpdatePair2> updatePairs;
+ UStringVector newNames;
+
int curIndex = 0;
- UINT32 numItemsInArchive;
+ UInt32 numItemsInArchive;
RINOK(GetArchive()->GetNumberOfItems(&numItemsInArchive));
for (UInt32 i = 0; i < numItemsInArchive; i++)
{
if (curIndex < realIndices.Size())
if (realIndices[curIndex] == i)
{
- CUpdatePair2 updatePair;
- updatePair.NewData = false;
- updatePair.NewProperties = true;
- updatePair.ExistInArchive = true;
- updatePair.ExistOnDisk = false;
- RINOK(IsArchiveItemAnti(GetArchive(), i, updatePair.IsAnti));
- updatePair.ArchiveItemIndex = i;
- updatePair.NewNameIsDefined = true;
-
- updatePair.NewName = newItemName;
+ CUpdatePair2 up2;
+ up2.NewData = false;
+ up2.NewProps = true;
+ RINOK(IsArchiveItemAnti(GetArchive(), i, up2.IsAnti));
+ up2.ArcIndex = i;
UString oldFullPath;
RINOK(GetArchiveItemPath(GetArchive(), i, DefaultName, oldFullPath));
@@ -516,26 +507,25 @@ HRESULT CAgent::RenameItem(
if (oldItemPath.CompareNoCase(oldFullPath.Left(oldItemPath.Length())) != 0)
return E_INVALIDARG;
- updatePair.NewName = newItemPath + oldFullPath.Mid(oldItemPath.Length());
- updatePairs.Add(updatePair);
+ up2.NewNameIndex = newNames.Add(newItemPath + oldFullPath.Mid(oldItemPath.Length()));
+ updatePairs.Add(up2);
curIndex++;
continue;
}
- CUpdatePair2 updatePair;
- updatePair.NewData = updatePair.NewProperties = false;
- updatePair.ExistInArchive = true;
- updatePair.ExistOnDisk = false;
- updatePair.IsAnti = false;
- updatePair.ArchiveItemIndex = i;
- updatePairs.Add(updatePair);
+ CUpdatePair2 up2;
+ up2.NewData = up2.NewProps = false;
+ up2.IsAnti = false;
+ up2.ArcIndex = i;
+ updatePairs.Add(up2);
}
updateCallbackSpec->Callback = &updateCallbackAgent;
updateCallbackSpec->UpdatePairs = &updatePairs;
+ updateCallbackSpec->NewNames = &newNames;
updateCallbackSpec->Archive = GetArchive();
return CommonUpdate(newArchiveName, updatePairs.Size(), updateCallback);
}
-STDMETHODIMP CAgent::SetProperties(const wchar_t **names,
+STDMETHODIMP CAgent::SetProperties(const wchar_t **names,
const PROPVARIANT *values, INT32 numProperties)
{
m_PropNames.Clear();
diff --git a/CPP/7zip/UI/Agent/AgentProxy.cpp b/CPP/7zip/UI/Agent/AgentProxy.cpp
index a50a26c7..704b5d33 100755
--- a/CPP/7zip/UI/Agent/AgentProxy.cpp
+++ b/CPP/7zip/UI/Agent/AgentProxy.cpp
@@ -80,7 +80,7 @@ void CProxyFolder::Clear()
Files.Clear();
}
-void CProxyFolder::GetPathParts(UStringVector &pathParts) const
+void CProxyFolder::GetPathParts(UStringVector &pathParts) const
{
pathParts.Clear();
UString result;
@@ -92,7 +92,7 @@ void CProxyFolder::GetPathParts(UStringVector &pathParts) const
}
}
-UString CProxyFolder::GetFullPathPrefix() const
+UString CProxyFolder::GetFullPathPrefix() const
{
UString result;
const CProxyFolder *current = this;
@@ -104,7 +104,7 @@ UString CProxyFolder::GetFullPathPrefix() const
return result;
}
-UString CProxyFolder::GetItemName(UInt32 index) const
+UString CProxyFolder::GetItemName(UInt32 index) const
{
if (index < (UInt32)Folders.Size())
return Folders[index].Name;
@@ -146,8 +146,8 @@ HRESULT CProxyArchive::Reload(IInArchive *archive, IProgress *progress)
return ReadObjects(archive, progress);
}
-HRESULT CProxyArchive::Load(IInArchive *archive,
- const UString &defaultName,
+HRESULT CProxyArchive::Load(IInArchive *archive,
+ const UString &defaultName,
// const FILETIME &defaultTime,
// UInt32 defaultAttributes,
IProgress *progress)
@@ -179,7 +179,7 @@ void CProxyFolder::CalculateSizes(IInArchive *archive)
{
UInt32 index = Files[i].Index;
Size += GetSize(archive, index, kpidSize);
- PackSize += GetSize(archive, index, kpidPackedSize);
+ PackSize += GetSize(archive, index, kpidPackSize);
{
NCOM::CPropVariant prop;
if (archive->GetProperty(index, kpidCRC, &prop) == S_OK)
@@ -213,14 +213,14 @@ HRESULT CProxyArchive::ReadObjects(IInArchive *archive, IProgress *progress)
RINOK(archive->GetNumberOfItems(&numItems));
if (progress != NULL)
{
- UINT64 totalItems = numItems;
+ UINT64 totalItems = numItems;
RINOK(progress->SetTotal(totalItems));
}
for(UInt32 i = 0; i < numItems; i++)
{
if (progress != NULL)
{
- UINT64 currentItemIndex = i;
+ UINT64 currentItemIndex = i;
RINOK(progress->SetCompleted(&currentItemIndex));
}
NCOM::CPropVariant propVariantPath;
diff --git a/CPP/7zip/UI/Agent/AgentProxy.h b/CPP/7zip/UI/Agent/AgentProxy.h
index 5cf7a05b..a0111088 100755
--- a/CPP/7zip/UI/Agent/AgentProxy.h
+++ b/CPP/7zip/UI/Agent/AgentProxy.h
@@ -53,7 +53,7 @@ public:
// UInt32 DefaultAttributes;
CProxyFolder RootFolder;
HRESULT Reload(IInArchive *archive, IProgress *progress);
- HRESULT Load(IInArchive *archive,
+ HRESULT Load(IInArchive *archive,
const UString &defaultName,
// const FILETIME &defaultTime,
// UInt32 defaultAttributes,
diff --git a/CPP/7zip/UI/Agent/ArchiveFolder.cpp b/CPP/7zip/UI/Agent/ArchiveFolder.cpp
index 3baa6202..780d26b8 100755
--- a/CPP/7zip/UI/Agent/ArchiveFolder.cpp
+++ b/CPP/7zip/UI/Agent/ArchiveFolder.cpp
@@ -19,11 +19,11 @@
using namespace NWindows;
using namespace NCOM;
-STDMETHODIMP CAgentFolder::CopyTo(const UINT32 *indices, UINT32 numItems,
+STDMETHODIMP CAgentFolder::CopyTo(const UINT32 *indices, UINT32 numItems,
const wchar_t *path, IFolderOperationsExtractCallback *callback)
{
COM_TRY_BEGIN
- CArchiveExtractCallback *extractCallbackSpec = new
+ CArchiveExtractCallback *extractCallbackSpec = new
CArchiveExtractCallback;
CMyComPtr<IArchiveExtractCallback> extractCallback = extractCallbackSpec;
UStringVector pathParts;
@@ -41,31 +41,31 @@ STDMETHODIMP CAgentFolder::CopyTo(const UINT32 *indices, UINT32 numItems,
IID_IFolderArchiveExtractCallback, &extractCallback2));
}
- NExtract::NPathMode::EEnum pathMode = _flatMode ?
+ NExtract::NPathMode::EEnum pathMode = _flatMode ?
NExtract::NPathMode::kNoPathnames :
NExtract::NPathMode::kCurrentPathnames;
extractCallbackSpec->InitForMulti(false, pathMode, NExtract::NOverwriteMode::kAskBefore);
- extractCallbackSpec->Init(_agentSpec->GetArchive(),
- extractCallback2,
+ extractCallbackSpec->Init(_agentSpec->GetArchive(),
+ extractCallback2,
false,
path,
- pathParts,
+ pathParts,
_agentSpec->DefaultName,
- _agentSpec->DefaultTime,
- _agentSpec->DefaultAttributes,
+ _agentSpec->DefaultTime,
+ _agentSpec->DefaultAttrib,
(UInt64)(Int64)-1
// ,_agentSpec->_srcDirectoryPrefix
);
CUIntVector realIndices;
GetRealIndices(indices, numItems, realIndices);
- return _agentSpec->GetArchive()->Extract(&realIndices.Front(),
+ return _agentSpec->GetArchive()->Extract(&realIndices.Front(),
realIndices.Size(), BoolToInt(false), extractCallback);
COM_TRY_END
}
-STDMETHODIMP CAgentFolder::MoveTo(const UINT32 * /* indices */, UINT32 /* numItems */,
+STDMETHODIMP CAgentFolder::MoveTo(const UINT32 * /* indices */, UINT32 /* numItems */,
const wchar_t * /* path */, IFolderOperationsExtractCallback * /* callback */)
{
return E_NOTIMPL;
diff --git a/CPP/7zip/UI/Agent/ArchiveFolderOpen.cpp b/CPP/7zip/UI/Agent/ArchiveFolderOpen.cpp
index 5f62dc9c..d983c13a 100755
--- a/CPP/7zip/UI/Agent/ArchiveFolderOpen.cpp
+++ b/CPP/7zip/UI/Agent/ArchiveFolderOpen.cpp
@@ -28,7 +28,7 @@ int CArchiveFolderManager::FindFormat(const UString &type)
return -1;
}
-STDMETHODIMP CArchiveFolderManager::OpenFolderFile(const wchar_t *filePath,
+STDMETHODIMP CArchiveFolderManager::OpenFolderFile(const wchar_t *filePath,
IFolderFolder **resultFolder, IProgress *progress)
{
CMyComPtr<IArchiveOpenCallback> openArchiveCallback;
@@ -122,7 +122,7 @@ STDMETHODIMP CArchiveFolderManager::GetTypes(BSTR *types)
*types = valueTemp.Detach();
return S_OK;
}
-STDMETHODIMP CArchiveFolderManager::CreateFolderFile(const wchar_t * type,
+STDMETHODIMP CArchiveFolderManager::CreateFolderFile(const wchar_t * type,
const wchar_t * filePath, IProgress progress)
{
return E_NOTIMPL;
diff --git a/CPP/7zip/UI/Agent/ArchiveFolderOut.cpp b/CPP/7zip/UI/Agent/ArchiveFolderOut.cpp
index 6bf41d61..304dce83 100755
--- a/CPP/7zip/UI/Agent/ArchiveFolderOut.cpp
+++ b/CPP/7zip/UI/Agent/ArchiveFolderOut.cpp
@@ -27,7 +27,7 @@ HRESULT CAgentFolder::CommonUpdateOperation(
bool deleteOperation,
bool createFolderOperation,
bool renameOperation,
- const wchar_t *newItemName,
+ const wchar_t *newItemName,
const NUpdateArchive::CActionSet *actionSet,
const UINT32 *indices, UINT32 numItems,
IFolderArchiveUpdateCallback *updateCallback100)
@@ -67,8 +67,8 @@ HRESULT CAgentFolder::CommonUpdateOperation(
{
result = _agentSpec->RenameItem(
tempFileName,
- indices, numItems,
- newItemName,
+ indices, numItems,
+ newItemName,
updateCallback100);
}
else
@@ -92,8 +92,15 @@ HRESULT CAgentFolder::CommonUpdateOperation(
tempFile.DisableDeleting();
if (!MyMoveFile(tempFileName, archiveFilePath ))
return GetLastError();
-
- RINOK(_agentSpec->ReOpen(NULL));
+
+ {
+ CMyComPtr<IArchiveOpenCallback> openCallback;
+ if (updateCallback100)
+ {
+ RINOK(updateCallback100->QueryInterface(IID_IArchiveOpenCallback, (void **)&openCallback));
+ }
+ RINOK(_agentSpec->ReOpen(openCallback));
+ }
////////////////////////////
// Restore FolderItem;
@@ -136,7 +143,7 @@ STDMETHODIMP CAgentFolder::CopyFrom(
RINOK(progressWrapper.QueryInterface(
IID_IFolderArchiveUpdateCallback, &updateCallback100));
}
- return CommonUpdateOperation(false, false, false, NULL,
+ return CommonUpdateOperation(false, false, false, NULL,
&NUpdateArchive::kAddActionSet, 0, 0, updateCallback100);
COM_TRY_END
}
@@ -152,7 +159,7 @@ STDMETHODIMP CAgentFolder::Delete(const UINT32 *indices, UINT32 numItems, IProgr
RINOK(progressWrapper.QueryInterface(
IID_IFolderArchiveUpdateCallback, &updateCallback100));
}
- return CommonUpdateOperation(true, false, false, NULL,
+ return CommonUpdateOperation(true, false, false, NULL,
&NUpdateArchive::kDeleteActionSet, indices, numItems, updateCallback100);
COM_TRY_END
}
@@ -185,7 +192,7 @@ STDMETHODIMP CAgentFolder::Rename(UINT32 index, const wchar_t *newName, IProgres
CMyComPtr<IProgress> progressWrapper = progress;
RINOK(progressWrapper.QueryInterface(IID_IFolderArchiveUpdateCallback, &updateCallback100));
}
- return CommonUpdateOperation(false, false, true, newName, NULL, &indices.Front(),
+ return CommonUpdateOperation(false, false, true, newName, NULL, &indices.Front(),
indices.Size(), updateCallback100);
COM_TRY_END
}
@@ -195,7 +202,7 @@ STDMETHODIMP CAgentFolder::CreateFile(const wchar_t * /* name */, IProgress * /*
return E_NOTIMPL;
}
-STDMETHODIMP CAgentFolder::SetProperty(UINT32 /* index */, PROPID /* propID */,
+STDMETHODIMP CAgentFolder::SetProperty(UINT32 /* index */, PROPID /* propID */,
const PROPVARIANT * /* value */, IProgress * /* progress */)
{
return E_NOTIMPL;
diff --git a/CPP/7zip/UI/Agent/UpdateCallbackAgent.cpp b/CPP/7zip/UI/Agent/UpdateCallbackAgent.cpp
index e00d837a..6f435b35 100755
--- a/CPP/7zip/UI/Agent/UpdateCallbackAgent.cpp
+++ b/CPP/7zip/UI/Agent/UpdateCallbackAgent.cpp
@@ -63,9 +63,9 @@ HRESULT CUpdateCallbackAgent::OpenFileError(const wchar_t *name, DWORD systemErr
if (Callback)
{
RINOK(Callback->UpdateErrorMessage(
- UString(L"WARNING: ") +
- NError::MyFormatMessageW(systemError) +
- UString(L": ") +
+ UString(L"WARNING: ") +
+ NError::MyFormatMessageW(systemError) +
+ UString(L": ") +
UString(name)));
return S_FALSE;
}
diff --git a/CPP/7zip/UI/Client7z/Client7z.cpp b/CPP/7zip/UI/Client7z/Client7z.cpp
index e059d3ac..82db4f08 100755
--- a/CPP/7zip/UI/Client7z/Client7z.cpp
+++ b/CPP/7zip/UI/Client7z/Client7z.cpp
@@ -20,7 +20,7 @@
// {23170F69-40C1-278A-1000-000110070000}
-DEFINE_GUID(CLSID_CFormat7z,
+DEFINE_GUID(CLSID_CFormat7z,
0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x07, 0x00, 0x00);
using namespace NWindows;
@@ -28,10 +28,10 @@ using namespace NWindows;
#define kDllName "7z.dll"
static const char *kCopyrightString = MY_7ZIP_VERSION
-" (" kDllName " client) "
+" (" kDllName " client) "
MY_COPYRIGHT " " MY_DATE;
-static const char *kHelpString =
+static const char *kHelpString =
"Usage: Client7z.exe [a | l | x ] archive.7z [fileName ...]\n"
"Examples:\n"
" Client7z.exe a archive.7z f1.txt f2.txt : compress two files to archive.7z\n"
@@ -40,8 +40,8 @@ static const char *kHelpString =
typedef UINT32 (WINAPI * CreateObjectFunc)(
- const GUID *clsID,
- const GUID *interfaceID,
+ const GUID *clsID,
+ const GUID *interfaceID,
void **outObject);
#ifdef _WIN32
@@ -51,7 +51,7 @@ static inline bool IsItWindowsNT()
{
OSVERSIONINFO versionInfo;
versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
- if (!::GetVersionEx(&versionInfo))
+ if (!::GetVersionEx(&versionInfo))
return false;
return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
}
@@ -90,7 +90,7 @@ static HRESULT IsArchiveItemProp(IInArchive *archive, UInt32 index, PROPID propI
{
NCOM::CPropVariant prop;
RINOK(archive->GetProperty(index, propID, &prop));
- if(prop.vt == VT_BOOL)
+ if (prop.vt == VT_BOOL)
result = VARIANT_BOOLToBool(prop.boolVal);
else if (prop.vt == VT_EMPTY)
result = false;
@@ -101,7 +101,7 @@ static HRESULT IsArchiveItemProp(IInArchive *archive, UInt32 index, PROPID propI
static HRESULT IsArchiveItemFolder(IInArchive *archive, UInt32 index, bool &result)
{
- return IsArchiveItemProp(archive, index, kpidIsFolder, result);
+ return IsArchiveItemProp(archive, index, kpidIsDir, result);
}
@@ -112,7 +112,7 @@ static const wchar_t *kEmptyFileAlias = L"[Content]";
// Archive Open callback class
-class CArchiveOpenCallback:
+class CArchiveOpenCallback:
public IArchiveOpenCallback,
public ICryptoGetTextPassword,
public CMyUnknownImp
@@ -146,7 +146,7 @@ STDMETHODIMP CArchiveOpenCallback::CryptoGetTextPassword(BSTR *password)
if (!PasswordIsDefined)
{
// You can ask real password here from user
- // Password = GetPassword(OutStream);
+ // Password = GetPassword(OutStream);
// PasswordIsDefined = true;
PrintError("Password is not defined");
return E_ABORT;
@@ -171,7 +171,7 @@ static const char *kCRCFailed = "CRC Failed";
static const char *kDataError = "Data Error";
static const char *kUnknownError = "Unknown Error";
-class CArchiveExtractCallback:
+class CArchiveExtractCallback:
public IArchiveExtractCallback,
public ICryptoGetTextPassword,
public CMyUnknownImp
@@ -199,11 +199,11 @@ private:
bool _extractMode;
struct CProcessedFileInfo
{
- FILETIME UTCLastWriteTime;
- UInt32 Attributes;
- bool IsDirectory;
- bool AttributesAreDefined;
- bool UTCLastWriteTimeIsDefined;
+ FILETIME MTime;
+ UInt32 Attrib;
+ bool isDir;
+ bool AttribDefined;
+ bool MTimeDefined;
} _processedFileInfo;
COutFileStream *_outFileStreamSpec;
@@ -237,7 +237,7 @@ STDMETHODIMP CArchiveExtractCallback::SetCompleted(const UInt64 * /* completeVal
return S_OK;
}
-STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index,
+STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index,
ISequentialOutStream **outStream, Int32 askExtractMode)
{
*outStream = 0;
@@ -245,17 +245,17 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index,
{
// Get Name
- NCOM::CPropVariant propVariant;
- RINOK(_archiveHandler->GetProperty(index, kpidPath, &propVariant));
+ NCOM::CPropVariant prop;
+ RINOK(_archiveHandler->GetProperty(index, kpidPath, &prop));
UString fullPath;
- if(propVariant.vt == VT_EMPTY)
+ if (prop.vt == VT_EMPTY)
fullPath = kEmptyFileAlias;
- else
+ else
{
- if(propVariant.vt != VT_BSTR)
+ if (prop.vt != VT_BSTR)
return E_FAIL;
- fullPath = propVariant.bstrVal;
+ fullPath = prop.bstrVal;
}
_filePath = fullPath;
}
@@ -264,38 +264,38 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index,
return S_OK;
{
- // Get Attributes
- NCOM::CPropVariant propVariant;
- RINOK(_archiveHandler->GetProperty(index, kpidAttributes, &propVariant));
- if (propVariant.vt == VT_EMPTY)
+ // Get Attrib
+ NCOM::CPropVariant prop;
+ RINOK(_archiveHandler->GetProperty(index, kpidAttrib, &prop));
+ if (prop.vt == VT_EMPTY)
{
- _processedFileInfo.Attributes = 0;
- _processedFileInfo.AttributesAreDefined = false;
+ _processedFileInfo.Attrib = 0;
+ _processedFileInfo.AttribDefined = false;
}
else
{
- if (propVariant.vt != VT_UI4)
+ if (prop.vt != VT_UI4)
return E_FAIL;
- _processedFileInfo.Attributes = propVariant.ulVal;
- _processedFileInfo.AttributesAreDefined = true;
+ _processedFileInfo.Attrib = prop.ulVal;
+ _processedFileInfo.AttribDefined = true;
}
}
- RINOK(IsArchiveItemFolder(_archiveHandler, index, _processedFileInfo.IsDirectory));
+ RINOK(IsArchiveItemFolder(_archiveHandler, index, _processedFileInfo.isDir));
{
// Get Modified Time
- NCOM::CPropVariant propVariant;
- RINOK(_archiveHandler->GetProperty(index, kpidLastWriteTime, &propVariant));
- _processedFileInfo.UTCLastWriteTimeIsDefined = false;
- switch(propVariant.vt)
+ NCOM::CPropVariant prop;
+ RINOK(_archiveHandler->GetProperty(index, kpidMTime, &prop));
+ _processedFileInfo.MTimeDefined = false;
+ switch(prop.vt)
{
case VT_EMPTY:
- // _processedFileInfo.UTCLastWriteTime = _utcLastWriteTimeDefault;
+ // _processedFileInfo.MTime = _utcMTimeDefault;
break;
case VT_FILETIME:
- _processedFileInfo.UTCLastWriteTime = propVariant.filetime;
- _processedFileInfo.UTCLastWriteTimeIsDefined = true;
+ _processedFileInfo.MTime = prop.filetime;
+ _processedFileInfo.MTimeDefined = true;
break;
default:
return E_FAIL;
@@ -304,12 +304,12 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index,
}
{
// Get Size
- NCOM::CPropVariant propVariant;
- RINOK(_archiveHandler->GetProperty(index, kpidSize, &propVariant));
- bool newFileSizeDefined = (propVariant.vt != VT_EMPTY);
+ NCOM::CPropVariant prop;
+ RINOK(_archiveHandler->GetProperty(index, kpidSize, &prop));
+ bool newFileSizeDefined = (prop.vt != VT_EMPTY);
UInt64 newFileSize;
if (newFileSizeDefined)
- newFileSize = ConvertPropVariantToUInt64(propVariant);
+ newFileSize = ConvertPropVariantToUInt64(prop);
}
@@ -323,14 +323,14 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index,
UString fullProcessedPath = _directoryPath + _filePath;
_diskFilePath = fullProcessedPath;
- if (_processedFileInfo.IsDirectory)
+ if (_processedFileInfo.isDir)
{
NFile::NDirectory::CreateComplexDirectory(fullProcessedPath);
}
else
{
- NFile::NFind::CFileInfoW fileInfo;
- if(NFile::NFind::FindFile(fullProcessedPath, fileInfo))
+ NFile::NFind::CFileInfoW fi;
+ if (NFile::NFind::FindFile(fullProcessedPath, fi))
{
if (!NFile::NDirectory::DeleteFileAlways(fullProcessedPath))
{
@@ -357,20 +357,13 @@ STDMETHODIMP CArchiveExtractCallback::PrepareOperation(Int32 askExtractMode)
_extractMode = false;
switch (askExtractMode)
{
- case NArchive::NExtract::NAskMode::kExtract:
- _extractMode = true;
+ case NArchive::NExtract::NAskMode::kExtract: _extractMode = true; break;
};
switch (askExtractMode)
{
- case NArchive::NExtract::NAskMode::kExtract:
- PrintString(kExtractingString);
- break;
- case NArchive::NExtract::NAskMode::kTest:
- PrintString(kTestingString);
- break;
- case NArchive::NExtract::NAskMode::kSkip:
- PrintString(kSkippingString);
- break;
+ case NArchive::NExtract::NAskMode::kExtract: PrintString(kExtractingString); break;
+ case NArchive::NExtract::NAskMode::kTest: PrintString(kTestingString); break;
+ case NArchive::NExtract::NAskMode::kSkip: PrintString(kSkippingString); break;
};
PrintString(_filePath);
return S_OK;
@@ -405,13 +398,13 @@ STDMETHODIMP CArchiveExtractCallback::SetOperationResult(Int32 operationResult)
if (_outFileStream != NULL)
{
- if (_processedFileInfo.UTCLastWriteTimeIsDefined)
- _outFileStreamSpec->SetLastWriteTime(&_processedFileInfo.UTCLastWriteTime);
+ if (_processedFileInfo.MTimeDefined)
+ _outFileStreamSpec->SetMTime(&_processedFileInfo.MTime);
RINOK(_outFileStreamSpec->Close());
}
_outFileStream.Release();
- if (_extractMode && _processedFileInfo.AttributesAreDefined)
- NFile::NDirectory::MySetFileAttributes(_diskFilePath, _processedFileInfo.Attributes);
+ if (_extractMode && _processedFileInfo.AttribDefined)
+ NFile::NDirectory::MySetFileAttributes(_diskFilePath, _processedFileInfo.Attrib);
PrintNewLine();
return S_OK;
}
@@ -422,7 +415,7 @@ STDMETHODIMP CArchiveExtractCallback::CryptoGetTextPassword(BSTR *password)
if (!PasswordIsDefined)
{
// You can ask real password here from user
- // Password = GetPassword(OutStream);
+ // Password = GetPassword(OutStream);
// PasswordIsDefined = true;
PrintError("Password is not defined");
return E_ABORT;
@@ -438,18 +431,19 @@ STDMETHODIMP CArchiveExtractCallback::CryptoGetTextPassword(BSTR *password)
// Archive Creating callback class
struct CDirItem
-{
- UInt32 Attributes;
- FILETIME CreationTime;
- FILETIME LastAccessTime;
- FILETIME LastWriteTime;
+{
UInt64 Size;
+ FILETIME CTime;
+ FILETIME ATime;
+ FILETIME MTime;
UString Name;
UString FullPath;
- bool IsDirectory() const { return (Attributes & FILE_ATTRIBUTE_DIRECTORY) != 0 ; }
+ UInt32 Attrib;
+
+ bool isDir() const { return (Attrib & FILE_ATTRIBUTE_DIRECTORY) != 0 ; }
};
-class CArchiveUpdateCallback:
+class CArchiveUpdateCallback:
public IArchiveUpdateCallback2,
public ICryptoGetTextPassword2,
public CMyUnknownImp
@@ -462,8 +456,8 @@ public:
STDMETHOD(SetCompleted)(const UInt64 *completeValue);
// IUpdateCallback2
- STDMETHOD(EnumProperties)(IEnumSTATPROPSTG **enumerator);
- STDMETHOD(GetUpdateItemInfo)(UInt32 index,
+ STDMETHOD(EnumProperties)(IEnumSTATPROPSTG **enumerator);
+ STDMETHOD(GetUpdateItemInfo)(UInt32 index,
Int32 *newData, Int32 *newProperties, UInt32 *indexInArchive);
STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value);
STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **inStream);
@@ -520,26 +514,26 @@ STDMETHODIMP CArchiveUpdateCallback::EnumProperties(IEnumSTATPROPSTG ** /* enume
return E_NOTIMPL;
}
-STDMETHODIMP CArchiveUpdateCallback::GetUpdateItemInfo(UInt32 /* index */,
+STDMETHODIMP CArchiveUpdateCallback::GetUpdateItemInfo(UInt32 /* index */,
Int32 *newData, Int32 *newProperties, UInt32 *indexInArchive)
{
- if(newData != NULL)
+ if (newData != NULL)
*newData = BoolToInt(true);
- if(newProperties != NULL)
+ if (newProperties != NULL)
*newProperties = BoolToInt(true);
- if(indexInArchive != NULL)
- *indexInArchive = UInt32(-1);
+ if (indexInArchive != NULL)
+ *indexInArchive = (UInt32)-1;
return S_OK;
}
STDMETHODIMP CArchiveUpdateCallback::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
{
- NWindows::NCOM::CPropVariant propVariant;
+ NWindows::NCOM::CPropVariant prop;
if (propID == kpidIsAnti)
{
- propVariant = false;
- propVariant.Detach(value);
+ prop = false;
+ prop.Detach(value);
return S_OK;
}
@@ -547,30 +541,16 @@ STDMETHODIMP CArchiveUpdateCallback::GetProperty(UInt32 index, PROPID propID, PR
const CDirItem &dirItem = (*DirItems)[index];
switch(propID)
{
- case kpidPath:
- propVariant = dirItem.Name;
- break;
- case kpidIsFolder:
- propVariant = dirItem.IsDirectory();
- break;
- case kpidSize:
- propVariant = dirItem.Size;
- break;
- case kpidAttributes:
- propVariant = dirItem.Attributes;
- break;
- case kpidLastAccessTime:
- propVariant = dirItem.LastAccessTime;
- break;
- case kpidCreationTime:
- propVariant = dirItem.CreationTime;
- break;
- case kpidLastWriteTime:
- propVariant = dirItem.LastWriteTime;
- break;
+ case kpidPath: prop = dirItem.Name; break;
+ case kpidIsDir: prop = dirItem.isDir(); break;
+ case kpidSize: prop = dirItem.Size; break;
+ case kpidAttrib: prop = dirItem.Attrib; break;
+ case kpidCTime: prop = dirItem.CTime; break;
+ case kpidATime: prop = dirItem.ATime; break;
+ case kpidMTime: prop = dirItem.MTime; break;
}
}
- propVariant.Detach(value);
+ prop.Detach(value);
return S_OK;
}
@@ -599,14 +579,14 @@ STDMETHODIMP CArchiveUpdateCallback::GetStream(UInt32 index, ISequentialInStream
const CDirItem &dirItem = (*DirItems)[index];
GetStream2(dirItem.Name);
- if(dirItem.IsDirectory())
+ if (dirItem.isDir())
return S_OK;
{
CInFileStream *inStreamSpec = new CInFileStream;
CMyComPtr<ISequentialInStream> inStreamLoc(inStreamSpec);
UString path = DirPrefix + dirItem.FullPath;
- if(!inStreamSpec->Open(path))
+ if (!inStreamSpec->Open(path))
{
DWORD sysError = ::GetLastError();
FailedCodes.Add(sysError);
@@ -654,7 +634,7 @@ STDMETHODIMP CArchiveUpdateCallback::GetVolumeStream(UInt32 index, ISequentialOu
fileName += VolExt;
COutFileStream *streamSpec = new COutFileStream;
CMyComPtr<ISequentialOutStream> streamLoc(streamSpec);
- if(!streamSpec->Create(fileName, false))
+ if (!streamSpec->Create(fileName, false))
return ::GetLastError();
*volumeStream = streamLoc.Detach();
return S_OK;
@@ -662,12 +642,12 @@ STDMETHODIMP CArchiveUpdateCallback::GetVolumeStream(UInt32 index, ISequentialOu
STDMETHODIMP CArchiveUpdateCallback::CryptoGetTextPassword2(Int32 *passwordIsDefined, BSTR *password)
{
- if (!PasswordIsDefined)
+ if (!PasswordIsDefined)
{
if (AskPassword)
{
// You can ask real password here from user
- // Password = GetPassword(OutStream);
+ // Password = GetPassword(OutStream);
// PasswordIsDefined = true;
PrintError("Password is not defined");
return E_ABORT;
@@ -726,24 +706,24 @@ int MY_CDECL main(int argc, char* argv[])
int i;
for (i = 3; i < argc; i++)
{
- CDirItem item;
+ CDirItem di;
UString name = GetUnicodeString(argv[i], CP_OEMCP);
- NFile::NFind::CFileInfoW fileInfo;
- if (!NFile::NFind::FindFile(name, fileInfo))
+ NFile::NFind::CFileInfoW fi;
+ if (!NFile::NFind::FindFile(name, fi))
{
PrintString(UString(L"Can't find file") + name);
return 1;
}
- item.Attributes = fileInfo.Attributes;
- item.Size = fileInfo.Size;
- item.CreationTime = fileInfo.CreationTime;
- item.LastAccessTime = fileInfo.LastAccessTime;
- item.LastWriteTime = fileInfo.LastWriteTime;
- item.Name = name;
- item.FullPath = name;
- dirItems.Add(item);
+ di.Attrib = fi.Attrib;
+ di.Size = fi.Size;
+ di.CTime = fi.CTime;
+ di.ATime = fi.ATime;
+ di.MTime = fi.MTime;
+ di.Name = name;
+ di.FullPath = name;
+ dirItems.Add(di);
}
COutFileStream *outFileStreamSpec = new COutFileStream;
CMyComPtr<IOutStream> outFileStream = outFileStreamSpec;
@@ -834,22 +814,22 @@ int MY_CDECL main(int argc, char* argv[])
{
// List command
UInt32 numItems = 0;
- archive->GetNumberOfItems(&numItems);
+ archive->GetNumberOfItems(&numItems);
for (UInt32 i = 0; i < numItems; i++)
{
{
// Get uncompressed size of file
- NWindows::NCOM::CPropVariant propVariant;
- archive->GetProperty(i, kpidSize, &propVariant);
- UString s = ConvertPropVariantToString(propVariant);
+ NWindows::NCOM::CPropVariant prop;
+ archive->GetProperty(i, kpidSize, &prop);
+ UString s = ConvertPropVariantToString(prop);
PrintString(s);
PrintString(" ");
}
{
// Get name of file
- NWindows::NCOM::CPropVariant propVariant;
- archive->GetProperty(i, kpidPath, &propVariant);
- UString s = ConvertPropVariantToString(propVariant);
+ NWindows::NCOM::CPropVariant prop;
+ archive->GetProperty(i, kpidPath, &prop);
+ UString s = ConvertPropVariantToString(prop);
PrintString(s);
}
PrintString("\n");
diff --git a/CPP/7zip/UI/Common/ArchiveCommandLine.cpp b/CPP/7zip/UI/Common/ArchiveCommandLine.cpp
index 6cf95f27..46e8a2a1 100755
--- a/CPP/7zip/UI/Common/ArchiveCommandLine.cpp
+++ b/CPP/7zip/UI/Common/ArchiveCommandLine.cpp
@@ -32,7 +32,7 @@ extern bool g_CaseSensitive;
#define MY_isatty_fileno(x) isatty(fileno(x))
#endif
-#define MY_IS_TERMINAL(x) (MY_isatty_fileno(x) != 0);
+#define MY_IS_TERMINAL(x) (MY_isatty_fileno(x) != 0);
using namespace NCommandLineParser;
using namespace NWindows;
@@ -48,7 +48,9 @@ enum Enum
kDisablePercents,
kArchiveType,
kYes,
+ #ifndef _NO_CRYPTO
kPassword,
+ #endif
kProperty,
kOutputDir,
kWorkingDir,
@@ -80,9 +82,9 @@ static const wchar_t kRecursedIDChar = 'R';
static const wchar_t *kRecursedPostCharSet = L"0-";
namespace NRecursedPostCharIndex {
- enum EEnum
+ enum EEnum
{
- kWildCardRecursionOnly = 0,
+ kWildCardRecursionOnly = 0,
kNoRecursion = 1
};
}
@@ -104,7 +106,7 @@ NExtract::NOverwriteMode::EEnum k_OverwriteModes[] =
NExtract::NOverwriteMode::kAutoRenameExisting
};
-static const CSwitchForm kSwitchForms[] =
+static const CSwitchForm kSwitchForms[] =
{
{ L"?", NSwitchType::kSimple, false },
{ L"H", NSwitchType::kSimple, false },
@@ -113,7 +115,9 @@ static const CSwitchForm kSwitchForms[] =
{ L"BD", NSwitchType::kSimple, false },
{ L"T", NSwitchType::kUnLimitedPostString, false, 1 },
{ L"Y", NSwitchType::kSimple, false },
+ #ifndef _NO_CRYPTO
{ L"P", NSwitchType::kUnLimitedPostString, false, 0 },
+ #endif
{ L"M", NSwitchType::kUnLimitedPostString, true, 1 },
{ L"O", NSwitchType::kUnLimitedPostString, false, 1 },
{ L"W", NSwitchType::kUnLimitedPostString, false, 0 },
@@ -138,7 +142,7 @@ static const CSwitchForm kSwitchForms[] =
{ L"SSC", NSwitchType::kPostChar, false, 0, 0, L"-" }
};
-static const CCommandForm g_CommandForms[] =
+static const CCommandForm g_CommandForms[] =
{
{ L"A", false },
{ L"U", false },
@@ -206,7 +210,7 @@ NExtract::NPathMode::EEnum CArchiveCommand::GetPathMode() const
bool CArchiveCommand::IsFromUpdateGroup() const
{
- return (CommandType == NCommandType::kAdd ||
+ return (CommandType == NCommandType::kAdd ||
CommandType == NCommandType::kUpdate ||
CommandType == NCommandType::kDelete);
}
@@ -215,9 +219,9 @@ static NRecursedType::EEnum GetRecursedTypeFromIndex(int index)
{
switch (index)
{
- case NRecursedPostCharIndex::kWildCardRecursionOnly:
+ case NRecursedPostCharIndex::kWildCardRecursionOnly:
return NRecursedType::kWildCardOnlyRecursed;
- case NRecursedPostCharIndex::kNoRecursion:
+ case NRecursedPostCharIndex::kNoRecursion:
return NRecursedType::kNonRecursed;
default:
return NRecursedType::kRecursed;
@@ -229,7 +233,7 @@ static bool ParseArchiveCommand(const UString &commandString, CArchiveCommand &c
UString commandStringUpper = commandString;
commandStringUpper.MakeUpper();
UString postString;
- int commandIndex = ParseCommand(kNumCommandForms, g_CommandForms, commandStringUpper,
+ int commandIndex = ParseCommand(kNumCommandForms, g_CommandForms, commandStringUpper,
postString) ;
if (commandIndex < 0)
return false;
@@ -240,7 +244,7 @@ static bool ParseArchiveCommand(const UString &commandString, CArchiveCommand &c
// ------------------------------------------------------------------
// filenames functions
-static bool AddNameToCensor(NWildcard::CCensor &wildcardCensor,
+static bool AddNameToCensor(NWildcard::CCensor &wildcardCensor,
const UString &name, bool include, NRecursedType::EEnum type)
{
bool isWildCard = DoesNameContainWildCard(name);
@@ -262,7 +266,7 @@ static bool AddNameToCensor(NWildcard::CCensor &wildcardCensor,
return true;
}
-static void AddToCensorFromListFile(NWildcard::CCensor &wildcardCensor,
+static void AddToCensorFromListFile(NWildcard::CCensor &wildcardCensor,
LPCWSTR fileName, bool include, NRecursedType::EEnum type, UINT codePage)
{
UStringVector names;
@@ -273,7 +277,7 @@ static void AddToCensorFromListFile(NWildcard::CCensor &wildcardCensor,
throw kIncorrectWildCardInListFile;
}
-static void AddCommandLineWildCardToCensr(NWildcard::CCensor &wildcardCensor,
+static void AddCommandLineWildCardToCensr(NWildcard::CCensor &wildcardCensor,
const UString &name, bool include, NRecursedType::EEnum recursedType)
{
if (!AddNameToCensor(wildcardCensor, name, include, recursedType))
@@ -282,13 +286,13 @@ static void AddCommandLineWildCardToCensr(NWildcard::CCensor &wildcardCensor,
static void AddToCensorFromNonSwitchesStrings(
int startIndex,
- NWildcard::CCensor &wildcardCensor,
- const UStringVector &nonSwitchStrings, NRecursedType::EEnum type,
+ NWildcard::CCensor &wildcardCensor,
+ const UStringVector &nonSwitchStrings, NRecursedType::EEnum type,
bool thereAreSwitchIncludes, UINT codePage)
{
- if(nonSwitchStrings.Size() == startIndex && (!thereAreSwitchIncludes))
+ if (nonSwitchStrings.Size() == startIndex && (!thereAreSwitchIncludes))
AddCommandLineWildCardToCensr(wildcardCensor, kUniversalWildcard, true, type);
- for(int i = startIndex; i < nonSwitchStrings.Size(); i++)
+ for (int i = startIndex; i < nonSwitchStrings.Size(); i++)
{
const UString &s = nonSwitchStrings[i];
if (s[0] == kFileListID)
@@ -299,8 +303,8 @@ static void AddToCensorFromNonSwitchesStrings(
}
#ifdef _WIN32
-static void ParseMapWithPaths(NWildcard::CCensor &wildcardCensor,
- const UString &switchParam, bool include,
+static void ParseMapWithPaths(NWildcard::CCensor &wildcardCensor,
+ const UString &switchParam, bool include,
NRecursedType::EEnum commonRecursedType)
{
int splitPos = switchParam.Find(L':');
@@ -337,7 +341,7 @@ static void ParseMapWithPaths(NWildcard::CCensor &wildcardCensor,
wchar_t c = curData[i];
if (c == L'\0')
{
- AddCommandLineWildCardToCensr(wildcardCensor,
+ AddCommandLineWildCardToCensr(wildcardCensor,
name, include, commonRecursedType);
name.Empty();
}
@@ -363,11 +367,11 @@ static void ParseMapWithPaths(NWildcard::CCensor &wildcardCensor,
}
#endif
-static void AddSwitchWildCardsToCensor(NWildcard::CCensor &wildcardCensor,
- const UStringVector &strings, bool include,
+static void AddSwitchWildCardsToCensor(NWildcard::CCensor &wildcardCensor,
+ const UStringVector &strings, bool include,
NRecursedType::EEnum commonRecursedType, UINT codePage)
{
- for(int i = 0; i < strings.Size(); i++)
+ for (int i = 0; i < strings.Size(); i++)
{
const UString &name = strings[i];
NRecursedType::EEnum recursedType;
@@ -451,7 +455,7 @@ static void ConvertToLongNames(const UString &prefix, NWildcard::CCensorNode &no
for (i = 0; i < node.SubNodes.Size(); i++)
{
NWildcard::CCensorNode &nextNode = node.SubNodes[i];
- ConvertToLongNames(prefix + nextNode.Name + wchar_t(NFile::NName::kDirDelimiter), nextNode);
+ ConvertToLongNames(prefix + nextNode.Name + wchar_t(NFile::NName::kDirDelimiter), nextNode);
}
}
@@ -483,14 +487,14 @@ const int kUpdatePairStateNotSupportedActions[] = {2, 2, 1, -1, -1, -1, -1};
const UString kUpdatePairActionIDSet = L"0123"; //Ignore, Copy, Compress, Create Anti
-const wchar_t *kUpdateIgnoreItselfPostStringID = L"-";
-const wchar_t kUpdateNewArchivePostCharID = '!';
+const wchar_t *kUpdateIgnoreItselfPostStringID = L"-";
+const wchar_t kUpdateNewArchivePostCharID = '!';
-static bool ParseUpdateCommandString2(const UString &command,
+static bool ParseUpdateCommandString2(const UString &command,
NUpdateArchive::CActionSet &actionSet, UString &postString)
{
- for(int i = 0; i < command.Length();)
+ for (int i = 0; i < command.Length();)
{
wchar_t c = MyCharUpper(command[i]);
int statePos = kUpdatePairStateIDSet.Find(c);
@@ -514,16 +518,16 @@ static bool ParseUpdateCommandString2(const UString &command,
return true;
}
-static void ParseUpdateCommandString(CUpdateOptions &options,
- const UStringVector &updatePostStrings,
+static void ParseUpdateCommandString(CUpdateOptions &options,
+ const UStringVector &updatePostStrings,
const NUpdateArchive::CActionSet &defaultActionSet)
{
- for(int i = 0; i < updatePostStrings.Size(); i++)
+ for (int i = 0; i < updatePostStrings.Size(); i++)
{
const UString &updateString = updatePostStrings[i];
- if(updateString.CompareNoCase(kUpdateIgnoreItselfPostStringID) == 0)
+ if (updateString.CompareNoCase(kUpdateIgnoreItselfPostStringID) == 0)
{
- if(options.UpdateArchiveItself)
+ if (options.UpdateArchiveItself)
{
options.UpdateArchiveItself = false;
options.Commands.Delete(0);
@@ -536,14 +540,14 @@ static void ParseUpdateCommandString(CUpdateOptions &options,
UString postString;
if (!ParseUpdateCommandString2(updateString, actionSet, postString))
ThrowUserErrorException();
- if(postString.IsEmpty())
+ if (postString.IsEmpty())
{
- if(options.UpdateArchiveItself)
+ if (options.UpdateArchiveItself)
options.Commands[0].ActionSet = actionSet;
}
else
{
- if(MyCharUpper(postString[0]) != kUpdateNewArchivePostCharID)
+ if (MyCharUpper(postString[0]) != kUpdateNewArchivePostCharID)
ThrowUserErrorException();
CUpdateArchiveCommand uc;
UString archivePath = postString.Mid(1);
@@ -603,20 +607,20 @@ static bool ParseComplexSize(const UString &src, UInt64 &result)
}
static void SetAddCommandOptions(
- NCommandType::EEnum commandType,
- const CParser &parser,
+ NCommandType::EEnum commandType,
+ const CParser &parser,
CUpdateOptions &options)
{
NUpdateArchive::CActionSet defaultActionSet;
switch(commandType)
{
- case NCommandType::kAdd:
+ case NCommandType::kAdd:
defaultActionSet = NUpdateArchive::kAddActionSet;
break;
- case NCommandType::kDelete:
+ case NCommandType::kDelete:
defaultActionSet = NUpdateArchive::kDeleteActionSet;
break;
- default:
+ default:
defaultActionSet = NUpdateArchive::kUpdateActionSet;
}
@@ -626,10 +630,10 @@ static void SetAddCommandOptions(
CUpdateArchiveCommand updateMainCommand;
updateMainCommand.ActionSet = defaultActionSet;
options.Commands.Add(updateMainCommand);
- if(parser[NKey::kUpdate].ThereIs)
- ParseUpdateCommandString(options, parser[NKey::kUpdate].PostStrings,
+ if (parser[NKey::kUpdate].ThereIs)
+ ParseUpdateCommandString(options, parser[NKey::kUpdate].PostStrings,
defaultActionSet);
- if(parser[NKey::kWorkingDir].ThereIs)
+ if (parser[NKey::kWorkingDir].ThereIs)
{
const UString &postString = parser[NKey::kWorkingDir].PostStrings[0];
if (postString.IsEmpty())
@@ -659,7 +663,7 @@ static void SetMethodOptions(const CParser &parser, CObjectVector<CProperty> &pr
if (parser[NKey::kProperty].ThereIs)
{
// options.MethodMode.Properties.Clear();
- for(int i = 0; i < parser[NKey::kProperty].PostStrings.Size(); i++)
+ for (int i = 0; i < parser[NKey::kProperty].PostStrings.Size(); i++)
{
CProperty property;
const UString &postString = parser[NKey::kProperty].PostStrings[i];
@@ -676,7 +680,7 @@ static void SetMethodOptions(const CParser &parser, CObjectVector<CProperty> &pr
}
}
-CArchiveCommandLineParser::CArchiveCommandLineParser():
+CArchiveCommandLineParser::CArchiveCommandLineParser():
parser(sizeof(kSwitchForms) / sizeof(kSwitchForms[0])) {}
void CArchiveCommandLineParser::Parse1(const UStringVector &commandStrings,
@@ -686,7 +690,7 @@ void CArchiveCommandLineParser::Parse1(const UStringVector &commandStrings,
{
parser.ParseStrings(kSwitchForms, commandStrings);
}
- catch(...)
+ catch(...)
{
ThrowUserErrorException();
}
@@ -715,7 +719,7 @@ struct CCodePagePair
UINT CodePage;
};
-static CCodePagePair g_CodePagePairs[] =
+static CCodePagePair g_CodePagePairs[] =
{
{ L"UTF-8", CP_UTF8 },
{ L"WIN", CP_ACP },
@@ -740,7 +744,7 @@ void CArchiveCommandLineParser::Parse2(CArchiveCommandLineOptions &options)
{
const UStringVector &nonSwitchStrings = parser.NonSwitchStrings;
int numNonSwitchStrings = nonSwitchStrings.Size();
- if(numNonSwitchStrings < kMinNonSwitchWords)
+ if (numNonSwitchStrings < kMinNonSwitchWords)
ThrowUserErrorException();
if (!ParseArchiveCommand(nonSwitchStrings[kCommandIndex], options.Command))
@@ -780,41 +784,45 @@ void CArchiveCommandLineParser::Parse2(CArchiveCommandLineOptions &options)
if (parser[NKey::kInclude].ThereIs)
{
thereAreSwitchIncludes = true;
- AddSwitchWildCardsToCensor(options.WildcardCensor,
+ AddSwitchWildCardsToCensor(options.WildcardCensor,
parser[NKey::kInclude].PostStrings, true, recursedType, codePage);
}
if (parser[NKey::kExclude].ThereIs)
- AddSwitchWildCardsToCensor(options.WildcardCensor,
+ AddSwitchWildCardsToCensor(options.WildcardCensor,
parser[NKey::kExclude].PostStrings, false, recursedType, codePage);
int curCommandIndex = kCommandIndex + 1;
- bool thereIsArchiveName = !parser[NKey::kNoArName].ThereIs &&
- options.Command.CommandType != NCommandType::kBenchmark &&
+ bool thereIsArchiveName = !parser[NKey::kNoArName].ThereIs &&
+ options.Command.CommandType != NCommandType::kBenchmark &&
options.Command.CommandType != NCommandType::kInfo;
if (thereIsArchiveName)
{
- if(curCommandIndex >= numNonSwitchStrings)
+ if (curCommandIndex >= numNonSwitchStrings)
ThrowUserErrorException();
options.ArchiveName = nonSwitchStrings[curCommandIndex++];
}
AddToCensorFromNonSwitchesStrings(
- curCommandIndex, options.WildcardCensor,
+ curCommandIndex, options.WildcardCensor,
nonSwitchStrings, recursedType, thereAreSwitchIncludes, codePage);
options.YesToAll = parser[NKey::kYes].ThereIs;
bool isExtractGroupCommand = options.Command.IsFromExtractGroup();
+ #ifndef _NO_CRYPTO
options.PasswordEnabled = parser[NKey::kPassword].ThereIs;
-
- if(options.PasswordEnabled)
+ if (options.PasswordEnabled)
options.Password = parser[NKey::kPassword].PostStrings[0];
+ #endif
options.StdInMode = parser[NKey::kStdIn].ThereIs;
options.ShowDialog = parser[NKey::kShowDialog].ThereIs;
- if(isExtractGroupCommand || options.Command.CommandType == NCommandType::kList)
+ if (parser[NKey::kArchiveType].ThereIs)
+ options.ArcType = parser[NKey::kArchiveType].PostStrings[0];
+
+ if (isExtractGroupCommand || options.Command.CommandType == NCommandType::kList)
{
if (options.StdInMode)
ThrowException("Reading archives from stdin is not implemented");
@@ -825,11 +833,11 @@ void CArchiveCommandLineParser::Parse2(CArchiveCommandLineOptions &options)
if (parser[NKey::kArInclude].ThereIs)
{
- AddSwitchWildCardsToCensor(archiveWildcardCensor,
+ AddSwitchWildCardsToCensor(archiveWildcardCensor,
parser[NKey::kArInclude].PostStrings, true, NRecursedType::kNonRecursed, codePage);
}
if (parser[NKey::kArExclude].ThereIs)
- AddSwitchWildCardsToCensor(archiveWildcardCensor,
+ AddSwitchWildCardsToCensor(archiveWildcardCensor,
parser[NKey::kArExclude].PostStrings, false, NRecursedType::kNonRecursed, codePage);
if (thereIsArchiveName)
@@ -841,21 +849,23 @@ void CArchiveCommandLineParser::Parse2(CArchiveCommandLineOptions &options)
archiveWildcardCensor.ExtendExclude();
- CObjectVector<CDirItem> dirItems;
- {
- UStringVector errorPaths;
- CRecordVector<DWORD> errorCodes;
- HRESULT res = EnumerateItems(archiveWildcardCensor, dirItems, NULL, errorPaths, errorCodes);
- if (res != S_OK || errorPaths.Size() > 0)
- throw "cannot find archive";
- }
UStringVector archivePaths;
- int i;
- for (i = 0; i < dirItems.Size(); i++)
+
{
- const CDirItem &dirItem = dirItems[i];
- if (!dirItem.IsDirectory())
- archivePaths.Add(dirItem.FullPath);
+ CDirItems dirItems;
+ {
+ UStringVector errorPaths;
+ CRecordVector<DWORD> errorCodes;
+ HRESULT res = EnumerateItems(archiveWildcardCensor, dirItems, NULL, errorPaths, errorCodes);
+ if (res != S_OK || errorPaths.Size() > 0)
+ throw "cannot find archive";
+ }
+ for (int i = 0; i < dirItems.Items.Size(); i++)
+ {
+ const CDirItem &dirItem = dirItems.Items[i];
+ if (!dirItem.IsDir())
+ archivePaths.Add(dirItems.GetPhyPath(i));
+ }
}
if (archivePaths.Size() == 0)
@@ -863,6 +873,7 @@ void CArchiveCommandLineParser::Parse2(CArchiveCommandLineOptions &options)
UStringVector archivePathsFull;
+ int i;
for (i = 0; i < archivePaths.Size(); i++)
{
UString fullPath;
@@ -881,33 +892,30 @@ void CArchiveCommandLineParser::Parse2(CArchiveCommandLineOptions &options)
if (isExtractGroupCommand)
{
- SetMethodOptions(parser, options.ExtractProperties);
+ SetMethodOptions(parser, options.ExtractProperties);
if (options.StdOutMode && options.IsStdOutTerminal && options.IsStdErrTerminal)
throw kSameTerminalError;
- if(parser[NKey::kOutputDir].ThereIs)
+ if (parser[NKey::kOutputDir].ThereIs)
{
options.OutputDir = parser[NKey::kOutputDir].PostStrings[0];
NFile::NName::NormalizeDirPathPrefix(options.OutputDir);
}
options.OverwriteMode = NExtract::NOverwriteMode::kAskBefore;
- if(parser[NKey::kOverwrite].ThereIs)
- options.OverwriteMode =
+ if (parser[NKey::kOverwrite].ThereIs)
+ options.OverwriteMode =
k_OverwriteModes[parser[NKey::kOverwrite].PostCharIndex];
else if (options.YesToAll)
options.OverwriteMode = NExtract::NOverwriteMode::kWithoutPrompt;
}
}
- else if(options.Command.IsFromUpdateGroup())
+ else if (options.Command.IsFromUpdateGroup())
{
CUpdateOptions &updateOptions = options.UpdateOptions;
- if(parser[NKey::kArchiveType].ThereIs)
- options.ArcType = parser[NKey::kArchiveType].PostStrings[0];
-
- SetAddCommandOptions(options.Command.CommandType, parser, updateOptions);
+ SetAddCommandOptions(options.Command.CommandType, parser, updateOptions);
- SetMethodOptions(parser, updateOptions.MethodMode.Properties);
+ SetMethodOptions(parser, updateOptions.MethodMode.Properties);
if (parser[NKey::kShareForWrite].ThereIs)
updateOptions.OpenShareForWrite = true;
@@ -916,8 +924,8 @@ void CArchiveCommandLineParser::Parse2(CArchiveCommandLineOptions &options)
if (options.EnablePercents)
{
- if ((options.StdOutMode && !options.IsStdErrTerminal) ||
- (!options.StdOutMode && !options.IsStdOutTerminal))
+ if ((options.StdOutMode && !options.IsStdErrTerminal) ||
+ (!options.StdOutMode && !options.IsStdOutTerminal))
options.EnablePercents = false;
}
@@ -940,19 +948,19 @@ void CArchiveCommandLineParser::Parse2(CArchiveCommandLineOptions &options)
throw "stdout mode and email mode cannot be combined";
if (updateOptions.StdOutMode && options.IsStdOutTerminal)
throw kTerminalOutError;
- if(updateOptions.StdInMode)
+ if (updateOptions.StdInMode)
updateOptions.StdInFileName = parser[NKey::kStdIn].PostStrings.Front();
#ifdef _WIN32
ConvertToLongNames(options.WildcardCensor);
#endif
}
- else if(options.Command.CommandType == NCommandType::kBenchmark)
+ else if (options.Command.CommandType == NCommandType::kBenchmark)
{
options.NumThreads = (UInt32)-1;
options.DictionarySize = (UInt32)-1;
options.NumIterations = 1;
- if (curCommandIndex < numNonSwitchStrings)
+ if (curCommandIndex < numNonSwitchStrings)
{
if (!ConvertStringToUInt32(nonSwitchStrings[curCommandIndex++], options.NumIterations))
ThrowUserErrorException();
@@ -994,10 +1002,10 @@ void CArchiveCommandLineParser::Parse2(CArchiveCommandLineOptions &options)
ThrowUserErrorException();
}
}
- else if(options.Command.CommandType == NCommandType::kInfo)
+ else if (options.Command.CommandType == NCommandType::kInfo)
{
}
- else
+ else
ThrowUserErrorException();
options.WildcardCensor.ExtendExclude();
}
diff --git a/CPP/7zip/UI/Common/ArchiveCommandLine.h b/CPP/7zip/UI/Common/ArchiveCommandLine.h
index 5f54b064..9c37f336 100755
--- a/CPP/7zip/UI/Common/ArchiveCommandLine.h
+++ b/CPP/7zip/UI/Common/ArchiveCommandLine.h
@@ -63,11 +63,13 @@ struct CArchiveCommandLineOptions
// NWildcard::CCensor ArchiveWildcardCensor;
NWildcard::CCensor WildcardCensor;
- CArchiveCommand Command;
+ CArchiveCommand Command;
UString ArchiveName;
+ #ifndef _NO_CRYPTO
bool PasswordEnabled;
UString Password;
+ #endif
bool TechMode;
// Extract
@@ -82,7 +84,7 @@ struct CArchiveCommandLineOptions
UString ArcType;
bool EnablePercents;
- // Benchmark
+ // Benchmark
UInt32 NumIterations;
UInt32 NumThreads;
UInt32 DictionarySize;
diff --git a/CPP/7zip/UI/Common/ArchiveExtractCallback.cpp b/CPP/7zip/UI/Common/ArchiveExtractCallback.cpp
index c3913e1c..5af5286b 100755
--- a/CPP/7zip/UI/Common/ArchiveExtractCallback.cpp
+++ b/CPP/7zip/UI/Common/ArchiveExtractCallback.cpp
@@ -32,10 +32,10 @@ void CArchiveExtractCallback::Init(
IInArchive *archiveHandler,
IFolderArchiveExtractCallback *extractCallback2,
bool stdOutMode,
- const UString &directoryPath,
+ const UString &directoryPath,
const UStringVector &removePathParts,
const UString &itemDefaultName,
- const FILETIME &utcLastWriteTimeDefault,
+ const FILETIME &utcMTimeDefault,
UInt32 attributesDefault,
UInt64 packSize)
{
@@ -52,7 +52,7 @@ void CArchiveExtractCallback::Init(
LocalProgressSpec->SendProgress = false;
_itemDefaultName = itemDefaultName;
- _utcLastWriteTimeDefault = utcLastWriteTimeDefault;
+ _utcMTimeDefault = utcMTimeDefault;
_attributesDefault = attributesDefault;
_removePathParts = removePathParts;
_archiveHandler = archiveHandler;
@@ -167,7 +167,7 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index, ISequentialOutStre
UString fullPath;
RINOK(GetArchiveItemPath(_archiveHandler, index, _itemDefaultName, fullPath));
- RINOK(IsArchiveItemFolder(_archiveHandler, index, _processedFileInfo.IsDirectory));
+ RINOK(IsArchiveItemFolder(_archiveHandler, index, _processedFileInfo.IsDir));
_filePath = fullPath;
@@ -209,7 +209,7 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index, ISequentialOutStre
{
NCOM::CPropVariant prop;
- RINOK(_archiveHandler->GetProperty(index, kpidAttributes, &prop));
+ RINOK(_archiveHandler->GetProperty(index, kpidAttrib, &prop));
if (prop.vt == VT_EMPTY)
{
_processedFileInfo.Attributes = _attributesDefault;
@@ -224,17 +224,14 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index, ISequentialOutStre
}
}
- RINOK(GetTime(index, kpidCreationTime, _processedFileInfo.CreationTime,
- _processedFileInfo.IsCreationTimeDefined));
- RINOK(GetTime(index, kpidLastWriteTime, _processedFileInfo.LastWriteTime,
- _processedFileInfo.IsLastWriteTimeDefined));
- RINOK(GetTime(index, kpidLastAccessTime, _processedFileInfo.LastAccessTime,
- _processedFileInfo.IsLastAccessTimeDefined));
+ RINOK(GetTime(index, kpidCTime, _processedFileInfo.CTime, _processedFileInfo.CTimeDefined));
+ RINOK(GetTime(index, kpidATime, _processedFileInfo.ATime, _processedFileInfo.ATimeDefined));
+ RINOK(GetTime(index, kpidMTime, _processedFileInfo.MTime, _processedFileInfo.MTimeDefined));
bool isAnti = false;
RINOK(IsArchiveItemProp(_archiveHandler, index, kpidIsAnti, isAnti));
- UStringVector pathParts;
+ UStringVector pathParts;
SplitPathToParts(fullPath, pathParts);
if(pathParts.IsEmpty())
@@ -265,7 +262,7 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index, ISequentialOutStre
UString processedPath = MakePathNameFromParts(pathParts);
if (!isAnti)
{
- if (!_processedFileInfo.IsDirectory)
+ if (!_processedFileInfo.IsDir)
{
if (!pathParts.IsEmpty())
pathParts.DeleteBack();
@@ -275,18 +272,18 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index, ISequentialOutStre
{
UString fullPathNew;
CreateComplexDirectory(pathParts, fullPathNew);
- if (_processedFileInfo.IsDirectory)
- NFile::NDirectory::SetDirTime(fullPathNew,
- (WriteCreated && _processedFileInfo.IsCreationTimeDefined) ? &_processedFileInfo.CreationTime : NULL,
- (WriteAccessed && _processedFileInfo.IsLastAccessTimeDefined) ? &_processedFileInfo.LastAccessTime : NULL,
- (WriteModified && _processedFileInfo.IsLastWriteTimeDefined) ? &_processedFileInfo.LastWriteTime : &_utcLastWriteTimeDefault);
+ if (_processedFileInfo.IsDir)
+ NFile::NDirectory::SetDirTime(fullPathNew,
+ (WriteCTime && _processedFileInfo.CTimeDefined) ? &_processedFileInfo.CTime : NULL,
+ (WriteATime && _processedFileInfo.ATimeDefined) ? &_processedFileInfo.ATime : NULL,
+ (WriteMTime && _processedFileInfo.MTimeDefined) ? &_processedFileInfo.MTime : &_utcMTimeDefault);
}
}
UString fullProcessedPath = _directoryPath + processedPath;
- if(_processedFileInfo.IsDirectory)
+ if(_processedFileInfo.IsDir)
{
_diskFilePath = fullProcessedPath;
if (isAnti)
@@ -307,9 +304,9 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index, ISequentialOutStre
{
Int32 overwiteResult;
RINOK(_extractCallback2->AskOverwrite(
- fullProcessedPath, &fileInfo.LastWriteTime, &fileInfo.Size, fullPath,
- _processedFileInfo.IsLastWriteTimeDefined ? &_processedFileInfo.LastWriteTime : NULL,
- newFileSizeDefined ? &newFileSize : NULL,
+ fullProcessedPath, &fileInfo.MTime, &fileInfo.Size, fullPath,
+ _processedFileInfo.MTimeDefined ? &_processedFileInfo.MTime : NULL,
+ newFileSizeDefined ? &newFileSize : NULL,
&overwiteResult))
switch(overwiteResult)
@@ -408,7 +405,7 @@ STDMETHODIMP CArchiveExtractCallback::PrepareOperation(Int32 askExtractMode)
case NArchive::NExtract::NAskMode::kExtract:
_extractMode = true;
};
- return _extractCallback2->PrepareOperation(_filePath, _processedFileInfo.IsDirectory,
+ return _extractCallback2->PrepareOperation(_filePath, _processedFileInfo.IsDir,
askExtractMode, _isSplit ? &_position: 0);
COM_TRY_END
}
@@ -430,15 +427,15 @@ STDMETHODIMP CArchiveExtractCallback::SetOperationResult(Int32 operationResult)
if (_outFileStream != NULL)
{
_outFileStreamSpec->SetTime(
- (WriteCreated && _processedFileInfo.IsCreationTimeDefined) ? &_processedFileInfo.CreationTime : NULL,
- (WriteAccessed && _processedFileInfo.IsLastAccessTimeDefined) ? &_processedFileInfo.LastAccessTime : NULL,
- (WriteModified && _processedFileInfo.IsLastWriteTimeDefined) ? &_processedFileInfo.LastWriteTime : &_utcLastWriteTimeDefault);
+ (WriteCTime && _processedFileInfo.CTimeDefined) ? &_processedFileInfo.CTime : NULL,
+ (WriteATime && _processedFileInfo.ATimeDefined) ? &_processedFileInfo.ATime : NULL,
+ (WriteMTime && _processedFileInfo.MTimeDefined) ? &_processedFileInfo.MTime : &_utcMTimeDefault);
_curSize = _outFileStreamSpec->ProcessedSize;
RINOK(_outFileStreamSpec->Close());
_outFileStream.Release();
}
UnpackSize += _curSize;
- if (_processedFileInfo.IsDirectory)
+ if (_processedFileInfo.IsDir)
NumFolders++;
else
NumFiles++;
@@ -470,7 +467,7 @@ STDMETHODIMP CArchiveExtractCallback::CryptoGetTextPassword(BSTR *password)
COM_TRY_BEGIN
if (!_cryptoGetTextPassword)
{
- RINOK(_extractCallback2.QueryInterface(IID_ICryptoGetTextPassword,
+ RINOK(_extractCallback2.QueryInterface(IID_ICryptoGetTextPassword,
&_cryptoGetTextPassword));
}
return _cryptoGetTextPassword->CryptoGetTextPassword(password);
diff --git a/CPP/7zip/UI/Common/ArchiveExtractCallback.h b/CPP/7zip/UI/Common/ArchiveExtractCallback.h
index 756dfb08..e895c54b 100755
--- a/CPP/7zip/UI/Common/ArchiveExtractCallback.h
+++ b/CPP/7zip/UI/Common/ArchiveExtractCallback.h
@@ -15,7 +15,7 @@
#include "ExtractMode.h"
-class CArchiveExtractCallback:
+class CArchiveExtractCallback:
public IArchiveExtractCallback,
// public IArchiveVolumeExtractCallback,
public ICryptoGetTextPassword,
@@ -26,15 +26,9 @@ public:
MY_UNKNOWN_IMP2(ICryptoGetTextPassword, ICompressProgressInfo)
// COM_INTERFACE_ENTRY(IArchiveVolumeExtractCallback)
- // IProgress
- STDMETHOD(SetTotal)(UInt64 size);
- STDMETHOD(SetCompleted)(const UInt64 *completeValue);
- STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize);
+ INTERFACE_IArchiveExtractCallback(;)
- // IExtractCallBack
- STDMETHOD(GetStream)(UInt32 index, ISequentialOutStream **outStream, Int32 askExtractMode);
- STDMETHOD(PrepareOperation)(Int32 askExtractMode);
- STDMETHOD(SetOperationResult)(Int32 resultEOperationResult);
+ STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize);
// IArchiveVolumeExtractCallback
// STDMETHOD(GetInStream)(const wchar_t *name, ISequentialInStream **inStream);
@@ -59,24 +53,24 @@ private:
bool _extractMode;
- bool WriteModified;
- bool WriteCreated;
- bool WriteAccessed;
+ bool WriteCTime;
+ bool WriteATime;
+ bool WriteMTime;
bool _encrypted;
struct CProcessedFileInfo
{
- FILETIME CreationTime;
- FILETIME LastWriteTime;
- FILETIME LastAccessTime;
+ FILETIME CTime;
+ FILETIME ATime;
+ FILETIME MTime;
UInt32 Attributes;
- bool IsCreationTimeDefined;
- bool IsLastWriteTimeDefined;
- bool IsLastAccessTimeDefined;
+ bool CTimeDefined;
+ bool ATimeDefined;
+ bool MTimeDefined;
- bool IsDirectory;
+ bool IsDir;
bool AttributesAreDefined;
} _processedFileInfo;
@@ -86,7 +80,7 @@ private:
UStringVector _removePathParts;
UString _itemDefaultName;
- FILETIME _utcLastWriteTimeDefault;
+ FILETIME _utcMTimeDefault;
UInt32 _attributesDefault;
bool _stdOutMode;
@@ -94,9 +88,9 @@ private:
HRESULT GetTime(int index, PROPID propID, FILETIME &filetime, bool &filetimeIsDefined);
public:
CArchiveExtractCallback():
- WriteModified(true),
- WriteCreated(true),
- WriteAccessed(false),
+ WriteCTime(true),
+ WriteATime(true),
+ WriteMTime(true),
_multiArchives(false)
{
LocalProgressSpec = new CLocalProgress();
@@ -113,23 +107,23 @@ public:
UInt64 NumFiles;
UInt64 UnpackSize;
- void InitForMulti(bool multiArchives,
+ void InitForMulti(bool multiArchives,
NExtract::NPathMode::EEnum pathMode,
- NExtract::NOverwriteMode::EEnum overwriteMode)
- {
- _multiArchives = multiArchives; NumFolders = NumFiles = UnpackSize = 0;
+ NExtract::NOverwriteMode::EEnum overwriteMode)
+ {
+ _multiArchives = multiArchives; NumFolders = NumFiles = UnpackSize = 0;
_pathMode = pathMode;
_overwriteMode = overwriteMode;
}
void Init(
- IInArchive *archiveHandler,
+ IInArchive *archiveHandler,
IFolderArchiveExtractCallback *extractCallback2,
bool stdOutMode,
const UString &directoryPath,
const UStringVector &removePathParts,
const UString &itemDefaultName,
- const FILETIME &utcLastWriteTimeDefault,
+ const FILETIME &utcMTimeDefault,
UInt32 attributesDefault,
UInt64 packSize);
diff --git a/CPP/7zip/UI/Common/ArchiveName.cpp b/CPP/7zip/UI/Common/ArchiveName.cpp
index 2d50ede1..a2fc6a0f 100755
--- a/CPP/7zip/UI/Common/ArchiveName.cpp
+++ b/CPP/7zip/UI/Common/ArchiveName.cpp
@@ -31,7 +31,7 @@ UString CreateArchiveName(const UString &srcName, bool fromPrev, bool keepName)
if (!NFile::NFind::FindFile(srcName, fileInfo))
return resultName;
resultName = fileInfo.Name;
- if (!fileInfo.IsDirectory() && !keepName)
+ if (!fileInfo.IsDir() && !keepName)
{
int dotPos = resultName.ReverseFind('.');
if (dotPos > 0)
diff --git a/CPP/7zip/UI/Common/ArchiveOpenCallback.cpp b/CPP/7zip/UI/Common/ArchiveOpenCallback.cpp
index 2f0c41a4..8f289d1b 100755
--- a/CPP/7zip/UI/Common/ArchiveOpenCallback.cpp
+++ b/CPP/7zip/UI/Common/ArchiveOpenCallback.cpp
@@ -15,61 +15,46 @@ using namespace NWindows;
STDMETHODIMP COpenCallbackImp::SetTotal(const UInt64 *files, const UInt64 *bytes)
{
COM_TRY_BEGIN
+ if (ReOpenCallback)
+ return ReOpenCallback->SetTotal(files, bytes);
if (!Callback)
return S_OK;
- return Callback->SetTotal(files, bytes);
+ return Callback->Open_SetTotal(files, bytes);
COM_TRY_END
}
STDMETHODIMP COpenCallbackImp::SetCompleted(const UInt64 *files, const UInt64 *bytes)
{
COM_TRY_BEGIN
+ if (ReOpenCallback)
+ return ReOpenCallback->SetCompleted(files, bytes);
if (!Callback)
return S_OK;
- return Callback->SetTotal(files, bytes);
+ return Callback->Open_SetCompleted(files, bytes);
COM_TRY_END
}
STDMETHODIMP COpenCallbackImp::GetProperty(PROPID propID, PROPVARIANT *value)
{
COM_TRY_BEGIN
- NCOM::CPropVariant propVariant;
+ NCOM::CPropVariant prop;
if (_subArchiveMode)
- {
switch(propID)
{
- case kpidName:
- propVariant = _subArchiveName;
- break;
+ case kpidName: prop = _subArchiveName; break;
}
- propVariant.Detach(value);
- return S_OK;
- }
- switch(propID)
- {
- case kpidName:
- propVariant = _fileInfo.Name;
- break;
- case kpidIsFolder:
- propVariant = _fileInfo.IsDirectory();
- break;
- case kpidSize:
- propVariant = _fileInfo.Size;
- break;
- case kpidAttributes:
- propVariant = (UInt32)_fileInfo.Attributes;
- break;
- case kpidLastAccessTime:
- propVariant = _fileInfo.LastAccessTime;
- break;
- case kpidCreationTime:
- propVariant = _fileInfo.CreationTime;
- break;
- case kpidLastWriteTime:
- propVariant = _fileInfo.LastWriteTime;
- break;
+ else
+ switch(propID)
+ {
+ case kpidName: prop = _fileInfo.Name; break;
+ case kpidIsDir: prop = _fileInfo.IsDir(); break;
+ case kpidSize: prop = _fileInfo.Size; break;
+ case kpidAttrib: prop = (UInt32)_fileInfo.Attrib; break;
+ case kpidCTime: prop = _fileInfo.CTime; break;
+ case kpidATime: prop = _fileInfo.ATime; break;
+ case kpidMTime: prop = _fileInfo.MTime; break;
}
- propVariant.Detach(value);
+ prop.Detach(value);
return S_OK;
COM_TRY_END
}
@@ -102,13 +87,13 @@ STDMETHODIMP COpenCallbackImp::GetStream(const wchar_t *name, IInStream **inStre
return S_FALSE;
if (Callback)
{
- RINOK(Callback->CheckBreak());
+ RINOK(Callback->Open_CheckBreak());
}
*inStream = NULL;
UString fullPath = _folderPrefix + name;
if (!NFile::NFind::FindFile(fullPath, _fileInfo))
return S_FALSE;
- if (_fileInfo.IsDirectory())
+ if (_fileInfo.IsDir())
return S_FALSE;
CInFileStreamVol *inFile = new CInFileStreamVol;
CMyComPtr<IInStream> inStreamTemp = inFile;
@@ -128,9 +113,16 @@ STDMETHODIMP COpenCallbackImp::GetStream(const wchar_t *name, IInStream **inStre
STDMETHODIMP COpenCallbackImp::CryptoGetTextPassword(BSTR *password)
{
COM_TRY_BEGIN
+ if (ReOpenCallback)
+ {
+ CMyComPtr<ICryptoGetTextPassword> getTextPassword;
+ ReOpenCallback.QueryInterface(IID_ICryptoGetTextPassword, &getTextPassword);
+ if (getTextPassword)
+ return getTextPassword->CryptoGetTextPassword(password);
+ }
if (!Callback)
return E_NOTIMPL;
- return Callback->CryptoGetTextPassword(password);
+ return Callback->Open_CryptoGetTextPassword(password);
COM_TRY_END
}
#endif
diff --git a/CPP/7zip/UI/Common/ArchiveOpenCallback.h b/CPP/7zip/UI/Common/ArchiveOpenCallback.h
index 12b2b325..ca445974 100755
--- a/CPP/7zip/UI/Common/ArchiveOpenCallback.h
+++ b/CPP/7zip/UI/Common/ArchiveOpenCallback.h
@@ -9,54 +9,61 @@
#ifndef _NO_CRYPTO
#include "../../IPassword.h"
-#endif
+#endif
#include "../../Archive/IArchive.h"
+#ifdef _NO_CRYPTO
+
+#define INTERFACE_IOpenCallbackUI_Crypto(x)
+
+#else
+
+#define INTERFACE_IOpenCallbackUI_Crypto(x) \
+ virtual HRESULT Open_CryptoGetTextPassword(BSTR *password) x; \
+ virtual HRESULT Open_GetPasswordIfAny(UString &password) x; \
+ virtual bool Open_WasPasswordAsked() x; \
+ virtual void Open_ClearPasswordWasAskedFlag() x; \
+
+#endif
+
+#define INTERFACE_IOpenCallbackUI(x) \
+ virtual HRESULT Open_CheckBreak() x; \
+ virtual HRESULT Open_SetTotal(const UInt64 *files, const UInt64 *bytes) x; \
+ virtual HRESULT Open_SetCompleted(const UInt64 *files, const UInt64 *bytes) x; \
+ INTERFACE_IOpenCallbackUI_Crypto(x)
+
struct IOpenCallbackUI
{
- virtual HRESULT CheckBreak() = 0;
- virtual HRESULT SetTotal(const UInt64 *files, const UInt64 *bytes) = 0;
- virtual HRESULT SetCompleted(const UInt64 *files, const UInt64 *bytes) = 0;
- #ifndef _NO_CRYPTO
- virtual HRESULT CryptoGetTextPassword(BSTR *password) = 0;
- virtual HRESULT GetPasswordIfAny(UString &password) = 0;
- virtual bool WasPasswordAsked() = 0;
- virtual void ClearPasswordWasAskedFlag() = 0;
- #endif
+ INTERFACE_IOpenCallbackUI(=0)
};
-class COpenCallbackImp:
+class COpenCallbackImp:
public IArchiveOpenCallback,
public IArchiveOpenVolumeCallback,
public IArchiveOpenSetSubArchiveName,
#ifndef _NO_CRYPTO
public ICryptoGetTextPassword,
- #endif
+ #endif
public CMyUnknownImp
{
public:
#ifndef _NO_CRYPTO
MY_UNKNOWN_IMP3(
- IArchiveOpenVolumeCallback,
+ IArchiveOpenVolumeCallback,
ICryptoGetTextPassword,
IArchiveOpenSetSubArchiveName
)
#else
MY_UNKNOWN_IMP2(
- IArchiveOpenVolumeCallback,
+ IArchiveOpenVolumeCallback,
IArchiveOpenSetSubArchiveName
)
#endif
- STDMETHOD(SetTotal)(const UInt64 *files, const UInt64 *bytes);
- STDMETHOD(SetCompleted)(const UInt64 *files, const UInt64 *bytes);
-
- // IArchiveOpenVolumeCallback
- STDMETHOD(GetProperty)(PROPID propID, PROPVARIANT *value);
- STDMETHOD(GetStream)(const wchar_t *name, IInStream **inStream);
+ INTERFACE_IArchiveOpenCallback(;)
+ INTERFACE_IArchiveOpenVolumeCallback(;)
#ifndef _NO_CRYPTO
- // ICryptoGetTextPassword
STDMETHOD(CryptoGetTextPassword)(BSTR *password);
#endif
@@ -75,6 +82,7 @@ private:
public:
UStringVector FileNames;
IOpenCallbackUI *Callback;
+ CMyComPtr<IArchiveOpenCallback> ReOpenCallback;
UInt64 TotalSize;
COpenCallbackImp(): Callback(NULL) {}
diff --git a/CPP/7zip/UI/Common/CompressCall.cpp b/CPP/7zip/UI/Common/CompressCall.cpp
index 5eba9194..3564c950 100755
--- a/CPP/7zip/UI/Common/CompressCall.cpp
+++ b/CPP/7zip/UI/Common/CompressCall.cpp
@@ -37,7 +37,7 @@ static void AddLagePagesSwitch(UString &params)
params += kLargePagesDisable;
}
-HRESULT MyCreateProcess(const UString &params,
+HRESULT MyCreateProcess(const UString &params,
LPCWSTR curDir, bool waitFinish,
NWindows::NSynchronization::CBaseEvent *event)
{
@@ -59,9 +59,9 @@ HRESULT MyCreateProcess(const UString &params,
CSysString curDirA;
if (curDir != 0)
curDirA = GetSystemString(curDir);
- result = ::CreateProcessA(NULL, (LPSTR)(LPCSTR)GetSystemString(params),
- NULL, NULL, FALSE, 0, NULL,
- ((curDir != 0) ? (LPCSTR)curDirA: 0),
+ result = ::CreateProcessA(NULL, (LPSTR)(LPCSTR)GetSystemString(params),
+ NULL, NULL, FALSE, 0, NULL,
+ ((curDir != 0) ? (LPCSTR)curDirA: 0),
&startupInfo, &processInformation);
}
else
@@ -76,9 +76,9 @@ HRESULT MyCreateProcess(const UString &params,
startupInfo.cbReserved2 = 0;
startupInfo.lpReserved2 = 0;
- result = ::CreateProcessW(NULL, (LPWSTR)(LPCWSTR)params,
- NULL, NULL, FALSE, 0, NULL,
- curDir,
+ result = ::CreateProcessW(NULL, (LPWSTR)(LPCWSTR)params,
+ NULL, NULL, FALSE, 0, NULL,
+ curDir,
&startupInfo, &processInformation);
}
if (result == 0)
@@ -114,7 +114,7 @@ static UString Get7zGuiPath()
return GetQuotedString(path);
}
-static HRESULT CreateTempEvent(const wchar_t *name,
+static HRESULT CreateTempEvent(const wchar_t *name,
NSynchronization::CManualResetEvent &event, UString &eventName)
{
CRandom random;
@@ -133,8 +133,8 @@ static HRESULT CreateTempEvent(const wchar_t *name,
}
}
-static HRESULT CreateMap(const UStringVector &names,
- const UString &id,
+static HRESULT CreateMap(const UStringVector &names,
+ const UString &id,
CFileMapping &fileMapping, NSynchronization::CManualResetEvent &event,
UString &params)
{
@@ -198,10 +198,10 @@ HRESULT CompressFiles(
const UString &curDir,
const UString &archiveName,
const UString &archiveType,
- const UStringVector &names,
- // const UString &outFolder,
+ const UStringVector &names,
+ // const UString &outFolder,
bool email,
- bool showDialog,
+ bool showDialog,
bool waitFinish)
{
/*
@@ -292,14 +292,14 @@ HRESULT CompressFiles(
for (int i = 0; i < names.Size(); i++)
{
const UString &unicodeString = names[i];
- memcpy(curData, (const wchar_t *)unicodeString ,
+ memcpy(curData, (const wchar_t *)unicodeString ,
unicodeString .Length() * sizeof(wchar_t));
curData += unicodeString.Length();
*curData++ = L'\0';
}
// MessageBox(0, params, 0, 0);
- RINOK(MyCreateProcess(params,
- (curDir.IsEmpty()? 0: (LPCWSTR)curDir),
+ RINOK(MyCreateProcess(params,
+ (curDir.IsEmpty()? 0: (LPCWSTR)curDir),
waitFinish, &event));
}
catch(...)
diff --git a/CPP/7zip/UI/Common/CompressCall.h b/CPP/7zip/UI/Common/CompressCall.h
index 2bb1c7be..feb45790 100755
--- a/CPP/7zip/UI/Common/CompressCall.h
+++ b/CPP/7zip/UI/Common/CompressCall.h
@@ -14,8 +14,8 @@ HRESULT CompressFiles(
const UString &curDir,
const UString &archiveName,
const UString &archiveType,
- const UStringVector &names,
- // const UString &outFolder,
+ const UStringVector &names,
+ // const UString &outFolder,
bool email, bool showDialog, bool waitFinish);
HRESULT ExtractArchives(
diff --git a/CPP/7zip/UI/Common/DefaultName.cpp b/CPP/7zip/UI/Common/DefaultName.cpp
index 8ee7c048..020cb50a 100755
--- a/CPP/7zip/UI/Common/DefaultName.cpp
+++ b/CPP/7zip/UI/Common/DefaultName.cpp
@@ -6,7 +6,7 @@
static const wchar_t *kEmptyFileAlias = L"[Content]";
-UString GetDefaultName2(const UString &fileName,
+static UString GetDefaultName3(const UString &fileName,
const UString &extension, const UString &addSubExtension)
{
int extLength = extension.Length();
@@ -24,3 +24,10 @@ UString GetDefaultName2(const UString &fileName,
return kEmptyFileAlias;
}
+UString GetDefaultName2(const UString &fileName,
+ const UString &extension, const UString &addSubExtension)
+{
+ UString name = GetDefaultName3(fileName, extension, addSubExtension);
+ name.TrimRight();
+ return name;
+}
diff --git a/CPP/7zip/UI/Common/DefaultName.h b/CPP/7zip/UI/Common/DefaultName.h
index a702cb0f..9764ff87 100755
--- a/CPP/7zip/UI/Common/DefaultName.h
+++ b/CPP/7zip/UI/Common/DefaultName.h
@@ -5,7 +5,7 @@
#include "Common/MyString.h"
-UString GetDefaultName2(const UString &fileName,
+UString GetDefaultName2(const UString &fileName,
const UString &extension, const UString &addSubExtension);
#endif
diff --git a/CPP/7zip/UI/Common/DirItem.h b/CPP/7zip/UI/Common/DirItem.h
index d2f2ab43..0f289483 100755
--- a/CPP/7zip/UI/Common/DirItem.h
+++ b/CPP/7zip/UI/Common/DirItem.h
@@ -8,28 +8,61 @@
#include "../../Archive/IArchive.h"
struct CDirItem
-{
- FILETIME CreationTime;
- FILETIME LastAccessTime;
- FILETIME LastWriteTime;
+{
UInt64 Size;
+ FILETIME CTime;
+ FILETIME ATime;
+ FILETIME MTime;
UString Name;
- UString FullPath;
- UInt32 Attributes;
- bool IsDirectory() const { return (Attributes & FILE_ATTRIBUTE_DIRECTORY) != 0 ; }
+ UInt32 Attrib;
+ int PhyParent;
+ int LogParent;
+
+ CDirItem(): PhyParent(-1), LogParent(-1) {}
+ bool IsDir() const { return (Attrib & FILE_ATTRIBUTE_DIRECTORY) != 0 ; }
};
-struct CArchiveItem
-{
- FILETIME LastWriteTime;
+class CDirItems
+{
+ UStringVector Prefixes;
+ CIntVector PhyParents;
+ CIntVector LogParents;
+
+ UString GetPrefixesPath(const CIntVector &parents, int index, const UString &name) const;
+public:
+ CObjectVector<CDirItem> Items;
+
+ int GetNumFolders() const { return Prefixes.Size(); }
+ UString GetPhyPath(int index) const;
+ UString GetLogPath(int index) const;
+
+ int AddPrefix(int phyParent, int logParent, const UString &prefix);
+ void DeleteLastPrefix();
+
+ void EnumerateDirectory(int phyParent, int logParent, const UString &phyPrefix,
+ UStringVector &errorPaths, CRecordVector<DWORD> &errorCodes);
+
+ void EnumerateDirItems2(
+ const UString &phyPrefix,
+ const UString &logPrefix,
+ const UStringVector &filePaths,
+ UStringVector &errorPaths, CRecordVector<DWORD> &errorCodes);
+
+ void ReserveDown();
+};
+
+struct CArcItem
+{
UInt64 Size;
+ FILETIME MTime;
UString Name;
- bool IsDirectory;
- bool SizeIsDefined;
+ bool IsDir;
+ bool SizeDefined;
bool Censored;
UInt32 IndexInServer;
- int FileTimeType;
- CArchiveItem(): IsDirectory(false), SizeIsDefined(false), Censored(false), FileTimeType(-1) {}
+ int TimeType;
+
+ CArcItem(): IsDir(false), SizeDefined(false), Censored(false), TimeType(-1) {}
};
#endif
diff --git a/CPP/7zip/UI/Common/EnumDirItems.cpp b/CPP/7zip/UI/Common/EnumDirItems.cpp
index 454092ec..3b01b6e8 100755
--- a/CPP/7zip/UI/Common/EnumDirItems.cpp
+++ b/CPP/7zip/UI/Common/EnumDirItems.cpp
@@ -2,6 +2,8 @@
#include "StdAfx.h"
+#include <stdio.h>
+
#include "Common/StringConvert.h"
#include "Common/Wildcard.h"
#include "Common/MyCom.h"
@@ -12,87 +14,171 @@ using namespace NWindows;
using namespace NFile;
using namespace NName;
-void AddDirFileInfo(
- const UString &prefix, // prefix for logical path
- const UString &fullPathName, // path on disk: can be relative to some basePrefix
- const NFind::CFileInfoW &fileInfo,
- CObjectVector<CDirItem> &dirItems)
+void AddDirFileInfo(int phyParent, int logParent,
+ const NFind::CFileInfoW &fi, CObjectVector<CDirItem> &dirItems)
{
- CDirItem item;
- item.Attributes = fileInfo.Attributes;
- item.Size = fileInfo.Size;
- item.CreationTime = fileInfo.CreationTime;
- item.LastAccessTime = fileInfo.LastAccessTime;
- item.LastWriteTime = fileInfo.LastWriteTime;
- item.Name = prefix + fileInfo.Name;
- item.FullPath = fullPathName;
- dirItems.Add(item);
+ CDirItem di;
+ di.Size = fi.Size;
+ di.CTime = fi.CTime;
+ di.ATime = fi.ATime;
+ di.MTime = fi.MTime;
+ di.Attrib = fi.Attrib;
+ di.PhyParent = phyParent;
+ di.LogParent = logParent;
+ di.Name = fi.Name;
+ dirItems.Add(di);
}
-static void EnumerateDirectory(
- const UString &baseFolderPrefix, // base (disk) prefix for scanning
- const UString &directory, // additional disk prefix starting from baseFolderPrefix
- const UString &prefix, // logical prefix
- CObjectVector<CDirItem> &dirItems,
- UStringVector &errorPaths,
- CRecordVector<DWORD> &errorCodes)
+UString CDirItems::GetPrefixesPath(const CIntVector &parents, int index, const UString &name) const
+{
+ UString path;
+ int len = name.Length();
+ int i;
+ for (i = index; i >= 0; i = parents[i])
+ len += Prefixes[i].Length();
+ int totalLen = len;
+ wchar_t *p = path.GetBuffer(len);
+ p[len] = 0;
+ len -= name.Length();
+ memcpy(p + len, (const wchar_t *)name, name.Length() * sizeof(wchar_t));
+ for (i = index; i >= 0; i = parents[i])
+ {
+ const UString &s = Prefixes[i];
+ len -= s.Length();
+ memcpy(p + len, (const wchar_t *)s, s.Length() * sizeof(wchar_t));
+ }
+ path.ReleaseBuffer(totalLen);
+ return path;
+}
+
+UString CDirItems::GetPhyPath(int index) const
+{
+ const CDirItem &di = Items[index];
+ return GetPrefixesPath(PhyParents, di.PhyParent, di.Name);
+}
+
+UString CDirItems::GetLogPath(int index) const
+{
+ const CDirItem &di = Items[index];
+ return GetPrefixesPath(LogParents, di.LogParent, di.Name);
+}
+
+void CDirItems::ReserveDown()
+{
+ Prefixes.ReserveDown();
+ PhyParents.ReserveDown();
+ LogParents.ReserveDown();
+ Items.ReserveDown();
+}
+
+int CDirItems::AddPrefix(int phyParent, int logParent, const UString &prefix)
+{
+ PhyParents.Add(phyParent);
+ LogParents.Add(logParent);
+ return Prefixes.Add(prefix);
+}
+
+void CDirItems::DeleteLastPrefix()
+{
+ PhyParents.DeleteBack();
+ LogParents.DeleteBack();
+ Prefixes.DeleteBack();
+}
+
+void CDirItems::EnumerateDirectory(int phyParent, int logParent, const UString &phyPrefix,
+ UStringVector &errorPaths, CRecordVector<DWORD> &errorCodes)
{
- NFind::CEnumeratorW enumerator(baseFolderPrefix + directory + wchar_t(kAnyStringWildcard));
+ NFind::CEnumeratorW enumerator(phyPrefix + (wchar_t)kAnyStringWildcard);
for (;;)
- {
- NFind::CFileInfoW fileInfo;
+ {
+ NFind::CFileInfoW fi;
bool found;
- if (!enumerator.Next(fileInfo, found))
+ if (!enumerator.Next(fi, found))
{
errorCodes.Add(::GetLastError());
- errorPaths.Add(baseFolderPrefix + directory);
+ errorPaths.Add(phyPrefix);
return;
}
if (!found)
break;
- AddDirFileInfo(prefix, directory + fileInfo.Name, fileInfo, dirItems);
- if (fileInfo.IsDirectory())
+ AddDirFileInfo(phyParent, logParent, fi, Items);
+ if (fi.IsDir())
{
- EnumerateDirectory(baseFolderPrefix, directory + fileInfo.Name + wchar_t(kDirDelimiter),
- prefix + fileInfo.Name + wchar_t(kDirDelimiter), dirItems, errorPaths, errorCodes);
+ const UString name2 = fi.Name + (wchar_t)kDirDelimiter;
+ int parent = AddPrefix(phyParent, logParent, name2);
+ EnumerateDirectory(parent, parent, phyPrefix + name2, errorPaths, errorCodes);
}
}
}
-void EnumerateDirItems(
- const UString &baseFolderPrefix, // base (disk) prefix for scanning
- const UStringVector &fileNames, // names relative to baseFolderPrefix
- const UString &archiveNamePrefix,
- CObjectVector<CDirItem> &dirItems,
- UStringVector &errorPaths,
- CRecordVector<DWORD> &errorCodes)
+void CDirItems::EnumerateDirItems2(const UString &phyPrefix, const UString &logPrefix,
+ const UStringVector &filePaths, UStringVector &errorPaths, CRecordVector<DWORD> &errorCodes)
{
- for(int i = 0; i < fileNames.Size(); i++)
+ int phyParent = phyPrefix.IsEmpty() ? -1 : AddPrefix(-1, -1, phyPrefix);
+ int logParent = logPrefix.IsEmpty() ? -1 : AddPrefix(-1, -1, logPrefix);
+
+ for (int i = 0; i < filePaths.Size(); i++)
{
- const UString &fileName = fileNames[i];
- NFind::CFileInfoW fileInfo;
- if (!NFind::FindFile(baseFolderPrefix + fileName, fileInfo))
+ const UString &filePath = filePaths[i];
+ NFind::CFileInfoW fi;
+ const UString phyPath = phyPrefix + filePath;
+ if (!NFind::FindFile(phyPath, fi))
{
errorCodes.Add(::GetLastError());
- errorPaths.Add(baseFolderPrefix + fileName);
+ errorPaths.Add(phyPath);
continue;
}
- AddDirFileInfo(archiveNamePrefix, fileName, fileInfo, dirItems);
- if (fileInfo.IsDirectory())
+ int delimiter = filePath.ReverseFind((wchar_t)kDirDelimiter);
+
+ int phyParentCur = phyParent;
+ if (delimiter >= 0)
+ phyParentCur = AddPrefix(phyParentCur, logParent, filePath.Left(delimiter + 1));
+ AddDirFileInfo(phyParentCur, logParent, fi, Items);
+ if (fi.IsDir())
{
- EnumerateDirectory(baseFolderPrefix, fileName + wchar_t(kDirDelimiter),
- archiveNamePrefix + fileInfo.Name + wchar_t(kDirDelimiter),
- dirItems, errorPaths, errorCodes);
+ const UString name2 = fi.Name + (wchar_t)kDirDelimiter;
+ int parent = AddPrefix(phyParentCur, logParent, name2);
+ EnumerateDirectory(parent, parent, phyPrefix + name2, errorPaths, errorCodes);
}
}
+ ReserveDown();
+}
+
+static HRESULT EnumerateDirItems(const NWildcard::CCensorNode &curNode,
+ int phyParent, int logParent, const UString &phyPrefix,
+ const UStringVector &addArchivePrefix,
+ CDirItems &dirItems,
+ bool enterToSubFolders,
+ IEnumDirItemCallback *callback,
+ UStringVector &errorPaths,
+ CRecordVector<DWORD> &errorCodes);
+
+static HRESULT EnumerateDirItems_Spec(const NWildcard::CCensorNode &curNode,
+ int phyParent, int logParent, const UString &curFolderName,
+ const UString &phyPrefix,
+ const UStringVector &addArchivePrefix,
+ CDirItems &dirItems,
+ bool enterToSubFolders,
+ IEnumDirItemCallback *callback,
+ UStringVector &errorPaths,
+ CRecordVector<DWORD> &errorCodes)
+
+{
+ const UString name2 = curFolderName + (wchar_t)kDirDelimiter;
+ int parent = dirItems.AddPrefix(phyParent, logParent, name2);
+ int numItems = dirItems.Items.Size();
+ HRESULT res = EnumerateDirItems(curNode, parent, parent, phyPrefix + name2,
+ addArchivePrefix, dirItems, enterToSubFolders, callback, errorPaths, errorCodes);
+ if (numItems == dirItems.Items.Size())
+ dirItems.DeleteLastPrefix();
+ return res;
}
-static HRESULT EnumerateDirItems(
- const NWildcard::CCensorNode &curNode,
- const UString &diskPrefix, // full disk path prefix
- const UString &archivePrefix, // prefix from root
+
+static HRESULT EnumerateDirItems(const NWildcard::CCensorNode &curNode,
+ int phyParent, int logParent, const UString &phyPrefix,
const UStringVector &addArchivePrefix, // prefix from curNode
- CObjectVector<CDirItem> &dirItems,
+ CDirItems &dirItems,
bool enterToSubFolders,
IEnumDirItemCallback *callback,
UStringVector &errorPaths,
@@ -102,7 +188,7 @@ static HRESULT EnumerateDirItems(
if (curNode.NeedCheckSubDirs())
enterToSubFolders = true;
if (callback)
- RINOK(callback->CheckBreak());
+ RINOK(callback->ScanProgress(dirItems.GetNumFolders(), dirItems.Items.Size(), phyPrefix));
// try direct_names case at first
if (addArchivePrefix.IsEmpty() && !enterToSubFolders)
@@ -127,30 +213,28 @@ static HRESULT EnumerateDirItems(
{
const NWildcard::CItem &item = curNode.IncludeItems[i];
const UString &name = item.PathParts.Front();
- const UString fullPath = diskPrefix + name;
- NFind::CFileInfoW fileInfo;
- if (!NFind::FindFile(fullPath, fileInfo))
+ const UString fullPath = phyPrefix + name;
+ NFind::CFileInfoW fi;
+ if (!NFind::FindFile(fullPath, fi))
{
errorCodes.Add(::GetLastError());
errorPaths.Add(fullPath);
continue;
}
- bool isDir = fileInfo.IsDirectory();
+ bool isDir = fi.IsDir();
if (isDir && !item.ForDir || !isDir && !item.ForFile)
{
errorCodes.Add((DWORD)E_FAIL);
errorPaths.Add(fullPath);
continue;
}
- const UString realName = fileInfo.Name;
- const UString realDiskPath = diskPrefix + realName;
{
UStringVector pathParts;
- pathParts.Add(fileInfo.Name);
+ pathParts.Add(fi.Name);
if (curNode.CheckPathToRoot(false, pathParts, !isDir))
continue;
}
- AddDirFileInfo(archivePrefix, realDiskPath, fileInfo, dirItems);
+ AddDirFileInfo(phyParent, logParent, fi, dirItems.Items);
if (!isDir)
continue;
@@ -167,11 +251,10 @@ static HRESULT EnumerateDirItems(
else
{
nextNode = &curNode;
- addArchivePrefixNew.Add(name); // don't change it to realName. It's for shortnames support
+ addArchivePrefixNew.Add(name); // don't change it to fi.Name. It's for shortnames support
}
- RINOK(EnumerateDirItems(*nextNode,
- realDiskPath + wchar_t(kDirDelimiter),
- archivePrefix + realName + wchar_t(kDirDelimiter),
+
+ RINOK(EnumerateDirItems_Spec(*nextNode, phyParent, logParent, fi.Name, phyPrefix,
addArchivePrefixNew, dirItems, true, callback, errorPaths, errorCodes));
}
for (i = 0; i < curNode.SubNodes.Size(); i++)
@@ -180,9 +263,9 @@ static HRESULT EnumerateDirItems(
if (!needEnterVector[i])
continue;
const NWildcard::CCensorNode &nextNode = curNode.SubNodes[i];
- const UString fullPath = diskPrefix + nextNode.Name;
- NFind::CFileInfoW fileInfo;
- if (!NFind::FindFile(fullPath, fileInfo))
+ const UString fullPath = phyPrefix + nextNode.Name;
+ NFind::CFileInfoW fi;
+ if (!NFind::FindFile(fullPath, fi))
{
if (!nextNode.AreThereIncludeItems())
continue;
@@ -190,15 +273,14 @@ static HRESULT EnumerateDirItems(
errorPaths.Add(fullPath);
continue;
}
- if (!fileInfo.IsDirectory())
+ if (!fi.IsDir())
{
errorCodes.Add((DWORD)E_FAIL);
errorPaths.Add(fullPath);
continue;
}
- RINOK(EnumerateDirItems(nextNode,
- diskPrefix + fileInfo.Name + wchar_t(kDirDelimiter),
- archivePrefix + fileInfo.Name + wchar_t(kDirDelimiter),
+
+ RINOK(EnumerateDirItems_Spec(nextNode, phyParent, logParent, fi.Name, phyPrefix,
UStringVector(), dirItems, false, callback, errorPaths, errorCodes));
}
return S_OK;
@@ -206,38 +288,38 @@ static HRESULT EnumerateDirItems(
}
- NFind::CEnumeratorW enumerator(diskPrefix + wchar_t(kAnyStringWildcard));
- for (;;)
+ NFind::CEnumeratorW enumerator(phyPrefix + wchar_t(kAnyStringWildcard));
+ for (int ttt = 0; ; ttt++)
{
- NFind::CFileInfoW fileInfo;
+ NFind::CFileInfoW fi;
bool found;
- if (!enumerator.Next(fileInfo, found))
+ if (!enumerator.Next(fi, found))
{
errorCodes.Add(::GetLastError());
- errorPaths.Add(diskPrefix);
+ errorPaths.Add(phyPrefix);
break;
}
if (!found)
break;
- if (callback)
- RINOK(callback->CheckBreak());
- const UString &name = fileInfo.Name;
+ if (callback && (ttt & 0xFF) == 0xFF)
+ RINOK(callback->ScanProgress(dirItems.GetNumFolders(), dirItems.Items.Size(), phyPrefix));
+ const UString &name = fi.Name;
bool enterToSubFolders2 = enterToSubFolders;
UStringVector addArchivePrefixNew = addArchivePrefix;
addArchivePrefixNew.Add(name);
{
UStringVector addArchivePrefixNewTemp(addArchivePrefixNew);
- if (curNode.CheckPathToRoot(false, addArchivePrefixNewTemp, !fileInfo.IsDirectory()))
+ if (curNode.CheckPathToRoot(false, addArchivePrefixNewTemp, !fi.IsDir()))
continue;
}
- if (curNode.CheckPathToRoot(true, addArchivePrefixNew, !fileInfo.IsDirectory()))
+ if (curNode.CheckPathToRoot(true, addArchivePrefixNew, !fi.IsDir()))
{
- AddDirFileInfo(archivePrefix, diskPrefix + name, fileInfo, dirItems);
- if (fileInfo.IsDirectory())
+ AddDirFileInfo(phyParent, logParent, fi, dirItems.Items);
+ if (fi.IsDir())
enterToSubFolders2 = true;
}
- if (!fileInfo.IsDirectory())
+ if (!fi.IsDir())
continue;
const NWildcard::CCensorNode *nextNode = 0;
@@ -256,17 +338,16 @@ static HRESULT EnumerateDirItems(
nextNode = &curNode;
addArchivePrefixNew.Add(name);
}
- RINOK(EnumerateDirItems(*nextNode,
- diskPrefix + name + wchar_t(kDirDelimiter),
- archivePrefix + name + wchar_t(kDirDelimiter),
+
+ RINOK(EnumerateDirItems_Spec(*nextNode, phyParent, logParent, name, phyPrefix,
addArchivePrefixNew, dirItems, enterToSubFolders2, callback, errorPaths, errorCodes));
}
return S_OK;
}
HRESULT EnumerateItems(
- const NWildcard::CCensor &censor,
- CObjectVector<CDirItem> &dirItems,
+ const NWildcard::CCensor &censor,
+ CDirItems &dirItems,
IEnumDirItemCallback *callback,
UStringVector &errorPaths,
CRecordVector<DWORD> &errorCodes)
@@ -274,8 +355,10 @@ HRESULT EnumerateItems(
for (int i = 0; i < censor.Pairs.Size(); i++)
{
const NWildcard::CPair &pair = censor.Pairs[i];
- RINOK(EnumerateDirItems(pair.Head, pair.Prefix, L"", UStringVector(), dirItems, false,
+ int phyParent = pair.Prefix.IsEmpty() ? -1 : dirItems.AddPrefix(-1, -1, pair.Prefix);
+ RINOK(EnumerateDirItems(pair.Head, phyParent, -1, pair.Prefix, UStringVector(), dirItems, false,
callback, errorPaths, errorCodes));
}
+ dirItems.ReserveDown();
return S_OK;
}
diff --git a/CPP/7zip/UI/Common/EnumDirItems.h b/CPP/7zip/UI/Common/EnumDirItems.h
index 8d5495a8..d0ce950e 100755
--- a/CPP/7zip/UI/Common/EnumDirItems.h
+++ b/CPP/7zip/UI/Common/EnumDirItems.h
@@ -4,35 +4,21 @@
#define __ENUM_DIR_ITEMS_H
#include "Common/Wildcard.h"
-#include "DirItem.h"
-
#include "Windows/FileFind.h"
+#include "DirItem.h"
-void AddDirFileInfo(
- const UString &prefix,
- const UString &fullPathName,
- const NWindows::NFile::NFind::CFileInfoW &fileInfo,
- CObjectVector<CDirItem> &dirItems);
-
-
-void EnumerateDirItems(
- const UString &baseFolderPrefix,
- const UStringVector &fileNames,
- const UString &archiveNamePrefix,
- CObjectVector<CDirItem> &dirItems,
- UStringVector &errorPaths,
- CRecordVector<DWORD> &errorCodes);
+void AddDirFileInfo(int phyParent, int logParent,
+ const NWindows::NFile::NFind::CFileInfoW &fi, CObjectVector<CDirItem> &dirItems);
struct IEnumDirItemCallback
{
- virtual HRESULT CheckBreak() { return S_OK; }
+ virtual HRESULT ScanProgress(UInt64 numFolders, UInt64 numFiles, const wchar_t *path) = 0;
};
-
HRESULT EnumerateItems(
- const NWildcard::CCensor &censor,
- CObjectVector<CDirItem> &dirItems,
- IEnumDirItemCallback *callback,
+ const NWildcard::CCensor &censor,
+ CDirItems &dirItems,
+ IEnumDirItemCallback *callback,
UStringVector &errorPaths,
CRecordVector<DWORD> &errorCodes);
diff --git a/CPP/7zip/UI/Common/ExitCode.h b/CPP/7zip/UI/Common/ExitCode.h
index 0aac3695..b6d7d4df 100755
--- a/CPP/7zip/UI/Common/ExitCode.h
+++ b/CPP/7zip/UI/Common/ExitCode.h
@@ -10,7 +10,7 @@ enum EEnum {
kSuccess = 0, // Successful operation
kWarning = 1, // Non fatal error(s) occurred
kFatalError = 2, // A fatal error occurred
- // kCRCError = 3, // A CRC error occurred when unpacking
+ // kCRCError = 3, // A CRC error occurred when unpacking
// kLockedArchive = 4, // Attempt to modify an archive previously locked
// kWriteError = 5, // Write to disk error
// kOpenError = 6, // Open file error
diff --git a/CPP/7zip/UI/Common/Extract.cpp b/CPP/7zip/UI/Common/Extract.cpp
index 0e56a08a..3ac497f4 100755
--- a/CPP/7zip/UI/Common/Extract.cpp
+++ b/CPP/7zip/UI/Common/Extract.cpp
@@ -12,10 +12,9 @@
using namespace NWindows;
-HRESULT DecompressArchive(
+static HRESULT DecompressArchive(
IInArchive *archive,
UInt64 packSize,
- const UString &defaultName,
const NWildcard::CCensorNode &wildcardCensor,
const CExtractOptions &options,
IExtractCallbackUI *callback,
@@ -45,7 +44,11 @@ HRESULT DecompressArchive(
UStringVector removePathParts;
UString outDir = options.OutputDir;
- outDir.Replace(L"*", defaultName);
+ outDir.Replace(L"*", options.DefaultItemName);
+ #ifdef _WIN32
+ outDir.TrimRight();
+ #endif
+
if(!outDir.IsEmpty())
if(!NFile::NDirectory::CreateComplexDirectory(outDir))
{
@@ -57,34 +60,34 @@ HRESULT DecompressArchive(
}
extractCallbackSpec->Init(
- archive,
+ archive,
callback,
options.StdOutMode,
- outDir,
- removePathParts,
- options.DefaultItemName,
- options.ArchiveFileInfo.LastWriteTime,
- options.ArchiveFileInfo.Attributes,
+ outDir,
+ removePathParts,
+ options.DefaultItemName,
+ options.ArchiveFileInfo.MTime,
+ options.ArchiveFileInfo.Attrib,
packSize);
#ifdef COMPRESS_MT
RINOK(SetProperties(archive, options.Properties));
#endif
- HRESULT result = archive->Extract(&realIndices.Front(),
+ HRESULT result = archive->Extract(&realIndices.Front(),
realIndices.Size(), options.TestMode? 1: 0, extractCallbackSpec);
return callback->ExtractResult(result);
}
HRESULT DecompressArchives(
- CCodecs *codecs,
- UStringVector &archivePaths, UStringVector &archivePathsFull,
+ CCodecs *codecs, const CIntVector &formatIndices,
+ UStringVector &archivePaths, UStringVector &archivePathsFull,
const NWildcard::CCensorNode &wildcardCensor,
const CExtractOptions &optionsSpec,
IOpenCallbackUI *openCallback,
- IExtractCallbackUI *extractCallback,
- UString &errorMessage,
+ IExtractCallbackUI *extractCallback,
+ UString &errorMessage,
CDecompressStat &stat)
{
stat.Clear();
@@ -95,13 +98,13 @@ HRESULT DecompressArchives(
for (i = 0; i < archivePaths.Size(); i++)
{
const UString &archivePath = archivePaths[i];
- NFile::NFind::CFileInfoW archiveFileInfo;
- if (!NFile::NFind::FindFile(archivePath, archiveFileInfo))
+ NFile::NFind::CFileInfoW fi;
+ if (!NFile::NFind::FindFile(archivePath, fi))
throw "there is no such archive";
- if (archiveFileInfo.IsDirectory())
+ if (fi.IsDir())
throw "can't decompress folder";
- archiveSizes.Add(archiveFileInfo.Size);
- totalPackSize += archiveFileInfo.Size;
+ archiveSizes.Add(fi.Size);
+ totalPackSize += fi.Size;
}
CArchiveExtractCallback *extractCallbackSpec = new CArchiveExtractCallback;
CMyComPtr<IArchiveExtractCallback> ec(extractCallbackSpec);
@@ -109,31 +112,60 @@ HRESULT DecompressArchives(
extractCallbackSpec->InitForMulti(multi, options.PathMode, options.OverwriteMode);
if (multi)
{
- RINOK(extractCallback->SetTotal(totalPackSize));
+ RINOK(extractCallback->SetTotal(totalPackSize));
}
for (i = 0; i < archivePaths.Size(); i++)
{
const UString &archivePath = archivePaths[i];
- NFile::NFind::CFileInfoW archiveFileInfo;
- if (!NFile::NFind::FindFile(archivePath, archiveFileInfo))
+ NFile::NFind::CFileInfoW fi;
+ if (!NFile::NFind::FindFile(archivePath, fi))
throw "there is no such archive";
- if (archiveFileInfo.IsDirectory())
+ if (fi.IsDir())
throw "there is no such archive";
- options.ArchiveFileInfo = archiveFileInfo;
+ options.ArchiveFileInfo = fi;
#ifndef _NO_CRYPTO
- openCallback->ClearPasswordWasAskedFlag();
+ openCallback->Open_ClearPasswordWasAskedFlag();
#endif
RINOK(extractCallback->BeforeOpen(archivePath));
CArchiveLink archiveLink;
- HRESULT result = MyOpenArchive(codecs, archivePath, archiveLink, openCallback);
+
+ CIntVector formatIndices2 = formatIndices;
+ #ifndef _SFX
+ if (formatIndices.IsEmpty())
+ {
+ int pos = archivePath.ReverseFind(L'.');
+ if (pos >= 0)
+ {
+ UString s = archivePath.Mid(pos + 1);
+ int index = codecs->FindFormatForExtension(s);
+ if (index >= 0 && s == L"001")
+ {
+ s = archivePath.Left(pos);
+ pos = s.ReverseFind(L'.');
+ if (pos >= 0)
+ {
+ int index2 = codecs->FindFormatForExtension(s.Mid(pos + 1));
+ if (index2 >= 0 && s.CompareNoCase(L"rar") != 0)
+ {
+ formatIndices2.Add(index2);
+ formatIndices2.Add(index);
+ }
+ }
+ }
+ }
+ }
+ #endif
+ HRESULT result = MyOpenArchive(codecs, formatIndices2, archivePath, archiveLink, openCallback);
+ if (result == E_ABORT)
+ return result;
bool crypted = false;
#ifndef _NO_CRYPTO
- crypted = openCallback->WasPasswordAsked();
+ crypted = openCallback->Open_WasPasswordAsked();
#endif
RINOK(extractCallback->OpenResult(archivePath, result, crypted));
@@ -154,12 +186,12 @@ HRESULT DecompressArchives(
if (archiveLink.VolumePaths.Size() != 0)
{
totalPackSize += archiveLink.VolumesSize;
- RINOK(extractCallback->SetTotal(totalPackSize));
+ RINOK(extractCallback->SetTotal(totalPackSize));
}
#ifndef _NO_CRYPTO
UString password;
- RINOK(openCallback->GetPasswordIfAny(password));
+ RINOK(openCallback->Open_GetPasswordIfAny(password));
if (!password.IsEmpty())
{
RINOK(extractCallback->SetPassword(password));
@@ -168,11 +200,10 @@ HRESULT DecompressArchives(
options.DefaultItemName = archiveLink.GetDefaultItemName();
RINOK(DecompressArchive(
- archiveLink.GetArchive(),
- archiveFileInfo.Size + archiveLink.VolumesSize,
- archiveLink.GetDefaultItemName(),
+ archiveLink.GetArchive(),
+ fi.Size + archiveLink.VolumesSize,
wildcardCensor, options, extractCallback, extractCallbackSpec, errorMessage));
- extractCallbackSpec->LocalProgressSpec->InSize += archiveFileInfo.Size +
+ extractCallbackSpec->LocalProgressSpec->InSize += fi.Size +
archiveLink.VolumesSize;
extractCallbackSpec->LocalProgressSpec->OutSize = extractCallbackSpec->UnpackSize;
if (!errorMessage.IsEmpty())
diff --git a/CPP/7zip/UI/Common/Extract.h b/CPP/7zip/UI/Common/Extract.h
index e7add12e..37add18b 100755
--- a/CPP/7zip/UI/Common/Extract.h
+++ b/CPP/7zip/UI/Common/Extract.h
@@ -40,16 +40,16 @@ public:
CCodecs *Codecs;
#endif
- CExtractOptions():
- StdOutMode(false),
- YesToAll(false),
+ CExtractOptions():
+ StdOutMode(false),
+ YesToAll(false),
TestMode(false),
PathMode(NExtract::NPathMode::kFullPathnames),
OverwriteMode(NExtract::NOverwriteMode::kAskBefore)
{}
/*
- bool FullPathMode() const { return (ExtractMode == NExtractMode::kTest) ||
+ bool FullPathMode() const { return (ExtractMode == NExtractMode::kTest) ||
(ExtractMode == NExtractMode::kFullPath); }
*/
};
@@ -65,13 +65,13 @@ struct CDecompressStat
};
HRESULT DecompressArchives(
- CCodecs *codecs,
+ CCodecs *codecs, const CIntVector &formatIndices,
UStringVector &archivePaths, UStringVector &archivePathsFull,
const NWildcard::CCensorNode &wildcardCensor,
const CExtractOptions &options,
IOpenCallbackUI *openCallback,
IExtractCallbackUI *extractCallback,
- UString &errorMessage,
+ UString &errorMessage,
CDecompressStat &stat);
#endif
diff --git a/CPP/7zip/UI/Common/ExtractMode.h b/CPP/7zip/UI/Common/ExtractMode.h
index 96b5a8cd..b448fb30 100755
--- a/CPP/7zip/UI/Common/ExtractMode.h
+++ b/CPP/7zip/UI/Common/ExtractMode.h
@@ -26,6 +26,6 @@ namespace NExtract {
kAutoRenameExisting
};
}
-}
+}
#endif
diff --git a/CPP/7zip/UI/Common/ExtractingFilePath.cpp b/CPP/7zip/UI/Common/ExtractingFilePath.cpp
index fa796ca6..5de388dd 100755
--- a/CPP/7zip/UI/Common/ExtractingFilePath.cpp
+++ b/CPP/7zip/UI/Common/ExtractingFilePath.cpp
@@ -14,6 +14,7 @@ static UString ReplaceIncorrectChars(const UString &s)
c = '_';
res += c;
}
+ res.TrimRight();
return res;
#else
return s;
diff --git a/CPP/7zip/UI/Common/HandlerLoader.h b/CPP/7zip/UI/Common/HandlerLoader.h
index 2a878019..4c7e1a8f 100755
--- a/CPP/7zip/UI/Common/HandlerLoader.h
+++ b/CPP/7zip/UI/Common/HandlerLoader.h
@@ -7,14 +7,14 @@
#include "Windows/DLL.h"
typedef UInt32 (WINAPI * CreateObjectFunc)(
- const GUID *clsID,
- const GUID *interfaceID,
+ const GUID *clsID,
+ const GUID *interfaceID,
void **outObject);
class CHandlerLoader: public NWindows::NDLL::CLibrary
{
public:
- HRESULT CreateHandler(LPCWSTR filepath, REFGUID clsID,
+ HRESULT CreateHandler(LPCWSTR filepath, REFGUID clsID,
void **archive, bool outHandler)
{
if (!Load(filepath))
@@ -27,7 +27,7 @@ public:
Free();
return res;
}
- HRESULT res = createObject(&clsID,
+ HRESULT res = createObject(&clsID,
outHandler ? &IID_IOutArchive : &IID_IInArchive, (void **)archive);
if (res != 0)
Free();
diff --git a/CPP/7zip/UI/Common/IFileExtractCallback.h b/CPP/7zip/UI/Common/IFileExtractCallback.h
index 284e9cb3..e8dcdce5 100755
--- a/CPP/7zip/UI/Common/IFileExtractCallback.h
+++ b/CPP/7zip/UI/Common/IFileExtractCallback.h
@@ -37,7 +37,10 @@ struct IExtractCallbackUI: IFolderArchiveExtractCallback
virtual HRESULT OpenResult(const wchar_t *name, HRESULT result, bool encrypted) = 0;
virtual HRESULT ThereAreNoFiles() = 0;
virtual HRESULT ExtractResult(HRESULT result) = 0;
+
+ #ifndef _NO_CRYPTO
virtual HRESULT SetPassword(const UString &password) = 0;
+ #endif
};
#endif
diff --git a/CPP/7zip/UI/Common/LoadCodecs.cpp b/CPP/7zip/UI/Common/LoadCodecs.cpp
index 52b2ebe8..79caf55e 100755
--- a/CPP/7zip/UI/Common/LoadCodecs.cpp
+++ b/CPP/7zip/UI/Common/LoadCodecs.cpp
@@ -47,7 +47,7 @@ static CSysString GetLibraryFolderPrefix()
#define kCodecsFolderName TEXT("Codecs")
#define kFormatsFolderName TEXT("Formats")
-static TCHAR *kMainDll = TEXT("7z.dll");
+static const TCHAR *kMainDll = TEXT("7z.dll");
#ifdef _WIN32
static LPCTSTR kRegistryPath = TEXT("Software\\7-zip");
@@ -69,15 +69,15 @@ static bool ReadPathFromRegistry(HKEY baseKey, CSysString &path)
CSysString GetBaseFolderPrefixFromRegistry()
{
CSysString moduleFolderPrefix = GetLibraryFolderPrefix();
- NFind::CFileInfo fileInfo;
- if (NFind::FindFile(moduleFolderPrefix + kMainDll, fileInfo))
- if (!fileInfo.IsDirectory())
+ NFind::CFileInfo fi;
+ if (NFind::FindFile(moduleFolderPrefix + kMainDll, fi))
+ if (!fi.IsDir())
return moduleFolderPrefix;
- if (NFind::FindFile(moduleFolderPrefix + kCodecsFolderName, fileInfo))
- if (fileInfo.IsDirectory())
+ if (NFind::FindFile(moduleFolderPrefix + kCodecsFolderName, fi))
+ if (fi.IsDir())
return moduleFolderPrefix;
- if (NFind::FindFile(moduleFolderPrefix + kFormatsFolderName, fileInfo))
- if (fileInfo.IsDirectory())
+ if (NFind::FindFile(moduleFolderPrefix + kFormatsFolderName, fi))
+ if (fi.IsDir())
return moduleFolderPrefix;
#ifdef _WIN32
CSysString path;
@@ -97,7 +97,7 @@ typedef UInt32 (WINAPI *CreateObjectFunc)(const GUID *clsID, const GUID *iid, vo
typedef UInt32 (WINAPI *SetLargePageModeFunc)();
-static HRESULT GetCoderClass(GetMethodPropertyFunc getMethodProperty, UInt32 index,
+static HRESULT GetCoderClass(GetMethodPropertyFunc getMethodProperty, UInt32 index,
PROPID propId, CLSID &clsId, bool &isAssigned)
{
NWindows::NCOM::CPropVariant prop;
@@ -142,8 +142,8 @@ HRESULT CCodecs::LoadCodecs()
}
static HRESULT ReadProp(
- GetHandlerPropertyFunc getProp,
- GetHandlerPropertyFunc2 getProp2,
+ GetHandlerPropertyFunc getProp,
+ GetHandlerPropertyFunc2 getProp2,
UInt32 index, PROPID propID, NCOM::CPropVariant &prop)
{
if (getProp2)
@@ -152,8 +152,8 @@ static HRESULT ReadProp(
}
static HRESULT ReadBoolProp(
- GetHandlerPropertyFunc getProp,
- GetHandlerPropertyFunc2 getProp2,
+ GetHandlerPropertyFunc getProp,
+ GetHandlerPropertyFunc2 getProp2,
UInt32 index, PROPID propID, bool &res)
{
NCOM::CPropVariant prop;
@@ -166,8 +166,8 @@ static HRESULT ReadBoolProp(
}
static HRESULT ReadStringProp(
- GetHandlerPropertyFunc getProp,
- GetHandlerPropertyFunc2 getProp2,
+ GetHandlerPropertyFunc getProp,
+ GetHandlerPropertyFunc2 getProp2,
UInt32 index, PROPID propID, UString &res)
{
NCOM::CPropVariant prop;
@@ -183,11 +183,11 @@ static HRESULT ReadStringProp(
static const unsigned int kNumArcsMax = 32;
static unsigned int g_NumArcs = 0;
-static const CArcInfo *g_Arcs[kNumArcsMax];
-void RegisterArc(const CArcInfo *arcInfo)
-{
+static const CArcInfo *g_Arcs[kNumArcsMax];
+void RegisterArc(const CArcInfo *arcInfo)
+{
if (g_NumArcs < kNumArcsMax)
- g_Arcs[g_NumArcs++] = arcInfo;
+ g_Arcs[g_NumArcs++] = arcInfo;
}
static void SplitString(const UString &srcString, UStringVector &destStrings)
@@ -334,7 +334,7 @@ int CCodecLib::FindIconIndex(const UString &ext) const
#endif
#ifdef _7ZIP_LARGE_PAGES
-extern "C"
+extern "C"
{
extern SIZE_T g_LargePageSize;
}
@@ -391,12 +391,12 @@ HRESULT CCodecs::LoadDll(const CSysString &dllPath)
HRESULT CCodecs::LoadDllsFromFolder(const CSysString &folderPrefix)
{
NFile::NFind::CEnumerator enumerator(folderPrefix + CSysString(TEXT("*")));
- NFile::NFind::CFileInfo fileInfo;
- while (enumerator.Next(fileInfo))
+ NFile::NFind::CFileInfo fi;
+ while (enumerator.Next(fi))
{
- if (fileInfo.IsDirectory())
+ if (fi.IsDir())
continue;
- RINOK(LoadDll(folderPrefix + fileInfo.Name));
+ RINOK(LoadDll(folderPrefix + fi.Name));
}
return S_OK;
}
@@ -442,14 +442,16 @@ HRESULT CCodecs::Load()
return S_OK;
}
-int CCodecs::FindFormatForArchiveName(const UString &archivePath) const
+#ifndef _SFX
+
+int CCodecs::FindFormatForArchiveName(const UString &arcPath) const
{
- int slashPos1 = archivePath.ReverseFind(L'\\');
- int slashPos2 = archivePath.ReverseFind(L'.');
- int dotPos = archivePath.ReverseFind(L'.');
+ int slashPos1 = arcPath.ReverseFind(L'\\');
+ int slashPos2 = arcPath.ReverseFind(L'.');
+ int dotPos = arcPath.ReverseFind(L'.');
if (dotPos < 0 || dotPos < slashPos1 || dotPos < slashPos2)
return -1;
- UString ext = archivePath.Mid(dotPos + 1);
+ UString ext = arcPath.Mid(dotPos + 1);
for (int i = 0; i < Formats.Size(); i++)
{
const CArcInfoEx &arc = Formats[i];
@@ -463,19 +465,47 @@ int CCodecs::FindFormatForArchiveName(const UString &archivePath) const
return -1;
}
+int CCodecs::FindFormatForExtension(const UString &ext) const
+{
+ if (ext.IsEmpty())
+ return -1;
+ for (int i = 0; i < Formats.Size(); i++)
+ if (Formats[i].FindExtension(ext) >= 0)
+ return i;
+ return -1;
+}
+
int CCodecs::FindFormatForArchiveType(const UString &arcType) const
{
for (int i = 0; i < Formats.Size(); i++)
- {
- const CArcInfoEx &arc = Formats[i];
- if (!arc.UpdateEnabled)
- continue;
- if (arc.Name.CompareNoCase(arcType) == 0)
+ if (Formats[i].Name.CompareNoCase(arcType) == 0)
return i;
- }
return -1;
}
+bool CCodecs::FindFormatForArchiveType(const UString &arcType, CIntVector &formatIndices) const
+{
+ formatIndices.Clear();
+ for (int pos = 0; pos < arcType.Length();)
+ {
+ int pos2 = arcType.Find('.', pos);
+ if (pos2 < 0)
+ pos2 = arcType.Length();
+ const UString name = arcType.Mid(pos, pos2 - pos);
+ int index = FindFormatForArchiveType(name);
+ if (index < 0 && name != L"*")
+ {
+ formatIndices.Clear();
+ return false;
+ }
+ formatIndices.Add(index);
+ pos = pos2 + 1;
+ }
+ return true;
+}
+
+#endif
+
#ifdef EXTERNAL_CODECS
#ifdef EXPORT_CODECS
@@ -487,9 +517,9 @@ STDAPI GetMethodProperty(UInt32 codecIndex, PROPID propID, PROPVARIANT *value);
STDMETHODIMP CCodecs::GetNumberOfMethods(UInt32 *numMethods)
{
- *numMethods =
+ *numMethods =
#ifdef EXPORT_CODECS
- g_NumCodecs +
+ g_NumCodecs +
#endif
Codecs.Size();
return S_OK;
@@ -502,7 +532,7 @@ STDMETHODIMP CCodecs::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *valu
return GetMethodProperty(index, propID, value);
#endif
- const CDllCodecInfo &ci = Codecs[index
+ const CDllCodecInfo &ci = Codecs[index
#ifdef EXPORT_CODECS
- g_NumCodecs
#endif
@@ -531,7 +561,7 @@ STDMETHODIMP CCodecs::CreateDecoder(UInt32 index, const GUID *iid, void **coder)
if (index < g_NumCodecs)
return CreateCoder2(false, index, iid, coder);
#endif
- const CDllCodecInfo &ci = Codecs[index
+ const CDllCodecInfo &ci = Codecs[index
#ifdef EXPORT_CODECS
- g_NumCodecs
#endif
@@ -547,7 +577,7 @@ STDMETHODIMP CCodecs::CreateEncoder(UInt32 index, const GUID *iid, void **coder)
if (index < g_NumCodecs)
return CreateCoder2(true, index, iid, coder);
#endif
- const CDllCodecInfo &ci = Codecs[index
+ const CDllCodecInfo &ci = Codecs[index
#ifdef EXPORT_CODECS
- g_NumCodecs
#endif
@@ -558,7 +588,7 @@ STDMETHODIMP CCodecs::CreateEncoder(UInt32 index, const GUID *iid, void **coder)
}
HRESULT CCodecs::CreateCoder(const UString &name, bool encode, CMyComPtr<ICompressCoder> &coder) const
-{
+{
for (int i = 0; i < Codecs.Size(); i++)
{
const CDllCodecInfo &codec = Codecs[i];
@@ -585,7 +615,7 @@ int CCodecs::GetCodecLibIndex(UInt32 index)
return -1;
#endif
#ifdef EXTERNAL_CODECS
- const CDllCodecInfo &ci = Codecs[index
+ const CDllCodecInfo &ci = Codecs[index
#ifdef EXPORT_CODECS
- g_NumCodecs
#endif
@@ -609,7 +639,7 @@ bool CCodecs::GetCodecEncoderIsAssigned(UInt32 index)
}
#endif
#ifdef EXTERNAL_CODECS
- const CDllCodecInfo &ci = Codecs[index
+ const CDllCodecInfo &ci = Codecs[index
#ifdef EXPORT_CODECS
- g_NumCodecs
#endif
diff --git a/CPP/7zip/UI/Common/LoadCodecs.h b/CPP/7zip/UI/Common/LoadCodecs.h
index dadcf7c2..71de2ff1 100755
--- a/CPP/7zip/UI/Common/LoadCodecs.h
+++ b/CPP/7zip/UI/Common/LoadCodecs.h
@@ -85,7 +85,7 @@ struct CArcInfoEx
void AddExts(const wchar_t* ext, const wchar_t* addExt);
- CArcInfoEx():
+ CArcInfoEx():
#ifdef EXTERNAL_CODECS
LibIndex(-1),
#endif
@@ -130,7 +130,7 @@ class CCodecs:
#endif
public CMyUnknownImp
{
-public:
+public:
#ifdef EXTERNAL_CODECS
CObjectVector<CCodecLib> Libs;
CObjectVector<CDllCodecInfo> Codecs;
@@ -148,8 +148,13 @@ public:
public:
CObjectVector<CArcInfoEx> Formats;
HRESULT Load();
- int FindFormatForArchiveName(const UString &archivePath) const;
+
+ #ifndef _SFX
+ int FindFormatForArchiveName(const UString &arcPath) const;
+ int FindFormatForExtension(const UString &ext) const;
int FindFormatForArchiveType(const UString &arcType) const;
+ bool FindFormatForArchiveType(const UString &arcType, CIntVector &formatIndices) const;
+ #endif
MY_UNKNOWN_IMP
@@ -166,8 +171,8 @@ public:
UString GetCodecName(UInt32 index);
HRESULT CreateInArchive(int formatIndex, CMyComPtr<IInArchive> &archive) const
- {
- const CArcInfoEx &ai = Formats[formatIndex];
+ {
+ const CArcInfoEx &ai = Formats[formatIndex];
#ifdef EXTERNAL_CODECS
if (ai.LibIndex < 0)
#endif
@@ -176,12 +181,12 @@ public:
return S_OK;
}
#ifdef EXTERNAL_CODECS
- return CreateArchiveHandler(ai, (void **)&archive, false);
+ return CreateArchiveHandler(ai, (void **)&archive, false);
#endif
}
HRESULT CreateOutArchive(int formatIndex, CMyComPtr<IOutArchive> &archive) const
- {
- const CArcInfoEx &ai = Formats[formatIndex];
+ {
+ const CArcInfoEx &ai = Formats[formatIndex];
#ifdef EXTERNAL_CODECS
if (ai.LibIndex < 0)
#endif
@@ -190,7 +195,7 @@ public:
return S_OK;
}
#ifdef EXTERNAL_CODECS
- return CreateArchiveHandler(ai, (void **)&archive, true);
+ return CreateArchiveHandler(ai, (void **)&archive, true);
#endif
}
int FindOutFormatFromName(const UString &name) const
diff --git a/CPP/7zip/UI/Common/OpenArchive.cpp b/CPP/7zip/UI/Common/OpenArchive.cpp
index 4bd93455..7037d876 100755
--- a/CPP/7zip/UI/Common/OpenArchive.cpp
+++ b/CPP/7zip/UI/Common/OpenArchive.cpp
@@ -52,11 +52,11 @@ HRESULT GetArchiveItemPath(IInArchive *archive, UInt32 index, const UString &def
return S_OK;
}
-HRESULT GetArchiveItemFileTime(IInArchive *archive, UInt32 index,
+HRESULT GetArchiveItemFileTime(IInArchive *archive, UInt32 index,
const FILETIME &defaultFileTime, FILETIME &fileTime)
{
NCOM::CPropVariant prop;
- RINOK(archive->GetProperty(index, kpidLastWriteTime, &prop));
+ RINOK(archive->GetProperty(index, kpidMTime, &prop));
if (prop.vt == VT_FILETIME)
fileTime = prop.filetime;
else if (prop.vt == VT_EMPTY)
@@ -81,7 +81,7 @@ HRESULT IsArchiveItemProp(IInArchive *archive, UInt32 index, PROPID propID, bool
HRESULT IsArchiveItemFolder(IInArchive *archive, UInt32 index, bool &result)
{
- return IsArchiveItemProp(archive, index, kpidIsFolder, result);
+ return IsArchiveItemProp(archive, index, kpidIsDir, result);
}
HRESULT IsArchiveItemAnti(IInArchive *archive, UInt32 index, bool &result)
@@ -112,9 +112,10 @@ static inline bool TestSignature(const Byte *p1, const Byte *p2, size_t size)
HRESULT OpenArchive(
CCodecs *codecs,
+ int arcTypeIndex,
IInStream *inStream,
- const UString &fileName,
- IInArchive **archiveResult,
+ const UString &fileName,
+ IInArchive **archiveResult,
int &formatIndex,
UString &defaultItemName,
IArchiveOpenCallback *openArchiveCallback)
@@ -127,6 +128,11 @@ HRESULT OpenArchive(
extension = fileName.Mid(dotPos + 1);
}
CIntVector orderIndices;
+ if (arcTypeIndex >= 0)
+ orderIndices.Add(arcTypeIndex);
+ else
+ {
+
int i;
int numFinded = 0;
for (i = 0; i < codecs->Formats.Size(); i++)
@@ -140,32 +146,84 @@ HRESULT OpenArchive(
{
CIntVector orderIndices2;
CByteBuffer byteBuffer;
- const size_t kBufferSize = (200 << 10);
+ const size_t kBufferSize = (1 << 21);
byteBuffer.SetCapacity(kBufferSize);
- Byte *buffer = byteBuffer;
RINOK(inStream->Seek(0, STREAM_SEEK_SET, NULL));
size_t processedSize = kBufferSize;
- RINOK(ReadStream(inStream, buffer, &processedSize));
+ RINOK(ReadStream(inStream, byteBuffer, &processedSize));
+ if (processedSize == 0)
+ return S_FALSE;
+
+ const Byte *buf = byteBuffer;
+ Byte hash[1 << 16];
+ memset(hash, 0xFF, 1 << 16);
+ Byte prevs[256];
+ if (orderIndices.Size() > 255)
+ return S_FALSE;
+ int i;
+ for (i = 0; i < orderIndices.Size(); i++)
+ {
+ const CArcInfoEx &ai = codecs->Formats[orderIndices[i]];
+ const CByteBuffer &sig = ai.StartSignature;
+ if (sig.GetCapacity() < 2)
+ continue;
+ UInt32 v = sig[0] | ((UInt32)sig[1] << 8);
+ prevs[i] = hash[v];
+ hash[v] = (Byte)i;
+ }
+
+ processedSize--;
for (UInt32 pos = 0; pos < processedSize; pos++)
{
- for (int i = 0; i < orderIndices.Size(); i++)
+ for (; hash[buf[pos] | ((UInt32)buf[pos + 1] << 8)] == 0xFF && pos < processedSize; pos++);
+ if (pos == processedSize)
+ break;
+ UInt32 v = buf[pos] | ((UInt32)buf[pos + 1] << 8);
+ Byte *ptr = &hash[v];
+ int i = *ptr;
+ do
{
int index = orderIndices[i];
const CArcInfoEx &ai = codecs->Formats[index];
const CByteBuffer &sig = ai.StartSignature;
- if (sig.GetCapacity() == 0)
- continue;
- if (pos + sig.GetCapacity() > processedSize)
- continue;
- if (TestSignature(buffer + pos, sig, sig.GetCapacity()))
- {
- orderIndices2.Add(index);
- orderIndices.Delete(i--);
- }
+ if (sig.GetCapacity() != 0 && pos + sig.GetCapacity() <= processedSize + 1)
+ if (TestSignature(buf + pos, sig, sig.GetCapacity()))
+ {
+ orderIndices2.Add(index);
+ orderIndices[i] = 0xFF;
+ *ptr = prevs[i];
+ }
+ ptr = &prevs[i];
+ i = *ptr;
}
+ while (i != 0xFF);
+ }
+
+ for (i = 0; i < orderIndices.Size(); i++)
+ {
+ int val = orderIndices[i];
+ if (val != 0xFF)
+ orderIndices2.Add(val);
}
- orderIndices2 += orderIndices;
orderIndices = orderIndices2;
+
+ if (orderIndices.Size() >= 2)
+ {
+ int isoIndex = codecs->FindFormatForArchiveType(L"iso");
+ int udfIndex = codecs->FindFormatForArchiveType(L"udf");
+ int iIso = -1;
+ int iUdf = -1;
+ for (int i = 0; i < orderIndices.Size(); i++)
+ {
+ if (orderIndices[i] == isoIndex) iIso = i;
+ if (orderIndices[i] == udfIndex) iUdf = i;
+ }
+ if (iUdf == iIso + 1)
+ {
+ orderIndices[iUdf] = isoIndex;
+ orderIndices[iIso] = udfIndex;
+ }
+ }
}
else if (extension == L"000" || extension == L"001")
{
@@ -195,9 +253,9 @@ HRESULT OpenArchive(
}
}
#endif
+ }
- HRESULT badResult = S_OK;
- for(i = 0; i < orderIndices.Size(); i++)
+ for(int i = 0; i < orderIndices.Size(); i++)
{
inStream->Seek(0, STREAM_SEEK_SET, NULL);
@@ -222,13 +280,7 @@ HRESULT OpenArchive(
HRESULT result = archive->Open(inStream, &kMaxCheckStartPosition, openArchiveCallback);
if (result == S_FALSE)
continue;
- if(result != S_OK)
- {
- badResult = result;
- if(result == E_ABORT)
- break;
- continue;
- }
+ RINOK(result);
*archiveResult = archive.Detach();
const CArcInfoEx &format = codecs->Formats[formatIndex];
if (format.Exts.Size() == 0)
@@ -240,21 +292,20 @@ HRESULT OpenArchive(
int subExtIndex = format.FindExtension(extension);
if (subExtIndex < 0)
subExtIndex = 0;
- defaultItemName = GetDefaultName2(fileName,
- format.Exts[subExtIndex].Ext,
+ defaultItemName = GetDefaultName2(fileName,
+ format.Exts[subExtIndex].Ext,
format.Exts[subExtIndex].AddExt);
}
return S_OK;
}
- if (badResult != S_OK)
- return badResult;
return S_FALSE;
}
HRESULT OpenArchive(
CCodecs *codecs,
- const UString &filePath,
- IInArchive **archiveResult,
+ int arcTypeIndex,
+ const UString &filePath,
+ IInArchive **archiveResult,
int &formatIndex,
UString &defaultItemName,
IArchiveOpenCallback *openArchiveCallback)
@@ -263,7 +314,7 @@ HRESULT OpenArchive(
CMyComPtr<IInStream> inStream(inStreamSpec);
if (!inStreamSpec->Open(filePath))
return GetLastError();
- return OpenArchive(codecs, inStream, ExtractFileNameFromPath(filePath),
+ return OpenArchive(codecs, arcTypeIndex, inStream, ExtractFileNameFromPath(filePath),
archiveResult, formatIndex,
defaultItemName, openArchiveCallback);
}
@@ -284,38 +335,54 @@ static void MakeDefaultName(UString &name)
HRESULT OpenArchive(
CCodecs *codecs,
- const UString &fileName,
- IInArchive **archive0,
- IInArchive **archive1,
+ const CIntVector &formatIndices,
+ const UString &fileName,
+ IInArchive **archive0,
+ IInArchive **archive1,
int &formatIndex0,
int &formatIndex1,
UString &defaultItemName0,
UString &defaultItemName1,
IArchiveOpenCallback *openArchiveCallback)
{
- HRESULT result = OpenArchive(codecs, fileName,
- archive0, formatIndex0, defaultItemName0, openArchiveCallback);
+ if (formatIndices.Size() >= 3)
+ return E_NOTIMPL;
+
+ int arcTypeIndex = -1;
+ if (formatIndices.Size() >= 1)
+ arcTypeIndex = formatIndices[formatIndices.Size() - 1];
+
+ HRESULT result = OpenArchive(codecs, arcTypeIndex, fileName,
+ archive0, formatIndex0, defaultItemName0, openArchiveCallback);
RINOK(result);
+
+ if (formatIndices.Size() == 1)
+ return S_OK;
+ arcTypeIndex = -1;
+ if (formatIndices.Size() >= 2)
+ arcTypeIndex = formatIndices[formatIndices.Size() - 2];
+
+ HRESULT resSpec = (formatIndices.Size() == 0 ? S_OK : E_NOTIMPL);
+
CMyComPtr<IInArchiveGetStream> getStream;
result = (*archive0)->QueryInterface(IID_IInArchiveGetStream, (void **)&getStream);
- if (result != S_OK || getStream == 0)
- return S_OK;
+ if (result != S_OK || !getStream)
+ return resSpec;
CMyComPtr<ISequentialInStream> subSeqStream;
result = getStream->GetStream(0, &subSeqStream);
- if (result != S_OK)
- return S_OK;
+ if (result != S_OK || !subSeqStream)
+ return resSpec;
CMyComPtr<IInStream> subStream;
- if (subSeqStream.QueryInterface(IID_IInStream, &subStream) != S_OK)
- return S_OK;
- if (!subStream)
- return S_OK;
+ result = subSeqStream.QueryInterface(IID_IInStream, &subStream);
+ if (result != S_OK || !subStream)
+ return resSpec;
UInt32 numItems;
RINOK((*archive0)->GetNumberOfItems(&numItems));
if (numItems < 1)
- return S_OK;
+ return resSpec;
UString subPath;
RINOK(GetArchiveItemPath(*archive0, 0, subPath))
@@ -338,39 +405,47 @@ HRESULT OpenArchive(
if (setSubArchiveName)
setSubArchiveName->SetSubArchiveName(subPath);
- result = OpenArchive(codecs, subStream, subPath,
+ result = OpenArchive(codecs, arcTypeIndex, subStream, subPath,
archive1, formatIndex1, defaultItemName1, openArchiveCallback);
+ resSpec = (formatIndices.Size() == 0 ? S_OK : S_FALSE);
+ if (result != S_OK)
+ return resSpec;
return S_OK;
}
static void SetCallback(const UString &archiveName,
- IOpenCallbackUI *openCallbackUI, CMyComPtr<IArchiveOpenCallback> &openCallback)
+ IOpenCallbackUI *openCallbackUI,
+ IArchiveOpenCallback *reOpenCallback,
+ CMyComPtr<IArchiveOpenCallback> &openCallback)
{
COpenCallbackImp *openCallbackSpec = new COpenCallbackImp;
openCallback = openCallbackSpec;
openCallbackSpec->Callback = openCallbackUI;
+ openCallbackSpec->ReOpenCallback = reOpenCallback;
UString fullName;
int fileNamePartStartIndex;
NFile::NDirectory::MyGetFullPathName(archiveName, fullName, fileNamePartStartIndex);
openCallbackSpec->Init(
- fullName.Left(fileNamePartStartIndex),
+ fullName.Left(fileNamePartStartIndex),
fullName.Mid(fileNamePartStartIndex));
}
HRESULT MyOpenArchive(
- CCodecs *codecs,
+ CCodecs *codecs,
+ int arcTypeIndex,
const UString &archiveName,
IInArchive **archive, UString &defaultItemName, IOpenCallbackUI *openCallbackUI)
{
CMyComPtr<IArchiveOpenCallback> openCallback;
- SetCallback(archiveName, openCallbackUI, openCallback);
+ SetCallback(archiveName, openCallbackUI, NULL, openCallback);
int formatInfo;
- return OpenArchive(codecs, archiveName, archive, formatInfo, defaultItemName, openCallback);
+ return OpenArchive(codecs, arcTypeIndex, archiveName, archive, formatInfo, defaultItemName, openCallback);
}
HRESULT MyOpenArchive(
CCodecs *codecs,
+ const CIntVector &formatIndices,
const UString &archiveName,
IInArchive **archive0,
IInArchive **archive1,
@@ -393,11 +468,11 @@ HRESULT MyOpenArchive(
openCallbackSpec->Init(prefix, name);
int formatIndex0, formatIndex1;
- RINOK(OpenArchive(codecs, archiveName,
- archive0,
- archive1,
- formatIndex0,
- formatIndex1,
+ RINOK(OpenArchive(codecs, formatIndices, archiveName,
+ archive0,
+ archive1,
+ formatIndex0,
+ formatIndex1,
defaultItemName0,
defaultItemName1,
openCallback));
@@ -427,27 +502,29 @@ void CArchiveLink::Release()
HRESULT OpenArchive(
CCodecs *codecs,
+ const CIntVector &formatIndices,
const UString &archiveName,
CArchiveLink &archiveLink,
IArchiveOpenCallback *openCallback)
{
- HRESULT res = OpenArchive(codecs, archiveName,
- &archiveLink.Archive0, &archiveLink.Archive1,
- archiveLink.FormatIndex0, archiveLink.FormatIndex1,
- archiveLink.DefaultItemName0, archiveLink.DefaultItemName1,
+ HRESULT res = OpenArchive(codecs, formatIndices, archiveName,
+ &archiveLink.Archive0, &archiveLink.Archive1,
+ archiveLink.FormatIndex0, archiveLink.FormatIndex1,
+ archiveLink.DefaultItemName0, archiveLink.DefaultItemName1,
openCallback);
archiveLink.IsOpen = (res == S_OK);
return res;
}
HRESULT MyOpenArchive(CCodecs *codecs,
- const UString &archiveName,
+ const CIntVector &formatIndices,
+ const UString &archiveName,
CArchiveLink &archiveLink,
IOpenCallbackUI *openCallbackUI)
{
- HRESULT res = MyOpenArchive(codecs, archiveName,
- &archiveLink.Archive0, &archiveLink.Archive1,
- archiveLink.DefaultItemName0, archiveLink.DefaultItemName1,
+ HRESULT res = MyOpenArchive(codecs, formatIndices, archiveName,
+ &archiveLink.Archive0, &archiveLink.Archive1,
+ archiveLink.DefaultItemName0, archiveLink.DefaultItemName1,
archiveLink.VolumePaths,
archiveLink.VolumesSize,
openCallbackUI);
@@ -455,18 +532,19 @@ HRESULT MyOpenArchive(CCodecs *codecs,
return res;
}
-HRESULT ReOpenArchive(CCodecs *codecs, CArchiveLink &archiveLink, const UString &fileName)
+HRESULT ReOpenArchive(CCodecs *codecs, CArchiveLink &archiveLink, const UString &fileName,
+ IArchiveOpenCallback *openCallback)
{
if (archiveLink.GetNumLevels() > 1)
return E_NOTIMPL;
if (archiveLink.GetNumLevels() == 0)
- return MyOpenArchive(codecs, fileName, archiveLink, 0);
+ return MyOpenArchive(codecs, CIntVector(), fileName, archiveLink, 0);
- CMyComPtr<IArchiveOpenCallback> openCallback;
- SetCallback(fileName, NULL, openCallback);
+ CMyComPtr<IArchiveOpenCallback> openCallbackNew;
+ SetCallback(fileName, NULL, openCallback, openCallbackNew);
- HRESULT res = ReOpenArchive(archiveLink.GetArchive(), fileName, openCallback);
+ HRESULT res = ReOpenArchive(archiveLink.GetArchive(), fileName, openCallbackNew);
archiveLink.IsOpen = (res == S_OK);
return res;
}
diff --git a/CPP/7zip/UI/Common/OpenArchive.h b/CPP/7zip/UI/Common/OpenArchive.h
index 7b424463..f1b4fda7 100755
--- a/CPP/7zip/UI/Common/OpenArchive.h
+++ b/CPP/7zip/UI/Common/OpenArchive.h
@@ -12,7 +12,7 @@
HRESULT GetArchiveItemPath(IInArchive *archive, UInt32 index, UString &result);
HRESULT GetArchiveItemPath(IInArchive *archive, UInt32 index, const UString &defaultName, UString &result);
-HRESULT GetArchiveItemFileTime(IInArchive *archive, UInt32 index,
+HRESULT GetArchiveItemFileTime(IInArchive *archive, UInt32 index,
const FILETIME &defaultFileTime, FILETIME &fileTime);
HRESULT IsArchiveItemProp(IInArchive *archive, UInt32 index, PROPID propID, bool &result);
HRESULT IsArchiveItemFolder(IInArchive *archive, UInt32 index, bool &result);
@@ -25,26 +25,29 @@ struct ISetSubArchiveName
HRESULT OpenArchive(
CCodecs *codecs,
+ int arcTypeIndex,
IInStream *inStream,
- const UString &fileName,
- IInArchive **archiveResult,
+ const UString &fileName,
+ IInArchive **archiveResult,
int &formatIndex,
UString &defaultItemName,
IArchiveOpenCallback *openArchiveCallback);
HRESULT OpenArchive(
CCodecs *codecs,
- const UString &filePath,
- IInArchive **archive,
+ int arcTypeIndex,
+ const UString &filePath,
+ IInArchive **archive,
int &formatIndex,
UString &defaultItemName,
IArchiveOpenCallback *openArchiveCallback);
HRESULT OpenArchive(
CCodecs *codecs,
- const UString &filePath,
- IInArchive **archive0,
- IInArchive **archive1,
+ const CIntVector &formatIndices,
+ const UString &filePath,
+ IInArchive **archive0,
+ IInArchive **archive1,
int &formatIndex0,
int &formatIndex1,
UString &defaultItemName0,
@@ -54,24 +57,6 @@ HRESULT OpenArchive(
HRESULT ReOpenArchive(IInArchive *archive, const UString &fileName, IArchiveOpenCallback *openArchiveCallback);
-HRESULT MyOpenArchive(
- CCodecs *codecs,
- const UString &archiveName,
- IInArchive **archive,
- UString &defaultItemName,
- IOpenCallbackUI *openCallbackUI);
-
-HRESULT MyOpenArchive(
- CCodecs *codecs,
- const UString &archiveName,
- IInArchive **archive0,
- IInArchive **archive1,
- UString &defaultItemName0,
- UString &defaultItemName1,
- UStringVector &volumePaths,
- UInt64 &volumesSize,
- IOpenCallbackUI *openCallbackUI);
-
struct CArchiveLink
{
CMyComPtr<IInArchive> Archive0;
@@ -84,10 +69,11 @@ struct CArchiveLink
UStringVector VolumePaths;
+ bool IsOpen;
UInt64 VolumesSize;
int GetNumLevels() const
- {
+ {
int result = 0;
if (Archive0)
{
@@ -98,8 +84,6 @@ struct CArchiveLink
return result;
}
- bool IsOpen;
-
CArchiveLink(): IsOpen(false), VolumesSize(0) {};
IInArchive *GetArchive() { return Archive1 != 0 ? Archive1: Archive0; }
@@ -111,20 +95,23 @@ struct CArchiveLink
HRESULT OpenArchive(
CCodecs *codecs,
- const UString &archiveName,
+ const CIntVector &formatIndices,
+ const UString &archiveName,
CArchiveLink &archiveLink,
IArchiveOpenCallback *openCallback);
HRESULT MyOpenArchive(
CCodecs *codecs,
- const UString &archiveName,
+ const CIntVector &formatIndices,
+ const UString &archiveName,
CArchiveLink &archiveLink,
IOpenCallbackUI *openCallbackUI);
HRESULT ReOpenArchive(
CCodecs *codecs,
- CArchiveLink &archiveLink,
- const UString &fileName);
+ CArchiveLink &archiveLink,
+ const UString &fileName,
+ IArchiveOpenCallback *openCallback);
#endif
diff --git a/CPP/7zip/UI/Common/PropIDUtils.cpp b/CPP/7zip/UI/Common/PropIDUtils.cpp
index 76596883..bf11ea15 100755
--- a/CPP/7zip/UI/Common/PropIDUtils.cpp
+++ b/CPP/7zip/UI/Common/PropIDUtils.cpp
@@ -36,14 +36,14 @@ UString ConvertPropertyToString(const PROPVARIANT &propVariant, PROPID propID, b
{
switch(propID)
{
- case kpidCreationTime:
- case kpidLastWriteTime:
- case kpidLastAccessTime:
+ case kpidCTime:
+ case kpidATime:
+ case kpidMTime:
{
if (propVariant.vt != VT_FILETIME)
return UString(); // It is error;
FILETIME localFileTime;
- if (propVariant.filetime.dwHighDateTime == 0 &&
+ if (propVariant.filetime.dwHighDateTime == 0 &&
propVariant.filetime.dwLowDateTime == 0)
return UString();
if (!::FileTimeToLocalFileTime(&propVariant.filetime, &localFileTime))
@@ -58,7 +58,7 @@ UString ConvertPropertyToString(const PROPVARIANT &propVariant, PROPID propID, b
ConvertUInt32ToHex(propVariant.ulVal, temp);
return temp;
}
- case kpidAttributes:
+ case kpidAttrib:
{
if(propVariant.vt != VT_UI4)
break;
@@ -67,7 +67,7 @@ UString ConvertPropertyToString(const PROPVARIANT &propVariant, PROPID propID, b
if (NFile::NFind::NAttributes::IsReadOnly(attributes)) result += L'R';
if (NFile::NFind::NAttributes::IsHidden(attributes)) result += L'H';
if (NFile::NFind::NAttributes::IsSystem(attributes)) result += L'S';
- if (NFile::NFind::NAttributes::IsDirectory(attributes)) result += L'D';
+ if (NFile::NFind::NAttributes::IsDir(attributes)) result += L'D';
if (NFile::NFind::NAttributes::IsArchived(attributes)) result += L'A';
if (NFile::NFind::NAttributes::IsCompressed(attributes)) result += L'C';
if (NFile::NFind::NAttributes::IsEncrypted(attributes)) result += L'E';
diff --git a/CPP/7zip/UI/Common/SetProperties.cpp b/CPP/7zip/UI/Common/SetProperties.cpp
index 201e95b5..4827f2a7 100755
--- a/CPP/7zip/UI/Common/SetProperties.cpp
+++ b/CPP/7zip/UI/Common/SetProperties.cpp
@@ -22,7 +22,7 @@ static void ParseNumberString(const UString &s, NCOM::CPropVariant &prop)
prop = s;
else if (result <= 0xFFFFFFFF)
prop = (UInt32)result;
- else
+ else
prop = result;
}
diff --git a/CPP/7zip/UI/Common/StdAfx.h b/CPP/7zip/UI/Common/StdAfx.h
index 100f4344..9a8e7d21 100755
--- a/CPP/7zip/UI/Common/StdAfx.h
+++ b/CPP/7zip/UI/Common/StdAfx.h
@@ -6,4 +6,4 @@
#include "../../../Common/MyWindows.h"
#include "../../../Common/NewHandler.h"
-#endif
+#endif
diff --git a/CPP/7zip/UI/Common/Update.cpp b/CPP/7zip/UI/Common/Update.cpp
index 8e879246..f2207557 100755
--- a/CPP/7zip/UI/Common/Update.cpp
+++ b/CPP/7zip/UI/Common/Update.cpp
@@ -6,37 +6,34 @@
#include "Common/IntToString.h"
#include "Common/StringConvert.h"
-#include "Common/CommandLineParser.h"
#ifdef _WIN32
#include "Windows/DLL.h"
#endif
-#include "Windows/Defs.h"
#include "Windows/FileDir.h"
#include "Windows/FileFind.h"
#include "Windows/FileName.h"
#include "Windows/PropVariant.h"
#include "Windows/PropVariantConversions.h"
-// #include "Windows/Synchronization.h"
+#include "Windows/Time.h"
#include "../../Common/FileStreams.h"
#include "../../Compress/Copy/CopyCoder.h"
#include "../Common/DirItem.h"
#include "../Common/EnumDirItems.h"
-#include "../Common/UpdateProduce.h"
#include "../Common/OpenArchive.h"
+#include "../Common/UpdateProduce.h"
-#include "TempFiles.h"
-#include "UpdateCallback.h"
#include "EnumDirItems.h"
#include "SetProperties.h"
+#include "TempFiles.h"
+#include "UpdateCallback.h"
-static const char *kUpdateIsNotSupoorted =
+static const char *kUpdateIsNotSupoorted =
"update operations are not supported for this archive";
-using namespace NCommandLineParser;
using namespace NWindows;
using namespace NCOM;
using namespace NFile;
@@ -52,7 +49,7 @@ static HRESULT CopyBlock(ISequentialInStream *inStream, ISequentialOutStream *ou
return copyCoder->Code(inStream, outStream, NULL, NULL, NULL);
}
-class COutMultiVolStream:
+class COutMultiVolStream:
public IOutStream,
public CMyUnknownImp
{
@@ -84,7 +81,7 @@ public:
_length = 0;
}
- HRESULT Close();
+ HRESULT Close();
MY_UNKNOWN_IMP1(IOutStream)
@@ -251,10 +248,15 @@ static const wchar_t *kSFXExtension =
L"";
#endif
-bool CUpdateOptions::Init(const CCodecs *codecs, const UString &arcPath, const UString &arcType)
+bool CUpdateOptions::Init(const CCodecs *codecs, const CIntVector &formatIndices, const UString &arcPath)
{
- if (!arcType.IsEmpty())
- MethodMode.FormatIndex = codecs->FindFormatForArchiveType(arcType);
+ if (formatIndices.Size() > 1)
+ return false;
+ int arcTypeIndex = -1;
+ if (formatIndices.Size() != 0)
+ arcTypeIndex = formatIndices[0];
+ if (arcTypeIndex >= 0)
+ MethodMode.FormatIndex = arcTypeIndex;
else
{
MethodMode.FormatIndex = codecs->FindFormatForArchiveName(arcPath);
@@ -264,6 +266,8 @@ bool CUpdateOptions::Init(const CCodecs *codecs, const UString &arcPath, const U
if (MethodMode.FormatIndex < 0)
return false;
const CArcInfoEx &arcInfo = codecs->Formats[MethodMode.FormatIndex];
+ if (!arcInfo.UpdateEnabled)
+ return false;
UString typeExt = arcInfo.GetMainExt();
UString ext = typeExt;
if (SfxMode)
@@ -284,16 +288,16 @@ bool CUpdateOptions::Init(const CCodecs *codecs, const UString &arcPath, const U
static HRESULT Compress(
CCodecs *codecs,
- const CActionSet &actionSet,
+ const CActionSet &actionSet,
IInArchive *archive,
const CCompressionMethodMode &compressionMethod,
- CArchivePath &archivePath,
- const CObjectVector<CArchiveItem> &archiveItems,
+ CArchivePath &archivePath,
+ const CObjectVector<CArcItem> &arcItems,
bool shareForWrite,
bool stdInMode,
/* const UString & stdInFileName, */
bool stdOutMode,
- const CObjectVector<CDirItem> &dirItems,
+ const CDirItems &dirItems,
bool sfxMode,
const UString &sfxModule,
const CRecordVector<UInt64> &volumesSizes,
@@ -342,11 +346,13 @@ static HRESULT Compress(
return E_FAIL;
}
- CObjectVector<CUpdatePair> updatePairs;
- GetUpdatePairInfoList(dirItems, archiveItems, fileTimeType, updatePairs); // must be done only once!!!
-
- CObjectVector<CUpdatePair2> updatePairs2;
- UpdateProduce(updatePairs, actionSet, updatePairs2);
+ CRecordVector<CUpdatePair2> updatePairs2;
+
+ {
+ CRecordVector<CUpdatePair> updatePairs;
+ GetUpdatePairInfoList(dirItems, arcItems, fileTimeType, updatePairs); // must be done only once!!!
+ UpdateProduce(updatePairs, actionSet, updatePairs2);
+ }
UInt32 numFiles = 0;
for (int i = 0; i < updatePairs2.Size(); i++)
@@ -363,7 +369,7 @@ static HRESULT Compress(
updateCallbackSpec->StdInMode = stdInMode;
updateCallbackSpec->Callback = callback;
updateCallbackSpec->DirItems = &dirItems;
- updateCallbackSpec->ArchiveItems = &archiveItems;
+ updateCallbackSpec->ArcItems = &arcItems;
updateCallbackSpec->UpdatePairs = &updatePairs2;
CMyComPtr<ISequentialOutStream> outStream;
@@ -496,27 +502,26 @@ HRESULT EnumerateInArchiveItems(const NWildcard::CCensor &censor,
IInArchive *archive,
const UString &defaultItemName,
const NWindows::NFile::NFind::CFileInfoW &archiveFileInfo,
- CObjectVector<CArchiveItem> &archiveItems)
+ CObjectVector<CArcItem> &arcItems)
{
- archiveItems.Clear();
+ arcItems.Clear();
UInt32 numItems;
RINOK(archive->GetNumberOfItems(&numItems));
- archiveItems.Reserve(numItems);
- for(UInt32 i = 0; i < numItems; i++)
+ arcItems.Reserve(numItems);
+ for (UInt32 i = 0; i < numItems; i++)
{
- CArchiveItem ai;
+ CArcItem ai;
RINOK(GetArchiveItemPath(archive, i, ai.Name));
- RINOK(IsArchiveItemFolder(archive, i, ai.IsDirectory));
- ai.Censored = censor.CheckPath(ai.Name.IsEmpty() ? defaultItemName : ai.Name, !ai.IsDirectory);
- RINOK(GetArchiveItemFileTime(archive, i,
- archiveFileInfo.LastWriteTime, ai.LastWriteTime));
+ RINOK(IsArchiveItemFolder(archive, i, ai.IsDir));
+ ai.Censored = censor.CheckPath(ai.Name.IsEmpty() ? defaultItemName : ai.Name, !ai.IsDir);
+ RINOK(GetArchiveItemFileTime(archive, i, archiveFileInfo.MTime, ai.MTime));
{
CPropVariant prop;
RINOK(archive->GetProperty(i, kpidSize, &prop));
- ai.SizeIsDefined = (prop.vt != VT_EMPTY);
- if (ai.SizeIsDefined)
+ ai.SizeDefined = (prop.vt != VT_EMPTY);
+ if (ai.SizeDefined)
ai.Size = ConvertPropVariantToUInt64(prop);
}
@@ -525,8 +530,8 @@ HRESULT EnumerateInArchiveItems(const NWildcard::CCensor &censor,
RINOK(archive->GetProperty(i, kpidTimeType, &prop));
if (prop.vt == VT_UI4)
{
- ai.FileTimeType = (int)(NFileTimeType::EEnum)prop.ulVal;
- switch(ai.FileTimeType)
+ ai.TimeType = (int)(NFileTimeType::EEnum)prop.ulVal;
+ switch(ai.TimeType)
{
case NFileTimeType::kWindows:
case NFileTimeType::kUnix:
@@ -539,7 +544,7 @@ HRESULT EnumerateInArchiveItems(const NWildcard::CCensor &censor,
}
ai.IndexInServer = i;
- archiveItems.Add(ai);
+ arcItems.Add(ai);
}
return S_OK;
}
@@ -548,9 +553,9 @@ HRESULT EnumerateInArchiveItems(const NWildcard::CCensor &censor,
static HRESULT UpdateWithItemLists(
CCodecs *codecs,
CUpdateOptions &options,
- IInArchive *archive,
- const CObjectVector<CArchiveItem> &archiveItems,
- const CObjectVector<CDirItem> &dirItems,
+ IInArchive *archive,
+ const CObjectVector<CArcItem> &arcItems,
+ CDirItems &dirItems,
CTempFiles &tempFiles,
CUpdateErrorInfo &errorInfo,
IUpdateCallbackUI2 *callback)
@@ -564,22 +569,22 @@ static HRESULT UpdateWithItemLists(
}
else
{
- RINOK(callback->StartArchive(command.ArchivePath.GetFinalPath(),
+ RINOK(callback->StartArchive(command.ArchivePath.GetFinalPath(),
i == 0 && options.UpdateArchiveItself && archive != 0));
}
RINOK(Compress(
codecs,
command.ActionSet, archive,
- options.MethodMode,
- command.ArchivePath,
- archiveItems,
+ options.MethodMode,
+ command.ArchivePath,
+ arcItems,
options.OpenShareForWrite,
- options.StdInMode,
+ options.StdInMode,
/* options.StdInFileName, */
options.StdOutMode,
- dirItems,
- options.SfxMode, options.SfxModule,
+ dirItems,
+ options.SfxMode, options.SfxModule,
options.VolumesSizes,
tempFiles,
errorInfo, callback));
@@ -606,7 +611,10 @@ public:
struct CEnumDirItemUpdateCallback: public IEnumDirItemCallback
{
IUpdateCallbackUI2 *Callback;
- HRESULT CheckBreak() { return Callback->CheckBreak(); }
+ HRESULT ScanProgress(UInt64 numFolders, UInt64 numFiles, const wchar_t *path)
+ {
+ return Callback->ScanProgress(numFolders, numFiles, path);
+ }
};
#ifdef _WIN32
@@ -622,7 +630,7 @@ typedef MY_MAPISENDDOCUMENTS FAR *MY_LPMAPISENDDOCUMENTS;
HRESULT UpdateArchive(
CCodecs *codecs,
- const NWildcard::CCensor &censor,
+ const NWildcard::CCensor &censor,
CUpdateOptions &options,
CUpdateErrorInfo &errorInfo,
IOpenCallbackUI *openCallback,
@@ -662,11 +670,16 @@ HRESULT UpdateArchive(
IInArchive *archive = 0;
if (NFind::FindFile(archiveName, archiveFileInfo))
{
- if (archiveFileInfo.IsDirectory())
+ if (archiveFileInfo.IsDir())
throw "there is no such archive";
if (options.VolumesSizes.Size() > 0)
return E_NOTIMPL;
- HRESULT result = MyOpenArchive(codecs, archiveName, archiveLink, openCallback);
+ CIntVector formatIndices;
+ if (options.MethodMode.FormatIndex >= 0)
+ formatIndices.Add(options.MethodMode.FormatIndex);
+ HRESULT result = MyOpenArchive(codecs, formatIndices, archiveName, archiveLink, openCallback);
+ if (result == E_ABORT)
+ return result;
RINOK(callback->OpenResult(archiveName, result));
RINOK(result);
if (archiveLink.VolumePaths.Size() > 1)
@@ -686,19 +699,16 @@ HRESULT UpdateArchive(
*/
}
- CObjectVector<CDirItem> dirItems;
+ CDirItems dirItems;
if (options.StdInMode)
{
- CDirItem item;
- item.FullPath = item.Name = options.StdInFileName;
- item.Size = (UInt64)(Int64)-1;
- item.Attributes = 0;
- SYSTEMTIME st;
- FILETIME ft;
- GetSystemTime(&st);
- SystemTimeToFileTime(&st, &ft);
- item.CreationTime = item.LastAccessTime = item.LastWriteTime = ft;
- dirItems.Add(item);
+ CDirItem di;
+ di.Name = options.StdInFileName;
+ di.Size = (UInt64)(Int64)-1;
+ di.Attrib = 0;
+ NTime::GetCurUtcFileTime(di.MTime);
+ di.CTime = di.ATime = di.MTime;
+ dirItems.Items.Add(di);
}
else
{
@@ -718,9 +728,10 @@ HRESULT UpdateArchive(
{
RINOK(callback->CanNotFindError(errorPaths[i], errorCodes[i]));
}
- if(res != S_OK)
+ if (res != S_OK)
{
- errorInfo.Message = L"Scanning error";
+ if (res != E_ABORT)
+ errorInfo.Message = L"Scanning error";
// errorInfo.FileName = errorPath;
return res;
}
@@ -785,14 +796,14 @@ HRESULT UpdateArchive(
}
}
- CObjectVector<CArchiveItem> archiveItems;
+ CObjectVector<CArcItem> arcItems;
if (archive != NULL)
{
- RINOK(EnumerateInArchiveItems(censor,
- archive, defaultItemName, archiveFileInfo, archiveItems));
+ RINOK(EnumerateInArchiveItems(censor,
+ archive, defaultItemName, archiveFileInfo, arcItems));
}
- RINOK(UpdateWithItemLists(codecs, options, archive, archiveItems, dirItems,
+ RINOK(UpdateWithItemLists(codecs, options, archive, arcItems, dirItems,
tempFiles, errorInfo, callback));
if (archive != NULL)
@@ -870,7 +881,7 @@ HRESULT UpdateArchive(
AString path = GetAnsiString(arcPath);
AString name = GetAnsiString(fileName);
// Warning!!! MAPISendDocuments function changes Current directory
- fnSend(0, ";", (LPSTR)(LPCSTR)path, (LPSTR)(LPCSTR)name, 0);
+ fnSend(0, ";", (LPSTR)(LPCSTR)path, (LPSTR)(LPCSTR)name, 0);
}
}
#endif
diff --git a/CPP/7zip/UI/Common/Update.h b/CPP/7zip/UI/Common/Update.h
index 49e4be81..46547bf9 100755
--- a/CPP/7zip/UI/Common/Update.h
+++ b/CPP/7zip/UI/Common/Update.h
@@ -17,7 +17,7 @@ struct CArchivePath
{
UString Prefix; // path(folder) prefix including slash
UString Name; // base name
- UString BaseExtension; // archive type extension or "exe" extension
+ UString BaseExtension; // archive type extension or "exe" extension
UString VolExtension; // archive type extension for volumes
bool Temp;
@@ -70,7 +70,7 @@ struct CArchivePath
path += UString(L'.') + BaseExtension;
path += L".tmp";
path += TempPostfix;
- return path;
+ return path;
}
};
@@ -111,7 +111,7 @@ struct CUpdateOptions
UString WorkingDir;
- bool Init(const CCodecs *codecs, const UString &arcPath, const UString &arcType);
+ bool Init(const CCodecs *codecs, const CIntVector &formatIndices, const UString &arcPath);
CUpdateOptions():
UpdateArchiveItself(true),
@@ -144,6 +144,7 @@ struct CUpdateErrorInfo: public CErrorInfo
INTERFACE_IUpdateCallbackUI(x) \
virtual HRESULT OpenResult(const wchar_t *name, HRESULT result) x; \
virtual HRESULT StartScanning() x; \
+ virtual HRESULT ScanProgress(UInt64 numFolders, UInt64 numFiles, const wchar_t *path) x; \
virtual HRESULT CanNotFindError(const wchar_t *name, DWORD systemError) x; \
virtual HRESULT FinishScanning() x; \
virtual HRESULT StartArchive(const wchar_t *name, bool updating) x; \
@@ -156,7 +157,7 @@ struct IUpdateCallbackUI2: public IUpdateCallbackUI
HRESULT UpdateArchive(
CCodecs *codecs,
- const NWildcard::CCensor &censor,
+ const NWildcard::CCensor &censor,
CUpdateOptions &options,
CUpdateErrorInfo &errorInfo,
IOpenCallbackUI *openCallback,
diff --git a/CPP/7zip/UI/Common/UpdateAction.cpp b/CPP/7zip/UI/Common/UpdateAction.cpp
index 5e3b5a10..845384fb 100755
--- a/CPP/7zip/UI/Common/UpdateAction.cpp
+++ b/CPP/7zip/UI/Common/UpdateAction.cpp
@@ -6,7 +6,7 @@
namespace NUpdateArchive {
-const CActionSet kAddActionSet =
+const CActionSet kAddActionSet =
{
NPairAction::kCopy,
NPairAction::kCopy,
@@ -17,7 +17,7 @@ const CActionSet kAddActionSet =
NPairAction::kCompress
};
-const CActionSet kUpdateActionSet =
+const CActionSet kUpdateActionSet =
{
NPairAction::kCopy,
NPairAction::kCopy,
@@ -28,7 +28,7 @@ const CActionSet kUpdateActionSet =
NPairAction::kCompress
};
-const CActionSet kFreshActionSet =
+const CActionSet kFreshActionSet =
{
NPairAction::kCopy,
NPairAction::kCopy,
@@ -39,7 +39,7 @@ const CActionSet kFreshActionSet =
NPairAction::kCompress
};
-const CActionSet kSynchronizeActionSet =
+const CActionSet kSynchronizeActionSet =
{
NPairAction::kCopy,
NPairAction::kIgnore,
@@ -50,7 +50,7 @@ const CActionSet kSynchronizeActionSet =
NPairAction::kCompress,
};
-const CActionSet kDeleteActionSet =
+const CActionSet kDeleteActionSet =
{
NPairAction::kCopy,
NPairAction::kIgnore,
diff --git a/CPP/7zip/UI/Common/UpdateAction.h b/CPP/7zip/UI/Common/UpdateAction.h
index aa050975..7da5ff2e 100755
--- a/CPP/7zip/UI/Common/UpdateAction.h
+++ b/CPP/7zip/UI/Common/UpdateAction.h
@@ -5,7 +5,7 @@
namespace NUpdateArchive {
- namespace NPairState
+ namespace NPairState
{
const int kNumValues = 7;
enum EEnum
diff --git a/CPP/7zip/UI/Common/UpdateCallback.cpp b/CPP/7zip/UI/Common/UpdateCallback.cpp
index a5f0a54f..dcca2a1a 100755
--- a/CPP/7zip/UI/Common/UpdateCallback.cpp
+++ b/CPP/7zip/UI/Common/UpdateCallback.cpp
@@ -20,8 +20,9 @@ CArchiveUpdateCallback::CArchiveUpdateCallback():
ShareForWrite(false),
StdInMode(false),
DirItems(0),
- ArchiveItems(0),
- UpdatePairs(0)
+ ArcItems(0),
+ UpdatePairs(0),
+ NewNames(0)
{}
@@ -48,49 +49,37 @@ STDMETHODIMP CArchiveUpdateCallback::SetRatioInfo(const UInt64 *inSize, const UI
/*
-STATPROPSTG kProperties[] =
+STATPROPSTG kProperties[] =
{
{ NULL, kpidPath, VT_BSTR},
- { NULL, kpidIsFolder, VT_BOOL},
+ { NULL, kpidIsDir, VT_BOOL},
{ NULL, kpidSize, VT_UI8},
- { NULL, kpidLastAccessTime, VT_FILETIME},
- { NULL, kpidCreationTime, VT_FILETIME},
- { NULL, kpidLastWriteTime, VT_FILETIME},
- { NULL, kpidAttributes, VT_UI4},
+ { NULL, kpidCTime, VT_FILETIME},
+ { NULL, kpidATime, VT_FILETIME},
+ { NULL, kpidMTime, VT_FILETIME},
+ { NULL, kpidAttrib, VT_UI4},
{ NULL, kpidIsAnti, VT_BOOL}
};
-*/
STDMETHODIMP CArchiveUpdateCallback::EnumProperties(IEnumSTATPROPSTG **)
{
- return E_NOTIMPL;
- /*
- return CStatPropEnumerator::CreateEnumerator(kProperties,
- sizeof(kProperties) / sizeof(kProperties[0]), enumerator);
- */
+ return CStatPropEnumerator::CreateEnumerator(kProperties, sizeof(kProperties) / sizeof(kProperties[0]), enumerator);
}
+*/
-STDMETHODIMP CArchiveUpdateCallback::GetUpdateItemInfo(UInt32 index,
- Int32 *newData, Int32 *newProperties, UInt32 *indexInArchive)
+STDMETHODIMP CArchiveUpdateCallback::GetUpdateItemInfo(UInt32 index,
+ Int32 *newData, Int32 *newProps, UInt32 *indexInArchive)
{
COM_TRY_BEGIN
RINOK(Callback->CheckBreak());
- const CUpdatePair2 &updatePair = (*UpdatePairs)[index];
- if(newData != NULL)
- *newData = BoolToInt(updatePair.NewData);
- if(newProperties != NULL)
- *newProperties = BoolToInt(updatePair.NewProperties);
- if(indexInArchive != NULL)
+ const CUpdatePair2 &up = (*UpdatePairs)[index];
+ if (newData != NULL) *newData = BoolToInt(up.NewData);
+ if (newProps != NULL) *newProps = BoolToInt(up.NewProps);
+ if (indexInArchive != NULL)
{
- if (updatePair.ExistInArchive)
- {
- if (ArchiveItems == 0)
- *indexInArchive = updatePair.ArchiveItemIndex;
- else
- *indexInArchive = (*ArchiveItems)[updatePair.ArchiveItemIndex].IndexInServer;
- }
- else
- *indexInArchive = UInt32(-1);
+ *indexInArchive = (UInt32)-1;
+ if (up.ExistInArchive())
+ *indexInArchive = (ArcItems == 0) ? up.ArcIndex : (*ArcItems)[up.ArcIndex].IndexInServer;
}
return S_OK;
COM_TRY_END
@@ -99,83 +88,69 @@ STDMETHODIMP CArchiveUpdateCallback::GetUpdateItemInfo(UInt32 index,
STDMETHODIMP CArchiveUpdateCallback::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
{
COM_TRY_BEGIN
- const CUpdatePair2 &updatePair = (*UpdatePairs)[index];
- NWindows::NCOM::CPropVariant propVariant;
+ const CUpdatePair2 &up = (*UpdatePairs)[index];
+ NWindows::NCOM::CPropVariant prop;
if (propID == kpidIsAnti)
{
- propVariant = updatePair.IsAnti;
- propVariant.Detach(value);
+ prop = up.IsAnti;
+ prop.Detach(value);
return S_OK;
}
- if (updatePair.IsAnti)
+ if (up.IsAnti)
{
switch(propID)
{
- case kpidIsFolder:
+ case kpidIsDir:
case kpidPath:
break;
case kpidSize:
- propVariant = (UInt64)0;
- propVariant.Detach(value);
+ prop = (UInt64)0;
+ prop.Detach(value);
return S_OK;
default:
- propVariant.Detach(value);
+ prop.Detach(value);
return S_OK;
}
}
- if(updatePair.ExistOnDisk)
+ if (up.ExistOnDisk())
{
- const CDirItem &dirItem = (*DirItems)[updatePair.DirItemIndex];
+ const CDirItem &di = DirItems->Items[up.DirIndex];
switch(propID)
{
- case kpidPath:
- propVariant = dirItem.Name;
- break;
- case kpidIsFolder:
- propVariant = dirItem.IsDirectory();
- break;
- case kpidSize:
- propVariant = dirItem.Size;
- break;
- case kpidAttributes:
- propVariant = dirItem.Attributes;
- break;
- case kpidLastAccessTime:
- propVariant = dirItem.LastAccessTime;
- break;
- case kpidCreationTime:
- propVariant = dirItem.CreationTime;
- break;
- case kpidLastWriteTime:
- propVariant = dirItem.LastWriteTime;
- break;
+ case kpidPath: prop = DirItems->GetLogPath(up.DirIndex); break;
+ case kpidIsDir: prop = di.IsDir(); break;
+ case kpidSize: prop = di.Size; break;
+ case kpidAttrib: prop = di.Attrib; break;
+ case kpidCTime: prop = di.CTime; break;
+ case kpidATime: prop = di.ATime; break;
+ case kpidMTime: prop = di.MTime; break;
}
}
else
{
if (propID == kpidPath)
{
- if (updatePair.NewNameIsDefined)
+ if (up.NewNameIndex >= 0)
{
- propVariant = updatePair.NewName;
- propVariant.Detach(value);
+ prop = (*NewNames)[up.NewNameIndex];
+ prop.Detach(value);
return S_OK;
}
}
- if (updatePair.ExistInArchive && Archive)
+ if (up.ExistInArchive() && Archive)
{
UInt32 indexInArchive;
- if (ArchiveItems == 0)
- indexInArchive = updatePair.ArchiveItemIndex;
+ if (ArcItems == 0)
+ indexInArchive = up.ArcIndex;
else
- indexInArchive = (*ArchiveItems)[updatePair.ArchiveItemIndex].IndexInServer;
+ indexInArchive = (*ArcItems)[up.ArcIndex].IndexInServer;
return Archive->GetProperty(indexInArchive, propID, value);
}
}
- propVariant.Detach(value);
+ prop.Detach(value);
return S_OK;
COM_TRY_END
}
@@ -183,21 +158,21 @@ STDMETHODIMP CArchiveUpdateCallback::GetProperty(UInt32 index, PROPID propID, PR
STDMETHODIMP CArchiveUpdateCallback::GetStream(UInt32 index, ISequentialInStream **inStream)
{
COM_TRY_BEGIN
- const CUpdatePair2 &updatePair = (*UpdatePairs)[index];
- if(!updatePair.NewData)
+ const CUpdatePair2 &up = (*UpdatePairs)[index];
+ if (!up.NewData)
return E_FAIL;
RINOK(Callback->CheckBreak());
RINOK(Callback->Finilize());
- if(updatePair.IsAnti)
+ if (up.IsAnti)
{
- return Callback->GetStream((*ArchiveItems)[updatePair.ArchiveItemIndex].Name, true);
+ return Callback->GetStream((*ArcItems)[up.ArcIndex].Name, true);
}
- const CDirItem &dirItem = (*DirItems)[updatePair.DirItemIndex];
- RINOK(Callback->GetStream(dirItem.Name, false));
+ const CDirItem &di = DirItems->Items[up.DirIndex];
+ RINOK(Callback->GetStream(DirItems->GetLogPath(up.DirIndex), false));
- if(dirItem.IsDirectory())
+ if (di.IsDir())
return S_OK;
if (StdInMode)
@@ -210,8 +185,8 @@ STDMETHODIMP CArchiveUpdateCallback::GetStream(UInt32 index, ISequentialInStream
{
CInFileStream *inStreamSpec = new CInFileStream;
CMyComPtr<ISequentialInStream> inStreamLoc(inStreamSpec);
- UString path = DirPrefix + dirItem.FullPath;
- if(!inStreamSpec->OpenShared(path, ShareForWrite))
+ const UString path = DirItems->GetPhyPath(up.DirIndex);
+ if (!inStreamSpec->OpenShared(path, ShareForWrite))
{
return Callback->OpenFileError(path, ::GetLastError());
}
@@ -252,7 +227,7 @@ STDMETHODIMP CArchiveUpdateCallback::GetVolumeStream(UInt32 index, ISequentialOu
fileName += VolExt;
COutFileStream *streamSpec = new COutFileStream;
CMyComPtr<ISequentialOutStream> streamLoc(streamSpec);
- if(!streamSpec->Create(fileName, false))
+ if (!streamSpec->Create(fileName, false))
return ::GetLastError();
*volumeStream = streamLoc.Detach();
return S_OK;
diff --git a/CPP/7zip/UI/Common/UpdateCallback.h b/CPP/7zip/UI/Common/UpdateCallback.h
index bf90ff9e..411ee011 100755
--- a/CPP/7zip/UI/Common/UpdateCallback.h
+++ b/CPP/7zip/UI/Common/UpdateCallback.h
@@ -31,7 +31,7 @@ struct IUpdateCallbackUI
INTERFACE_IUpdateCallbackUI(=0)
};
-class CArchiveUpdateCallback:
+class CArchiveUpdateCallback:
public IArchiveUpdateCallback2,
public ICryptoGetTextPassword2,
public ICompressProgressInfo,
@@ -39,25 +39,13 @@ class CArchiveUpdateCallback:
{
public:
MY_UNKNOWN_IMP3(
- IArchiveUpdateCallback2,
+ IArchiveUpdateCallback2,
ICryptoGetTextPassword2,
ICompressProgressInfo)
- // IProgress
- STDMETHOD(SetTotal)(UInt64 size);
- STDMETHOD(SetCompleted)(const UInt64 *completeValue);
STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize);
- // IUpdateCallback
- STDMETHOD(EnumProperties)(IEnumSTATPROPSTG **enumerator);
- STDMETHOD(GetUpdateItemInfo)(UInt32 index,
- Int32 *newData, Int32 *newProperties, UInt32 *indexInArchive);
- STDMETHOD(GetProperty)(UInt32 index, PROPID propID, PROPVARIANT *value);
- STDMETHOD(GetStream)(UInt32 index, ISequentialInStream **inStream);
- STDMETHOD(SetOperationResult)(Int32 operationResult);
-
- STDMETHOD(GetVolumeSize)(UInt32 index, UInt64 *size);
- STDMETHOD(GetVolumeStream)(UInt32 index, ISequentialOutStream **volumeStream);
+ INTERFACE_IArchiveUpdateCallback2(;)
STDMETHOD(CryptoGetTextPassword2)(Int32 *passwordIsDefined, BSTR *password);
@@ -68,12 +56,12 @@ public:
IUpdateCallbackUI *Callback;
- UString DirPrefix;
bool ShareForWrite;
bool StdInMode;
- const CObjectVector<CDirItem> *DirItems;
- const CObjectVector<CArchiveItem> *ArchiveItems;
- const CObjectVector<CUpdatePair2> *UpdatePairs;
+ const CDirItems *DirItems;
+ const CObjectVector<CArcItem> *ArcItems;
+ const CRecordVector<CUpdatePair2> *UpdatePairs;
+ const UStringVector *NewNames;
CMyComPtr<IInArchive> Archive;
CArchiveUpdateCallback();
diff --git a/CPP/7zip/UI/Common/UpdatePair.cpp b/CPP/7zip/UI/Common/UpdatePair.cpp
index 2ee0f167..26a1a8de 100755
--- a/CPP/7zip/UI/Common/UpdatePair.cpp
+++ b/CPP/7zip/UI/Common/UpdatePair.cpp
@@ -42,7 +42,7 @@ static const wchar_t *kDuplicateFileNameMessage = L"Duplicate filename:";
/*
static const char *kNotCensoredCollisionMessaged = "Internal file name collision:\n";
-static const char *kSameTimeChangedSizeCollisionMessaged =
+static const char *kSameTimeChangedSizeCollisionMessaged =
"Collision between files with same date/time and different sizes:\n";
*/
@@ -61,92 +61,103 @@ static void TestDuplicateString(const UStringVector &strings, const CIntVector &
}
void GetUpdatePairInfoList(
- const CObjectVector<CDirItem> &dirItems,
- const CObjectVector<CArchiveItem> &archiveItems,
+ const CDirItems &dirItems,
+ const CObjectVector<CArcItem> &arcItems,
NFileTimeType::EEnum fileTimeType,
- CObjectVector<CUpdatePair> &updatePairs)
+ CRecordVector<CUpdatePair> &updatePairs)
{
- CIntVector dirIndices, archiveIndices;
- UStringVector dirNames, archiveNames;
+ CIntVector dirIndices, arcIndices;
- int numDirItems = dirItems.Size();
- int i;
- for(i = 0; i < numDirItems; i++)
- dirNames.Add(dirItems[i].Name);
- SortFileNames(dirNames, dirIndices);
- TestDuplicateString(dirNames, dirIndices);
+ int numDirItems = dirItems.Items.Size();
+ int numArcItems = arcItems.Size();
+
+
+ {
+ UStringVector arcNames;
+ arcNames.Reserve(numArcItems);
+ for (int i = 0; i < numArcItems; i++)
+ arcNames.Add(arcItems[i].Name);
+ SortFileNames(arcNames, arcIndices);
+ TestDuplicateString(arcNames, arcIndices);
+ }
- int numArchiveItems = archiveItems.Size();
- for(i = 0; i < numArchiveItems; i++)
- archiveNames.Add(archiveItems[i].Name);
- SortFileNames(archiveNames, archiveIndices);
- TestDuplicateString(archiveNames, archiveIndices);
+ UStringVector dirNames;
+ {
+ dirNames.Reserve(numDirItems);
+ for (int i = 0; i < numDirItems; i++)
+ dirNames.Add(dirItems.GetLogPath(i));
+ SortFileNames(dirNames, dirIndices);
+ TestDuplicateString(dirNames, dirIndices);
+ }
- int dirItemIndex = 0, archiveItemIndex = 0;
- CUpdatePair pair;
- while(dirItemIndex < numDirItems && archiveItemIndex < numArchiveItems)
+ int dirIndex = 0, arcIndex = 0;
+ while (dirIndex < numDirItems && arcIndex < numArcItems)
{
- int dirItemIndex2 = dirIndices[dirItemIndex],
- archiveItemIndex2 = archiveIndices[archiveItemIndex];
- const CDirItem &dirItem = dirItems[dirItemIndex2];
- const CArchiveItem &archiveItem = archiveItems[archiveItemIndex2];
- int compareResult = CompareFileNames(dirItem.Name, archiveItem.Name);
+ CUpdatePair pair;
+ int dirIndex2 = dirIndices[dirIndex];
+ int arcIndex2 = arcIndices[arcIndex];
+ const CDirItem &di = dirItems.Items[dirIndex2];
+ const CArcItem &ai = arcItems[arcIndex2];
+ int compareResult = CompareFileNames(dirNames[dirIndex2], ai.Name);
if (compareResult < 0)
{
- pair.State = NUpdateArchive::NPairState::kOnlyOnDisk;
- pair.DirItemIndex = dirItemIndex2;
- dirItemIndex++;
+ pair.State = NUpdateArchive::NPairState::kOnlyOnDisk;
+ pair.DirIndex = dirIndex2;
+ dirIndex++;
}
else if (compareResult > 0)
{
- pair.State = archiveItem.Censored ?
- NUpdateArchive::NPairState::kOnlyInArchive: NUpdateArchive::NPairState::kNotMasked;
- pair.ArchiveItemIndex = archiveItemIndex2;
- archiveItemIndex++;
+ pair.State = ai.Censored ?
+ NUpdateArchive::NPairState::kOnlyInArchive:
+ NUpdateArchive::NPairState::kNotMasked;
+ pair.ArcIndex = arcIndex2;
+ arcIndex++;
}
else
{
- if (!archiveItem.Censored)
- throw 1082022;; // TTString(kNotCensoredCollisionMessaged + dirItem.Name);
- pair.DirItemIndex = dirItemIndex2;
- pair.ArchiveItemIndex = archiveItemIndex2;
- switch (MyCompareTime(archiveItem.FileTimeType != - 1 ?
- (NFileTimeType::EEnum)archiveItem.FileTimeType : fileTimeType, dirItem.LastWriteTime, archiveItem.LastWriteTime))
+ if (!ai.Censored)
+ throw 1082022;
+ pair.DirIndex = dirIndex2;
+ pair.ArcIndex = arcIndex2;
+ switch (MyCompareTime(
+ ai.TimeType != - 1 ? (NFileTimeType::EEnum)ai.TimeType : fileTimeType,
+ di.MTime, ai.MTime))
{
- case -1:
- pair.State = NUpdateArchive::NPairState::kNewInArchive;
- break;
- case 1:
- pair.State = NUpdateArchive::NPairState::kOldInArchive;
- break;
+ case -1: pair.State = NUpdateArchive::NPairState::kNewInArchive; break;
+ case 1: pair.State = NUpdateArchive::NPairState::kOldInArchive; break;
default:
- if (archiveItem.SizeIsDefined)
- if (dirItem.Size != archiveItem.Size)
- // throw 1082034; // kSameTimeChangedSizeCollisionMessaged;
+ if (ai.SizeDefined)
+ if (di.Size != ai.Size)
pair.State = NUpdateArchive::NPairState::kUnknowNewerFiles;
else
pair.State = NUpdateArchive::NPairState::kSameFiles;
else
pair.State = NUpdateArchive::NPairState::kUnknowNewerFiles;
}
- dirItemIndex++;
- archiveItemIndex++;
+ dirIndex++;
+ arcIndex++;
}
updatePairs.Add(pair);
}
- for(;dirItemIndex < numDirItems; dirItemIndex++)
+
+ for (; dirIndex < numDirItems; dirIndex++)
{
+ CUpdatePair pair;
pair.State = NUpdateArchive::NPairState::kOnlyOnDisk;
- pair.DirItemIndex = dirIndices[dirItemIndex];
+ pair.DirIndex = dirIndices[dirIndex];
updatePairs.Add(pair);
}
- for(;archiveItemIndex < numArchiveItems; archiveItemIndex++)
+
+ for (; arcIndex < numArcItems; arcIndex++)
{
- int archiveItemIndex2 = archiveIndices[archiveItemIndex];
- const CArchiveItem &archiveItem = archiveItems[archiveItemIndex2];
- pair.State = archiveItem.Censored ?
- NUpdateArchive::NPairState::kOnlyInArchive: NUpdateArchive::NPairState::kNotMasked;
- pair.ArchiveItemIndex = archiveItemIndex2;
+ CUpdatePair pair;
+ int arcIndex2 = arcIndices[arcIndex];
+ pair.State = arcItems[arcIndex2].Censored ?
+ NUpdateArchive::NPairState::kOnlyInArchive:
+ NUpdateArchive::NPairState::kNotMasked;
+ pair.ArcIndex = arcIndex2;
updatePairs.Add(pair);
}
+
+ updatePairs.ReserveDown();
}
diff --git a/CPP/7zip/UI/Common/UpdatePair.h b/CPP/7zip/UI/Common/UpdatePair.h
index f50a23f8..3a332649 100755
--- a/CPP/7zip/UI/Common/UpdatePair.h
+++ b/CPP/7zip/UI/Common/UpdatePair.h
@@ -11,14 +11,15 @@
struct CUpdatePair
{
NUpdateArchive::NPairState::EEnum State;
- int ArchiveItemIndex;
- int DirItemIndex;
+ int ArcIndex;
+ int DirIndex;
+ CUpdatePair(): ArcIndex(-1), DirIndex(-1) {}
};
void GetUpdatePairInfoList(
- const CObjectVector<CDirItem> &dirItems,
- const CObjectVector<CArchiveItem> &archiveItems,
+ const CDirItems &dirItems,
+ const CObjectVector<CArcItem> &arcItems,
NFileTimeType::EEnum fileTimeType,
- CObjectVector<CUpdatePair> &updatePairs);
+ CRecordVector<CUpdatePair> &updatePairs);
#endif
diff --git a/CPP/7zip/UI/Common/UpdateProduce.cpp b/CPP/7zip/UI/Common/UpdateProduce.cpp
index 5552161a..b2bc59a5 100755
--- a/CPP/7zip/UI/Common/UpdateProduce.cpp
+++ b/CPP/7zip/UI/Common/UpdateProduce.cpp
@@ -6,58 +6,49 @@
using namespace NUpdateArchive;
-static const char *kUpdateActionSetCollision =
- "Internal collision in update action set";
+static const char *kUpdateActionSetCollision = "Internal collision in update action set";
void UpdateProduce(
- const CObjectVector<CUpdatePair> &updatePairs,
+ const CRecordVector<CUpdatePair> &updatePairs,
const NUpdateArchive::CActionSet &actionSet,
- CObjectVector<CUpdatePair2> &operationChain)
+ CRecordVector<CUpdatePair2> &operationChain)
{
- for(int i = 0; i < updatePairs.Size(); i++)
+ for (int i = 0; i < updatePairs.Size(); i++)
{
- // CUpdateArchiveRange aRange;
const CUpdatePair &pair = updatePairs[i];
- CUpdatePair2 pair2;
- pair2.IsAnti = false;
- pair2.ArchiveItemIndex = pair.ArchiveItemIndex;
- pair2.DirItemIndex = pair.DirItemIndex;
- pair2.ExistInArchive = (pair.State != NPairState::kOnlyOnDisk);
- pair2.ExistOnDisk = (pair.State != NPairState::kOnlyInArchive && pair.State != NPairState::kNotMasked);
+ CUpdatePair2 up2;
+ up2.IsAnti = false;
+ up2.DirIndex = pair.DirIndex;
+ up2.ArcIndex = pair.ArcIndex;
+ up2.NewData = up2.NewProps = true;
switch(actionSet.StateActions[pair.State])
{
case NPairAction::kIgnore:
/*
if (pair.State != NPairState::kOnlyOnDisk)
- IgnoreArchiveItem(m_ArchiveItems[pair.ArchiveItemIndex]);
+ IgnoreArchiveItem(m_ArchiveItems[pair.ArcIndex]);
// cout << "deleting";
*/
- break;
+ continue;
+
case NPairAction::kCopy:
- {
- if (pair.State == NPairState::kOnlyOnDisk)
- throw kUpdateActionSetCollision;
- pair2.NewData = pair2.NewProperties = false;
- operationChain.Add(pair2);
- break;
- }
+ if (pair.State == NPairState::kOnlyOnDisk)
+ throw kUpdateActionSetCollision;
+ up2.NewData = up2.NewProps = false;
+ break;
+
case NPairAction::kCompress:
- {
- if (pair.State == NPairState::kOnlyInArchive ||
+ if (pair.State == NPairState::kOnlyInArchive ||
pair.State == NPairState::kNotMasked)
- throw kUpdateActionSetCollision;
- pair2.NewData = pair2.NewProperties = true;
- operationChain.Add(pair2);
- break;
- }
+ throw kUpdateActionSetCollision;
+ break;
+
case NPairAction::kCompressAsAnti:
- {
- pair2.IsAnti = true;
- pair2.NewData = pair2.NewProperties = true;
- operationChain.Add(pair2);
- break;
- }
+ up2.IsAnti = true;
+ break;
}
+ operationChain.Add(up2);
}
+ operationChain.ReserveDown();
}
diff --git a/CPP/7zip/UI/Common/UpdateProduce.h b/CPP/7zip/UI/Common/UpdateProduce.h
index 8f58dab9..7e1a4a3f 100755
--- a/CPP/7zip/UI/Common/UpdateProduce.h
+++ b/CPP/7zip/UI/Common/UpdateProduce.h
@@ -7,25 +7,23 @@
struct CUpdatePair2
{
- // bool OperationIsCompress;
bool NewData;
- bool NewProperties;
-
- bool ExistInArchive;
- bool ExistOnDisk;
+ bool NewProps;
bool IsAnti;
- int ArchiveItemIndex;
- int DirItemIndex;
+
+ int DirIndex;
+ int ArcIndex;
+ int NewNameIndex;
- bool NewNameIsDefined;
- UString NewName;
+ bool ExistOnDisk() const { return DirIndex != -1; }
+ bool ExistInArchive() const { return ArcIndex != -1; }
- CUpdatePair2(): NewNameIsDefined(false) {}
+ CUpdatePair2(): IsAnti(false), DirIndex(-1), ArcIndex(-1), NewNameIndex(-1) {}
};
void UpdateProduce(
- const CObjectVector<CUpdatePair> &updatePairs,
+ const CRecordVector<CUpdatePair> &updatePairs,
const NUpdateArchive::CActionSet &actionSet,
- CObjectVector<CUpdatePair2> &operationChain);
+ CRecordVector<CUpdatePair2> &operationChain);
#endif
diff --git a/CPP/7zip/UI/Common/WorkDir.cpp b/CPP/7zip/UI/Common/WorkDir.cpp
index 8db6f4f1..e97275b1 100755
--- a/CPP/7zip/UI/Common/WorkDir.cpp
+++ b/CPP/7zip/UI/Common/WorkDir.cpp
@@ -10,8 +10,8 @@
#include "Windows/FileName.h"
#include "Windows/FileDir.h"
-static inline UINT GetCurrentCodePage()
- { return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
+static inline UINT GetCurrentCodePage()
+ { return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
using namespace NWindows;
using namespace NFile;
diff --git a/CPP/7zip/UI/Common/ZipRegistry.cpp b/CPP/7zip/UI/Common/ZipRegistry.cpp
index 1f076caf..4bba19f8 100755
--- a/CPP/7zip/UI/Common/ZipRegistry.cpp
+++ b/CPP/7zip/UI/Common/ZipRegistry.cpp
@@ -15,7 +15,7 @@
using namespace NWindows;
using namespace NRegistry;
-static const TCHAR *kCUBasePath = TEXT("Software\\7-ZIP");
+static const TCHAR *kCUBasePath = TEXT("Software") TEXT(STRING_PATH_SEPARATOR) TEXT("7-ZIP");
static NSynchronization::CCriticalSection g_RegistryOperationsCriticalSection;
@@ -31,7 +31,7 @@ static const TCHAR *kExtractionShowPasswordValueName = TEXT("ShowPassword");
static CSysString GetKeyPath(const CSysString &path)
{
- return CSysString(kCUBasePath) + CSysString('\\') + CSysString(path);
+ return CSysString(kCUBasePath) + CSysString(CHAR_PATH_SEPARATOR) + path;
}
void SaveExtractionInfo(const NExtract::CInfo &info)
@@ -69,9 +69,9 @@ void ReadExtractionInfo(NExtract::CInfo &info)
{
CKey pathHistoryKey;
- if(pathHistoryKey.Open(extractionKey, kExtractionPathHistoryKeyName, KEY_READ) ==
+ if(pathHistoryKey.Open(extractionKey, kExtractionPathHistoryKeyName, KEY_READ) ==
ERROR_SUCCESS)
- {
+ {
for (;;)
{
wchar_t numberString[16];
@@ -109,7 +109,7 @@ void ReadExtractionInfo(NExtract::CInfo &info)
break;
}
}
- if (extractionKey.QueryValue(kExtractionShowPasswordValueName,
+ if (extractionKey.QueryValue(kExtractionShowPasswordValueName,
info.ShowPassword) != ERROR_SUCCESS)
info.ShowPassword = false;
}
@@ -234,15 +234,15 @@ void ReadCompressionInfo(NCompression::CInfo &info)
NSynchronization::CCriticalSectionLock lock(g_RegistryOperationsCriticalSection);
CKey compressionKey;
- if(compressionKey.Open(HKEY_CURRENT_USER,
+ if(compressionKey.Open(HKEY_CURRENT_USER,
GetKeyPath(kCompressionKeyName), KEY_READ) != ERROR_SUCCESS)
return;
{
CKey historyArchivesKey;
- if(historyArchivesKey.Open(compressionKey, kCompressionHistoryArchivesKeyName, KEY_READ) ==
+ if(historyArchivesKey.Open(compressionKey, kCompressionHistoryArchivesKeyName, KEY_READ) ==
ERROR_SUCCESS)
- {
+ {
for (;;)
{
wchar_t numberString[16];
@@ -267,9 +267,9 @@ void ReadCompressionInfo(NCompression::CInfo &info)
{
CKey optionsKey;
- if(optionsKey.Open(compressionKey, kCompressionOptionsKeyName, KEY_READ) ==
+ if(optionsKey.Open(compressionKey, kCompressionOptionsKeyName, KEY_READ) ==
ERROR_SUCCESS)
- {
+ {
CSysStringVector formatIDs;
optionsKey.EnumKeys(formatIDs);
for(int i = 0; i < formatIDs.Size(); i++)
@@ -302,10 +302,10 @@ void ReadCompressionInfo(NCompression::CInfo &info)
CSysString archiveType;
if (compressionKey.QueryValue(kCompressionLastFormatValueName, archiveType) == ERROR_SUCCESS)
info.ArchiveType = GetUnicodeString(archiveType);
- if (compressionKey.QueryValue(kCompressionShowPasswordValueName,
+ if (compressionKey.QueryValue(kCompressionShowPasswordValueName,
info.ShowPassword) != ERROR_SUCCESS)
info.ShowPassword = false;
- if (compressionKey.QueryValue(kCompressionEncryptHeadersValueName,
+ if (compressionKey.QueryValue(kCompressionEncryptHeadersValueName,
info.EncryptHeaders) != ERROR_SUCCESS)
info.EncryptHeaders = false;
/*
diff --git a/CPP/7zip/UI/Common/ZipRegistry.h b/CPP/7zip/UI/Common/ZipRegistry.h
index 753287d9..30be8d89 100755
--- a/CPP/7zip/UI/Common/ZipRegistry.h
+++ b/CPP/7zip/UI/Common/ZipRegistry.h
@@ -31,9 +31,9 @@ namespace NCompression {
UInt32 Order;
UInt32 BlockLogSize;
UInt32 NumThreads;
- void ResetForLevelChange()
- {
- BlockLogSize = NumThreads = Level = Dictionary = Order = UInt32(-1);
+ void ResetForLevelChange()
+ {
+ BlockLogSize = NumThreads = Level = Dictionary = Order = UInt32(-1);
Method.Empty();
// EncryptionMethod.Empty();
// Options.Empty();
diff --git a/CPP/7zip/UI/Console/Console.dsp b/CPP/7zip/UI/Console/Console.dsp
index e8f83664..ba5cd727 100755
--- a/CPP/7zip/UI/Console/Console.dsp
+++ b/CPP/7zip/UI/Console/Console.dsp
@@ -316,6 +316,10 @@ SOURCE=..\..\..\Windows\System.h
# End Source File
# Begin Source File
+SOURCE=..\..\..\Windows\Time.cpp
+# End Source File
+# Begin Source File
+
SOURCE=..\..\..\Windows\Time.h
# End Source File
# End Group
diff --git a/CPP/7zip/UI/Console/ConsoleClose.h b/CPP/7zip/UI/Console/ConsoleClose.h
index 3c5fd55d..9019c4ce 100755
--- a/CPP/7zip/UI/Console/ConsoleClose.h
+++ b/CPP/7zip/UI/Console/ConsoleClose.h
@@ -14,7 +14,7 @@ public:
virtual ~CCtrlHandlerSetter();
};
-class CCtrlBreakException
+class CCtrlBreakException
{};
void CheckCtrlBreak();
diff --git a/CPP/7zip/UI/Console/ExtractCallbackConsole.cpp b/CPP/7zip/UI/Console/ExtractCallbackConsole.cpp
index d693cb4b..65b74fce 100755
--- a/CPP/7zip/UI/Console/ExtractCallbackConsole.cpp
+++ b/CPP/7zip/UI/Console/ExtractCallbackConsole.cpp
@@ -24,9 +24,9 @@ using namespace NWindows;
using namespace NFile;
using namespace NDirectory;
-static const char *kTestingString = "Testing ";
-static const char *kExtractingString = "Extracting ";
-static const char *kSkippingString = "Skipping ";
+static const char *kTestString = "Testing ";
+static const char *kExtractString = "Extracting ";
+static const char *kSkipString = "Skipping ";
// static const char *kCantAutoRename = "can not create file with auto name\n";
// static const char *kCantRenameFile = "can not rename existing file\n";
@@ -64,7 +64,7 @@ STDMETHODIMP CExtractCallbackConsole::AskOverwrite(
const wchar_t *newName, const FILETIME *, const UInt64 *,
Int32 *answer)
{
- (*OutStream) << "file " << existName <<
+ (*OutStream) << "file " << existName <<
"\nalready exists. Overwrite with " << endl;
(*OutStream) << newName;
@@ -72,25 +72,13 @@ STDMETHODIMP CExtractCallbackConsole::AskOverwrite(
switch(overwriteAnswer)
{
- case NUserAnswerMode::kQuit:
- return E_ABORT;
- case NUserAnswerMode::kNo:
- *answer = NOverwriteAnswer::kNo;
- break;
- case NUserAnswerMode::kNoAll:
- *answer = NOverwriteAnswer::kNoToAll;
- break;
- case NUserAnswerMode::kYesAll:
- *answer = NOverwriteAnswer::kYesToAll;
- break;
- case NUserAnswerMode::kYes:
- *answer = NOverwriteAnswer::kYes;
- break;
- case NUserAnswerMode::kAutoRename:
- *answer = NOverwriteAnswer::kAutoRename;
- break;
- default:
- return E_FAIL;
+ case NUserAnswerMode::kQuit: return E_ABORT;
+ case NUserAnswerMode::kNo: *answer = NOverwriteAnswer::kNo; break;
+ case NUserAnswerMode::kNoAll: *answer = NOverwriteAnswer::kNoToAll; break;
+ case NUserAnswerMode::kYesAll: *answer = NOverwriteAnswer::kYesToAll; break;
+ case NUserAnswerMode::kYes: *answer = NOverwriteAnswer::kYes; break;
+ case NUserAnswerMode::kAutoRename: *answer = NOverwriteAnswer::kAutoRename; break;
+ default: return E_FAIL;
}
return S_OK;
}
@@ -99,15 +87,9 @@ STDMETHODIMP CExtractCallbackConsole::PrepareOperation(const wchar_t *name, bool
{
switch (askExtractMode)
{
- case NArchive::NExtract::NAskMode::kExtract:
- (*OutStream) << kExtractingString;
- break;
- case NArchive::NExtract::NAskMode::kTest:
- (*OutStream) << kTestingString;
- break;
- case NArchive::NExtract::NAskMode::kSkip:
- (*OutStream) << kSkippingString;
- break;
+ case NArchive::NExtract::NAskMode::kExtract: (*OutStream) << kExtractString; break;
+ case NArchive::NExtract::NAskMode::kTest: (*OutStream) << kTestString; break;
+ case NArchive::NExtract::NAskMode::kSkip: (*OutStream) << kSkipString; break;
};
(*OutStream) << name;
if (position != 0)
@@ -154,11 +136,20 @@ STDMETHODIMP CExtractCallbackConsole::SetOperationResult(Int32 operationResult,
return S_OK;
}
+#ifndef _NO_CRYPTO
+
+HRESULT CExtractCallbackConsole::SetPassword(const UString &password)
+{
+ PasswordIsDefined = true;
+ Password = password;
+ return S_OK;
+}
+
STDMETHODIMP CExtractCallbackConsole::CryptoGetTextPassword(BSTR *password)
{
if (!PasswordIsDefined)
{
- Password = GetPassword(OutStream);
+ Password = GetPassword(OutStream);
PasswordIsDefined = true;
}
CMyComBSTR tempName(Password);
@@ -166,6 +157,8 @@ STDMETHODIMP CExtractCallbackConsole::CryptoGetTextPassword(BSTR *password)
return S_OK;
}
+#endif
+
HRESULT CExtractCallbackConsole::BeforeOpen(const wchar_t *name)
{
NumArchives++;
@@ -180,10 +173,19 @@ HRESULT CExtractCallbackConsole::OpenResult(const wchar_t * /* name */, HRESULT
if (result != S_OK)
{
(*OutStream) << "Error: ";
- if (encrypted)
- (*OutStream) << "Can not open encrypted archive. Wrong password?";
+ if (result == S_FALSE)
+ {
+ (*OutStream) << (encrypted ?
+ "Can not open encrypted archive. Wrong password?" :
+ "Can not open file as archive");
+ }
else
- (*OutStream) << "Can not open file as archive";
+ {
+ if (result == E_OUTOFMEMORY)
+ (*OutStream) << "Can't allocate required memory";
+ else
+ (*OutStream) << NError::MyFormatMessage(result);
+ }
(*OutStream) << endl;
NumArchiveErrors++;
}
@@ -203,7 +205,7 @@ HRESULT CExtractCallbackConsole::ExtractResult(HRESULT result)
(*OutStream) << endl;
if (NumFileErrorsInCurrentArchive == 0)
(*OutStream) << kEverythingIsOk << endl;
- else
+ else
{
NumArchiveErrors++;
(*OutStream) << "Sub items Errors: " << NumFileErrorsInCurrentArchive << endl;
@@ -226,10 +228,3 @@ HRESULT CExtractCallbackConsole::ExtractResult(HRESULT result)
(*OutStream) << endl;
return S_OK;
}
-
-HRESULT CExtractCallbackConsole::SetPassword(const UString &password)
-{
- PasswordIsDefined = true;
- Password = password;
- return S_OK;
-}
diff --git a/CPP/7zip/UI/Console/ExtractCallbackConsole.h b/CPP/7zip/UI/Console/ExtractCallbackConsole.h
index 7e5d9c5d..e42ca6f4 100755
--- a/CPP/7zip/UI/Console/ExtractCallbackConsole.h
+++ b/CPP/7zip/UI/Console/ExtractCallbackConsole.h
@@ -10,13 +10,20 @@
#include "../../Archive/IArchive.h"
#include "../Common/ArchiveExtractCallback.h"
-class CExtractCallbackConsole:
+class CExtractCallbackConsole:
public IExtractCallbackUI,
+ #ifndef _NO_CRYPTO
public ICryptoGetTextPassword,
+ #endif
public CMyUnknownImp
{
public:
- MY_UNKNOWN_IMP2(IFolderArchiveExtractCallback, ICryptoGetTextPassword)
+ MY_QUERYINTERFACE_BEGIN2(IFolderArchiveExtractCallback)
+ #ifndef _NO_CRYPTO
+ MY_QUERYINTERFACE_ENTRY(ICryptoGetTextPassword)
+ #endif
+ MY_QUERYINTERFACE_END
+ MY_ADDREF_RELEASE
STDMETHOD(SetTotal)(UInt64 total);
STDMETHOD(SetCompleted)(const UInt64 *completeValue);
@@ -31,19 +38,20 @@ public:
STDMETHOD(MessageError)(const wchar_t *message);
STDMETHOD(SetOperationResult)(Int32 operationResult, bool encrypted);
- // ICryptoGetTextPassword
- STDMETHOD(CryptoGetTextPassword)(BSTR *password);
-
HRESULT BeforeOpen(const wchar_t *name);
HRESULT OpenResult(const wchar_t *name, HRESULT result, bool encrypted);
HRESULT ThereAreNoFiles();
HRESULT ExtractResult(HRESULT result);
+
+ #ifndef _NO_CRYPTO
HRESULT SetPassword(const UString &password);
+ STDMETHOD(CryptoGetTextPassword)(BSTR *password);
-public:
bool PasswordIsDefined;
UString Password;
+
+ #endif
UInt64 NumArchives;
UInt64 NumArchiveErrors;
diff --git a/CPP/7zip/UI/Console/List.cpp b/CPP/7zip/UI/Console/List.cpp
index 6ba2830e..82a08f2f 100755
--- a/CPP/7zip/UI/Console/List.cpp
+++ b/CPP/7zip/UI/Console/List.cpp
@@ -14,6 +14,7 @@
#include "Windows/Defs.h"
#include "Windows/PropVariantConversions.h"
#include "Windows/FileDir.h"
+#include "Windows/Error.h"
#include "../../Archive/IArchive.h"
@@ -30,17 +31,17 @@ struct CPropIdToName
const wchar_t *Name;
};
-static CPropIdToName kPropIdToName[] =
+static CPropIdToName kPropIdToName[] =
{
{ kpidPath, L"Path" },
{ kpidName, L"Name" },
- { kpidIsFolder, L"Folder" },
+ { kpidIsDir, L"Folder" },
{ kpidSize, L"Size" },
- { kpidPackedSize, L"Packed Size" },
- { kpidAttributes, L"Attributes" },
- { kpidCreationTime, L"Created" },
- { kpidLastAccessTime, L"Accessed" },
- { kpidLastWriteTime, L"Modified" },
+ { kpidPackSize, L"Packed Size" },
+ { kpidAttrib, L"Attributes" },
+ { kpidCTime, L"Created" },
+ { kpidATime, L"Accessed" },
+ { kpidMTime, L"Modified" },
{ kpidSolid, L"Solid" },
{ kpidCommented, L"Commented" },
{ kpidEncrypted, L"Encrypted" },
@@ -59,7 +60,7 @@ static CPropIdToName kPropIdToName[] =
{ kpidComment, L"Comment" },
{ kpidPosition, L"Position" },
{ kpidPrefix, L"Prefix" },
- { kpidNumSubFolders, L"Folders" },
+ { kpidNumSubDirs, L"Folders" },
{ kpidNumSubFiles, L"Files" },
{ kpidUnpackVer, L"Version" },
{ kpidVolume, L"Volume" },
@@ -67,32 +68,33 @@ static CPropIdToName kPropIdToName[] =
{ kpidOffset, L"Offset" },
{ kpidLinks, L"Links" },
{ kpidNumBlocks, L"Blocks" },
- { kpidNumVolumes, L"Volumes" }
+ { kpidNumVolumes, L"Volumes" },
+
+ { kpidBit64, L"64-bit" },
+ { kpidBigEndian, L"Big-endian" },
+ { kpidCpu, L"CPU" },
+ { kpidPhySize, L"Physical Size" },
+ { kpidHeadersSize, L"Headers Size" },
+ { kpidChecksum, L"Checksum" },
+ { kpidCharacts, L"Characteristics" },
+ { kpidVa, L"Virtual Address" },
+ { kpidFreeSpace, L"Free Space" },
+ { kpidClusterSize, L"Cluster Size" }
};
-static const char kEmptyAttributeChar = '.';
-static const char kDirectoryAttributeChar = 'D';
-static const char kReadonlyAttributeChar = 'R';
-static const char kHiddenAttributeChar = 'H';
-static const char kSystemAttributeChar = 'S';
-static const char kArchiveAttributeChar = 'A';
+static const char kEmptyAttribChar = '.';
static const char *kListing = "Listing archive: ";
static const wchar_t *kFilesMessage = L"files";
static const wchar_t *kDirsMessage = L"folders";
-static void GetAttributesString(DWORD wa, bool directory, char *s)
+static void GetAttribString(DWORD wa, bool isDir, char *s)
{
- s[0] = ((wa & FILE_ATTRIBUTE_DIRECTORY) != 0 || directory) ?
- kDirectoryAttributeChar: kEmptyAttributeChar;
- s[1] = ((wa & FILE_ATTRIBUTE_READONLY) != 0)?
- kReadonlyAttributeChar: kEmptyAttributeChar;
- s[2] = ((wa & FILE_ATTRIBUTE_HIDDEN) != 0) ?
- kHiddenAttributeChar: kEmptyAttributeChar;
- s[3] = ((wa & FILE_ATTRIBUTE_SYSTEM) != 0) ?
- kSystemAttributeChar: kEmptyAttributeChar;
- s[4] = ((wa & FILE_ATTRIBUTE_ARCHIVE) != 0) ?
- kArchiveAttributeChar: kEmptyAttributeChar;
+ s[0] = ((wa & FILE_ATTRIBUTE_DIRECTORY) != 0 || isDir) ? 'D' : kEmptyAttribChar;
+ s[1] = ((wa & FILE_ATTRIBUTE_READONLY) != 0) ? 'R': kEmptyAttribChar;
+ s[2] = ((wa & FILE_ATTRIBUTE_HIDDEN) != 0) ? 'H': kEmptyAttribChar;
+ s[3] = ((wa & FILE_ATTRIBUTE_SYSTEM) != 0) ? 'S': kEmptyAttribChar;
+ s[4] = ((wa & FILE_ATTRIBUTE_ARCHIVE) != 0) ? 'A': kEmptyAttribChar;
s[5] = '\0';
}
@@ -123,12 +125,12 @@ struct CFieldInfoInit
int Width;
};
-CFieldInfoInit kStandardFieldTable[] =
+CFieldInfoInit kStandardFieldTable[] =
{
- { kpidLastWriteTime, L" Date Time", kLeft, kLeft, 0, 19 },
- { kpidAttributes, L"Attr", kRight, kCenter, 1, 5 },
+ { kpidMTime, L" Date Time", kLeft, kLeft, 0, 19 },
+ { kpidAttrib, L"Attr", kRight, kCenter, 1, 5 },
{ kpidSize, L"Size", kRight, kRight, 1, 12 },
- { kpidPackedSize, L"Compressed", kRight, kRight, 1, 12 },
+ { kpidPackSize, L"Compressed", kRight, kRight, 1, 12 },
{ kpidPath, L"Name", kLeft, kLeft, 2, 24 }
};
@@ -168,12 +170,11 @@ public:
HRESULT Init(IInArchive *archive);
void PrintTitle();
void PrintTitleLines();
- HRESULT PrintItemInfo(IInArchive *archive,
+ HRESULT PrintItemInfo(IInArchive *archive,
const UString &defaultItemName,
- const NWindows::NFile::NFind::CFileInfoW &archiveFileInfo,
UInt32 index,
bool techMode);
- HRESULT PrintSummaryInfo(UInt64 numFiles, UInt64 numDirs,
+ HRESULT PrintSummaryInfo(UInt64 numFiles, UInt64 numDirs,
const UInt64 *size, const UInt64 *compressedSize);
};
@@ -204,7 +205,9 @@ static UString GetPropName(PROPID propID, BSTR name)
}
if (name)
return name;
- return L"?";
+ wchar_t s[32];
+ ConvertUInt64ToString(propID, s);
+ return s;
}
HRESULT CFieldPrinter::Init(IInArchive *archive)
@@ -232,7 +235,7 @@ void CFieldPrinter::PrintTitle()
{
const CFieldInfo &fieldInfo = _fields[i];
PrintSpaces(fieldInfo.PrefixSpacesWidth);
- PrintString(fieldInfo.TitleAdjustment,
+ PrintString(fieldInfo.TitleAdjustment,
((fieldInfo.PropID == kpidPath) ? 0: fieldInfo.Width), fieldInfo.Name);
}
}
@@ -255,16 +258,16 @@ BOOL IsFileTimeZero(CONST FILETIME *lpFileTime)
}
static const char *kEmptyTimeString = " ";
-void PrintTime(const NCOM::CPropVariant &propVariant)
+void PrintTime(const NCOM::CPropVariant &prop)
{
- if (propVariant.vt != VT_FILETIME)
+ if (prop.vt != VT_FILETIME)
throw "incorrect item";
- if (IsFileTimeZero(&propVariant.filetime))
+ if (IsFileTimeZero(&prop.filetime))
g_StdOut << kEmptyTimeString;
else
{
FILETIME localFileTime;
- if (!FileTimeToLocalFileTime(&propVariant.filetime, &localFileTime))
+ if (!FileTimeToLocalFileTime(&prop.filetime, &localFileTime))
throw "FileTimeToLocalFileTime error";
char s[32];
if (ConvertFileTimeToString(localFileTime, s, true, true))
@@ -274,9 +277,8 @@ void PrintTime(const NCOM::CPropVariant &propVariant)
}
}
-HRESULT CFieldPrinter::PrintItemInfo(IInArchive *archive,
- const UString &defaultItemName,
- const NWindows::NFile::NFind::CFileInfoW &archiveFileInfo,
+HRESULT CFieldPrinter::PrintItemInfo(IInArchive *archive,
+ const UString &defaultItemName,
UInt32 index,
bool techMode)
{
@@ -294,32 +296,27 @@ HRESULT CFieldPrinter::PrintItemInfo(IInArchive *archive,
if (!techMode)
PrintSpaces(fieldInfo.PrefixSpacesWidth);
- NCOM::CPropVariant propVariant;
+ NCOM::CPropVariant prop;
if (fieldInfo.PropID == kpidPath)
{
UString s;
RINOK(GetArchiveItemPath(archive, index, defaultItemName, s));
- propVariant = s;
+ prop = s;
}
else
{
- RINOK(archive->GetProperty(index, fieldInfo.PropID, &propVariant));
+ RINOK(archive->GetProperty(index, fieldInfo.PropID, &prop));
}
if (techMode)
{
g_StdOut << fieldInfo.Name << " = ";
}
int width = (fieldInfo.PropID == kpidPath) ? 0: fieldInfo.Width;
- if (propVariant.vt == VT_EMPTY)
+ if (prop.vt == VT_EMPTY)
{
switch(fieldInfo.PropID)
{
- case kpidPath:
- propVariant = defaultItemName;
- break;
- case kpidLastWriteTime:
- propVariant = archiveFileInfo.LastWriteTime;
- break;
+ case kpidPath: prop = defaultItemName; break;
default:
if (techMode)
g_StdOut << endl;
@@ -328,33 +325,33 @@ HRESULT CFieldPrinter::PrintItemInfo(IInArchive *archive,
continue;
}
}
- if (fieldInfo.PropID == kpidLastWriteTime)
+ if (fieldInfo.PropID == kpidMTime)
{
- PrintTime(propVariant);
+ PrintTime(prop);
}
- else if (fieldInfo.PropID == kpidAttributes)
+ else if (fieldInfo.PropID == kpidAttrib)
{
- if (propVariant.vt != VT_UI4)
+ if (prop.vt != VT_UI4)
throw "incorrect item";
- UInt32 attributes = propVariant.ulVal;
+ UInt32 attributes = prop.ulVal;
bool isFolder;
RINOK(IsArchiveItemFolder(archive, index, isFolder));
char s[8];
- GetAttributesString(attributes, isFolder, s);
+ GetAttribString(attributes, isFolder, s);
g_StdOut << s;
}
- else if (propVariant.vt == VT_BSTR)
+ else if (prop.vt == VT_BSTR)
{
if (techMode)
- g_StdOut << propVariant.bstrVal;
+ g_StdOut << prop.bstrVal;
else
- PrintString(fieldInfo.TextAdjustment, width, propVariant.bstrVal);
+ PrintString(fieldInfo.TextAdjustment, width, prop.bstrVal);
}
else
{
- UString s = ConvertPropertyToString(propVariant, fieldInfo.PropID);
- s.Replace(wchar_t(0xA), L' ');
- s.Replace(wchar_t(0xD), L' ');
+ UString s = ConvertPropertyToString(prop, fieldInfo.PropID);
+ s.Replace(wchar_t(0xA), L' ');
+ s.Replace(wchar_t(0xD), L' ');
if (techMode)
g_StdOut << s;
@@ -376,17 +373,17 @@ void PrintNumberString(EAdjustment adjustment, int width, const UInt64 *value)
}
-HRESULT CFieldPrinter::PrintSummaryInfo(UInt64 numFiles, UInt64 numDirs,
+HRESULT CFieldPrinter::PrintSummaryInfo(UInt64 numFiles, UInt64 numDirs,
const UInt64 *size, const UInt64 *compressedSize)
{
for (int i = 0; i < _fields.Size(); i++)
{
const CFieldInfo &fieldInfo = _fields[i];
PrintSpaces(fieldInfo.PrefixSpacesWidth);
- NCOM::CPropVariant propVariant;
+ NCOM::CPropVariant prop;
if (fieldInfo.PropID == kpidSize)
PrintNumberString(fieldInfo.TextAdjustment, fieldInfo.Width, size);
- else if (fieldInfo.PropID == kpidPackedSize)
+ else if (fieldInfo.PropID == kpidPackSize)
PrintNumberString(fieldInfo.TextAdjustment, fieldInfo.Width, compressedSize);
else if (fieldInfo.PropID == kpidPath)
{
@@ -402,7 +399,7 @@ HRESULT CFieldPrinter::PrintSummaryInfo(UInt64 numFiles, UInt64 numDirs,
temp += kDirsMessage;
PrintString(fieldInfo.TextAdjustment, 0, temp);
}
- else
+ else
PrintString(fieldInfo.TextAdjustment, fieldInfo.Width, L"");
}
return S_OK;
@@ -410,20 +407,23 @@ HRESULT CFieldPrinter::PrintSummaryInfo(UInt64 numFiles, UInt64 numDirs,
bool GetUInt64Value(IInArchive *archive, UInt32 index, PROPID propID, UInt64 &value)
{
- NCOM::CPropVariant propVariant;
- if (archive->GetProperty(index, propID, &propVariant) != S_OK)
+ NCOM::CPropVariant prop;
+ if (archive->GetProperty(index, propID, &prop) != S_OK)
throw "GetPropertyValue error";
- if (propVariant.vt == VT_EMPTY)
+ if (prop.vt == VT_EMPTY)
return false;
- value = ConvertPropVariantToUInt64(propVariant);
+ value = ConvertPropVariantToUInt64(prop);
return true;
}
-HRESULT ListArchives(
- CCodecs *codecs,
+HRESULT ListArchives(CCodecs *codecs, const CIntVector &formatIndices,
UStringVector &archivePaths, UStringVector &archivePathsFull,
const NWildcard::CCensorNode &wildcardCensor,
- bool enableHeaders, bool techMode, bool &passwordEnabled, UString &password, UInt64 &numErrors)
+ bool enableHeaders, bool techMode,
+ #ifndef _NO_CRYPTO
+ bool &passwordEnabled, UString &password,
+ #endif
+ UInt64 &numErrors)
{
numErrors = 0;
CFieldPrinter fieldPrinter;
@@ -435,14 +435,8 @@ HRESULT ListArchives(
for (int i = 0; i < archivePaths.Size(); i++)
{
const UString &archiveName = archivePaths[i];
- NFile::NFind::CFileInfoW archiveFileInfo;
- if (!NFile::NFind::FindFile(archiveName, archiveFileInfo) || archiveFileInfo.IsDirectory())
- {
- g_StdOut << endl << "Error: " << archiveName << " is not archive" << endl;
- numErrors++;
- continue;
- }
- if (archiveFileInfo.IsDirectory())
+ NFile::NFind::CFileInfoW fi;
+ if (!NFile::NFind::FindFile(archiveName, fi) || fi.IsDir())
{
g_StdOut << endl << "Error: " << archiveName << " is not file" << endl;
numErrors++;
@@ -453,13 +447,27 @@ HRESULT ListArchives(
COpenCallbackConsole openCallback;
openCallback.OutStream = &g_StdOut;
+
+ #ifndef _NO_CRYPTO
+
openCallback.PasswordIsDefined = passwordEnabled;
openCallback.Password = password;
- HRESULT result = MyOpenArchive(codecs, archiveName, archiveLink, &openCallback);
+ #endif
+
+ HRESULT result = MyOpenArchive(codecs, formatIndices, archiveName, archiveLink, &openCallback);
if (result != S_OK)
{
- g_StdOut << endl << "Error: " << archiveName << " is not supported archive" << endl;
+ if (result == E_ABORT)
+ return result;
+ g_StdOut << endl << "Error: " << archiveName << ": ";
+ if (result == S_FALSE)
+ g_StdOut << "is not supported archive";
+ else if (result == E_OUTOFMEMORY)
+ g_StdOut << "Can't allocate required memory";
+ else
+ g_StdOut << NError::MyFormatMessage(result);
+ g_StdOut << endl;
numErrors++;
continue;
}
@@ -534,14 +542,14 @@ HRESULT ListArchives(
if (!wildcardCensor.CheckPath(filePath, !isFolder))
continue;
- fieldPrinter.PrintItemInfo(archive, defaultItemName, archiveFileInfo, i, techMode);
+ fieldPrinter.PrintItemInfo(archive, defaultItemName, i, techMode);
UInt64 packSize, unpackSize;
if (!GetUInt64Value(archive, i, kpidSize, unpackSize))
unpackSize = 0;
else
totalUnPackSizePointer = &totalUnPackSize;
- if (!GetUInt64Value(archive, i, kpidPackedSize, packSize))
+ if (!GetUInt64Value(archive, i, kpidPackSize, packSize))
packSize = 0;
else
totalPackSizePointer = &totalPackSize;
diff --git a/CPP/7zip/UI/Console/List.h b/CPP/7zip/UI/Console/List.h
index 6e9fa240..bb4287e6 100755
--- a/CPP/7zip/UI/Console/List.h
+++ b/CPP/7zip/UI/Console/List.h
@@ -6,11 +6,14 @@
#include "Common/Wildcard.h"
#include "../Common/LoadCodecs.h"
-HRESULT ListArchives(
- CCodecs *codecs,
+HRESULT ListArchives(CCodecs *codecs, const CIntVector &formatIndices,
UStringVector &archivePaths, UStringVector &archivePathsFull,
const NWildcard::CCensorNode &wildcardCensor,
- bool enableHeaders, bool techMode, bool &passwordEnabled, UString &password, UInt64 &errors);
+ bool enableHeaders, bool techMode,
+ #ifndef _NO_CRYPTO
+ bool &passwordEnabled, UString &password,
+ #endif
+ UInt64 &errors);
#endif
diff --git a/CPP/7zip/UI/Console/Main.cpp b/CPP/7zip/UI/Console/Main.cpp
index 265d2212..87d48e95 100755
--- a/CPP/7zip/UI/Console/Main.cpp
+++ b/CPP/7zip/UI/Console/Main.cpp
@@ -40,8 +40,8 @@
#include "../../MyVersion.h"
#if defined( _WIN32) && defined( _7ZIP_LARGE_PAGES)
-extern "C"
-{
+extern "C"
+{
#include "../../../../C/Alloc.h"
}
#endif
@@ -64,7 +64,7 @@ static const char *kCopyrightString = "\n7-Zip"
" " MY_VERSION_COPYRIGHT_DATE "\n";
-static const char *kHelpString =
+static const char *kHelpString =
"\nUsage: 7z"
#ifdef _NO_CRYPTO
"r"
@@ -96,7 +96,9 @@ static const char *kHelpString =
" -i[r[-|0]]{@listfile|!wildcard}: Include filenames\n"
" -m{Parameters}: set compression Method\n"
" -o{Directory}: set Output directory\n"
+ #ifndef _NO_CRYPTO
" -p{Password}: set Password\n"
+ #endif
" -r[-|0]: Recurse subdirectories\n"
" -scs{UTF-8 | WIN | DOS}: set charset for list files\n"
" -sfx[{name}]: Create SFX archive\n"
@@ -117,6 +119,7 @@ static const char *kHelpString =
static const char *kEverythingIsOk = "Everything is Ok";
static const char *kUserErrorMessage = "Incorrect command line"; // NExitCode::kUserError
+static const char *kNoFormats = "7-Zip cannot find the code that works with archives.";
static const wchar_t *kDefaultSfxModule = L"7zCon.sfx";
@@ -148,7 +151,7 @@ static void ShowCopyrightAndHelp(CStdOutStream &s, bool needHelp)
{
s << kCopyrightString;
// s << "# CPUs: " << (UInt64)NWindows::NSystem::GetNumberOfProcessors() << "\n";
- if (needHelp)
+ if (needHelp)
s << kHelpString;
}
@@ -175,18 +178,20 @@ static inline char GetHex(Byte value)
return (char)((value < 10) ? ('0' + value) : ('A' + (value - 10)));
}
+const char *kUnsupportedArcTypeMessage = "Unsupported archive type";
+
int Main2(
- #ifndef _WIN32
+ #ifndef _WIN32
int numArguments, const char *arguments[]
#endif
)
{
- #ifdef _WIN32
+ #ifdef _WIN32
SetFileApisToOEM();
#endif
UStringVector commandStrings;
- #ifdef _WIN32
+ #ifdef _WIN32
NCommandLineParser::SplitCommandLine(GetCommandLineW(), commandStrings);
#else
GetArguments(numArguments, arguments, commandStrings);
@@ -240,6 +245,17 @@ int Main2(
throw CSystemException(result);
bool isExtractGroupCommand = options.Command.IsFromExtractGroup();
+
+ if (codecs->Formats.Size() == 0 &&
+ (isExtractGroupCommand ||
+ options.Command.CommandType == NCommandType::kList ||
+ options.Command.IsFromUpdateGroup()))
+ throw kNoFormats;
+
+ CIntVector formatIndices;
+ if (!codecs->FindFormatForArchiveType(options.ArcType, formatIndices))
+ throw kUnsupportedArcTypeMessage;
+
if (options.Command.CommandType == NCommandType::kInfo)
{
stdStream << endl << "Formats:" << endl;
@@ -373,14 +389,21 @@ int Main2(
CMyComPtr<IFolderArchiveExtractCallback> extractCallback = ecs;
ecs->OutStream = &stdStream;
+
+ #ifndef _NO_CRYPTO
ecs->PasswordIsDefined = options.PasswordEnabled;
ecs->Password = options.Password;
+ #endif
+
ecs->Init();
COpenCallbackConsole openCallback;
openCallback.OutStream = &stdStream;
+
+ #ifndef _NO_CRYPTO
openCallback.PasswordIsDefined = options.PasswordEnabled;
openCallback.Password = options.Password;
+ #endif
CExtractOptions eo;
eo.StdOutMode = options.StdOutMode;
@@ -396,9 +419,10 @@ int Main2(
CDecompressStat stat;
HRESULT result = DecompressArchives(
codecs,
- options.ArchivePathsSorted,
+ formatIndices,
+ options.ArchivePathsSorted,
options.ArchivePathsFullSorted,
- options.WildcardCensor.Pairs.Front().Head,
+ options.WildcardCensor.Pairs.Front().Head,
eo, &openCallback, ecs, errorMessage, stat);
if (!errorMessage.IsEmpty())
{
@@ -430,7 +454,7 @@ int Main2(
stdStream << "Folders: " << stat.NumFolders << endl;
if (stat.NumFiles != 1 || stat.NumFolders != 0)
stdStream << "Files: " << stat.NumFiles << endl;
- stdStream
+ stdStream
<< "Size: " << stat.UnpackSize << endl
<< "Compressed: " << stat.PackSize << endl;
}
@@ -439,13 +463,17 @@ int Main2(
UInt64 numErrors = 0;
HRESULT result = ListArchives(
codecs,
- options.ArchivePathsSorted,
+ formatIndices,
+ options.ArchivePathsSorted,
options.ArchivePathsFullSorted,
- options.WildcardCensor.Pairs.Front().Head,
- options.EnableHeaders,
+ options.WildcardCensor.Pairs.Front().Head,
+ options.EnableHeaders,
options.TechMode,
- options.PasswordEnabled,
- options.Password, numErrors);
+ #ifndef _NO_CRYPTO
+ options.PasswordEnabled,
+ options.Password,
+ #endif
+ numErrors);
if (numErrors > 0)
{
g_StdOut << endl << "Errors: " << numErrors;
@@ -463,28 +491,33 @@ int Main2(
if (uo.SfxMode && uo.SfxModule.IsEmpty())
uo.SfxModule = kDefaultSfxModule;
- bool passwordIsDefined =
- options.PasswordEnabled && !options.Password.IsEmpty();
-
COpenCallbackConsole openCallback;
openCallback.OutStream = &stdStream;
+
+ #ifndef _NO_CRYPTO
+ bool passwordIsDefined =
+ options.PasswordEnabled && !options.Password.IsEmpty();
openCallback.PasswordIsDefined = passwordIsDefined;
openCallback.Password = options.Password;
+ #endif
CUpdateCallbackConsole callback;
callback.EnablePercents = options.EnablePercents;
+
+ #ifndef _NO_CRYPTO
callback.PasswordIsDefined = passwordIsDefined;
callback.AskPassword = options.PasswordEnabled && options.Password.IsEmpty();
callback.Password = options.Password;
+ #endif
callback.StdOutMode = uo.StdOutMode;
callback.Init(&stdStream);
CUpdateErrorInfo errorInfo;
- if (!uo.Init(codecs, options.ArchiveName, options.ArcType))
- throw "Unsupported archive type";
- HRESULT result = UpdateArchive(codecs,
- options.WildcardCensor, uo,
+ if (!uo.Init(codecs, formatIndices, options.ArchiveName))
+ throw kUnsupportedArcTypeMessage;
+ HRESULT result = UpdateArchive(codecs,
+ options.WildcardCensor, uo,
errorInfo, &openCallback, &callback);
int exitCode = NExitCode::kSuccess;
@@ -557,7 +590,7 @@ int Main2(
}
return exitCode;
}
- else
+ else
PrintHelpAndExit(stdStream);
return 0;
}
diff --git a/CPP/7zip/UI/Console/MainAr.cpp b/CPP/7zip/UI/Console/MainAr.cpp
index 6cc5cf9d..02918d79 100755
--- a/CPP/7zip/UI/Console/MainAr.cpp
+++ b/CPP/7zip/UI/Console/MainAr.cpp
@@ -28,7 +28,7 @@ static inline bool IsItWindowsNT()
{
OSVERSIONINFO versionInfo;
versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
- if (!::GetVersionEx(&versionInfo))
+ if (!::GetVersionEx(&versionInfo))
return false;
return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
}
@@ -36,7 +36,7 @@ static inline bool IsItWindowsNT()
#endif
extern int Main2(
- #ifndef _WIN32
+ #ifndef _WIN32
int numArguments, const char *arguments[]
#endif
);
@@ -50,7 +50,7 @@ static const char *kInternalExceptionMessage = "\n\nInternal Error #";
int MY_CDECL main
(
-#ifndef _WIN32
+#ifndef _WIN32
int numArguments, const char *arguments[]
#endif
)
@@ -62,7 +62,7 @@ int numArguments, const char *arguments[]
#ifndef _WIN64
if (!IsItWindowsNT())
{
- (*g_StdStream) << "This program requires Windows NT/2000/XP/2003/Vista";
+ (*g_StdStream) << "This program requires Windows NT/2000/2003/2008/XP/Vista";
return NExitCode::kFatalError;
}
#endif
@@ -112,7 +112,7 @@ int numArguments, const char *arguments[]
}
UString message;
NError::MyFormatMessage(systemError.ErrorCode, message);
- (*g_StdStream) << endl << endl << "System error:" << endl <<
+ (*g_StdStream) << endl << endl << "System error:" << endl <<
message << endl;
return (NExitCode::kFatalError);
}
diff --git a/CPP/7zip/UI/Console/OpenCallbackConsole.cpp b/CPP/7zip/UI/Console/OpenCallbackConsole.cpp
index 06ff165f..892123d4 100755
--- a/CPP/7zip/UI/Console/OpenCallbackConsole.cpp
+++ b/CPP/7zip/UI/Console/OpenCallbackConsole.cpp
@@ -7,30 +7,32 @@
#include "ConsoleClose.h"
#include "UserInputUtils.h"
-HRESULT COpenCallbackConsole::CheckBreak()
+HRESULT COpenCallbackConsole::Open_CheckBreak()
{
if (NConsoleClose::TestBreakSignal())
return E_ABORT;
return S_OK;
}
-HRESULT COpenCallbackConsole::SetTotal(const UInt64 *, const UInt64 *)
+HRESULT COpenCallbackConsole::Open_SetTotal(const UInt64 *, const UInt64 *)
{
- return CheckBreak();
+ return Open_CheckBreak();
}
-HRESULT COpenCallbackConsole::SetCompleted(const UInt64 *, const UInt64 *)
+HRESULT COpenCallbackConsole::Open_SetCompleted(const UInt64 *, const UInt64 *)
{
- return CheckBreak();
+ return Open_CheckBreak();
}
-HRESULT COpenCallbackConsole::CryptoGetTextPassword(BSTR *password)
+#ifndef _NO_CRYPTO
+
+HRESULT COpenCallbackConsole::Open_CryptoGetTextPassword(BSTR *password)
{
PasswordWasAsked = true;
- RINOK(CheckBreak());
+ RINOK(Open_CheckBreak());
if (!PasswordIsDefined)
{
- Password = GetPassword(OutStream);
+ Password = GetPassword(OutStream);
PasswordIsDefined = true;
}
CMyComBSTR temp(Password);
@@ -38,21 +40,21 @@ HRESULT COpenCallbackConsole::CryptoGetTextPassword(BSTR *password)
return S_OK;
}
-HRESULT COpenCallbackConsole::GetPasswordIfAny(UString &password)
+HRESULT COpenCallbackConsole::Open_GetPasswordIfAny(UString &password)
{
if (PasswordIsDefined)
password = Password;
return S_OK;
}
-bool COpenCallbackConsole::WasPasswordAsked()
+bool COpenCallbackConsole::Open_WasPasswordAsked()
{
return PasswordWasAsked;
}
-void COpenCallbackConsole::ClearPasswordWasAskedFlag()
+void COpenCallbackConsole::Open_ClearPasswordWasAskedFlag()
{
PasswordWasAsked = false;
}
-
+#endif
diff --git a/CPP/7zip/UI/Console/OpenCallbackConsole.h b/CPP/7zip/UI/Console/OpenCallbackConsole.h
index db0e9bd8..c002e6a7 100755
--- a/CPP/7zip/UI/Console/OpenCallbackConsole.h
+++ b/CPP/7zip/UI/Console/OpenCallbackConsole.h
@@ -9,19 +9,16 @@
class COpenCallbackConsole: public IOpenCallbackUI
{
public:
- HRESULT CheckBreak();
- HRESULT SetTotal(const UInt64 *files, const UInt64 *bytes);
- HRESULT SetCompleted(const UInt64 *files, const UInt64 *bytes);
- HRESULT CryptoGetTextPassword(BSTR *password);
- HRESULT GetPasswordIfAny(UString &password);
- bool WasPasswordAsked();
- void ClearPasswordWasAskedFlag();
+ INTERFACE_IOpenCallbackUI(;)
CStdOutStream *OutStream;
+
+ #ifndef _NO_CRYPTO
bool PasswordIsDefined;
- UString Password;
bool PasswordWasAsked;
+ UString Password;
COpenCallbackConsole(): PasswordIsDefined(false), PasswordWasAsked(false) {}
+ #endif
};
#endif
diff --git a/CPP/7zip/UI/Console/PercentPrinter.cpp b/CPP/7zip/UI/Console/PercentPrinter.cpp
index 47aafd73..28452b17 100755
--- a/CPP/7zip/UI/Console/PercentPrinter.cpp
+++ b/CPP/7zip/UI/Console/PercentPrinter.cpp
@@ -65,25 +65,25 @@ void CPercentPrinter::RePrintRatio()
int i;
if (m_NumExtraChars == 0)
{
- for (i = 0; i < extraSize; i++)
+ for (i = 0; i < extraSize; i++)
*p++ = ' ';
m_NumExtraChars = extraSize;
}
- for (i = 0; i < m_NumExtraChars; i++)
+ for (i = 0; i < m_NumExtraChars; i++)
*p++ = '\b';
m_NumExtraChars = extraSize;
for (; size < m_NumExtraChars; size++)
*p++ = ' ';
MyStringCopy(p, s);
(*OutStream) << fullString;
- OutStream->Flush();
+ OutStream->Flush();
m_PrevValue = m_CurValue;
}
void CPercentPrinter::PrintRatio()
{
- if (m_CurValue < m_PrevValue + m_MinStepSize &&
+ if (m_CurValue < m_PrevValue + m_MinStepSize &&
m_CurValue + m_MinStepSize > m_PrevValue && m_NumExtraChars != 0)
return;
RePrintRatio();
diff --git a/CPP/7zip/UI/Console/PercentPrinter.h b/CPP/7zip/UI/Console/PercentPrinter.h
index e8b40916..97f2e6ad 100755
--- a/CPP/7zip/UI/Console/PercentPrinter.h
+++ b/CPP/7zip/UI/Console/PercentPrinter.h
@@ -16,7 +16,7 @@ class CPercentPrinter
public:
CStdOutStream *OutStream;
- CPercentPrinter(UInt64 minStepSize = 1): m_MinStepSize(minStepSize),
+ CPercentPrinter(UInt64 minStepSize = 1): m_MinStepSize(minStepSize),
m_PrevValue(0), m_CurValue(0), m_Total(1), m_NumExtraChars(0) {}
void SetTotal(UInt64 total) { m_Total = total; m_PrevValue = 0; }
void SetRatio(UInt64 doneValue) { m_CurValue = doneValue; }
diff --git a/CPP/7zip/UI/Console/StdAfx.h b/CPP/7zip/UI/Console/StdAfx.h
index 8531cc9c..2e4be10b 100755
--- a/CPP/7zip/UI/Console/StdAfx.h
+++ b/CPP/7zip/UI/Console/StdAfx.h
@@ -6,4 +6,4 @@
#include "../../../Common/MyWindows.h"
#include "../../../Common/NewHandler.h"
-#endif
+#endif
diff --git a/CPP/7zip/UI/Console/UpdateCallbackConsole.cpp b/CPP/7zip/UI/Console/UpdateCallbackConsole.cpp
index dd4e2b9e..f8621567 100755
--- a/CPP/7zip/UI/Console/UpdateCallbackConsole.cpp
+++ b/CPP/7zip/UI/Console/UpdateCallbackConsole.cpp
@@ -42,6 +42,11 @@ HRESULT CUpdateCallbackConsole::StartScanning()
return S_OK;
}
+HRESULT CUpdateCallbackConsole::ScanProgress(UInt64 /* numFolders */, UInt64 /* numFiles */, const wchar_t * /* path */)
+{
+ return CheckBreak();
+}
+
HRESULT CUpdateCallbackConsole::CanNotFindError(const wchar_t *name, DWORD systemError)
{
CantFindFiles.Add(name);
@@ -71,7 +76,7 @@ HRESULT CUpdateCallbackConsole::StartArchive(const wchar_t *name, bool updating)
if(updating)
(*OutStream) << kUpdatingArchiveMessage;
else
- (*OutStream) << kCreatingArchiveMessage;
+ (*OutStream) << kCreatingArchiveMessage;
if (name != 0)
(*OutStream) << name;
else
@@ -186,21 +191,32 @@ HRESULT CUpdateCallbackConsole::SetOperationResult(Int32 )
{
m_NeedBeClosed = true;
m_NeedNewLine = true;
- return S_OK;
+ return S_OK;
}
HRESULT CUpdateCallbackConsole::CryptoGetTextPassword2(Int32 *passwordIsDefined, BSTR *password)
{
- if (!PasswordIsDefined)
+ #ifdef _NO_CRYPTO
+
+ *passwordIsDefined = false;
+ CMyComBSTR tempName(L"");
+ *password = tempName.Detach();
+
+ #else
+
+ if (!PasswordIsDefined)
{
if (AskPassword)
{
- Password = GetPassword(OutStream);
+ Password = GetPassword(OutStream);
PasswordIsDefined = true;
}
}
*passwordIsDefined = BoolToInt(PasswordIsDefined);
CMyComBSTR tempName(Password);
*password = tempName.Detach();
+
+ #endif
+
return S_OK;
}
diff --git a/CPP/7zip/UI/Console/UpdateCallbackConsole.h b/CPP/7zip/UI/Console/UpdateCallbackConsole.h
index d04e1ad4..da8d8cc2 100755
--- a/CPP/7zip/UI/Console/UpdateCallbackConsole.h
+++ b/CPP/7zip/UI/Console/UpdateCallbackConsole.h
@@ -21,15 +21,18 @@ public:
bool EnablePercents;
bool StdOutMode;
+ #ifndef _NO_CRYPTO
bool PasswordIsDefined;
UString Password;
bool AskPassword;
+ #endif
-
- CUpdateCallbackConsole():
+ CUpdateCallbackConsole():
m_PercentPrinter(1 << 16),
+ #ifndef _NO_CRYPTO
PasswordIsDefined(false),
AskPassword(false),
+ #endif
StdOutMode(false),
EnablePercents(true),
m_WarningsMode(false)
diff --git a/CPP/7zip/UI/Console/UserInputUtils.cpp b/CPP/7zip/UI/Console/UserInputUtils.cpp
index 164af99c..8a202c2c 100755
--- a/CPP/7zip/UI/Console/UserInputUtils.cpp
+++ b/CPP/7zip/UI/Console/UserInputUtils.cpp
@@ -15,7 +15,7 @@ static const char kAutoRename = 'U';
static const char kQuit = 'Q';
static const char *kFirstQuestionMessage = "?\n";
-static const char *kHelpQuestionMessage =
+static const char *kHelpQuestionMessage =
"(Y)es / (N)o / (A)lways / (S)kip all / A(u)to rename / (Q)uit? ";
// return true if pressed Quite;
@@ -54,5 +54,5 @@ UString GetPassword(CStdOutStream *outStream)
(*outStream) << "\nEnter password:";
outStream->Flush();
AString oemPassword = g_StdIn.ScanStringUntilNewLine();
- return MultiByteToUnicodeString(oemPassword, CP_OEMCP);
+ return MultiByteToUnicodeString(oemPassword, CP_OEMCP);
}
diff --git a/CPP/7zip/UI/Console/afxres.h b/CPP/7zip/UI/Console/afxres.h
deleted file mode 100755
index c2fadd4a..00000000
--- a/CPP/7zip/UI/Console/afxres.h
+++ /dev/null
@@ -1 +0,0 @@
-#include <winresrc.h>
diff --git a/CPP/7zip/UI/Console/makefile b/CPP/7zip/UI/Console/makefile
index dc347889..1fde7c66 100755
--- a/CPP/7zip/UI/Console/makefile
+++ b/CPP/7zip/UI/Console/makefile
@@ -47,6 +47,7 @@ WIN_OBJS = \
$O\PropVariantConversions.obj \
$O\Registry.obj \
$O\System.obj \
+ $O\Time.obj \
7ZIP_COMMON_OBJS = \
$O\FilePathAutoRename.obj \
diff --git a/CPP/7zip/UI/Explorer/ContextMenu.cpp b/CPP/7zip/UI/Explorer/ContextMenu.cpp
index 5a736eb1..0b16bc89 100755
--- a/CPP/7zip/UI/Explorer/ContextMenu.cpp
+++ b/CPP/7zip/UI/Explorer/ContextMenu.cpp
@@ -25,7 +25,7 @@
#include "../Common/ZipRegistry.h"
#include "../Common/ArchiveName.h"
-#ifdef LANG
+#ifdef LANG
#include "../FileManager/LangUtils.h"
#endif
@@ -70,7 +70,7 @@ HRESULT CZipContextMenu::GetFileNames(LPDATAOBJECT dataObject, UStringVector &fi
return S_OK;
}
-STDMETHODIMP CZipContextMenu::Initialize(LPCITEMIDLIST pidlFolder,
+STDMETHODIMP CZipContextMenu::Initialize(LPCITEMIDLIST pidlFolder,
LPDATAOBJECT dataObject, HKEY /* hkeyProgID */)
{
// OutputDebugString(TEXT("::Initialize\r\n"));
@@ -97,7 +97,7 @@ STDMETHODIMP CZipContextMenu::Initialize(LPCITEMIDLIST pidlFolder,
return GetFileNames(dataObject, _fileNames);
}
-STDMETHODIMP CZipContextMenu::InitContextMenu(const wchar_t * /* folder */,
+STDMETHODIMP CZipContextMenu::InitContextMenu(const wchar_t * /* folder */,
const wchar_t **names, UINT32 numFiles)
{
_fileNames.Clear();
@@ -135,94 +135,94 @@ struct CContextMenuCommand
UINT32 LangID;
};
-static CContextMenuCommand g_Commands[] =
+static CContextMenuCommand g_Commands[] =
{
- {
+ {
NContextMenuFlags::kOpen,
- CZipContextMenu::kOpen,
- L"Open",
- IDS_CONTEXT_OPEN,
- IDS_CONTEXT_OPEN_HELP,
+ CZipContextMenu::kOpen,
+ L"Open",
+ IDS_CONTEXT_OPEN,
+ IDS_CONTEXT_OPEN_HELP,
0x02000103
},
- {
- NContextMenuFlags::kExtract,
- CZipContextMenu::kExtract,
- L"Extract",
- IDS_CONTEXT_EXTRACT,
- IDS_CONTEXT_EXTRACT_HELP,
- 0x02000105
+ {
+ NContextMenuFlags::kExtract,
+ CZipContextMenu::kExtract,
+ L"Extract",
+ IDS_CONTEXT_EXTRACT,
+ IDS_CONTEXT_EXTRACT_HELP,
+ 0x02000105
},
- {
- NContextMenuFlags::kExtractHere,
- CZipContextMenu::kExtractHere,
- L"ExtractHere",
- IDS_CONTEXT_EXTRACT_HERE,
- IDS_CONTEXT_EXTRACT_HERE_HELP,
+ {
+ NContextMenuFlags::kExtractHere,
+ CZipContextMenu::kExtractHere,
+ L"ExtractHere",
+ IDS_CONTEXT_EXTRACT_HERE,
+ IDS_CONTEXT_EXTRACT_HERE_HELP,
0x0200010B
},
- {
- NContextMenuFlags::kExtractTo,
- CZipContextMenu::kExtractTo,
- L"ExtractTo",
- IDS_CONTEXT_EXTRACT_TO,
- IDS_CONTEXT_EXTRACT_TO_HELP,
+ {
+ NContextMenuFlags::kExtractTo,
+ CZipContextMenu::kExtractTo,
+ L"ExtractTo",
+ IDS_CONTEXT_EXTRACT_TO,
+ IDS_CONTEXT_EXTRACT_TO_HELP,
0x0200010D
},
- {
- NContextMenuFlags::kTest,
- CZipContextMenu::kTest,
- L"Test",
- IDS_CONTEXT_TEST,
- IDS_CONTEXT_TEST_HELP,
+ {
+ NContextMenuFlags::kTest,
+ CZipContextMenu::kTest,
+ L"Test",
+ IDS_CONTEXT_TEST,
+ IDS_CONTEXT_TEST_HELP,
0x02000109
},
- {
- NContextMenuFlags::kCompress,
- CZipContextMenu::kCompress,
- L"Compress",
- IDS_CONTEXT_COMPRESS,
- IDS_CONTEXT_COMPRESS_HELP,
- 0x02000107,
+ {
+ NContextMenuFlags::kCompress,
+ CZipContextMenu::kCompress,
+ L"Compress",
+ IDS_CONTEXT_COMPRESS,
+ IDS_CONTEXT_COMPRESS_HELP,
+ 0x02000107,
},
- {
- NContextMenuFlags::kCompressEmail,
- CZipContextMenu::kCompressEmail,
- L"CompressEmail",
- IDS_CONTEXT_COMPRESS_EMAIL,
- IDS_CONTEXT_COMPRESS_EMAIL_HELP,
+ {
+ NContextMenuFlags::kCompressEmail,
+ CZipContextMenu::kCompressEmail,
+ L"CompressEmail",
+ IDS_CONTEXT_COMPRESS_EMAIL,
+ IDS_CONTEXT_COMPRESS_EMAIL_HELP,
0x02000111
},
- {
- NContextMenuFlags::kCompressTo7z,
- CZipContextMenu::kCompressTo7z,
- L"CompressTo7z",
- IDS_CONTEXT_COMPRESS_TO,
- IDS_CONTEXT_COMPRESS_TO_HELP,
+ {
+ NContextMenuFlags::kCompressTo7z,
+ CZipContextMenu::kCompressTo7z,
+ L"CompressTo7z",
+ IDS_CONTEXT_COMPRESS_TO,
+ IDS_CONTEXT_COMPRESS_TO_HELP,
0x0200010F
},
- {
- NContextMenuFlags::kCompressTo7zEmail,
- CZipContextMenu::kCompressTo7zEmail,
- L"CompressTo7zEmail",
- IDS_CONTEXT_COMPRESS_TO_EMAIL,
- IDS_CONTEXT_COMPRESS_TO_EMAIL_HELP,
+ {
+ NContextMenuFlags::kCompressTo7zEmail,
+ CZipContextMenu::kCompressTo7zEmail,
+ L"CompressTo7zEmail",
+ IDS_CONTEXT_COMPRESS_TO_EMAIL,
+ IDS_CONTEXT_COMPRESS_TO_EMAIL_HELP,
0x02000113
},
- {
- NContextMenuFlags::kCompressToZip,
- CZipContextMenu::kCompressToZip,
- L"CompressToZip",
- IDS_CONTEXT_COMPRESS_TO,
- IDS_CONTEXT_COMPRESS_TO_HELP,
+ {
+ NContextMenuFlags::kCompressToZip,
+ CZipContextMenu::kCompressToZip,
+ L"CompressToZip",
+ IDS_CONTEXT_COMPRESS_TO,
+ IDS_CONTEXT_COMPRESS_TO_HELP,
0x0200010F
},
- {
- NContextMenuFlags::kCompressToZipEmail,
- CZipContextMenu::kCompressToZipEmail,
- L"CompressToZipEmail",
- IDS_CONTEXT_COMPRESS_TO_EMAIL,
- IDS_CONTEXT_COMPRESS_TO_EMAIL_HELP,
+ {
+ NContextMenuFlags::kCompressToZipEmail,
+ CZipContextMenu::kCompressToZipEmail,
+ L"CompressToZipEmail",
+ IDS_CONTEXT_COMPRESS_TO_EMAIL,
+ IDS_CONTEXT_COMPRESS_TO_EMAIL_HELP,
0x02000113
}
};
@@ -235,7 +235,7 @@ int FindCommand(CZipContextMenu::ECommandInternalID &id)
return -1;
}
-void CZipContextMenu::FillCommand(ECommandInternalID id,
+void CZipContextMenu::FillCommand(ECommandInternalID id,
UString &mainString, CCommandMapItem &commandMapItem)
{
int i = FindCommand(id);
@@ -245,7 +245,7 @@ void CZipContextMenu::FillCommand(ECommandInternalID id,
commandMapItem.CommandInternalID = command.CommandInternalID;
commandMapItem.Verb = (UString)kMainVerb + (UString)command.Verb;
commandMapItem.HelpString = LangString(command.ResourceHelpID, command.LangID + 1);
- mainString = LangString(command.ResourceID, command.LangID);
+ mainString = LangString(command.ResourceID, command.LangID);
}
static bool MyInsertMenu(CMenu &menu, int pos, UINT id, const UString &s)
@@ -253,12 +253,12 @@ static bool MyInsertMenu(CMenu &menu, int pos, UINT id, const UString &s)
CMenuItem menuItem;
menuItem.fType = MFT_STRING;
menuItem.fMask = MIIM_TYPE | MIIM_ID;
- menuItem.wID = id;
+ menuItem.wID = id;
menuItem.StringValue = s;
return menu.InsertItem(pos, true, menuItem);
}
-static const wchar_t *kArcExts[] =
+static const wchar_t *kArcExts[] =
{
L"7z",
L"bz2",
@@ -289,9 +289,9 @@ static UString GetSubFolderNameForExtract(const UString &archiveName)
if (dotPos > 0)
{
const UString ext2 = res.Mid(dotPos + 1);
- if (ext.CompareNoCase(L"rar") == 0 &&
- (ext2.CompareNoCase(L"part001") == 0 ||
- ext2.CompareNoCase(L"part01") == 0 ||
+ if (ext.CompareNoCase(L"rar") == 0 &&
+ (ext2.CompareNoCase(L"part001") == 0 ||
+ ext2.CompareNoCase(L"part01") == 0 ||
ext2.CompareNoCase(L"part1") == 0) ||
IsItArcExt(ext2) && ext.CompareNoCase(L"001") == 0)
res = res.Left(dotPos);
@@ -309,10 +309,23 @@ static UString GetReducedString(const UString &s)
return s.Left(kFirstPartSize) + UString(L" ... ") + s.Right(kMaxSize - kFirstPartSize);
}
-static const wchar_t *kExtractExludeExtensions[] =
+static const wchar_t *kExtractExludeExtensions[] =
{
- L"txt", L"htm", L"html", L"xml",
- L"bmp", L"gif", L"jpeg", L"jpg"
+ L"txt", L"htm", L"html", L"xml", L"xsd", L"xsl", L"xslt", L"asp", L"aspx", L"css", L"shtml",
+ L"bmp", L"gif", L"jpeg", L"jpg", L"png", L"tiff", L"ico",
+ L"3gp", L"avi", L"mov", L"mpeg", L"mpg", L"mpe", L"wmv",
+ L"aac", L"ape", L"fla", L"flac", L"la", L"mp3", L"m4a", L"mp4", L"ofr", L"ogg",
+ L"pac", L"ra", L"rm", L"rka", L"shn", L"swa", L"tta", L"wv", L"wma", L"wav",
+ L"ps", L"eps",
+ L"inl", L"inc", L"idl", L"h", L"hpp", L"hxx", L"c", L"cpp", L"cxx", L"rc", L"java",
+ L"cs", L"pas", L"bas", L"vb", L"cls", L"ctl", L"frm", L"dlg", L"def",
+ L"f77", L"f", L"f90", L"f95",
+ L"asm", L"sql", L"manifest", L"dep",
+ L"mak", L"clw", L"csproj", L"vcproj", L"sln", L"dsp", L"dsw",
+ L"bat", L"cmd",
+ L"awk", L"sed", L"hta", L"js", L"php", L"php3", L"php4", L"php5",
+ L"phptml", L"pl", L"pm", L"py", L"pyo", L"rb", L"sh", L"tcl", L"vbs",
+ L"tex", L"ans", L"asc", L"srt", L"reg", L"ini", L"rtf", L"pdf"
};
static bool DoNeedExtract(const UString &name)
@@ -334,11 +347,11 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
LoadLangOneTime();
if(_fileNames.Size() == 0)
return E_FAIL;
- UINT currentCommandID = commandIDFirst;
+ UINT currentCommandID = commandIDFirst;
if ((flags & 0x000F) != CMF_NORMAL &&
(flags & CMF_VERBSONLY) == 0 &&
- (flags & CMF_EXPLORE) == 0)
- return MAKE_HRESULT(SEVERITY_SUCCESS, 0, currentCommandID);
+ (flags & CMF_EXPLORE) == 0)
+ return MAKE_HRESULT(SEVERITY_SUCCESS, 0, currentCommandID);
_commandMap.Clear();
@@ -359,7 +372,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
commandMapItem.HelpString = LangString(IDS_CONTEXT_CAPTION_HELP, 0x02000102);
_commandMap.Add(commandMapItem);
- menuItem.wID = currentCommandID++;
+ menuItem.wID = currentCommandID++;
subIndex = 0;
}
else
@@ -381,14 +394,14 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
NFile::NFind::CFileInfoW fileInfo;
if (!NFile::NFind::FindFile(fileName, fileInfo))
return E_FAIL;
- if (!fileInfo.IsDirectory() && DoNeedExtract(fileInfo.Name))
+ if (!fileInfo.IsDir() && DoNeedExtract(fileInfo.Name))
{
// Open
if ((contextMenuFlags & NContextMenuFlags::kOpen) != 0)
{
CCommandMapItem commandMapItem;
FillCommand(kOpen, mainString, commandMapItem);
- MyInsertMenu(popupMenu, subIndex++, currentCommandID++, mainString);
+ MyInsertMenu(popupMenu, subIndex++, currentCommandID++, mainString);
_commandMap.Add(commandMapItem);
}
}
@@ -402,7 +415,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
NFile::NFind::CFileInfoW fileInfo;
if (!NFile::NFind::FindFile(_fileNames[i], fileInfo))
return E_FAIL;
- if (!fileInfo.IsDirectory() && DoNeedExtract(fileInfo.Name))
+ if (!fileInfo.IsDir() && DoNeedExtract(fileInfo.Name))
needExtract = true;
}
const UString &fileName = _fileNames.Front();
@@ -423,7 +436,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
else
commandMapItem.Folder = folderPrefix;
commandMapItem.Folder += GetSubFolderNameForExtract(fileInfo.Name) + UString(L'\\');
- MyInsertMenu(popupMenu, subIndex++, currentCommandID++, mainString);
+ MyInsertMenu(popupMenu, subIndex++, currentCommandID++, mainString);
_commandMap.Add(commandMapItem);
}
@@ -432,7 +445,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
{
CCommandMapItem commandMapItem;
FillCommand(kExtractHere, mainString, commandMapItem);
- MyInsertMenu(popupMenu, subIndex++, currentCommandID++, mainString);
+ MyInsertMenu(popupMenu, subIndex++, currentCommandID++, mainString);
if (_dropMode)
commandMapItem.Folder = _dropPath;
else
@@ -450,14 +463,14 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
if (_fileNames.Size() == 1)
folder = GetSubFolderNameForExtract(fileInfo.Name);
else
- folder = L'*';
+ folder = L'*';
if (_dropMode)
commandMapItem.Folder = _dropPath;
else
commandMapItem.Folder = folderPrefix;
commandMapItem.Folder += folder;
s = MyFormatNew(s, GetReducedString(UString(L"\"") + folder + UString(L"\\\"")));
- MyInsertMenu(popupMenu, subIndex++, currentCommandID++, s);
+ MyInsertMenu(popupMenu, subIndex++, currentCommandID++, s);
_commandMap.Add(commandMapItem);
}
// Test
@@ -465,7 +478,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
{
CCommandMapItem commandMapItem;
FillCommand(kTest, mainString, commandMapItem);
- MyInsertMenu(popupMenu, subIndex++, currentCommandID++, mainString);
+ MyInsertMenu(popupMenu, subIndex++, currentCommandID++, mainString);
_commandMap.Add(commandMapItem);
}
}
@@ -485,7 +498,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
commandMapItem.Folder = archivePathPrefix;
commandMapItem.Archive = archiveName;
FillCommand(kCompress, mainString, commandMapItem);
- MyInsertMenu(popupMenu, subIndex++, currentCommandID++, mainString);
+ MyInsertMenu(popupMenu, subIndex++, currentCommandID++, mainString);
_commandMap.Add(commandMapItem);
}
@@ -496,7 +509,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
CCommandMapItem commandMapItem;
commandMapItem.Archive = archiveName;
FillCommand(kCompressEmail, mainString, commandMapItem);
- MyInsertMenu(popupMenu, subIndex++, currentCommandID++, mainString);
+ MyInsertMenu(popupMenu, subIndex++, currentCommandID++, mainString);
_commandMap.Add(commandMapItem);
}
@@ -514,7 +527,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
commandMapItem.ArchiveType = L"7z";
UString t = UString(L"\"") + GetReducedString(archiveName7z) + UString(L"\"");
s = MyFormatNew(s, t);
- MyInsertMenu(popupMenu, subIndex++, currentCommandID++, s);
+ MyInsertMenu(popupMenu, subIndex++, currentCommandID++, s);
_commandMap.Add(commandMapItem);
}
@@ -528,7 +541,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
commandMapItem.ArchiveType = L"7z";
UString t = UString(L"\"") + GetReducedString(archiveName7z) + UString(L"\"");
s = MyFormatNew(s, t);
- MyInsertMenu(popupMenu, subIndex++, currentCommandID++, s);
+ MyInsertMenu(popupMenu, subIndex++, currentCommandID++, s);
_commandMap.Add(commandMapItem);
}
@@ -546,7 +559,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
commandMapItem.ArchiveType = L"zip";
UString t = UString(L"\"") + GetReducedString(archiveNameZip) + UString(L"\"");
s = MyFormatNew(s, t);
- MyInsertMenu(popupMenu, subIndex++, currentCommandID++, s);
+ MyInsertMenu(popupMenu, subIndex++, currentCommandID++, s);
_commandMap.Add(commandMapItem);
}
@@ -560,7 +573,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
commandMapItem.ArchiveType = L"zip";
UString t = UString(L"\"") + GetReducedString(archiveNameZip) + UString(L"\"");
s = MyFormatNew(s, t);
- MyInsertMenu(popupMenu, subIndex++, currentCommandID++, s);
+ MyInsertMenu(popupMenu, subIndex++, currentCommandID++, s);
_commandMap.Add(commandMapItem);
}
}
@@ -568,14 +581,14 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
// don't use InsertMenu: See MSDN:
// PRB: Duplicate Menu Items In the File Menu For a Shell Context Menu Extension
- // ID: Q214477
+ // ID: Q214477
if (cascadedMenu)
{
CMenuItem menuItem;
menuItem.fType = MFT_STRING;
menuItem.fMask = MIIM_SUBMENU | MIIM_TYPE | MIIM_ID;
- menuItem.wID = currentCommandID++;
+ menuItem.wID = currentCommandID++;
menuItem.hSubMenu = popupMenu.Detach();
menuDestroyer.Disable();
menuItem.StringValue = LangString(IDS_CONTEXT_POPUP_CAPTION, 0x02000101);
@@ -584,7 +597,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
menu.InsertItem(indexMenu++, true, menuItem);
}
- return MAKE_HRESULT(SEVERITY_SUCCESS, 0, currentCommandID - commandIDFirst);
+ return MAKE_HRESULT(SEVERITY_SUCCESS, 0, currentCommandID - commandIDFirst);
}
@@ -671,14 +684,14 @@ STDMETHODIMP CZipContextMenu::InvokeCommand(LPCMINVOKECOMMANDINFO commandInfo)
case kCompressToZip:
case kCompressToZipEmail:
{
- bool email =
- (commandInternalID == kCompressEmail) ||
+ bool email =
+ (commandInternalID == kCompressEmail) ||
(commandInternalID == kCompressTo7zEmail) ||
(commandInternalID == kCompressToZipEmail);
- bool showDialog =
- (commandInternalID == kCompress) ||
+ bool showDialog =
+ (commandInternalID == kCompress) ||
(commandInternalID == kCompressEmail);
- CompressFiles(commandMapItem.Folder,
+ CompressFiles(commandMapItem.Folder,
commandMapItem.Archive, commandMapItem.ArchiveType,
_fileNames, email, showDialog, false);
break;
@@ -687,7 +700,7 @@ STDMETHODIMP CZipContextMenu::InvokeCommand(LPCMINVOKECOMMANDINFO commandInfo)
}
catch(...)
{
- MyMessageBox(IDS_ERROR, 0x02000605);
+ ShowErrorMessageRes(IDS_ERROR, 0x02000605);
}
return S_OK;
}
@@ -702,17 +715,17 @@ static void MyCopyString(void *dest, const wchar_t *src, bool writeInUnicode)
lstrcpyA((char *)dest, GetAnsiString(src));
}
-STDMETHODIMP CZipContextMenu::GetCommandString(UINT_PTR commandOffset, UINT uType,
+STDMETHODIMP CZipContextMenu::GetCommandString(UINT_PTR commandOffset, UINT uType,
UINT * /* pwReserved */ , LPSTR pszName, UINT /* cchMax */)
{
int cmdOffset = (int)commandOffset;
switch(uType)
- {
+ {
case GCS_VALIDATEA:
case GCS_VALIDATEW:
if(cmdOffset < 0 || cmdOffset >= _commandMap.Size())
return S_FALSE;
- else
+ else
return S_OK;
}
if(cmdOffset < 0 || cmdOffset >= _commandMap.Size())
diff --git a/CPP/7zip/UI/Explorer/ContextMenu.h b/CPP/7zip/UI/Explorer/ContextMenu.h
index 88b33178..be9f9167 100755
--- a/CPP/7zip/UI/Explorer/ContextMenu.h
+++ b/CPP/7zip/UI/Explorer/ContextMenu.h
@@ -4,7 +4,7 @@
#define __CONTEXTMENU_H
// {23170F69-40C1-278A-1000-000100020000}
-DEFINE_GUID(CLSID_CZipContextMenu,
+DEFINE_GUID(CLSID_CZipContextMenu,
0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00);
#include "Common/MyString.h"
@@ -13,7 +13,7 @@ DEFINE_GUID(CLSID_CZipContextMenu,
#include "../FileManager/MyCom2.h"
-class CZipContextMenu:
+class CZipContextMenu:
public IContextMenu,
public IShellExtInit,
public IInitContextMenu,
@@ -53,7 +53,7 @@ public:
///////////////////////////////
// IShellExtInit
- STDMETHOD(Initialize)(LPCITEMIDLIST pidlFolder,
+ STDMETHOD(Initialize)(LPCITEMIDLIST pidlFolder,
LPDATAOBJECT dataObject, HKEY hkeyProgID);
/////////////////////////////
@@ -67,7 +67,7 @@ public:
// IInitContextMenu
- STDMETHOD(InitContextMenu)(const wchar_t *folder, const wchar_t **names, UINT32 numFiles);
+ STDMETHOD(InitContextMenu)(const wchar_t *folder, const wchar_t **names, UINT32 numFiles);
private:
UStringVector _fileNames;
bool _dropMode;
@@ -76,7 +76,7 @@ private:
HRESULT GetFileNames(LPDATAOBJECT dataObject, UStringVector &fileNames);
int FindVerb(const UString &verb);
- void FillCommand(ECommandInternalID id, UString &mainString,
+ void FillCommand(ECommandInternalID id, UString &mainString,
CCommandMapItem &commandMapItem);
public:
CZipContextMenu();
diff --git a/CPP/7zip/UI/Explorer/ContextMenuFlags.h b/CPP/7zip/UI/Explorer/ContextMenuFlags.h
index d138baf9..248b7602 100755
--- a/CPP/7zip/UI/Explorer/ContextMenuFlags.h
+++ b/CPP/7zip/UI/Explorer/ContextMenuFlags.h
@@ -22,13 +22,13 @@ namespace NContextMenuFlags
const UINT32 kCompressToZip = 1 << 12;
const UINT32 kCompressToZipEmail = 1 << 13;
- inline UINT32 GetDefaultFlags() {
- return
- kOpen | kTest |
+ inline UINT32 GetDefaultFlags() {
+ return
+ kOpen | kTest |
kExtract | kExtractHere | kExtractTo |
- kCompress | kCompressEmail |
- kCompressTo7z | kCompressTo7zEmail |
- kCompressToZip | kCompressToZipEmail; }
+ kCompress | kCompressEmail |
+ kCompressTo7z | kCompressTo7zEmail |
+ kCompressToZip | kCompressToZipEmail; }
}
#endif
diff --git a/CPP/7zip/UI/Explorer/DllExports.cpp b/CPP/7zip/UI/Explorer/DllExports.cpp
index 6072e92a..6fed7cda 100755
--- a/CPP/7zip/UI/Explorer/DllExports.cpp
+++ b/CPP/7zip/UI/Explorer/DllExports.cpp
@@ -42,8 +42,8 @@ static LPCTSTR kApprovedKeyPath = TEXT("Software\\Microsoft\\Windows\\CurrentVer
// #define ODS(sz) OutputDebugString(L#sz)
-class CShellExtClassFactory:
- public IClassFactory,
+class CShellExtClassFactory:
+ public IClassFactory,
public CMyUnknownImp
{
public:
@@ -89,7 +89,7 @@ static bool IsItWindowsNT()
{
OSVERSIONINFO versionInfo;
versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
- if (!::GetVersionEx(&versionInfo))
+ if (!::GetVersionEx(&versionInfo))
return false;
return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
}
@@ -107,7 +107,7 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID)
return FALSE;
#else
g_IsNT = IsItWindowsNT();
- #endif
+ #endif
}
else if (dwReason == DLL_PROCESS_DETACH)
{
@@ -183,7 +183,7 @@ static BOOL RegisterServer(CLSID clsid, LPCWSTR title)
if (!NDLL::MyGetModuleFileName(g_hInstance, modulePath))
return FALSE;
- CRegItem clsidEntries[] =
+ CRegItem clsidEntries[] =
{
HKEY_CLASSES_ROOT, kClsidMask, NULL, title,
HKEY_CLASSES_ROOT, kClsidInprocMask, NULL, modulePath,
@@ -197,7 +197,7 @@ static BOOL RegisterServer(CLSID clsid, LPCWSTR title)
TCHAR subKey[MAX_PATH];
wsprintf(subKey, clsidEntries[i].SubKey, clsidString);
NRegistry::CKey key;
- if (key.Create(clsidEntries[i].hRootKey, subKey, NULL,
+ if (key.Create(clsidEntries[i].hRootKey, subKey, NULL,
REG_OPTION_NON_VOLATILE, KEY_WRITE) != NOERROR)
return FALSE;
key.SetValue(clsidEntries[i].ValueName, clsidEntries[i].Data);
@@ -206,7 +206,7 @@ static BOOL RegisterServer(CLSID clsid, LPCWSTR title)
if(IsItWindowsNT())
{
NRegistry::CKey key;
- if (key.Create(HKEY_LOCAL_MACHINE, kApprovedKeyPath, NULL,
+ if (key.Create(HKEY_LOCAL_MACHINE, kApprovedKeyPath, NULL,
REG_OPTION_NON_VOLATILE, KEY_WRITE) == NOERROR)
key.SetValue(GetUnicodeString(clsidString), title);
}
@@ -249,8 +249,8 @@ STDAPI DllUnregisterServer(void)
}
STDAPI CreateObject(
- const GUID *classID,
- const GUID *interfaceID,
+ const GUID *classID,
+ const GUID *interfaceID,
void **outObject)
{
LoadLangOneTime();
diff --git a/CPP/7zip/UI/Explorer/Explorer.dsp b/CPP/7zip/UI/Explorer/Explorer.dsp
index 811ee2c5..a4c99ed6 100755
--- a/CPP/7zip/UI/Explorer/Explorer.dsp
+++ b/CPP/7zip/UI/Explorer/Explorer.dsp
@@ -430,6 +430,14 @@ SOURCE=..\..\..\Windows\Control\Dialog.h
# End Source File
# Begin Source File
+SOURCE=..\..\..\Windows\Control\ListView.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\Control\ListView.h
+# End Source File
+# Begin Source File
+
SOURCE=..\..\..\Windows\Control\PropertyPage.cpp
# End Source File
# Begin Source File
diff --git a/CPP/7zip/UI/Explorer/FoldersPage.cpp b/CPP/7zip/UI/Explorer/FoldersPage.cpp
index b3470390..67d5e867 100755
--- a/CPP/7zip/UI/Explorer/FoldersPage.cpp
+++ b/CPP/7zip/UI/Explorer/FoldersPage.cpp
@@ -17,7 +17,7 @@
using namespace NWindows;
-static CIDLangPair kIDLangPairs[] =
+static CIDLangPair kIDLangPairs[] =
{
{ IDC_FOLDERS_STATIC_WORKING_FOLDER, 0x01000210 },
{ IDC_FOLDERS_WORK_RADIO_SYSTEM, 0x01000211 },
@@ -35,14 +35,14 @@ static const int kWorkModeButtons[] =
static const int kNumWorkModeButtons = sizeof(kWorkModeButtons) / sizeof(kWorkModeButtons[0]);
-bool CFoldersPage::OnInit()
+bool CFoldersPage::OnInit()
{
LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
ReadWorkDirInfo(m_WorkDirInfo);
CheckButton(IDC_FOLDERS_WORK_CHECK_FOR_REMOVABLE, m_WorkDirInfo.ForRemovableOnly);
- CheckRadioButton(kWorkModeButtons[0], kWorkModeButtons[kNumWorkModeButtons - 1],
+ CheckRadioButton(kWorkModeButtons[0], kWorkModeButtons[kNumWorkModeButtons - 1],
kWorkModeButtons[m_WorkDirInfo.Mode]);
m_WorkPath.Init(*this, IDC_FOLDERS_WORK_EDIT_PATH);
@@ -100,7 +100,7 @@ void CFoldersPage::ModifiedEvent()
}
bool CFoldersPage::OnButtonClicked(int buttonID, HWND buttonHWND)
-{
+{
for (int i = 0; i < kNumWorkModeButtons; i++)
if (buttonID == kWorkModeButtons[i])
{
@@ -132,7 +132,7 @@ bool CFoldersPage::OnCommand(int code, int itemID, LPARAM lParam)
return CPropertyPage::OnCommand(code, itemID, lParam);
}
-void CFoldersPage::OnFoldersWorkButtonPath()
+void CFoldersPage::OnFoldersWorkButtonPath()
{
UString currentPath;
m_WorkPath.GetText(currentPath);
@@ -142,7 +142,7 @@ void CFoldersPage::OnFoldersWorkButtonPath()
m_WorkPath.SetText(resultPath);
}
-LONG CFoldersPage::OnApply()
+LONG CFoldersPage::OnApply()
{
GetWorkDir(m_WorkDirInfo);
SaveWorkDirInfo(m_WorkDirInfo);
@@ -151,7 +151,7 @@ LONG CFoldersPage::OnApply()
static LPCWSTR kFoldersTopic = L"fm/plugins/7-zip/options.htm#folders";
-void CFoldersPage::OnNotifyHelp()
+void CFoldersPage::OnNotifyHelp()
{
ShowHelpWindow(NULL, kFoldersTopic);
}
diff --git a/CPP/7zip/UI/Explorer/FoldersPage.rc b/CPP/7zip/UI/Explorer/FoldersPage.rc
index cb9694a6..7b2d4231 100755
--- a/CPP/7zip/UI/Explorer/FoldersPage.rc
+++ b/CPP/7zip/UI/Explorer/FoldersPage.rc
@@ -18,19 +18,19 @@ CAPTION "Folders"
MY_FONT
BEGIN
GROUPBOX "&Working folder", IDC_FOLDERS_STATIC_WORKING_FOLDER, marg, marg, xSize2, 98
- CONTROL "&System temp folder", IDC_FOLDERS_WORK_RADIO_SYSTEM, "Button", BS_AUTORADIOBUTTON | WS_GROUP,
+ CONTROL "&System temp folder", IDC_FOLDERS_WORK_RADIO_SYSTEM, "Button", BS_AUTORADIOBUTTON | WS_GROUP,
gPos, 20, gSize, 10
- CONTROL "&Current", IDC_FOLDERS_WORK_RADIO_CURRENT, "Button", BS_AUTORADIOBUTTON,
+ CONTROL "&Current", IDC_FOLDERS_WORK_RADIO_CURRENT, "Button", BS_AUTORADIOBUTTON,
gPos, 34, gSize, 10
- CONTROL "Specified:", IDC_FOLDERS_WORK_RADIO_SPECIFIED, "Button", BS_AUTORADIOBUTTON,
+ CONTROL "Specified:", IDC_FOLDERS_WORK_RADIO_SPECIFIED, "Button", BS_AUTORADIOBUTTON,
gPos, 48, gSize, 10
EDITTEXT IDC_FOLDERS_WORK_EDIT_PATH, gPos2, 63, gSize - marg3 - bDotsSize - 10, 14, ES_AUTOHSCROLL
PUSHBUTTON "...", IDC_FOLDERS_WORK_BUTTON_PATH, xSize - marg - marg2 - bDotsSize, 63, bDotsSize, bYSize
- CONTROL "Use for removable drives only", IDC_FOLDERS_WORK_CHECK_FOR_REMOVABLE, "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
+ CONTROL "Use for removable drives only", IDC_FOLDERS_WORK_CHECK_FOR_REMOVABLE, "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
gPos, 87, gSize, 10
END
-STRINGTABLE
+STRINGTABLE
BEGIN
IDS_FOLDERS_SET_WORK_PATH_TITLE "Specify a location for temporary archive files."
END
diff --git a/CPP/7zip/UI/Explorer/MyMessages.cpp b/CPP/7zip/UI/Explorer/MyMessages.cpp
index 58ab1f85..62ac42ec 100755
--- a/CPP/7zip/UI/Explorer/MyMessages.cpp
+++ b/CPP/7zip/UI/Explorer/MyMessages.cpp
@@ -7,50 +7,52 @@
#include "Windows/Error.h"
#include "Windows/ResourceString.h"
-#ifdef LANG
+#ifdef LANG
#include "../FileManager/LangUtils.h"
#endif
using namespace NWindows;
-void MyMessageBox(HWND window, LPCWSTR message)
-{
- ::MessageBoxW(window, message, L"7-Zip", 0);
+void ShowErrorMessage(HWND window, LPCWSTR message)
+{
+ ::MessageBoxW(window, message, L"7-Zip", MB_OK | MB_ICONSTOP);
}
-void MyMessageBoxResource(HWND window, UINT32 id
- #ifdef LANG
- ,UINT32 langID
+void ShowErrorMessageHwndRes(HWND window, UINT resID
+ #ifdef LANG
+ , UInt32 langID
#endif
)
{
- #ifdef LANG
- MyMessageBox(window, LangString(id, langID));
+ ShowErrorMessage(window,
+ #ifdef LANG
+ LangString(resID, langID)
#else
- MyMessageBox(window, MyLoadStringW(id));
+ MyLoadStringW(resID)
#endif
+ );
}
-void MyMessageBox(UINT32 id
- #ifdef LANG
- ,UINT32 langID
+void ShowErrorMessageRes(UINT resID
+ #ifdef LANG
+ , UInt32 langID
#endif
)
{
- MyMessageBoxResource(0, id
- #ifdef LANG
+ ShowErrorMessageHwndRes(0, resID
+ #ifdef LANG
, langID
#endif
);
}
-void ShowErrorMessage(HWND window, DWORD message)
+void ShowErrorMessageDWORD(HWND window, DWORD errorCode)
{
- MyMessageBox(window, NError::MyFormatMessageW(message));
+ ShowErrorMessage(window, NError::MyFormatMessageW(errorCode));
}
void ShowLastErrorMessage(HWND window)
{
- ShowErrorMessage(window, ::GetLastError());
+ ShowErrorMessageDWORD(window, ::GetLastError());
}
diff --git a/CPP/7zip/UI/Explorer/MyMessages.h b/CPP/7zip/UI/Explorer/MyMessages.h
index 5bd63cc4..10da975b 100755
--- a/CPP/7zip/UI/Explorer/MyMessages.h
+++ b/CPP/7zip/UI/Explorer/MyMessages.h
@@ -4,27 +4,25 @@
#define __MYMESSAGES_H
#include "Common/MyString.h"
+#include "Common/Types.h"
-void MyMessageBox(HWND window, LPCWSTR message);
+void ShowErrorMessage(HWND window, LPCWSTR message);
+inline void ShowErrorMessage(LPCWSTR message) { ShowErrorMessage(0, message); }
-inline void MyMessageBox(LPCWSTR message)
- { MyMessageBox(0, message); }
-
-void MyMessageBoxResource(HWND window, UINT32 id
- #ifdef LANG
- ,UINT32 langID
+void ShowErrorMessageHwndRes(HWND window, UINT resID
+ #ifdef LANG
+ , UInt32 langID
#endif
);
-void MyMessageBox(UINT32 id
- #ifdef LANG
- ,UINT32 langID
+void ShowErrorMessageRes(UINT resID
+ #ifdef LANG
+ , UInt32 langID
#endif
);
-void ShowErrorMessage(HWND window, DWORD errorMessage);
-inline void ShowErrorMessage(DWORD errorMessage)
- { ShowErrorMessage(0, errorMessage); }
+// void ShowErrorMessageDWORD(HWND window, DWORD errorCode);
+// inline void ErrorMessageDWORD(DWORD errorCode) { ShowErrorMessageDWORD(0, errorCode); }
void ShowLastErrorMessage(HWND window = 0);
#endif
diff --git a/CPP/7zip/UI/Explorer/OptionsDialog.cpp b/CPP/7zip/UI/Explorer/OptionsDialog.cpp
index 4b2d3b51..b0deaf0d 100755
--- a/CPP/7zip/UI/Explorer/OptionsDialog.cpp
+++ b/CPP/7zip/UI/Explorer/OptionsDialog.cpp
@@ -34,11 +34,11 @@ static INT_PTR OptionsDialog(HWND hwndOwner)
page.Page = pagePinters[i];
pages.Add(page);
}
- return NControl::MyPropertySheet(pages, hwndOwner,
+ return NControl::MyPropertySheet(pages, hwndOwner,
LangString(IDS_CONFIG_DIALOG_CAPTION, 0x01000000));
}
-STDMETHODIMP CSevenZipOptions::PluginOptions(HWND hWnd,
+STDMETHODIMP CSevenZipOptions::PluginOptions(HWND hWnd,
IPluginOptionsCallback * /* callback */)
{
/*
diff --git a/CPP/7zip/UI/Explorer/OptionsDialog.h b/CPP/7zip/UI/Explorer/OptionsDialog.h
index affa4329..ac51f6e3 100755
--- a/CPP/7zip/UI/Explorer/OptionsDialog.h
+++ b/CPP/7zip/UI/Explorer/OptionsDialog.h
@@ -7,10 +7,10 @@
#include "Common/MyCom.h"
// {23170F69-40C1-278D-1000-000100020000}
-DEFINE_GUID(CLSID_CSevenZipOptions,
+DEFINE_GUID(CLSID_CSevenZipOptions,
0x23170F69, 0x40C1, 0x278D, 0x10, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00);
-class CSevenZipOptions:
+class CSevenZipOptions:
public IPluginOptions,
public CMyUnknownImp
{
diff --git a/CPP/7zip/UI/Explorer/RegistryContextMenu.cpp b/CPP/7zip/UI/Explorer/RegistryContextMenu.cpp
index 73a8420e..ee0078b7 100755
--- a/CPP/7zip/UI/Explorer/RegistryContextMenu.cpp
+++ b/CPP/7zip/UI/Explorer/RegistryContextMenu.cpp
@@ -61,7 +61,7 @@ static bool CheckDragDropMenuHandlerCommon(const CSysString &keyName)
}
bool CheckContextMenuHandler()
-{
+{
return CheckContextMenuHandlerCommon(kRootKeyNameForFile) &&
// CheckContextMenuHandlerCommon(kRootKeyNameForFolder) &&
CheckContextMenuHandlerCommon(kRootKeyNameForDirectory) &&
@@ -86,12 +86,12 @@ static void DeleteDragDropMenuHandlerCommon(const CSysString &keyName)
}
void DeleteContextMenuHandler()
-{
- DeleteContextMenuHandlerCommon(kRootKeyNameForFile);
+{
+ DeleteContextMenuHandlerCommon(kRootKeyNameForFile);
DeleteContextMenuHandlerCommon(kRootKeyNameForFolder);
DeleteContextMenuHandlerCommon(kRootKeyNameForDirectory);
DeleteContextMenuHandlerCommon(kRootKeyNameForDrive);
- DeleteDragDropMenuHandlerCommon(kRootKeyNameForFile);
+ DeleteDragDropMenuHandlerCommon(kRootKeyNameForFile);
DeleteDragDropMenuHandlerCommon(kRootKeyNameForFolder);
DeleteDragDropMenuHandlerCommon(kRootKeyNameForDirectory);
DeleteDragDropMenuHandlerCommon(kRootKeyNameForDrive);
@@ -116,8 +116,8 @@ static void AddDragDropMenuHandlerCommon(const CSysString &keyName)
}
void AddContextMenuHandler()
-{
- AddContextMenuHandlerCommon(kRootKeyNameForFile);
+{
+ AddContextMenuHandlerCommon(kRootKeyNameForFile);
// AddContextMenuHandlerCommon(kRootKeyNameForFolder);
AddContextMenuHandlerCommon(kRootKeyNameForDirectory);
diff --git a/CPP/7zip/UI/Explorer/StdAfx.h b/CPP/7zip/UI/Explorer/StdAfx.h
index b9c0ee3a..d978a3a4 100755
--- a/CPP/7zip/UI/Explorer/StdAfx.h
+++ b/CPP/7zip/UI/Explorer/StdAfx.h
@@ -4,7 +4,7 @@
#define __STDAFX_H
#define _WIN32_WINNT 0x0400
-// it's hack for Windows NT supporting
+// it's hack for Windows NT supporting
#define WINVER 0x0400
// #define _WIN32_IE 0x0500
@@ -23,4 +23,4 @@
#include "Common/NewHandler.h"
-#endif
+#endif
diff --git a/CPP/7zip/UI/Explorer/SystemPage.cpp b/CPP/7zip/UI/Explorer/SystemPage.cpp
index dd60b6d5..602e4387 100755
--- a/CPP/7zip/UI/Explorer/SystemPage.cpp
+++ b/CPP/7zip/UI/Explorer/SystemPage.cpp
@@ -21,7 +21,7 @@
using namespace NContextMenuFlags;
-static CIDLangPair kIDLangPairs[] =
+static CIDLangPair kIDLangPairs[] =
{
{ IDC_SYSTEM_INTEGRATE_TO_CONTEXT_MENU, 0x01000301},
{ IDC_SYSTEM_CASCADED_MENU, 0x01000302},
@@ -37,7 +37,7 @@ struct CContextMenuItem
UInt32 Flag;
};
-static CContextMenuItem kMenuItems[] =
+static CContextMenuItem kMenuItems[] =
{
{ IDS_CONTEXT_OPEN, 0x02000103, kOpen},
{ IDS_CONTEXT_EXTRACT, 0x02000105, kExtract},
@@ -61,7 +61,7 @@ bool CSystemPage::OnInit()
_initMode = true;
LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
- CheckButton(IDC_SYSTEM_INTEGRATE_TO_CONTEXT_MENU,
+ CheckButton(IDC_SYSTEM_INTEGRATE_TO_CONTEXT_MENU,
NZipRootRegistry::CheckContextMenuHandler());
CheckButton(IDC_SYSTEM_CASCADED_MENU, ReadCascadedMenu());
@@ -73,29 +73,18 @@ bool CSystemPage::OnInit()
m_ListView.Attach(GetItem(IDC_SYSTEM_OPTIONS_LIST));
/*
- CheckButton(IDC_SYSTEM_INTEGRATE_TO_CONTEXT_MENU,
+ CheckButton(IDC_SYSTEM_INTEGRATE_TO_CONTEXT_MENU,
NRegistryAssociations::CheckContextMenuHandler());
*/
UInt32 newFlags = LVS_EX_CHECKBOXES | LVS_EX_FULLROWSELECT;
m_ListView.SetExtendedListViewStyle(newFlags, newFlags);
- UString s; // = TEXT("Items"); // LangLoadString(IDS_PROPERTY_EXTENSION, 0x02000205);
- LVCOLUMNW column;
- column.mask = LVCF_WIDTH | LVCF_TEXT | LVCF_FMT | LVCF_SUBITEM;
- column.cx = 270;
- column.fmt = LVCFMT_LEFT;
- column.pszText = (LPWSTR)(LPCWSTR)s;
- column.iSubItem = 0;
- m_ListView.InsertColumn(0, &column);
+ m_ListView.InsertColumn(0, L"", 270);
for (int i = 0; i < kNumMenuItems; i++)
{
CContextMenuItem &menuItem = kMenuItems[i];
- LVITEMW item;
- item.iItem = i;
- item.mask = LVIF_TEXT | LVIF_PARAM;
- item.lParam = i;
UString s = LangString(menuItem.ControlID, menuItem.LangID);
@@ -126,11 +115,7 @@ bool CSystemPage::OnInit()
}
}
- // UString MyFormatNew(const UString &format, const UString &argument);
-
- item.pszText = (LPWSTR)(LPCWSTR)s;
- item.iSubItem = 0;
- int itemIndex = m_ListView.InsertItem(&item);
+ int itemIndex = m_ListView.InsertItem(i, s);
m_ListView.SetCheckState(itemIndex, ((contextMenuFlags & menuItem.Flag) != 0));
}
@@ -170,7 +155,7 @@ void CSystemPage::OnNotifyHelp()
}
bool CSystemPage::OnButtonClicked(int buttonID, HWND buttonHWND)
-{
+{
switch(buttonID)
{
case IDC_SYSTEM_CASCADED_MENU:
@@ -182,8 +167,8 @@ bool CSystemPage::OnButtonClicked(int buttonID, HWND buttonHWND)
}
-bool CSystemPage::OnNotify(UINT controlID, LPNMHDR lParam)
-{
+bool CSystemPage::OnNotify(UINT controlID, LPNMHDR lParam)
+{
if (lParam->hwndFrom == HWND(m_ListView))
{
switch(lParam->code)
@@ -191,8 +176,8 @@ bool CSystemPage::OnNotify(UINT controlID, LPNMHDR lParam)
case (LVN_ITEMCHANGED):
return OnItemChanged((const NMLISTVIEW *)lParam);
}
- }
- return CPropertyPage::OnNotify(controlID, lParam);
+ }
+ return CPropertyPage::OnNotify(controlID, lParam);
}
diff --git a/CPP/7zip/UI/Explorer/SystemPage.rc b/CPP/7zip/UI/Explorer/SystemPage.rc
index a3b36409..611fd58b 100755
--- a/CPP/7zip/UI/Explorer/SystemPage.rc
+++ b/CPP/7zip/UI/Explorer/SystemPage.rc
@@ -10,15 +10,15 @@ IDD_SYSTEM DIALOG 0, 0, xSize, ySize MY_PAGE_STYLE
CAPTION "System"
MY_FONT
BEGIN
- CONTROL "Integrate 7-Zip to shell context menu", IDC_SYSTEM_INTEGRATE_TO_CONTEXT_MENU,
- "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
+ CONTROL "Integrate 7-Zip to shell context menu", IDC_SYSTEM_INTEGRATE_TO_CONTEXT_MENU,
+ "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
marg, marg, xSize2, 10
- CONTROL "Cascaded context menu", IDC_SYSTEM_CASCADED_MENU,
- "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
+ CONTROL "Cascaded context menu", IDC_SYSTEM_CASCADED_MENU,
+ "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
marg, 21, xSize2, 10
- LTEXT "Context menu items:", IDC_SYSTEM_STATIC_CONTEXT_MENU_ITEMS,
+ LTEXT "Context menu items:", IDC_SYSTEM_STATIC_CONTEXT_MENU_ITEMS,
marg, 37, xSize2, 8
- CONTROL "List1", IDC_SYSTEM_OPTIONS_LIST, "SysListView32",
- LVS_REPORT | LVS_SINGLESEL | LVS_NOCOLUMNHEADER | WS_BORDER | WS_TABSTOP,
+ CONTROL "List1", IDC_SYSTEM_OPTIONS_LIST, "SysListView32",
+ LVS_REPORT | LVS_SINGLESEL | LVS_NOCOLUMNHEADER | WS_BORDER | WS_TABSTOP,
marg, 50, xSize2, ySize - marg - 50
END
diff --git a/CPP/7zip/UI/Explorer/makefile b/CPP/7zip/UI/Explorer/makefile
index c58531d8..ab9aff10 100755
--- a/CPP/7zip/UI/Explorer/makefile
+++ b/CPP/7zip/UI/Explorer/makefile
@@ -43,6 +43,7 @@ WIN_OBJS = \
WIN_CTRL_OBJS = \
$O\Dialog.obj \
+ $O\ListView.obj \
$O\PropertyPage.obj \
UI_COMMON_OBJS = \
diff --git a/CPP/7zip/UI/Explorer/resource.h b/CPP/7zip/UI/Explorer/resource.h
index aec1e7cd..75fa4981 100755
--- a/CPP/7zip/UI/Explorer/resource.h
+++ b/CPP/7zip/UI/Explorer/resource.h
@@ -1,31 +1,31 @@
-#define IDS_CONTEXT_EXTRACT 42
-#define IDS_CONTEXT_EXTRACT_HELP 43
-#define IDS_CONTEXT_COMPRESS 44
-#define IDS_CONTEXT_COMPRESS_HELP 45
-#define IDS_CONTEXT_OPEN 46
-#define IDS_CONTEXT_OPEN_HELP 47
-#define IDS_CONTEXT_TEST 48
-#define IDS_CONTEXT_TEST_HELP 49
-#define IDS_CONTEXT_CAPTION_HELP 50
-#define IDS_CONTEXT_POPUP_CAPTION 51
+#define IDS_CONTEXT_EXTRACT 142
+#define IDS_CONTEXT_EXTRACT_HELP 143
+#define IDS_CONTEXT_COMPRESS 144
+#define IDS_CONTEXT_COMPRESS_HELP 145
+#define IDS_CONTEXT_OPEN 146
+#define IDS_CONTEXT_OPEN_HELP 147
+#define IDS_CONTEXT_TEST 148
+#define IDS_CONTEXT_TEST_HELP 149
+#define IDS_CONTEXT_CAPTION_HELP 150
+#define IDS_CONTEXT_POPUP_CAPTION 151
-#define IDS_CONTEXT_EXTRACT_HERE 52
-#define IDS_CONTEXT_EXTRACT_HERE_HELP 53
+#define IDS_CONTEXT_EXTRACT_HERE 152
+#define IDS_CONTEXT_EXTRACT_HERE_HELP 153
-#define IDS_CONTEXT_EXTRACT_TO 54
-#define IDS_CONTEXT_EXTRACT_TO_HELP 55
+#define IDS_CONTEXT_EXTRACT_TO 154
+#define IDS_CONTEXT_EXTRACT_TO_HELP 155
-#define IDS_CONTEXT_COMPRESS_TO 56
-#define IDS_CONTEXT_COMPRESS_TO_HELP 57
+#define IDS_CONTEXT_COMPRESS_TO 156
+#define IDS_CONTEXT_COMPRESS_TO_HELP 157
-#define IDS_CONTEXT_COMPRESS_EMAIL 58
-#define IDS_CONTEXT_COMPRESS_EMAIL_HELP 59
+#define IDS_CONTEXT_COMPRESS_EMAIL 158
+#define IDS_CONTEXT_COMPRESS_EMAIL_HELP 159
-#define IDS_CONTEXT_COMPRESS_TO_EMAIL 60
-#define IDS_CONTEXT_COMPRESS_TO_EMAIL_HELP 61
+#define IDS_CONTEXT_COMPRESS_TO_EMAIL 160
+#define IDS_CONTEXT_COMPRESS_TO_EMAIL_HELP 161
-#define IDS_CONTEXT_FOLDER 70
-#define IDS_CONTEXT_ARCHIVE 71
+#define IDS_CONTEXT_FOLDER 170
+#define IDS_CONTEXT_ARCHIVE 171
#define IDS_ERROR 100
#define IDS_CONFIG_DIALOG_CAPTION 102
diff --git a/CPP/7zip/UI/Far/ExtractEngine.cpp b/CPP/7zip/UI/Far/ExtractEngine.cpp
index 2ffb14c1..89dacf59 100755
--- a/CPP/7zip/UI/Far/ExtractEngine.cpp
+++ b/CPP/7zip/UI/Far/ExtractEngine.cpp
@@ -26,8 +26,8 @@ CExtractCallBackImp::~CExtractCallBackImp()
void CExtractCallBackImp::Init(
UINT codePage,
- CProgressBox *progressBox,
- bool passwordIsDefined,
+ CProgressBox *progressBox,
+ bool passwordIsDefined,
const UString &password)
{
m_PasswordIsDefined = passwordIsDefined;
@@ -36,28 +36,30 @@ void CExtractCallBackImp::Init(
m_ProgressBox = progressBox;
}
-STDMETHODIMP CExtractCallBackImp::SetTotal(UINT64 size)
+STDMETHODIMP CExtractCallBackImp::SetTotal(UInt64 size)
{
- if (m_ProgressBox != 0)
- {
- m_ProgressBox->SetTotal(size);
- m_ProgressBox->PrintCompeteValue(0);
- }
+ _total = size;
+ _totalIsDefined = true;
return S_OK;
}
-STDMETHODIMP CExtractCallBackImp::SetCompleted(const UINT64 *completeValue)
+STDMETHODIMP CExtractCallBackImp::SetCompleted(const UInt64 *completeValue)
{
- if(WasEscPressed())
+ if (WasEscPressed())
return E_ABORT;
- if (m_ProgressBox != 0 && completeValue != NULL)
- m_ProgressBox->PrintCompeteValue(*completeValue);
+ _processedIsDefined = (completeValue != NULL);
+ if (_processedIsDefined)
+ _processed = *completeValue;
+ if (m_ProgressBox != 0)
+ m_ProgressBox->Progress(
+ _totalIsDefined ? &_total: NULL,
+ _processedIsDefined ? &_processed: NULL, AString());
return S_OK;
}
STDMETHODIMP CExtractCallBackImp::AskOverwrite(
- const wchar_t *existName, const FILETIME *existTime, const UINT64 *existSize,
- const wchar_t *newName, const FILETIME *newTime, const UINT64 *newSize,
+ const wchar_t *existName, const FILETIME *existTime, const UInt64 *existSize,
+ const wchar_t *newName, const FILETIME *newTime, const UInt64 *newSize,
INT32 *answer)
{
NOverwriteDialog::CFileInfo oldFileInfo, newFileInfo;
@@ -76,7 +78,7 @@ STDMETHODIMP CExtractCallBackImp::AskOverwrite(
newFileInfo.Size = *newSize;
newFileInfo.Name = GetSystemString(newName, m_CodePage);
- NOverwriteDialog::NResult::EEnum result =
+ NOverwriteDialog::NResult::EEnum result =
NOverwriteDialog::Execute(oldFileInfo, newFileInfo);
switch(result)
@@ -106,9 +108,9 @@ STDMETHODIMP CExtractCallBackImp::AskOverwrite(
return S_OK;
}
-STDMETHODIMP CExtractCallBackImp::PrepareOperation(const wchar_t *name, bool /* isFolder */, INT32 /* askExtractMode */, const UINT64 * /* position */)
+STDMETHODIMP CExtractCallBackImp::PrepareOperation(const wchar_t *name, bool /* isFolder */, INT32 /* askExtractMode */, const UInt64 * /* position */)
{
- if(WasEscPressed())
+ if (WasEscPressed())
return E_ABORT;
m_CurrentFilePath = name;
return S_OK;
@@ -137,12 +139,12 @@ STDMETHODIMP CExtractCallBackImp::SetOperationResult(INT32 operationResult, bool
idMessage = NMessageID::kExtractUnsupportedMethod;
break;
case NArchive::NExtract::NOperationResult::kCRCError:
- idMessage = encrypted ?
+ idMessage = encrypted ?
NMessageID::kExtractCRCFailedEncrypted :
NMessageID::kExtractCRCFailed;
break;
case NArchive::NExtract::NOperationResult::kDataError:
- idMessage = encrypted ?
+ idMessage = encrypted ?
NMessageID::kExtractDataErrorEncrypted :
NMessageID::kExtractDataError;
break;
@@ -150,7 +152,7 @@ STDMETHODIMP CExtractCallBackImp::SetOperationResult(INT32 operationResult, bool
return E_FAIL;
}
char buffer[512];
- const AString s = GetSystemString(m_CurrentFilePath, m_CodePage);
+ const AString s = UnicodeStringToMultiByte(m_CurrentFilePath, m_CodePage);
sprintf(buffer, g_StartupInfo.GetMsgString(idMessage), (const char *)s);
if (g_StartupInfo.ShowMessage(buffer) == -1)
return E_ABORT;
diff --git a/CPP/7zip/UI/Far/ExtractEngine.h b/CPP/7zip/UI/Far/ExtractEngine.h
index 5cccf6ef..62486fb1 100755
--- a/CPP/7zip/UI/Far/ExtractEngine.h
+++ b/CPP/7zip/UI/Far/ExtractEngine.h
@@ -11,7 +11,7 @@
#include "ProgressBox.h"
-class CExtractCallBackImp:
+class CExtractCallBackImp:
public IFolderArchiveExtractCallback,
public ICryptoGetTextPassword,
public CMyUnknownImp
@@ -20,15 +20,15 @@ public:
MY_UNKNOWN_IMP1(ICryptoGetTextPassword)
// IProgress
- STDMETHOD(SetTotal)(UINT64 size);
- STDMETHOD(SetCompleted)(const UINT64 *completeValue);
+ STDMETHOD(SetTotal)(UInt64 size);
+ STDMETHOD(SetCompleted)(const UInt64 *completeValue);
// IExtractCallBack
STDMETHOD(AskOverwrite)(
- const wchar_t *existName, const FILETIME *existTime, const UINT64 *existSize,
- const wchar_t *newName, const FILETIME *newTime, const UINT64 *newSize,
+ const wchar_t *existName, const FILETIME *existTime, const UInt64 *existSize,
+ const wchar_t *newName, const FILETIME *newTime, const UInt64 *newSize,
INT32 *result);
- STDMETHOD (PrepareOperation)(const wchar_t *name, bool isFolder, INT32 askExtractMode, const UINT64 *position);
+ STDMETHOD (PrepareOperation)(const wchar_t *name, bool isFolder, INT32 askExtractMode, const UInt64 *position);
STDMETHOD(MessageError)(const wchar_t *message);
STDMETHOD(SetOperationResult)(INT32 resultEOperationResult, bool encrypted);
@@ -36,14 +36,22 @@ public:
STDMETHOD(CryptoGetTextPassword)(BSTR *password);
private:
+ UInt64 _total;
+ UInt64 _processed;
+
+ bool _totalIsDefined;
+ bool _processedIsDefined;
+
UString m_CurrentFilePath;
+ /*
struct CProcessedFileInfo
{
- FILETIME UTCLastWriteTime;
- bool IsDirectory;
+ FILETIME MTime;
+ bool isDir;
UINT32 Attributes;
} m_ProcessedFileInfo;
+ */
CProgressBox *m_ProgressBox;
UINT m_CodePage;
@@ -53,15 +61,16 @@ private:
void CreateComplexDirectory(const UStringVector &dirPathParts);
/*
- void GetPropertyValue(LPITEMIDLIST anItemIDList, PROPID aPropId,
+ void GetPropertyValue(LPITEMIDLIST anItemIDList, PROPID aPropId,
PROPVARIANT *aValue);
bool IsEncrypted(LPITEMIDLIST anItemIDList);
*/
void AddErrorMessage(LPCTSTR message);
public:
+ CExtractCallBackImp(): _totalIsDefined(false), _processedIsDefined(false) {}
~CExtractCallBackImp();
- void Init(UINT codePage,
- CProgressBox *progressBox,
+ void Init(UINT codePage,
+ CProgressBox *progressBox,
bool passwordIsDefined, const UString &password);
};
diff --git a/CPP/7zip/UI/Far/Far.dsp b/CPP/7zip/UI/Far/Far.dsp
index 17392f74..8c1d1357 100755
--- a/CPP/7zip/UI/Far/Far.dsp
+++ b/CPP/7zip/UI/Far/Far.dsp
@@ -336,6 +336,10 @@ SOURCE=..\..\..\Windows\Synchronization.cpp
SOURCE=..\..\..\Windows\Synchronization.h
# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\Windows\Time.cpp
+# End Source File
# End Group
# Begin Group "UI Common"
diff --git a/CPP/7zip/UI/Far/FarUtils.cpp b/CPP/7zip/UI/Far/FarUtils.cpp
index c4a30524..e06bfe3e 100755
--- a/CPP/7zip/UI/Far/FarUtils.cpp
+++ b/CPP/7zip/UI/Far/FarUtils.cpp
@@ -15,7 +15,7 @@ namespace NFar {
CStartupInfo g_StartupInfo;
-void CStartupInfo::Init(const PluginStartupInfo &pluginStartupInfo,
+void CStartupInfo::Init(const PluginStartupInfo &pluginStartupInfo,
const CSysString &pliginNameForRegestry)
{
m_Data = pluginStartupInfo;
@@ -29,18 +29,18 @@ const char *CStartupInfo::GetMsgString(int messageId)
return (const char*)m_Data.GetMsg(m_Data.ModuleNumber, messageId);
}
-int CStartupInfo::ShowMessage(unsigned int flags,
+int CStartupInfo::ShowMessage(unsigned int flags,
const char *helpTopic, const char **items, int numItems, int numButtons)
{
- return m_Data.Message(m_Data.ModuleNumber, flags, (char *)helpTopic,
+ return m_Data.Message(m_Data.ModuleNumber, flags, (char *)helpTopic,
(char **)items, numItems, numButtons);
}
namespace NMessageID
{
- enum
+ enum
{
- kOk,
+ kOk,
kCancel,
kWarning,
kError
@@ -49,10 +49,47 @@ namespace NMessageID
int CStartupInfo::ShowMessage(const char *message)
{
- const char *messagesItems[]= { GetMsgString(NMessageID::kError), message,
- GetMsgString(NMessageID::kOk) };
- return ShowMessage(FMSG_WARNING, NULL, messagesItems,
- sizeof(messagesItems) / sizeof(messagesItems[0]), 1);
+ const char *items[]= { GetMsgString(NMessageID::kError), message, GetMsgString(NMessageID::kOk) };
+ return ShowMessage(FMSG_WARNING, NULL, items, sizeof(items) / sizeof(items[0]), 1);
+}
+
+static void SplitString(const AString &srcString, AStringVector &destStrings)
+{
+ destStrings.Clear();
+ AString string;
+ int len = srcString.Length();
+ if (len == 0)
+ return;
+ for (int i = 0; i < len; i++)
+ {
+ char c = srcString[i];
+ if (c == '\n')
+ {
+ if (!string.IsEmpty())
+ {
+ destStrings.Add(string);
+ string.Empty();
+ }
+ }
+ else
+ string += c;
+ }
+ if (!string.IsEmpty())
+ destStrings.Add(string);
+}
+
+int CStartupInfo::ShowMessageLines(const char *message)
+{
+ AStringVector strings;
+ SplitString(message, strings);
+ const int kNumStringsMax = 20;
+ const char *items[kNumStringsMax + 1] = { GetMsgString(NMessageID::kError) };
+ int pos = 1;
+ for (int i = 0; i < strings.Size() && pos < kNumStringsMax; i++)
+ items[pos++] = strings[i];
+ items[pos++] = GetMsgString(NMessageID::kOk);
+
+ return ShowMessage(FMSG_WARNING, NULL, items, pos, 1);
}
int CStartupInfo::ShowMessage(int messageId)
@@ -60,10 +97,10 @@ int CStartupInfo::ShowMessage(int messageId)
return ShowMessage(GetMsgString(messageId));
}
-int CStartupInfo::ShowDialog(int X1, int Y1, int X2, int Y2,
+int CStartupInfo::ShowDialog(int X1, int Y1, int X2, int Y2,
const char *helpTopic, struct FarDialogItem *items, int numItems)
{
- return m_Data.Dialog(m_Data.ModuleNumber, X1, Y1, X2, Y2, (char *)helpTopic,
+ return m_Data.Dialog(m_Data.ModuleNumber, X1, Y1, X2, Y2, (char *)helpTopic,
items, numItems);
}
@@ -75,7 +112,7 @@ int CStartupInfo::ShowDialog(int sizeX, int sizeY,
inline static BOOL GetBOOLValue(bool v) { return (v? TRUE: FALSE); }
-void CStartupInfo::InitDialogItems(const CInitDialogItem *srcItems,
+void CStartupInfo::InitDialogItems(const CInitDialogItem *srcItems,
FarDialogItem *destItems, int numItems)
{
for (int i = 0; i < numItems; i++)
@@ -136,19 +173,19 @@ CSysString CStartupInfo::GetFullKeyName(const CSysString &keyName) const
}
-LONG CStartupInfo::CreateRegKey(HKEY parentKey,
+LONG CStartupInfo::CreateRegKey(HKEY parentKey,
const CSysString &keyName, NRegistry::CKey &destKey) const
{
return destKey.Create(parentKey, GetFullKeyName(keyName));
}
-LONG CStartupInfo::OpenRegKey(HKEY parentKey,
- const CSysString &keyName, NRegistry::CKey &destKey) const
+LONG CStartupInfo::OpenRegKey(HKEY parentKey,
+ const CSysString &keyName, NRegistry::CKey &destKey) const
{
return destKey.Open(parentKey, GetFullKeyName(keyName));
}
-void CStartupInfo::SetRegKeyValue(HKEY parentKey, const CSysString &keyName,
+void CStartupInfo::SetRegKeyValue(HKEY parentKey, const CSysString &keyName,
LPCTSTR valueName, LPCTSTR value) const
{
NRegistry::CKey regKey;
@@ -156,7 +193,7 @@ void CStartupInfo::SetRegKeyValue(HKEY parentKey, const CSysString &keyName,
regKey.SetValue(valueName, value);
}
-void CStartupInfo::SetRegKeyValue(HKEY parentKey, const CSysString &keyName,
+void CStartupInfo::SetRegKeyValue(HKEY parentKey, const CSysString &keyName,
LPCTSTR valueName, UINT32 value) const
{
NRegistry::CKey regKey;
@@ -164,7 +201,7 @@ void CStartupInfo::SetRegKeyValue(HKEY parentKey, const CSysString &keyName,
regKey.SetValue(valueName, value);
}
-void CStartupInfo::SetRegKeyValue(HKEY parentKey, const CSysString &keyName,
+void CStartupInfo::SetRegKeyValue(HKEY parentKey, const CSysString &keyName,
LPCTSTR valueName, bool value) const
{
NRegistry::CKey regKey;
@@ -289,7 +326,7 @@ int CStartupInfo::Menu(
struct FarMenuItem *items,
int numItems)
{
- return m_Data.Menu(m_Data.ModuleNumber, x, y, maxHeight, flags, (char *)title,
+ return m_Data.Menu(m_Data.ModuleNumber, x, y, maxHeight, flags, (char *)title,
(char *)aBottom, (char *)helpTopic, breakKeys, breakCode, items, numItems);
}
@@ -308,7 +345,7 @@ int CStartupInfo::Menu(
unsigned int flags,
const char *title,
const char *helpTopic,
- const CSysStringVector &items,
+ const CSysStringVector &items,
int selectedItem)
{
CRecordVector<FarMenuItem> farMenuItems;
@@ -368,9 +405,14 @@ void PrintErrorMessage(const char *message, int code)
void PrintErrorMessage(const char *message, const char *text)
{
CSysString tmp = message;
- tmp += ": ";
+ tmp += ":\n";
tmp += text;
- g_StartupInfo.ShowMessage(tmp);
+ g_StartupInfo.ShowMessageLines(tmp);
+}
+
+void PrintErrorMessage(const char *message, const wchar_t *text)
+{
+ PrintErrorMessage(message, UnicodeStringToMultiByte(text, CP_OEMCP));
}
bool WasEscPressed()
diff --git a/CPP/7zip/UI/Far/FarUtils.h b/CPP/7zip/UI/Far/FarUtils.h
index 4e2f83cd..e0126cdc 100755
--- a/CPP/7zip/UI/Far/FarUtils.h
+++ b/CPP/7zip/UI/Far/FarUtils.h
@@ -49,37 +49,38 @@ class CStartupInfo
CSysString m_RegistryPath;
CSysString GetFullKeyName(const CSysString &keyName) const;
- LONG CreateRegKey(HKEY parentKey,
+ LONG CreateRegKey(HKEY parentKey,
const CSysString &keyName, NWindows::NRegistry::CKey &destKey) const;
- LONG OpenRegKey(HKEY parentKey,
+ LONG OpenRegKey(HKEY parentKey,
const CSysString &keyName, NWindows::NRegistry::CKey &destKey) const;
public:
- void Init(const PluginStartupInfo &pluginStartupInfo,
+ void Init(const PluginStartupInfo &pluginStartupInfo,
const CSysString &pliginNameForRegestry);
const char *GetMsgString(int messageId);
- int ShowMessage(unsigned int flags, const char *helpTopic,
+ int ShowMessage(unsigned int flags, const char *helpTopic,
const char **items, int numItems, int numButtons);
int ShowMessage(const char *message);
+ int ShowMessageLines(const char *message);
int ShowMessage(int messageId);
- int ShowDialog(int X1, int Y1, int X2, int Y2,
+ int ShowDialog(int X1, int Y1, int X2, int Y2,
const char *helpTopic, struct FarDialogItem *items, int numItems);
int ShowDialog(int sizeX, int sizeY,
const char *helpTopic, struct FarDialogItem *items, int numItems);
- void InitDialogItems(const CInitDialogItem *srcItems,
+ void InitDialogItems(const CInitDialogItem *srcItems,
FarDialogItem *destItems, int numItems);
HANDLE SaveScreen(int X1, int Y1, int X2, int Y2);
HANDLE SaveScreen();
void RestoreScreen(HANDLE handle);
- void SetRegKeyValue(HKEY parentKey, const CSysString &keyName,
+ void SetRegKeyValue(HKEY parentKey, const CSysString &keyName,
const LPCTSTR valueName, LPCTSTR value) const;
- void SetRegKeyValue(HKEY hRoot, const CSysString &keyName,
+ void SetRegKeyValue(HKEY hRoot, const CSysString &keyName,
const LPCTSTR valueName, UINT32 value) const;
- void SetRegKeyValue(HKEY hRoot, const CSysString &keyName,
+ void SetRegKeyValue(HKEY hRoot, const CSysString &keyName,
const LPCTSTR valueName, bool value) const;
CSysString QueryRegKeyValue(HKEY parentKey, const CSysString &keyName,
@@ -124,17 +125,17 @@ public:
unsigned int flags,
const char *title,
const char *helpTopic,
- const CSysStringVector &items,
+ const CSysStringVector &items,
int selectedItem);
- int Editor(const char *fileName, const char *title,
+ int Editor(const char *fileName, const char *title,
int X1, int Y1, int X2, int Y2, DWORD flags, int startLine, int startChar)
- { return m_Data.Editor((char *)fileName, (char *)title, X1, Y1, X2, Y2,
+ { return m_Data.Editor((char *)fileName, (char *)title, X1, Y1, X2, Y2,
flags, startLine, startChar); }
int Editor(const char *fileName)
{ return Editor(fileName, NULL, 0, 0, -1, -1, 0, -1, -1); }
- int Viewer(const char *fileName, const char *title,
+ int Viewer(const char *fileName, const char *title,
int X1, int Y1, int X2, int Y2, DWORD flags)
{ return m_Data.Viewer((char *)fileName, (char *)title, X1, Y1, X2, Y2, flags); }
int Viewer(const char *fileName)
@@ -157,7 +158,8 @@ public:
extern CStartupInfo g_StartupInfo;
void PrintErrorMessage(const char *message, int code);
-void PrintErrorMessage(const char *message, const char *aText);
+void PrintErrorMessage(const char *message, const char *text);
+void PrintErrorMessage(const char *message, const wchar_t *text);
#define MY_TRY_BEGIN try\
{
@@ -170,8 +172,10 @@ void PrintErrorMessage(const char *message, const char *aText);
#define MY_TRY_END2(x, y) }\
catch(int n) { PrintErrorMessage(x, n); return y; }\
- catch(const CSysString &s) { PrintErrorMessage(x, s); return y; }\
+ catch(const AString &s) { PrintErrorMessage(x, s); return y; }\
catch(const char *s) { PrintErrorMessage(x, s); return y; }\
+ catch(const UString &s) { PrintErrorMessage(x, s); return y; }\
+ catch(const wchar_t *s) { PrintErrorMessage(x, s); return y; }\
catch(...) { g_StartupInfo.ShowMessage(x); return y; }
bool WasEscPressed();
diff --git a/CPP/7zip/UI/Far/Main.cpp b/CPP/7zip/UI/Far/Main.cpp
index 0409855d..39c84391 100755
--- a/CPP/7zip/UI/Far/Main.cpp
+++ b/CPP/7zip/UI/Far/Main.cpp
@@ -43,11 +43,11 @@ static const char *kHelpTopicConfig = "Config";
extern "C"
{
void WINAPI SetStartupInfo(struct PluginStartupInfo *info);
- HANDLE WINAPI OpenFilePlugin(char *name, const unsigned char *Data,
+ HANDLE WINAPI OpenFilePlugin(char *name, const unsigned char *Data,
unsigned int DataSize);
HANDLE WINAPI OpenPlugin(int openFrom, int item);
void WINAPI ClosePlugin(HANDLE plugin);
- int WINAPI GetFindData(HANDLE plugin, struct PluginPanelItem **panelItems,
+ int WINAPI GetFindData(HANDLE plugin, struct PluginPanelItem **panelItems,
int *itemsNumber, int OpMode);
void WINAPI FreeFindData(HANDLE plugin, struct PluginPanelItem *panelItems,
int itemsNumber);
@@ -71,7 +71,7 @@ static bool IsItWindowsNT()
{
OSVERSIONINFO versionInfo;
versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
- if (!::GetVersionEx(&versionInfo))
+ if (!::GetVersionEx(&versionInfo))
return false;
return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
}
@@ -84,7 +84,7 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID)
g_hInstance = hInstance;
#ifndef _UNICODE
g_IsNT = IsItWindowsNT();
- #endif
+ #endif
}
return TRUE;
}
@@ -96,19 +96,17 @@ static struct COptions
static const char *kPliginNameForRegestry = "7-ZIP";
-// #define MY_TRY_BEGIN MY_TRY_BEGIN NCOM::CComInitializer aComInitializer;
-
void WINAPI SetStartupInfo(struct PluginStartupInfo *info)
{
MY_TRY_BEGIN;
g_StartupInfo.Init(*info, kPliginNameForRegestry);
g_Options.Enabled = g_StartupInfo.QueryRegKeyValue(
- HKEY_CURRENT_USER, kRegisrtryMainKeyName,
+ HKEY_CURRENT_USER, kRegisrtryMainKeyName,
kRegisrtryValueNameEnabled, kPluginEnabledDefault);
MY_TRY_END1("SetStartupInfo");
}
-class COpenArchiveCallback:
+class COpenArchiveCallback:
public IArchiveOpenCallback,
public IArchiveOpenVolumeCallback,
public IProgress,
@@ -117,14 +115,20 @@ class COpenArchiveCallback:
{
DWORD m_StartTickValue;
bool m_MessageBoxIsShown;
- CMessageBox *m_MessageBox;
- UINT64 m_NumFiles;
- UINT64 m_NumFilesMax;
- UINT64 m_NumFilesPrev;
- bool m_NumFilesDefined;
- UINT64 m_NumBytes;
- bool m_NumBytesDefined;
- UINT32 m_PrevTickCount;
+
+ CProgressBox _progressBox;
+
+ UInt64 _numFilesTotal;
+ UInt64 _numFilesCur;
+ UInt64 _numBytesTotal;
+ UInt64 _numBytesCur;
+
+ bool _numFilesTotalDefined;
+ bool _numFilesCurDefined;
+ bool _numBytesTotalDefined;
+ bool _numBytesCurDefined;
+
+ DWORD m_PrevTickCount;
NWindows::NFile::NFind::CFileInfoW _fileInfo;
public:
@@ -141,12 +145,12 @@ public:
)
// IProgress
- STDMETHOD(SetTotal)(UINT64 total);
- STDMETHOD(SetCompleted)(const UINT64 *aCompleteValue);
+ STDMETHOD(SetTotal)(UInt64 total);
+ STDMETHOD(SetCompleted)(const UInt64 *aCompleteValue);
// IArchiveOpenCallback
- STDMETHOD(SetTotal)(const UINT64 *numFiles, const UINT64 *numBytes);
- STDMETHOD(SetCompleted)(const UINT64 *numFiles, const UINT64 *numBytes);
+ STDMETHOD(SetTotal)(const UInt64 *numFiles, const UInt64 *numBytes);
+ STDMETHOD(SetCompleted)(const UInt64 *numFiles, const UInt64 *numBytes);
// IArchiveOpenVolumeCallback
STDMETHOD(GetProperty)(PROPID propID, PROPVARIANT *value);
@@ -155,18 +159,21 @@ public:
// ICryptoGetTextPassword
STDMETHOD(CryptoGetTextPassword)(BSTR *password);
- void Init(CMessageBox *messageBox)
+ void Init()
{
PasswordIsDefined = false;
- m_NumFilesMax = 0;
+ _numFilesTotalDefined = false;
+ _numFilesCurDefined = false;
+ _numBytesTotalDefined = false;
+ _numBytesCurDefined = false;
+
m_MessageBoxIsShown = false;
m_PrevTickCount = GetTickCount();
- m_MessageBox = messageBox;
}
- void ShowMessage(const UINT64 *completed);
+ void ShowMessage();
- void LoadFileInfo(const UString &folderPrefix,
+ void LoadFileInfo(const UString &folderPrefix,
const UString &fileName)
{
_folderPrefix = folderPrefix;
@@ -175,15 +182,17 @@ public:
}
};
-void COpenArchiveCallback::ShowMessage(const UINT64 *completed)
+void COpenArchiveCallback::ShowMessage()
{
- UINT32 currentTime = GetTickCount();
+ DWORD currentTime = GetTickCount();
if (!m_MessageBoxIsShown)
{
- if (currentTime - m_PrevTickCount < 400)
+ if (currentTime - m_PrevTickCount < 100)
return;
- m_MessageBox->Init(g_StartupInfo.GetMsgString(NMessageID::kWaitTitle),
- g_StartupInfo.GetMsgString(NMessageID::kReading), 2, 30);
+ _progressBox.Init(
+ // g_StartupInfo.GetMsgString(NMessageID::kWaitTitle),
+ g_StartupInfo.GetMsgString(NMessageID::kReading), 48);
+
m_MessageBoxIsShown = true;
}
else
@@ -192,72 +201,96 @@ void COpenArchiveCallback::ShowMessage(const UINT64 *completed)
return;
}
m_PrevTickCount = currentTime;
- char aMessage[256];
- sprintf(aMessage, "%5I64u", m_NumFilesMax);
- char aMessage2[256];
- aMessage2[0] = '\0';
- if (completed != NULL)
- sprintf(aMessage2, "%5I64u", *completed);
- const char *aMessages[2] =
- {aMessage, aMessage2 };
- m_MessageBox->ShowProcessMessages(aMessages);
+
+ UInt64 total = 0, cur = 0;
+ bool curIsDefined = false, totalIsDefined = false;
+
+ char message[256] = { 0 };
+ if (_numFilesCurDefined)
+ ConvertUInt64ToStringAligned(_numFilesCur, message, 5);
+
+ if (_numFilesTotalDefined)
+ {
+ strcat(message, " / ");
+ ConvertUInt64ToStringAligned(_numFilesTotal, message + strlen(message), 5);
+ total = _numFilesTotal;
+ totalIsDefined = true;
+ if (_numFilesCurDefined)
+ {
+ cur = _numFilesCur;
+ curIsDefined = true;
+ }
+ }
+ else if (_numBytesTotalDefined)
+ {
+ total = _numBytesTotal;
+ totalIsDefined = true;
+ if (_numBytesCurDefined)
+ {
+ cur = _numBytesCur;
+ curIsDefined = true;
+ }
+ }
+ _progressBox.Progress(
+ totalIsDefined ? &total: NULL,
+ curIsDefined ? &cur: NULL,
+ message);
}
-STDMETHODIMP COpenArchiveCallback::SetTotal(const UINT64 *numFiles, const UINT64 *numBytes)
+STDMETHODIMP COpenArchiveCallback::SetTotal(const UInt64 *numFiles, const UInt64 *numBytes)
{
if (WasEscPressed())
return E_ABORT;
- m_NumFilesDefined = (numFiles != NULL);
- if (m_NumFilesDefined)
- m_NumFiles = *numFiles;
- m_NumBytesDefined = (numBytes != NULL);
- if (m_NumBytesDefined)
- m_NumBytes = *numBytes;
+
+ _numFilesTotalDefined = (numFiles != NULL);
+ if (_numFilesTotalDefined)
+ _numFilesTotal = *numFiles;
+
+ _numBytesTotalDefined = (numBytes != NULL);
+ if (_numBytesTotalDefined)
+ _numBytesTotal = *numBytes;
+
return S_OK;
}
-STDMETHODIMP COpenArchiveCallback::SetCompleted(const UINT64 *numFiles, const UINT64 * /* numBytes */)
+STDMETHODIMP COpenArchiveCallback::SetCompleted(const UInt64 *numFiles, const UInt64 *numBytes)
{
if (WasEscPressed())
return E_ABORT;
- if (numFiles == NULL)
- return S_OK;
- m_NumFilesMax = *numFiles;
+
+ _numFilesCurDefined = (numFiles != NULL);
+ if (_numFilesCurDefined)
+ _numFilesCur = *numFiles;
+
+ _numBytesCurDefined = (numBytes != NULL);
+ if (_numBytesCurDefined)
+ _numBytesCur = *numBytes;
+
// if (*numFiles % 100 != 0)
// return S_OK;
- ShowMessage(NULL);
+ ShowMessage();
return S_OK;
}
-STDMETHODIMP COpenArchiveCallback::SetTotal(const UINT64 /* total */)
+STDMETHODIMP COpenArchiveCallback::SetTotal(const UInt64 /* total */)
{
if (WasEscPressed())
return E_ABORT;
- /*
- aNumFilesDefined = (numFiles != NULL);
- if (aNumFilesDefined)
- aNumFiles = *numFiles;
- aNumBytesDefined = (numBytes != NULL);
- if (aNumBytesDefined)
- aNumBytes = *numBytes;
- */
return S_OK;
}
-STDMETHODIMP COpenArchiveCallback::SetCompleted(const UINT64 *completed)
+STDMETHODIMP COpenArchiveCallback::SetCompleted(const UInt64 *completed)
{
if (WasEscPressed())
return E_ABORT;
if (completed == NULL)
return S_OK;
- // if (*completed % 100 != 0)
- // return S_OK;
- ShowMessage(completed);
+ ShowMessage();
return S_OK;
}
-STDMETHODIMP COpenArchiveCallback::GetStream(const wchar_t *name,
+STDMETHODIMP COpenArchiveCallback::GetStream(const wchar_t *name,
IInStream **inStream)
{
if (WasEscPressed())
@@ -266,7 +299,7 @@ STDMETHODIMP COpenArchiveCallback::GetStream(const wchar_t *name,
UString fullPath = _folderPrefix + name;
if (!NWindows::NFile::NFind::FindFile(fullPath, _fileInfo))
return S_FALSE;
- if (_fileInfo.IsDirectory())
+ if (_fileInfo.IsDir())
return S_FALSE;
CInFileStream *inFile = new CInFileStream;
CMyComPtr<IInStream> inStreamTemp = inFile;
@@ -279,32 +312,18 @@ STDMETHODIMP COpenArchiveCallback::GetStream(const wchar_t *name,
STDMETHODIMP COpenArchiveCallback::GetProperty(PROPID propID, PROPVARIANT *value)
{
- NWindows::NCOM::CPropVariant propVariant;
+ NWindows::NCOM::CPropVariant prop;
switch(propID)
{
- case kpidName:
- propVariant = GetUnicodeString(_fileInfo.Name, CP_OEMCP);
- break;
- case kpidIsFolder:
- propVariant = _fileInfo.IsDirectory();
- break;
- case kpidSize:
- propVariant = _fileInfo.Size;
- break;
- case kpidAttributes:
- propVariant = (UINT32)_fileInfo.Attributes;
- break;
- case kpidLastAccessTime:
- propVariant = _fileInfo.LastAccessTime;
- break;
- case kpidCreationTime:
- propVariant = _fileInfo.CreationTime;
- break;
- case kpidLastWriteTime:
- propVariant = _fileInfo.LastWriteTime;
- break;
+ case kpidName: prop = GetUnicodeString(_fileInfo.Name, CP_OEMCP); break;
+ case kpidIsDir: prop = _fileInfo.IsDir(); break;
+ case kpidSize: prop = _fileInfo.Size; break;
+ case kpidAttrib: prop = (UInt32)_fileInfo.Attrib; break;
+ case kpidCTime: prop = _fileInfo.CTime; break;
+ case kpidATime: prop = _fileInfo.ATime; break;
+ case kpidMTime: prop = _fileInfo.MTime; break;
}
- propVariant.Detach(value);
+ prop.Detach(value);
return S_OK;
}
@@ -315,7 +334,7 @@ HRESULT GetPassword(UString &password)
password.Empty();
CInitDialogItem initItems[]=
{
- { DI_DOUBLEBOX, 3, 1, 72, 4, false, false, 0, false, NMessageID::kGetPasswordTitle, NULL, NULL },
+ { DI_DOUBLEBOX, 3, 1, 72, 4, false, false, 0, false, NMessageID::kGetPasswordTitle, NULL, NULL },
{ DI_TEXT, 5, 2, 0, 0, false, false, DIF_SHOWAMPERSAND, false, NMessageID::kEnterPasswordForFile, NULL, NULL },
{ DI_PSWEDIT, 5, 3, 70, 3, true, false, 0, true, -1, "", NULL }
};
@@ -329,7 +348,7 @@ HRESULT GetPassword(UString &password)
return (E_ABORT);
AString oemPassword = dialogItems[2].Data;
- password = MultiByteToUnicodeString(oemPassword, CP_OEMCP);
+ password = MultiByteToUnicodeString(oemPassword, CP_OEMCP);
return S_OK;
}
@@ -346,14 +365,14 @@ STDMETHODIMP COpenArchiveCallback::CryptoGetTextPassword(BSTR *password)
}
/*
-HRESULT OpenArchive(const CSysString &fileName,
- IInFolderArchive **archiveHandlerResult,
+HRESULT OpenArchive(const CSysString &fileName,
+ IInFolderArchive **archiveHandlerResult,
CArchiverInfo &archiverInfoResult,
UString &defaultName,
IArchiveOpenCallback *openArchiveCallback)
{
- HRESULT OpenArchive(const CSysString &fileName,
- IInArchive **archive,
+ HRESULT OpenArchive(const CSysString &fileName,
+ IInArchive **archive,
CArchiverInfo &archiverInfoResult,
IArchiveOpenCallback *openArchiveCallback);
}
@@ -371,7 +390,7 @@ static HANDLE MyOpenFilePlugin(const char *name)
NFile::NFind::CFileInfoW fileInfo;
if (!NFile::NFind::FindFile(fullName, fileInfo))
return INVALID_HANDLE_VALUE;
- if (fileInfo.IsDirectory())
+ if (fileInfo.IsDir())
return INVALID_HANDLE_VALUE;
@@ -380,19 +399,18 @@ static HANDLE MyOpenFilePlugin(const char *name)
// CArchiverInfo archiverInfoResult;
// ::OutputDebugString("before OpenArchive\n");
- COpenArchiveCallback *openArchiveCallbackSpec = new COpenArchiveCallback;
-
- CMyComPtr<IArchiveOpenCallback> openArchiveCallback = openArchiveCallbackSpec;
-
- // if ((opMode & OPM_SILENT) == 0 && (opMode & OPM_FIND ) == 0)
CScreenRestorer screenRestorer;
- CMessageBox m_MessageBox;
{
screenRestorer.Save();
}
- openArchiveCallbackSpec->Init(&m_MessageBox);
+
+ COpenArchiveCallback *openArchiveCallbackSpec = new COpenArchiveCallback;
+ CMyComPtr<IArchiveOpenCallback> openArchiveCallback = openArchiveCallbackSpec;
+
+ // if ((opMode & OPM_SILENT) == 0 && (opMode & OPM_FIND ) == 0)
+ openArchiveCallbackSpec->Init();
openArchiveCallbackSpec->LoadFileInfo(
- fullName.Left(fileNamePartStartIndex),
+ fullName.Left(fileNamePartStartIndex),
fullName.Mid(fileNamePartStartIndex));
// ::OutputDebugString("before OpenArchive\n");
@@ -402,7 +420,7 @@ static HANDLE MyOpenFilePlugin(const char *name)
HRESULT result = archiveHandler->Open(
GetUnicodeString(fullName, CP_OEMCP), &archiveType, openArchiveCallback);
/*
- HRESULT result = ::OpenArchive(fullName, &archiveHandler,
+ HRESULT result = ::OpenArchive(fullName, &archiveHandler,
archiverInfoResult, defaultName, openArchiveCallback);
*/
if (result != S_OK)
@@ -415,8 +433,8 @@ static HANDLE MyOpenFilePlugin(const char *name)
// ::OutputDebugString("after OpenArchive\n");
CPlugin *plugin = new CPlugin(
- fullName,
- // defaultName,
+ fullName,
+ // defaultName,
archiveHandler,
(const wchar_t *)archiveType
);
@@ -428,7 +446,7 @@ static HANDLE MyOpenFilePlugin(const char *name)
return (HANDLE)(plugin);
}
-HANDLE WINAPI OpenFilePlugin(char *name,
+HANDLE WINAPI OpenFilePlugin(char *name,
const unsigned char * /* data */, unsigned int /* dataSize */)
{
MY_TRY_BEGIN;
@@ -449,7 +467,7 @@ HANDLE WINAPI OpenPlugin(int openFrom, int item)
CSysString fileName = (const char *)(UINT_PTR)item;
if(fileName.IsEmpty())
return INVALID_HANDLE_VALUE;
- if (fileName.Length() >= 2 &&
+ if (fileName.Length() >= 2 &&
fileName[0] == '\"' && fileName[fileName.Length() - 1] == '\"')
fileName = fileName.Mid(1, fileName.Length() - 2);
@@ -509,13 +527,13 @@ void WINAPI FreeFindData(HANDLE plugin, struct PluginPanelItem *panelItems,
{
MY_TRY_BEGIN;
((CPlugin *)plugin)->FreeFindData(panelItems, itemsNumber);
- MY_TRY_END1("FreeFindData");
+ MY_TRY_END1("FreeFindData");
}
int WINAPI GetFiles(HANDLE plugin, struct PluginPanelItem *panelItems,
int itemsNumber, int move, char *destPath, int opMode)
{
- MY_TRY_BEGIN;
+ MY_TRY_BEGIN;
return(((CPlugin *)plugin)->GetFiles(panelItems, itemsNumber, move, destPath, opMode));
MY_TRY_END2("GetFiles", NFileOperationReturnCode::kError);
}
@@ -546,7 +564,7 @@ void WINAPI GetPluginInfo(struct PluginInfo *info)
info->PluginConfigStrings = (char **)pluginCfgStrings;
info->PluginConfigStringsNumber = sizeof(pluginCfgStrings) / sizeof(pluginCfgStrings[0]);
info->CommandPrefix = (char *)kCommandPrefix;
- MY_TRY_END1("GetPluginInfo");
+ MY_TRY_END1("GetPluginInfo");
}
int WINAPI Configure(int /* itemNumber */)
@@ -572,7 +590,7 @@ int WINAPI Configure(int /* itemNumber */)
FarDialogItem dialogItems[kNumDialogItems];
g_StartupInfo.InitDialogItems(initItems, dialogItems, kNumDialogItems);
- int askCode = g_StartupInfo.ShowDialog(76, kYSize,
+ int askCode = g_StartupInfo.ShowDialog(76, kYSize,
kHelpTopicConfig, dialogItems, kNumDialogItems);
if (askCode != kOkButtonIndex)
@@ -590,7 +608,7 @@ void WINAPI GetOpenPluginInfo(HANDLE plugin,struct OpenPluginInfo *info)
{
MY_TRY_BEGIN;
((CPlugin *)plugin)->GetOpenPluginInfo(info);
- MY_TRY_END1("GetOpenPluginInfo");
+ MY_TRY_END1("GetOpenPluginInfo");
}
int WINAPI PutFiles(HANDLE plugin, struct PluginPanelItem *panelItems,
@@ -606,7 +624,7 @@ int WINAPI DeleteFiles(HANDLE plugin, PluginPanelItem *panelItems,
{
MY_TRY_BEGIN;
return(((CPlugin *)plugin)->DeleteFiles(panelItems, itemsNumber, opMode));
- MY_TRY_END2("DeleteFiles", FALSE);
+ MY_TRY_END2("DeleteFiles", FALSE);
}
int WINAPI ProcessKey(HANDLE plugin, int key, unsigned int controlState)
diff --git a/CPP/7zip/UI/Far/Messages.h b/CPP/7zip/UI/Far/Messages.h
index 9d3060a1..1281b235 100755
--- a/CPP/7zip/UI/Far/Messages.h
+++ b/CPP/7zip/UI/Far/Messages.h
@@ -7,7 +7,7 @@ namespace NMessageID {
enum EEnum
{
- kOk,
+ kOk,
kCancel,
kWarning,
@@ -24,22 +24,22 @@ enum EEnum
kExtension,
kIsFolder,
kSize,
- kPackedSize,
+ kPackSize,
kAttributes,
- kCreationTime,
- kLastAccessTime,
- kLastWriteTime,
- kSolid,
- kCommented,
- kEncrypted,
- kSplitBefore,
+ kCTime,
+ kATime,
+ kMTime,
+ kSolid,
+ kCommented,
+ kEncrypted,
+ kSplitBefore,
kSplitAfter,
- kDictionarySize,
- kCRC,
+ kDictionarySize,
+ kCRC,
kType,
kAnti,
- kMethod,
- kHostOS,
+ kMethod,
+ kHostOS,
kFileSystem,
kUser,
kGroup,
@@ -56,6 +56,15 @@ enum EEnum
kNumBlocks,
kNumVolumes,
+ kBit64,
+ kBigEndian,
+ kCpu,
+ kPhySize,
+ kHeadersSize,
+ kChecksum,
+ kCharacts,
+ kVa,
+
kGetPasswordTitle,
kEnterPasswordForFile,
diff --git a/CPP/7zip/UI/Far/OverwriteDialog.cpp b/CPP/7zip/UI/Far/OverwriteDialog.cpp
index 9272942f..6935fa10 100755
--- a/CPP/7zip/UI/Far/OverwriteDialog.cpp
+++ b/CPP/7zip/UI/Far/OverwriteDialog.cpp
@@ -27,7 +27,7 @@ struct CFileInfoStrings
};
void SetFileInfoStrings(const CFileInfo &fileInfo,
- CFileInfoStrings &fileInfoStrings)
+ CFileInfoStrings &fileInfoStrings)
{
char buffer[256];
@@ -70,7 +70,7 @@ NResult::EEnum Execute(const CFileInfo &oldFileInfo, const CFileInfo &newFileInf
{ DI_DOUBLEBOX, 3, 1, kXSize - 4, kYSize - 2, false, false, 0, false, NMessageID::kOverwriteTitle, NULL, NULL },
{ DI_TEXT, 5, 2, 0, 0, false, false, 0, false, NMessageID::kOverwriteMessage1, NULL, NULL },
- { DI_TEXT, 3, 3, 0, 0, false, false, DIF_BOXCOLOR|DIF_SEPARATOR, false, -1, "", NULL },
+ { DI_TEXT, 3, 3, 0, 0, false, false, DIF_BOXCOLOR|DIF_SEPARATOR, false, -1, "", NULL },
{ DI_TEXT, 5, 4, 0, 0, false, false, 0, false, NMessageID::kOverwriteMessageWouldYouLike, NULL, NULL },
@@ -84,7 +84,7 @@ NResult::EEnum Execute(const CFileInfo &oldFileInfo, const CFileInfo &newFileInf
{ DI_TEXT, 7, 13, 0, 0, false, false, 0, false, -1, newFileInfoStrings.Size, NULL },
{ DI_TEXT, 7, 14, 0, 0, false, false, 0, false, -1, newFileInfoStrings.Time, NULL },
- { DI_TEXT, 3, kYSize - 5, 0, 0, false, false, DIF_BOXCOLOR|DIF_SEPARATOR, false, -1, "", NULL },
+ { DI_TEXT, 3, kYSize - 5, 0, 0, false, false, DIF_BOXCOLOR|DIF_SEPARATOR, false, -1, "", NULL },
{ DI_BUTTON, 0, kYSize - 4, 0, 0, true, false, DIF_CENTERGROUP, true, NMessageID::kOverwriteYes, NULL, NULL },
{ DI_BUTTON, 0, kYSize - 4, 0, 0, false, false, DIF_CENTERGROUP, false, NMessageID::kOverwriteYesToAll, NULL, NULL },
@@ -97,7 +97,7 @@ NResult::EEnum Execute(const CFileInfo &oldFileInfo, const CFileInfo &newFileInf
const int kNumDialogItems = sizeof(anInitItems) / sizeof(anInitItems[0]);
FarDialogItem aDialogItems[kNumDialogItems];
g_StartupInfo.InitDialogItems(anInitItems, aDialogItems, kNumDialogItems);
- int anAskCode = g_StartupInfo.ShowDialog(kXSize, kYSize,
+ int anAskCode = g_StartupInfo.ShowDialog(kXSize, kYSize,
NULL, aDialogItems, kNumDialogItems);
const int kButtonStartPos = kNumDialogItems - 6;
if (anAskCode >= kButtonStartPos && anAskCode < kNumDialogItems)
diff --git a/CPP/7zip/UI/Far/Plugin.cpp b/CPP/7zip/UI/Far/Plugin.cpp
index 40851c0c..65253f01 100755
--- a/CPP/7zip/UI/Far/Plugin.cpp
+++ b/CPP/7zip/UI/Far/Plugin.cpp
@@ -4,34 +4,24 @@
#include "Plugin.h"
+#include "Common/IntToString.h"
#include "Common/StringConvert.h"
#include "Common/Wildcard.h"
-#include "Windows/PropVariantConversions.h"
-#include "Windows/FileName.h"
#include "Windows/FileDir.h"
+#include "Windows/FileName.h"
+#include "Windows/PropVariantConversions.h"
#include "../Common/PropIDUtils.h"
-#include "Messages.h"
#include "FarUtils.h"
+#include "Messages.h"
using namespace NWindows;
using namespace NFar;
-CSysString ConvertPropertyToString2(const PROPVARIANT &propVariant, PROPID propID)
-{
- if (propVariant.vt == VT_BSTR)
- return GetSystemString(propVariant.bstrVal, CP_OEMCP);
- if (propVariant.vt != VT_BOOL)
- return GetSystemString(ConvertPropertyToString(propVariant, propID), CP_OEMCP);
- int messageID = VARIANT_BOOLToBool(propVariant.boolVal) ?
- NMessageID::kYes : NMessageID::kNo;
- return g_StartupInfo.GetMsgString(messageID);
-}
-
-CPlugin::CPlugin(const UString &fileName,
- // const UString &defaultName,
+CPlugin::CPlugin(const UString &fileName,
+ // const UString &defaultName,
IInFolderArchive *archiveHandler,
UString archiveTypeName
):
@@ -53,19 +43,19 @@ CPlugin::~CPlugin()
static void MyGetFileTime(IFolderFolder *anArchiveFolder, UInt32 itemIndex,
PROPID propID, FILETIME &fileTime)
{
- NCOM::CPropVariant propVariant;
- if (anArchiveFolder->GetProperty(itemIndex, propID, &propVariant) != S_OK)
+ NCOM::CPropVariant prop;
+ if (anArchiveFolder->GetProperty(itemIndex, propID, &prop) != S_OK)
throw 271932;
- if (propVariant.vt == VT_EMPTY)
+ if (prop.vt == VT_EMPTY)
{
fileTime.dwHighDateTime = 0;
fileTime.dwLowDateTime = 0;
}
- else
+ else
{
- if (propVariant.vt != VT_FILETIME)
+ if (prop.vt != VT_FILETIME)
throw 4191730;
- fileTime = propVariant.filetime;
+ fileTime = prop.filetime;
}
}
@@ -74,14 +64,14 @@ static void MyGetFileTime(IFolderFolder *anArchiveFolder, UInt32 itemIndex,
void CPlugin::ReadPluginPanelItem(PluginPanelItem &panelItem, UInt32 itemIndex)
{
- NCOM::CPropVariant propVariant;
- if (_folder->GetProperty(itemIndex, kpidName, &propVariant) != S_OK)
+ NCOM::CPropVariant prop;
+ if (_folder->GetProperty(itemIndex, kpidName, &prop) != S_OK)
throw 271932;
- if (propVariant.vt != VT_BSTR)
+ if (prop.vt != VT_BSTR)
throw 272340;
- CSysString oemString = UnicodeStringToMultiByte(propVariant.bstrVal, CP_OEMCP);
+ CSysString oemString = UnicodeStringToMultiByte(prop.bstrVal, CP_OEMCP);
const int kFileNameSizeMax = (int)(sizeof(panelItem.FindData.cFileName) / sizeof(panelItem.FindData.cFileName[0]) - 1);
if (oemString.Length() > kFileNameSizeMax)
oemString = oemString.Left(kFileNameSizeMax);
@@ -92,49 +82,49 @@ void CPlugin::ReadPluginPanelItem(PluginPanelItem &panelItem, UInt32 itemIndex)
MyStringCopy(panelItem.FindData.cFileName, (const char *)oemString);
panelItem.FindData.cAlternateFileName[0] = 0;
- if (_folder->GetProperty(itemIndex, kpidAttributes, &propVariant) != S_OK)
+ if (_folder->GetProperty(itemIndex, kpidAttrib, &prop) != S_OK)
throw 271932;
- if (propVariant.vt == VT_UI4)
- panelItem.FindData.dwFileAttributes = propVariant.ulVal;
- else if (propVariant.vt == VT_EMPTY)
- panelItem.FindData.dwFileAttributes = m_FileInfo.Attributes;
+ if (prop.vt == VT_UI4)
+ panelItem.FindData.dwFileAttributes = prop.ulVal;
+ else if (prop.vt == VT_EMPTY)
+ panelItem.FindData.dwFileAttributes = m_FileInfo.Attrib;
else
throw 21631;
- if (_folder->GetProperty(itemIndex, kpidIsFolder, &propVariant) != S_OK)
+ if (_folder->GetProperty(itemIndex, kpidIsDir, &prop) != S_OK)
throw 271932;
- if (propVariant.vt == VT_BOOL)
+ if (prop.vt == VT_BOOL)
{
- if (VARIANT_BOOLToBool(propVariant.boolVal))
+ if (VARIANT_BOOLToBool(prop.boolVal))
panelItem.FindData.dwFileAttributes |= FILE_ATTRIBUTE_DIRECTORY;
}
- else if (propVariant.vt != VT_EMPTY)
+ else if (prop.vt != VT_EMPTY)
throw 21632;
- if (_folder->GetProperty(itemIndex, kpidSize, &propVariant) != S_OK)
+ if (_folder->GetProperty(itemIndex, kpidSize, &prop) != S_OK)
throw 271932;
UInt64 length;
- if (propVariant.vt == VT_EMPTY)
+ if (prop.vt == VT_EMPTY)
length = 0;
else
- length = ::ConvertPropVariantToUInt64(propVariant);
+ length = ::ConvertPropVariantToUInt64(prop);
panelItem.FindData.nFileSizeLow = (UInt32)length;
panelItem.FindData.nFileSizeHigh = (UInt32)(length >> 32);
- MyGetFileTime(_folder, itemIndex, kpidCreationTime, panelItem.FindData.ftCreationTime);
- MyGetFileTime(_folder, itemIndex, kpidLastAccessTime, panelItem.FindData.ftLastAccessTime);
- MyGetFileTime(_folder, itemIndex, kpidLastWriteTime, panelItem.FindData.ftLastWriteTime);
+ MyGetFileTime(_folder, itemIndex, kpidCTime, panelItem.FindData.ftCreationTime);
+ MyGetFileTime(_folder, itemIndex, kpidATime, panelItem.FindData.ftLastAccessTime);
+ MyGetFileTime(_folder, itemIndex, kpidMTime, panelItem.FindData.ftLastWriteTime);
- if (panelItem.FindData.ftLastWriteTime.dwHighDateTime == 0 &&
+ if (panelItem.FindData.ftLastWriteTime.dwHighDateTime == 0 &&
panelItem.FindData.ftLastWriteTime.dwLowDateTime == 0)
- panelItem.FindData.ftLastWriteTime = m_FileInfo.LastWriteTime;
+ panelItem.FindData.ftLastWriteTime = m_FileInfo.MTime;
- if (_folder->GetProperty(itemIndex, kpidPackedSize, &propVariant) != S_OK)
+ if (_folder->GetProperty(itemIndex, kpidPackSize, &prop) != S_OK)
throw 271932;
- if (propVariant.vt == VT_EMPTY)
+ if (prop.vt == VT_EMPTY)
length = 0;
else
- length = ::ConvertPropVariantToUInt64(propVariant);
+ length = ::ConvertPropVariantToUInt64(prop);
panelItem.PackSize = UInt32(length);
panelItem.PackSizeHigh = UInt32(length >> 32);
@@ -151,7 +141,7 @@ void CPlugin::ReadPluginPanelItem(PluginPanelItem &panelItem, UInt32 itemIndex)
panelItem.Reserved[2] = 0;
}
-int CPlugin::GetFindData(PluginPanelItem **panelItems,
+int CPlugin::GetFindData(PluginPanelItem **panelItems,
int *itemsNumber, int opMode)
{
// CScreenRestorer screenRestorer;
@@ -221,12 +211,12 @@ int CPlugin::SetDirectory(const char *aszDir, int /* opMode */)
if (path == L"\\")
{
_folder.Release();
- m_ArchiveHandler->BindToRootFolder(&_folder);
+ m_ArchiveHandler->BindToRootFolder(&_folder);
}
else if (path == L"..")
{
CMyComPtr<IFolderFolder> newFolder;
- _folder->BindToParentFolder(&newFolder);
+ _folder->BindToParentFolder(&newFolder);
if (newFolder == NULL)
throw 40312;
_folder = newFolder;
@@ -238,7 +228,7 @@ int CPlugin::SetDirectory(const char *aszDir, int /* opMode */)
if (path[0] == L'\\')
{
_folder.Release();
- m_ArchiveHandler->BindToRootFolder(&_folder);
+ m_ArchiveHandler->BindToRootFolder(&_folder);
path = path.Mid(1);
}
UStringVector pathParts;
@@ -257,7 +247,7 @@ void CPlugin::GetPathParts(UStringVector &pathParts)
for (;;)
{
CMyComPtr<IFolderFolder> newFolder;
- folderItem->BindToParentFolder(&newFolder);
+ folderItem->BindToParentFolder(&newFolder);
if (newFolder == NULL)
break;
NCOM::CPropVariant prop;
@@ -289,17 +279,17 @@ struct CPROPIDToName
int PluginID;
};
-static CPROPIDToName kPROPIDToName[] =
+static CPROPIDToName kPROPIDToName[] =
{
{ kpidName, NMessageID::kName },
{ kpidExtension, NMessageID::kExtension },
- { kpidIsFolder, NMessageID::kIsFolder },
+ { kpidIsDir, NMessageID::kIsFolder },
{ kpidSize, NMessageID::kSize },
- { kpidPackedSize, NMessageID::kPackedSize },
- { kpidAttributes, NMessageID::kAttributes },
- { kpidCreationTime, NMessageID::kCreationTime },
- { kpidLastAccessTime, NMessageID::kLastAccessTime },
- { kpidLastWriteTime, NMessageID::kLastWriteTime },
+ { kpidPackSize, NMessageID::kPackSize },
+ { kpidAttrib, NMessageID::kAttributes },
+ { kpidCTime, NMessageID::kCTime },
+ { kpidATime, NMessageID::kATime },
+ { kpidMTime, NMessageID::kMTime },
{ kpidSolid, NMessageID::kSolid },
{ kpidCommented, NMessageID::kCommented },
{ kpidEncrypted, NMessageID::kEncrypted },
@@ -317,7 +307,7 @@ static CPROPIDToName kPROPIDToName[] =
{ kpidBlock, NMessageID::kBlock },
{ kpidComment, NMessageID::kComment },
{ kpidPosition, NMessageID::kPosition },
- { kpidNumSubFolders, NMessageID::kNumSubFolders },
+ { kpidNumSubDirs, NMessageID::kNumSubFolders },
{ kpidNumSubFiles, NMessageID::kNumSubFiles },
{ kpidUnpackVer, NMessageID::kUnpackVer },
{ kpidVolume, NMessageID::kVolume },
@@ -325,7 +315,16 @@ static CPROPIDToName kPROPIDToName[] =
{ kpidOffset, NMessageID::kOffset },
{ kpidLinks, NMessageID::kLinks },
{ kpidNumBlocks, NMessageID::kNumBlocks },
- { kpidNumVolumes, NMessageID::kNumVolumes }
+ { kpidNumVolumes, NMessageID::kNumVolumes },
+
+ { kpidBit64, NMessageID::kBit64 },
+ { kpidBigEndian, NMessageID::kBigEndian },
+ { kpidCpu, NMessageID::kCpu },
+ { kpidPhySize, NMessageID::kPhySize },
+ { kpidHeadersSize, NMessageID::kHeadersSize },
+ { kpidChecksum, NMessageID::kChecksum },
+ { kpidCharacts, NMessageID::kCharacts },
+ { kpidVa, NMessageID::kVa }
};
static const int kNumPROPIDToName = sizeof(kPROPIDToName) / sizeof(kPROPIDToName[0]);
@@ -347,15 +346,15 @@ struct CPropertyIDInfo
// char CharID;
};
-static CPropertyIDInfo kPropertyIDInfos[] =
+static CPropertyIDInfo kPropertyIDInfos[] =
{
{ kpidName, "N", 0},
{ kpidSize, "S", 8},
{ kpidPackedSize, "P", 8},
- { kpidAttributes, "A", 0},
- { kpidCreationTime, "DC", 14},
- { kpidLastAccessTime, "DA", 14},
- { kpidLastWriteTime, "DM", 14},
+ { kpidAttrib, "A", 0},
+ { kpidCTime, "DC", 14},
+ { kpidATime, "DA", 14},
+ { kpidMTime, "DM", 14},
{ kpidSolid, NULL, 0, 'S'},
{ kpidEncrypted, NULL, 0, 'P'}
@@ -368,7 +367,7 @@ static CPropertyIDInfo kPropertyIDInfos[] =
// { kpidType, L"Type" }
};
-static const int kNumPropertyIDInfos = sizeof(kPropertyIDInfos) /
+static const int kNumPropertyIDInfos = sizeof(kPropertyIDInfos) /
sizeof(kPropertyIDInfos[0]);
static int FindPropertyInfo(PROPID propID)
@@ -415,6 +414,88 @@ void CPlugin::AddColumn(PROPID propID)
}
*/
+static AString GetNameOfProp(PROPID propID, const wchar_t *name)
+{
+ int index = FindPropertyToName(propID);
+ if (index < 0)
+ {
+ if (name)
+ return UnicodeStringToMultiByte((const wchar_t *)name, CP_OEMCP);
+ char s[32];
+ ConvertUInt64ToString(propID, s);
+ return s;
+ }
+ return g_StartupInfo.GetMsgString(kPROPIDToName[index].PluginID);
+}
+
+static AString GetNameOfProp2(PROPID propID, const wchar_t *name)
+{
+ AString s = GetNameOfProp(propID, name);
+ if (s.Length() > (kInfoPanelLineSize - 1))
+ s = s.Left(kInfoPanelLineSize - 1);
+ return s;
+}
+
+static AString ConvertSizeToString(UInt64 value)
+{
+ char s[32];
+ ConvertUInt64ToString(value, s);
+ int i = MyStringLen(s);
+ int pos = sizeof(s) / sizeof(s[0]);
+ s[--pos] = L'\0';
+ while (i > 3)
+ {
+ s[--pos] = s[--i];
+ s[--pos] = s[--i];
+ s[--pos] = s[--i];
+ s[--pos] = ' ';
+ }
+ while (i > 0)
+ s[--pos] = s[--i];
+ return s + pos;
+}
+
+static AString PropToString(const NCOM::CPropVariant &prop, PROPID propID)
+{
+ AString s;
+
+ if (prop.vt == VT_BSTR)
+ s = GetSystemString(prop.bstrVal, CP_OEMCP);
+ else if (prop.vt == VT_BOOL)
+ {
+ int messageID = VARIANT_BOOLToBool(prop.boolVal) ?
+ NMessageID::kYes : NMessageID::kNo;
+ return g_StartupInfo.GetMsgString(messageID);
+ }
+ else if (prop.vt != VT_EMPTY)
+ {
+ if ((
+ propID == kpidSize ||
+ propID == kpidPackSize ||
+ propID == kpidNumSubDirs ||
+ propID == kpidNumSubFiles ||
+ propID == kpidNumBlocks ||
+ propID == kpidPhySize ||
+ propID == kpidHeadersSize ||
+ propID == kpidClusterSize
+ ) && (prop.vt == VT_UI8 || prop.vt == VT_UI4))
+ s = ConvertSizeToString(ConvertPropVariantToUInt64(prop));
+ else
+ s = UnicodeStringToMultiByte(ConvertPropertyToString(prop, propID), CP_OEMCP);
+ }
+ s.Replace((char)0xA, ' ');
+ s.Replace((char)0xD, ' ');
+ return s;
+}
+
+static AString PropToString2(const NCOM::CPropVariant &prop, PROPID propID)
+{
+ AString s = PropToString(prop, propID);
+ if (s.Length() > (kInfoPanelLineSize - 1))
+ s = s.Left(kInfoPanelLineSize - 1);
+ return s;
+}
+
void CPlugin::GetOpenPluginInfo(struct OpenPluginInfo *info)
{
info->StructSize = sizeof(*info);
@@ -439,10 +520,10 @@ void CPlugin::GetOpenPluginInfo(struct OpenPluginInfo *info)
name = fullName.Mid(index);
}
- m_PannelTitle =
- UString(L' ') +
- _archiveTypeName +
- UString(L':') +
+ m_PannelTitle =
+ UString(L' ') +
+ _archiveTypeName +
+ UString(L':') +
name +
UString(L' ');
if (!m_CurrentDir.IsEmpty())
@@ -463,46 +544,73 @@ void CPlugin::GetOpenPluginInfo(struct OpenPluginInfo *info)
int numItems = 2;
- CMyComPtr<IFolderProperties> folderProperties;
- _folder.QueryInterface(IID_IFolderProperties, &folderProperties);
- if (folderProperties)
{
- UInt32 numProps;
- if (folderProperties->GetNumberOfFolderProperties(&numProps) == S_OK)
+ CMyComPtr<IFolderProperties> folderProperties;
+ _folder.QueryInterface(IID_IFolderProperties, &folderProperties);
+ if (folderProperties)
+ {
+ UInt32 numProps;
+ if (folderProperties->GetNumberOfFolderProperties(&numProps) == S_OK)
+ {
+ for (UInt32 i = 0; i < numProps && numItems < kNumInfoLinesMax; i++)
+ {
+ CMyComBSTR name;
+ PROPID propID;
+ VARTYPE vt;
+ if (folderProperties->GetFolderPropertyInfo(i, &name, &propID, &vt) != S_OK)
+ continue;
+ NCOM::CPropVariant prop;
+ if (_folder->GetFolderProperty(propID, &prop) != S_OK || prop.vt == VT_EMPTY)
+ continue;
+
+ InfoPanelLine &item = m_InfoLines[numItems++];
+ MyStringCopy(item.Text, (const char *)GetNameOfProp2(propID, name));
+ MyStringCopy(item.Data, (const char *)PropToString2(prop, propID));
+ }
+ }
+ }
+ }
+
+ if (numItems < kNumInfoLinesMax)
+ {
+ InfoPanelLine &item = m_InfoLines[numItems++];
+ MyStringCopy(item.Text, "");
+ MyStringCopy(item.Data, "");
+ item.Separator = TRUE;
+ }
+
+ {
+ CMyComPtr<IGetFolderArchiveProperties> getFolderArchiveProperties;
+ _folder.QueryInterface(IID_IGetFolderArchiveProperties, &getFolderArchiveProperties);
+ if (getFolderArchiveProperties)
{
- for (UInt32 i = 0; i < numProps && numItems < kNumInfoLinesMax; i++)
+ CMyComPtr<IFolderArchiveProperties> getProps;
+ getFolderArchiveProperties->GetFolderArchiveProperties(&getProps);
+ if (getProps)
{
- CMyComBSTR name;
- PROPID propID;
- VARTYPE vt;
- if (folderProperties->GetFolderPropertyInfo(i, &name, &propID, &vt) != S_OK)
- continue;
-
- InfoPanelLine &item = m_InfoLines[numItems];
- int index = FindPropertyToName(propID);
- AString s;
- if (index < 0)
+ UInt32 numProps;
+ if (getProps->GetNumberOfArchiveProperties(&numProps) == S_OK)
{
- if (name != 0)
- s = (const char *)UnicodeStringToMultiByte((const wchar_t *)name, CP_OEMCP);
+ /*
+ if (numProps > 0)
+ message += kSeparator;
+ */
+ for (UInt32 i = 0; i < numProps && numItems < kNumInfoLinesMax; i++)
+ {
+ CMyComBSTR name;
+ PROPID propID;
+ VARTYPE vt;
+ if (getProps->GetArchivePropertyInfo(i, &name, &propID, &vt) != S_OK)
+ continue;
+ NCOM::CPropVariant prop;
+ if (getProps->GetArchiveProperty(propID, &prop) != S_OK || prop.vt == VT_EMPTY)
+ continue;
+ InfoPanelLine &item = m_InfoLines[numItems++];
+ MyStringCopy(item.Text, (const char *)GetNameOfProp2(propID, name));
+ MyStringCopy(item.Data, (const char *)PropToString2(prop, propID));
+
+ }
}
- else
- s = g_StartupInfo.GetMsgString(kPROPIDToName[index].PluginID);
-
- if (s.Length() > (kInfoPanelLineSize - 1))
- s = s.Left(kInfoPanelLineSize - 1);
- MyStringCopy(item.Text, (const char *)s);
-
- NCOM::CPropVariant propVariant;
- if (_folder->GetFolderProperty(propID, &propVariant) != S_OK)
- continue;
- s = ConvertPropertyToString2(propVariant, propID);
- s.Replace((char)0xA, ' ');
- s.Replace((char)0xD, ' ');
- if (s.Length() > (kInfoPanelLineSize - 1))
- s = s.Left(kInfoPanelLineSize - 1);
- MyStringCopy(item.Data, (const char *)s);
- numItems++;
}
}
}
@@ -523,10 +631,10 @@ void CPlugin::GetOpenPluginInfo(struct OpenPluginInfo *info)
AddColumn(kpidName);
AddColumn(kpidSize);
AddColumn(kpidPackedSize);
- AddColumn(kpidLastWriteTime);
- AddColumn(kpidCreationTime);
- AddColumn(kpidLastAccessTime);
- AddColumn(kpidAttributes);
+ AddColumn(kpidMTime);
+ AddColumn(kpidCTime);
+ AddColumn(kpidATime);
+ AddColumn(kpidAttrib);
PanelMode.ColumnTypes = (char *)(const char *)PanelModeColumnTypes;
PanelMode.ColumnWidths = (char *)(const char *)PanelModeColumnWidths;
@@ -565,8 +673,8 @@ HRESULT CPlugin::ShowAttributesWindow()
PluginPanelItem pluginPanelItem;
if (!g_StartupInfo.ControlGetActivePanelCurrentItemInfo(pluginPanelItem))
return S_FALSE;
- if (strcmp(pluginPanelItem.FindData.cFileName, "..") == 0 &&
- NFile::NFind::NAttributes::IsDirectory(pluginPanelItem.FindData.dwFileAttributes))
+ if (strcmp(pluginPanelItem.FindData.cFileName, "..") == 0 &&
+ NFile::NFind::NAttributes::IsDir(pluginPanelItem.FindData.dwFileAttributes))
return S_FALSE;
int itemIndex = pluginPanelItem.UserData;
@@ -580,63 +688,57 @@ HRESULT CPlugin::ShowAttributesWindow()
PROPID propID;
VARTYPE vt;
RINOK(_folder->GetPropertyInfo(i, &name, &propID, &vt));
- CArchiveItemProperty destProperty;
- destProperty.Type = vt;
- destProperty.ID = propID;
- if (destProperty.ID == kpidPath)
- destProperty.ID = kpidName;
- AString propName;
- {
- if (name != NULL)
- destProperty.Name = UnicodeStringToMultiByte((const wchar_t *)name, CP_OEMCP);
- else
- destProperty.Name = "?";
- }
- properties.Add(destProperty);
+ CArchiveItemProperty prop;
+ prop.Type = vt;
+ prop.ID = propID;
+ if (prop.ID == kpidPath)
+ prop.ID = kpidName;
+ prop.Name = GetNameOfProp(propID, name);
+ properties.Add(prop);
}
int size = 2;
CRecordVector<CInitDialogItem> initDialogItems;
int xSize = 70;
- CInitDialogItem initDialogItem =
+ CInitDialogItem idi =
{ DI_DOUBLEBOX, 3, 1, xSize - 4, size - 2, false, false, 0, false, NMessageID::kProperties, NULL, NULL };
- initDialogItems.Add(initDialogItem);
+ initDialogItems.Add(idi);
AStringVector values;
for (i = 0; i < properties.Size(); i++)
{
const CArchiveItemProperty &property = properties[i];
- CInitDialogItem initDialogItem =
+ CInitDialogItem idi =
{ DI_TEXT, 5, 3 + i, 0, 0, false, false, 0, false, 0, NULL, NULL };
int index = FindPropertyToName(property.ID);
if (index < 0)
{
- initDialogItem.DataMessageId = -1;
- initDialogItem.DataString = property.Name;
+ idi.DataMessageId = -1;
+ idi.DataString = property.Name;
}
else
- initDialogItem.DataMessageId = kPROPIDToName[index].PluginID;
- initDialogItems.Add(initDialogItem);
+ idi.DataMessageId = kPROPIDToName[index].PluginID;
+ initDialogItems.Add(idi);
- NCOM::CPropVariant propVariant;
- RINOK(_folder->GetProperty(itemIndex, property.ID, &propVariant));
- CSysString s = ConvertPropertyToString2(propVariant, property.ID);
+ NCOM::CPropVariant prop;
+ RINOK(_folder->GetProperty(itemIndex, property.ID, &prop));
+ CSysString s = PropToString(prop, property.ID);
values.Add(s);
{
- CInitDialogItem initDialogItem =
+ CInitDialogItem idi =
{ DI_TEXT, 30, 3 + i, 0, 0, false, false, 0, false, -1, NULL, NULL };
- initDialogItems.Add(initDialogItem);
+ initDialogItems.Add(idi);
}
}
int numLines = values.Size();
for (i = 0; i < numLines; i++)
{
- CInitDialogItem &initDialogItem = initDialogItems[1 + i * 2 + 1];
- initDialogItem.DataString = values[i];
+ CInitDialogItem &idi = initDialogItems[1 + i * 2 + 1];
+ idi.DataString = values[i];
}
int numDialogItems = initDialogItems.Size();
@@ -645,7 +747,7 @@ HRESULT CPlugin::ShowAttributesWindow()
dialogItems.Reserve(numDialogItems);
for (i = 0; i < numDialogItems; i++)
dialogItems.Add(FarDialogItem());
- g_StartupInfo.InitDialogItems(&initDialogItems.Front(),
+ g_StartupInfo.InitDialogItems(&initDialogItems.Front(),
&dialogItems.Front(), numDialogItems);
int maxLen = 0;
@@ -695,8 +797,8 @@ int CPlugin::ProcessKey(int key, unsigned int controlState)
PanelInfo panelInfo;
g_StartupInfo.ControlGetActivePanelInfo(panelInfo);
GetFilesReal(panelInfo.SelectedItems,
- panelInfo.SelectedItemsNumber, FALSE,
- UnicodeStringToMultiByte(folderPath, CP_OEMCP), OPM_SILENT, true);
+ panelInfo.SelectedItemsNumber, FALSE,
+ UnicodeStringToMultiByte(folderPath, CP_OEMCP), OPM_SILENT, true);
g_StartupInfo.Control(this, FCTL_UPDATEPANEL, NULL);
g_StartupInfo.Control(this, FCTL_REDRAWPANEL, NULL);
g_StartupInfo.Control(this, FCTL_UPDATEANOTHERPANEL, NULL);
diff --git a/CPP/7zip/UI/Far/Plugin.h b/CPP/7zip/UI/Far/Plugin.h
index d9b99fa9..034b1556 100755
--- a/CPP/7zip/UI/Far/Plugin.h
+++ b/CPP/7zip/UI/Far/Plugin.h
@@ -13,7 +13,7 @@
#include "FarUtils.h"
-const UInt32 kNumInfoLinesMax = 30; // Change it;
+const UInt32 kNumInfoLinesMax = 64;
class CPlugin
{
@@ -53,8 +53,8 @@ public:
UString Password;
- CPlugin(const UString &fileName,
- // const UString &aDefaultName,
+ CPlugin(const UString &fileName,
+ // const UString &aDefaultName,
IInFolderArchive *archiveHandler,
UString archiveTypeName
);
@@ -73,10 +73,10 @@ public:
HRESULT ExtractFiles(
bool decompressAllItems,
- const UINT32 *indices,
- UINT32 numIndices,
- bool silent,
- NExtract::NPathMode::EEnum pathMode,
+ const UINT32 *indices,
+ UINT32 numIndices,
+ bool silent,
+ NExtract::NPathMode::EEnum pathMode,
NExtract::NOverwriteMode::EEnum overwriteMode,
const UString &destPath,
bool passwordIsDefined, const UString &password);
@@ -84,7 +84,7 @@ public:
NFar::NFileOperationReturnCode::EEnum GetFiles(struct PluginPanelItem *aPanelItem, int itemsNumber,
int move, char *destPath, int opMode);
- NFar::NFileOperationReturnCode::EEnum GetFilesReal(struct PluginPanelItem *aPanelItems,
+ NFar::NFileOperationReturnCode::EEnum GetFilesReal(struct PluginPanelItem *aPanelItems,
int itemsNumber, int move, const char *_aDestPath, int opMode, bool aShowBox);
NFar::NFileOperationReturnCode::EEnum PutFiles(struct PluginPanelItem *aPanelItems, int itemsNumber,
diff --git a/CPP/7zip/UI/Far/PluginCommon.cpp b/CPP/7zip/UI/Far/PluginCommon.cpp
index 3e8e3cee..ce1a18bb 100755
--- a/CPP/7zip/UI/Far/PluginCommon.cpp
+++ b/CPP/7zip/UI/Far/PluginCommon.cpp
@@ -5,7 +5,7 @@
#include "Plugin.h"
/*
-void CPlugin::AddRealIndexOfFile(const CArchiveFolderItem &aFolder,
+void CPlugin::AddRealIndexOfFile(const CArchiveFolderItem &aFolder,
int anIndexInVector, vector<int> &aRealIndexes)
{
const CArchiveFolderFileItem &anItem = aFolder.m_FileSubItems[anIndexInVector];
@@ -15,7 +15,7 @@ void CPlugin::AddRealIndexOfFile(const CArchiveFolderItem &aFolder,
aRealIndexes.push_back(aHandlerItemIndex);
}
-void CPlugin::AddRealIndexes(const CArchiveFolderItem &anItem,
+void CPlugin::AddRealIndexes(const CArchiveFolderItem &anItem,
vector<int> &aRealIndexes)
{
int aHandlerItemIndex = m_ProxyHandler->GetHandlerItemIndex(anItem.m_Properties);
@@ -28,7 +28,7 @@ void CPlugin::AddRealIndexes(const CArchiveFolderItem &anItem,
}
-void CPlugin::GetRealIndexes(PluginPanelItem *aPanelItems, int anItemsNumber,
+void CPlugin::GetRealIndexes(PluginPanelItem *aPanelItems, int anItemsNumber,
vector<int> &aRealIndexes)
{
aRealIndexes.clear();
diff --git a/CPP/7zip/UI/Far/PluginDelete.cpp b/CPP/7zip/UI/Far/PluginDelete.cpp
index 95e43a36..a1dfb915 100755
--- a/CPP/7zip/UI/Far/PluginDelete.cpp
+++ b/CPP/7zip/UI/Far/PluginDelete.cpp
@@ -54,11 +54,11 @@ int CPlugin::DeleteFiles(PluginPanelItem *panelItems, int numItems,
}
else if (numItems > 1)
{
- sprintf(msg, g_StartupInfo.GetMsgString(NMessageID::kDeleteNumberOfFiles),
+ sprintf(msg, g_StartupInfo.GetMsgString(NMessageID::kDeleteNumberOfFiles),
numItems);
msgItems[1] = msg;
}
- if (g_StartupInfo.ShowMessage(FMSG_WARNING, NULL, msgItems,
+ if (g_StartupInfo.ShowMessage(FMSG_WARNING, NULL, msgItems,
sizeof(msgItems) / sizeof(msgItems[0]), 2) != 0)
return (FALSE);
}
@@ -71,8 +71,9 @@ int CPlugin::DeleteFiles(PluginPanelItem *panelItems, int numItems,
screenRestorer.Save();
progressBoxPointer = &progressBox;
- progressBox.Init(g_StartupInfo.GetMsgString(NMessageID::kWaitTitle),
- g_StartupInfo.GetMsgString(NMessageID::kDeleting), 1 << 17);
+ progressBox.Init(
+ // g_StartupInfo.GetMsgString(NMessageID::kWaitTitle),
+ g_StartupInfo.GetMsgString(NMessageID::kDeleting), 48);
}
NWorkDir::CInfo workDirInfo;
@@ -112,11 +113,11 @@ int CPlugin::DeleteFiles(PluginPanelItem *panelItems, int numItems,
CUpdateCallback100Imp *updateCallbackSpec = new CUpdateCallback100Imp;
CMyComPtr<IFolderArchiveUpdateCallback> updateCallback(updateCallbackSpec );
- updateCallbackSpec->Init(m_ArchiveHandler, &progressBox);
+ updateCallbackSpec->Init(/* m_ArchiveHandler, */ &progressBox);
result = outArchive->DeleteItems(
- tempFileName,
+ tempFileName,
&indices.Front(), indices.Size(),
updateCallback);
updateCallback.Release();
diff --git a/CPP/7zip/UI/Far/PluginRead.cpp b/CPP/7zip/UI/Far/PluginRead.cpp
index 503ff639..7cf7c3c6 100755
--- a/CPP/7zip/UI/Far/PluginRead.cpp
+++ b/CPP/7zip/UI/Far/PluginRead.cpp
@@ -24,14 +24,14 @@ static const char *kHelpTopicExtrFromSevenZip = "Extract";
static const char kDirDelimiter = '\\';
-static const char *kExractPathHistoryName = "7-ZipExtractPath";
+static const char *kExractPathHistoryName = "7-ZipExtractPath";
HRESULT CPlugin::ExtractFiles(
bool decompressAllItems,
- const UINT32 *indices,
- UINT32 numIndices,
+ const UINT32 *indices,
+ UINT32 numIndices,
bool silent,
- NExtract::NPathMode::EEnum pathMode,
+ NExtract::NPathMode::EEnum pathMode,
NExtract::NOverwriteMode::EEnum overwriteMode,
const UString &destPath,
bool passwordIsDefined, const UString &password)
@@ -44,8 +44,9 @@ HRESULT CPlugin::ExtractFiles(
screenRestorer.Save();
progressBoxPointer = &progressBox;
- progressBox.Init(g_StartupInfo.GetMsgString(NMessageID::kWaitTitle),
- g_StartupInfo.GetMsgString(NMessageID::kExtracting), 1 << 17);
+ progressBox.Init(
+ // g_StartupInfo.GetMsgString(NMessageID::kWaitTitle),
+ g_StartupInfo.GetMsgString(NMessageID::kExtracting), 48);
}
@@ -54,10 +55,10 @@ HRESULT CPlugin::ExtractFiles(
extractCallbackSpec->Init(
CP_OEMCP,
- progressBoxPointer,
+ progressBoxPointer,
/*
GetDefaultName(m_FileName, m_ArchiverInfo.Extension),
- m_FileInfo.LastWriteTime, m_FileInfo.Attributes,
+ m_FileInfo.MTime, m_FileInfo.Attributes,
*/
passwordIsDefined, password);
@@ -74,14 +75,14 @@ HRESULT CPlugin::ExtractFiles(
}
}
-NFileOperationReturnCode::EEnum CPlugin::GetFiles(struct PluginPanelItem *panelItems,
+NFileOperationReturnCode::EEnum CPlugin::GetFiles(struct PluginPanelItem *panelItems,
int itemsNumber, int move, char *_aDestPath, int opMode)
{
- return GetFilesReal(panelItems, itemsNumber, move,
+ return GetFilesReal(panelItems, itemsNumber, move,
_aDestPath, opMode, (opMode & OPM_SILENT) == 0);
}
-NFileOperationReturnCode::EEnum CPlugin::GetFilesReal(struct PluginPanelItem *panelItems,
+NFileOperationReturnCode::EEnum CPlugin::GetFilesReal(struct PluginPanelItem *panelItems,
int itemsNumber, int move, const char *_aDestPath, int opMode, bool showBox)
{
if(move != 0)
@@ -130,31 +131,31 @@ NFileOperationReturnCode::EEnum CPlugin::GetFilesReal(struct PluginPanelItem *pa
// { DI_EDIT, 5, 3, kXSize - 6, 3, true, false, 0, false, -1, destPath, NULL},
{ DI_SINGLEBOX, 4, 5, kXMid - 2, 5 + 4, false, false, 0, false, NMessageID::kExtractPathMode, NULL, NULL },
- { DI_RADIOBUTTON, 6, 6, 0, 0, false,
- extractionInfo.PathMode == NExtract::NPathMode::kFullPathnames,
+ { DI_RADIOBUTTON, 6, 6, 0, 0, false,
+ extractionInfo.PathMode == NExtract::NPathMode::kFullPathnames,
DIF_GROUP, false, NMessageID::kExtractPathFull, NULL, NULL },
- { DI_RADIOBUTTON, 6, 7, 0, 0, false,
+ { DI_RADIOBUTTON, 6, 7, 0, 0, false,
extractionInfo.PathMode == NExtract::NPathMode::kCurrentPathnames,
0, false, NMessageID::kExtractPathCurrent, NULL, NULL },
{ DI_RADIOBUTTON, 6, 8, 0, 0, false,
- extractionInfo.PathMode == NExtract::NPathMode::kNoPathnames,
+ extractionInfo.PathMode == NExtract::NPathMode::kNoPathnames,
false, 0, NMessageID::kExtractPathNo, NULL, NULL },
{ DI_SINGLEBOX, kXMid, 5, kXSize - 6, 5 + kNumOverwriteOptions, false, false, 0, false, NMessageID::kExtractOwerwriteMode, NULL, NULL },
- { DI_RADIOBUTTON, kXMid + 2, 6, 0, 0, false,
- extractionInfo.OverwriteMode == NExtract::NOverwriteMode::kAskBefore,
+ { DI_RADIOBUTTON, kXMid + 2, 6, 0, 0, false,
+ extractionInfo.OverwriteMode == NExtract::NOverwriteMode::kAskBefore,
DIF_GROUP, false, NMessageID::kExtractOwerwriteAsk, NULL, NULL },
- { DI_RADIOBUTTON, kXMid + 2, 7, 0, 0, false,
- extractionInfo.OverwriteMode == NExtract::NOverwriteMode::kWithoutPrompt,
+ { DI_RADIOBUTTON, kXMid + 2, 7, 0, 0, false,
+ extractionInfo.OverwriteMode == NExtract::NOverwriteMode::kWithoutPrompt,
0, false, NMessageID::kExtractOwerwritePrompt, NULL, NULL },
- { DI_RADIOBUTTON, kXMid + 2, 8, 0, 0, false,
- extractionInfo.OverwriteMode == NExtract::NOverwriteMode::kSkipExisting,
+ { DI_RADIOBUTTON, kXMid + 2, 8, 0, 0, false,
+ extractionInfo.OverwriteMode == NExtract::NOverwriteMode::kSkipExisting,
0, false, NMessageID::kExtractOwerwriteSkip, NULL, NULL },
- { DI_RADIOBUTTON, kXMid + 2, 9, 0, 0, false,
- extractionInfo.OverwriteMode == NExtract::NOverwriteMode::kAutoRename,
+ { DI_RADIOBUTTON, kXMid + 2, 9, 0, 0, false,
+ extractionInfo.OverwriteMode == NExtract::NOverwriteMode::kAutoRename,
0, false, NMessageID::kExtractOwerwriteAutoRename, NULL, NULL },
- { DI_RADIOBUTTON, kXMid + 2, 10, 0, 0, false,
- extractionInfo.OverwriteMode == NExtract::NOverwriteMode::kAutoRenameExisting,
+ { DI_RADIOBUTTON, kXMid + 2, 10, 0, 0, false,
+ extractionInfo.OverwriteMode == NExtract::NOverwriteMode::kAutoRenameExisting,
0, false, NMessageID::kExtractOwerwriteAutoRenameExisting, NULL, NULL },
{ DI_SINGLEBOX, 4, 10, kXMid- 2, 10 + 3, false, false, 0, false, NMessageID::kExtractFilesMode, NULL, NULL },
@@ -164,7 +165,7 @@ NFileOperationReturnCode::EEnum CPlugin::GetFilesReal(struct PluginPanelItem *pa
{ DI_SINGLEBOX, kXMid, kPasswordYPos, kXSize - 6, kPasswordYPos + 2, false, false, 0, false, NMessageID::kExtractPassword, NULL, NULL },
{ DI_PSWEDIT, kXMid + 2, kPasswordYPos + 1, kXSize - 8, 12, false, false, 0, false, -1, oemPassword, NULL},
- { DI_TEXT, 3, kYSize - 4, 0, 0, false, false, DIF_BOXCOLOR|DIF_SEPARATOR, false, -1, "", NULL },
+ { DI_TEXT, 3, kYSize - 4, 0, 0, false, false, DIF_BOXCOLOR|DIF_SEPARATOR, false, -1, "", NULL },
{ DI_BUTTON, 0, kYSize - 3, 0, 0, false, false, DIF_CENTERGROUP, true, NMessageID::kExtractExtract, NULL, NULL },
@@ -179,7 +180,7 @@ NFileOperationReturnCode::EEnum CPlugin::GetFilesReal(struct PluginPanelItem *pa
g_StartupInfo.InitDialogItems(initItems, dialogItems, kNumDialogItems);
for (;;)
{
- int askCode = g_StartupInfo.ShowDialog(kXSize, kYSize,
+ int askCode = g_StartupInfo.ShowDialog(kXSize, kYSize,
kHelpTopicExtrFromSevenZip, dialogItems, kNumDialogItems);
if (askCode != kOkButtonIndex)
return NFileOperationReturnCode::kInterruptedByUser;
@@ -239,7 +240,7 @@ NFileOperationReturnCode::EEnum CPlugin::GetFilesReal(struct PluginPanelItem *pa
throw 31806;
oemPassword = dialogItems[kPasswordIndex].Data;
- password = MultiByteToUnicodeString(oemPassword, CP_OEMCP);
+ password = MultiByteToUnicodeString(oemPassword, CP_OEMCP);
passwordIsDefined = !password.IsEmpty();
}
@@ -255,11 +256,11 @@ NFileOperationReturnCode::EEnum CPlugin::GetFilesReal(struct PluginPanelItem *pa
for (int i = 0; i < itemsNumber; i++)
indices.Add(panelItems[i].UserData);
- HRESULT result = ExtractFiles(decompressAllItems, &indices.Front(), itemsNumber,
- !showBox, extractionInfo.PathMode, extractionInfo.OverwriteMode,
- MultiByteToUnicodeString(destPath, CP_OEMCP),
+ HRESULT result = ExtractFiles(decompressAllItems, &indices.Front(), itemsNumber,
+ !showBox, extractionInfo.PathMode, extractionInfo.OverwriteMode,
+ MultiByteToUnicodeString(destPath, CP_OEMCP),
passwordIsDefined, password);
- // HRESULT result = ExtractFiles(decompressAllItems, realIndices, !showBox,
+ // HRESULT result = ExtractFiles(decompressAllItems, realIndices, !showBox,
// extractionInfo, destPath, passwordIsDefined, password);
if (result != S_OK)
{
diff --git a/CPP/7zip/UI/Far/PluginWrite.cpp b/CPP/7zip/UI/Far/PluginWrite.cpp
index 80f9916a..2f7fbc83 100755
--- a/CPP/7zip/UI/Far/PluginWrite.cpp
+++ b/CPP/7zip/UI/Far/PluginWrite.cpp
@@ -34,9 +34,9 @@ static const char *kHelpTopic = "Update";
static LPCWSTR kTempArcivePrefix = L"7zA";
-static const char *kArchiveHistoryKeyName = "7-ZipArcName";
+static const char *kArchiveHistoryKeyName = "7-ZipArcName";
-static UINT32 g_MethodMap[] = { 0, 1, 3, 5, 7, 9 };
+static UINT32 g_MethodMap[] = { 0, 1, 3, 5, 7, 9 };
static HRESULT SetOutProperties(IOutFolderArchive *outArchive, UINT32 method)
{
@@ -55,7 +55,7 @@ static HRESULT SetOutProperties(IOutFolderArchive *outArchive, UINT32 method)
}
NFileOperationReturnCode::EEnum CPlugin::PutFiles(
- struct PluginPanelItem *panelItems, int numItems,
+ struct PluginPanelItem *panelItems, int numItems,
int moveMode, int opMode)
{
if(moveMode != 0)
@@ -95,17 +95,17 @@ NFileOperationReturnCode::EEnum CPlugin::PutFiles(
struct CInitDialogItem initItems[]={
{ DI_DOUBLEBOX, 3, 1, 72, kYSize - 2, false, false, 0, false, NMessageID::kUpdateTitle, NULL, NULL },
{ DI_SINGLEBOX, 4, 2, kXMid - 2, 2 + 7, false, false, 0, false, NMessageID::kUpdateMethod, NULL, NULL },
- { DI_RADIOBUTTON, 6, 3, 0, 0, methodIndex == 0, methodIndex == 0,
+ { DI_RADIOBUTTON, 6, 3, 0, 0, methodIndex == 0, methodIndex == 0,
DIF_GROUP, false, NMessageID::kUpdateMethodStore, NULL, NULL },
- { DI_RADIOBUTTON, 6, 4, 0, 0, methodIndex == 1, methodIndex == 1,
+ { DI_RADIOBUTTON, 6, 4, 0, 0, methodIndex == 1, methodIndex == 1,
0, false, NMessageID::kUpdateMethodFastest, NULL, NULL },
- { DI_RADIOBUTTON, 6, 5, 0, 0, methodIndex == 2, methodIndex == 2,
+ { DI_RADIOBUTTON, 6, 5, 0, 0, methodIndex == 2, methodIndex == 2,
0, false, NMessageID::kUpdateMethodFast, NULL, NULL },
- { DI_RADIOBUTTON, 6, 6, 0, 0, methodIndex == 3, methodIndex == 3,
+ { DI_RADIOBUTTON, 6, 6, 0, 0, methodIndex == 3, methodIndex == 3,
0, false, NMessageID::kUpdateMethodNormal, NULL, NULL },
- { DI_RADIOBUTTON, 6, 7, 0, 0, methodIndex == 4, methodIndex == 4,
+ { DI_RADIOBUTTON, 6, 7, 0, 0, methodIndex == 4, methodIndex == 4,
0, false, NMessageID::kUpdateMethodMaximum, NULL, NULL },
- { DI_RADIOBUTTON, 6, 8, 0, 0, methodIndex == 5, methodIndex == 5,
+ { DI_RADIOBUTTON, 6, 8, 0, 0, methodIndex == 5, methodIndex == 5,
0, false, NMessageID::kUpdateMethodUltra, NULL, NULL },
{ DI_SINGLEBOX, kXMid, 2, 70, 2 + 5, false, false, 0, false, NMessageID::kUpdateMode, NULL, NULL },
@@ -113,12 +113,12 @@ NFileOperationReturnCode::EEnum CPlugin::PutFiles(
DIF_GROUP, false, NMessageID::kUpdateModeAdd, NULL, NULL },
{ DI_RADIOBUTTON, kXMid + 2, 4, 0, 0, false, false,
0, false, NMessageID::kUpdateModeUpdate, NULL, NULL },
- { DI_RADIOBUTTON, kXMid + 2, 5, 0, 0, false, false,
+ { DI_RADIOBUTTON, kXMid + 2, 5, 0, 0, false, false,
0, false, NMessageID::kUpdateModeFreshen, NULL, NULL },
{ DI_RADIOBUTTON, kXMid + 2, 6, 0, 0, false, false,
0, false, NMessageID::kUpdateModeSynchronize, NULL, NULL },
- { DI_TEXT, 3, kYSize - 4, 0, 0, false, false, DIF_BOXCOLOR|DIF_SEPARATOR, false, -1, "", NULL },
+ { DI_TEXT, 3, kYSize - 4, 0, 0, false, false, DIF_BOXCOLOR|DIF_SEPARATOR, false, -1, "", NULL },
{ DI_BUTTON, 0, kYSize - 3, 0, 0, false, false, DIF_CENTERGROUP, true, NMessageID::kUpdateAdd, NULL, NULL },
{ DI_BUTTON, 0, kYSize - 3, 0, 0, false, false, DIF_CENTERGROUP, false, NMessageID::kCancel, NULL, NULL }
@@ -128,7 +128,7 @@ NFileOperationReturnCode::EEnum CPlugin::PutFiles(
const int kOkButtonIndex = kNumDialogItems - 2;
FarDialogItem dialogItems[kNumDialogItems];
g_StartupInfo.InitDialogItems(initItems, dialogItems, kNumDialogItems);
- int askCode = g_StartupInfo.ShowDialog(76, kYSize,
+ int askCode = g_StartupInfo.ShowDialog(76, kYSize,
kHelpTopic, dialogItems, kNumDialogItems);
if (askCode != kOkButtonIndex)
return NFileOperationReturnCode::kInterruptedByUser;
@@ -184,8 +184,9 @@ NFileOperationReturnCode::EEnum CPlugin::PutFiles(
screenRestorer.Save();
progressBoxPointer = &progressBox;
- progressBox.Init(g_StartupInfo.GetMsgString(NMessageID::kWaitTitle),
- g_StartupInfo.GetMsgString(NMessageID::kUpdating), 1 << 16);
+ progressBox.Init(
+ // g_StartupInfo.GetMsgString(NMessageID::kWaitTitle),
+ g_StartupInfo.GetMsgString(NMessageID::kUpdating), 48);
}
////////////////////////////
@@ -223,8 +224,8 @@ NFileOperationReturnCode::EEnum CPlugin::PutFiles(
// CSysString aCurrentFolder;
// MyGetCurrentDirectory(aCurrentFolder);
- // outArchive->SetFiles(MultiByteToUnicodeString(aCurrentFolder, CP_OEMCP),
- outArchive->SetFiles(L"",
+ // outArchive->SetFiles(MultiByteToUnicodeString(aCurrentFolder, CP_OEMCP),
+ outArchive->SetFiles(L"",
&fileNamePointers.Front(), fileNamePointers.Size());
BYTE actionSetByte[NUpdateArchive::NPairState::kNumValues];
for (i = 0; i < NUpdateArchive::NPairState::kNumValues; i++)
@@ -233,7 +234,7 @@ NFileOperationReturnCode::EEnum CPlugin::PutFiles(
CUpdateCallback100Imp *updateCallbackSpec = new CUpdateCallback100Imp;
CMyComPtr<IFolderArchiveUpdateCallback> updateCallback(updateCallbackSpec );
- updateCallbackSpec->Init(m_ArchiveHandler, &progressBox);
+ updateCallbackSpec->Init(/* m_ArchiveHandler, */ &progressBox);
if (SetOutProperties(outArchive, compressionInfo.Level) != S_OK)
return NFileOperationReturnCode::kError;
@@ -243,8 +244,8 @@ NFileOperationReturnCode::EEnum CPlugin::PutFiles(
outArchive.Release();
/*
- HRESULT result = Compress(fileNames, anArchivePrefix, *actionSet,
- m_ProxyHandler.get(),
+ HRESULT result = Compress(fileNames, anArchivePrefix, *actionSet,
+ m_ProxyHandler.get(),
m_ArchiverInfo.ClassID, compressionInfo.Method == 0,
compressionInfo.Method == 2, tempFileName, progressBoxPointer);
*/
@@ -305,7 +306,7 @@ NFileOperationReturnCode::EEnum CPlugin::PutFiles(
{
const PluginPanelItem &aPluginPanelItem = panelItems[i];
bool result;
- if(NFile::NFind::NAttributes::IsDirectory(aPluginPanelItem.FindData.dwFileAttributes))
+ if(NFile::NFind::NAttributes::IsDir(aPluginPanelItem.FindData.dwFileAttributes))
result = NFile::NDirectory::RemoveDirectoryWithSubItems(
aPluginPanelItem.FindData.cFileName);
else
@@ -397,7 +398,7 @@ UString CParsedPath::MergePath() const
/*
// {23170F69-40C1-278A-1000-000100030000}
-DEFINE_GUID(CLSID_CAgentArchiveHandler,
+DEFINE_GUID(CLSID_CAgentArchiveHandler,
0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x00, 0x03, 0x00, 0x00);
*/
@@ -412,11 +413,11 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
{
const PluginPanelItem &panelItem = pluginPanelItems[i];
CSysString fullName;
- if (strcmp(panelItem.FindData.cFileName, "..") == 0 &&
- NFind::NAttributes::IsDirectory(panelItem.FindData.dwFileAttributes))
+ if (strcmp(panelItem.FindData.cFileName, "..") == 0 &&
+ NFind::NAttributes::IsDir(panelItem.FindData.dwFileAttributes))
return E_FAIL;
- if (strcmp(panelItem.FindData.cFileName, ".") == 0 &&
- NFind::NAttributes::IsDirectory(panelItem.FindData.dwFileAttributes))
+ if (strcmp(panelItem.FindData.cFileName, ".") == 0 &&
+ NFind::NAttributes::IsDir(panelItem.FindData.dwFileAttributes))
return E_FAIL;
if (!MyGetFullPathName(panelItem.FindData.cFileName, fullName))
return E_FAIL;
@@ -498,7 +499,7 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
char updateAddToArchiveString[512];
const AString s = GetSystemString(arcInfo.Name, CP_OEMCP);
- sprintf(updateAddToArchiveString,
+ sprintf(updateAddToArchiveString,
g_StartupInfo.GetMsgString(NMessageID::kUpdateAddToArchive), (const char *)s);
int methodIndex = 0;
@@ -520,34 +521,34 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
// { DI_EDIT, 5, 3, 70, 3, true, false, 0, false, -1, archiveName, NULL},
{ DI_SINGLEBOX, 4, 4, kXMid - 2, 4 + 7, false, false, 0, false, NMessageID::kUpdateMethod, NULL, NULL },
- { DI_RADIOBUTTON, 6, 5, 0, 0, false, methodIndex == 0,
+ { DI_RADIOBUTTON, 6, 5, 0, 0, false, methodIndex == 0,
DIF_GROUP, false, NMessageID::kUpdateMethodStore, NULL, NULL },
- { DI_RADIOBUTTON, 6, 6, 0, 0, false, methodIndex == 1,
+ { DI_RADIOBUTTON, 6, 6, 0, 0, false, methodIndex == 1,
0, false, NMessageID::kUpdateMethodFastest, NULL, NULL },
- { DI_RADIOBUTTON, 6, 7, 0, 0, false, methodIndex == 2,
+ { DI_RADIOBUTTON, 6, 7, 0, 0, false, methodIndex == 2,
0, false, NMessageID::kUpdateMethodFast, NULL, NULL },
- { DI_RADIOBUTTON, 6, 8, 0, 0, false, methodIndex == 3,
+ { DI_RADIOBUTTON, 6, 8, 0, 0, false, methodIndex == 3,
0, false, NMessageID::kUpdateMethodNormal, NULL, NULL },
- { DI_RADIOBUTTON, 6, 9, 0, 0, false, methodIndex == 4,
+ { DI_RADIOBUTTON, 6, 9, 0, 0, false, methodIndex == 4,
false, 0, NMessageID::kUpdateMethodMaximum, NULL, NULL },
- { DI_RADIOBUTTON, 6, 10, 0, 0, false, methodIndex == 5,
+ { DI_RADIOBUTTON, 6, 10, 0, 0, false, methodIndex == 5,
false, 0, NMessageID::kUpdateMethodUltra, NULL, NULL },
{ DI_SINGLEBOX, kXMid, 4, 70, 4 + 5, false, false, 0, false, NMessageID::kUpdateMode, NULL, NULL },
- { DI_RADIOBUTTON, kXMid + 2, 5, 0, 0, false,
+ { DI_RADIOBUTTON, kXMid + 2, 5, 0, 0, false,
actionSet == &kAddActionSet,
DIF_GROUP, false, NMessageID::kUpdateModeAdd, NULL, NULL },
- { DI_RADIOBUTTON, kXMid + 2, 6, 0, 0, false,
+ { DI_RADIOBUTTON, kXMid + 2, 6, 0, 0, false,
actionSet == &kUpdateActionSet,
0, false, NMessageID::kUpdateModeUpdate, NULL, NULL },
- { DI_RADIOBUTTON, kXMid + 2, 7, 0, 0, false,
+ { DI_RADIOBUTTON, kXMid + 2, 7, 0, 0, false,
actionSet == &kFreshActionSet,
0, false, NMessageID::kUpdateModeFreshen, NULL, NULL },
- { DI_RADIOBUTTON, kXMid + 2, 8, 0, 0, false,
+ { DI_RADIOBUTTON, kXMid + 2, 8, 0, 0, false,
actionSet == &kSynchronizeActionSet,
0, false, NMessageID::kUpdateModeSynchronize, NULL, NULL },
- { DI_TEXT, 3, kYSize - 4, 0, 0, false, false, DIF_BOXCOLOR|DIF_SEPARATOR, false, -1, "", NULL },
+ { DI_TEXT, 3, kYSize - 4, 0, 0, false, false, DIF_BOXCOLOR|DIF_SEPARATOR, false, -1, "", NULL },
{ DI_BUTTON, 0, kYSize - 3, 0, 0, false, false, DIF_CENTERGROUP, true, NMessageID::kUpdateAdd, NULL, NULL },
{ DI_BUTTON, 0, kYSize - 3, 0, 0, false, false, DIF_CENTERGROUP, false, NMessageID::kUpdateSelectArchiver, NULL, NULL },
@@ -561,7 +562,7 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
FarDialogItem dialogItems[kNumDialogItems];
g_StartupInfo.InitDialogItems(initItems, dialogItems, kNumDialogItems);
- int askCode = g_StartupInfo.ShowDialog(76, kYSize,
+ int askCode = g_StartupInfo.ShowDialog(76, kYSize,
kHelpTopic, dialogItems, kNumDialogItems);
archiveNameA = dialogItems[kArchiveNameIndex].Data;
@@ -598,7 +599,7 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
}
}
- int index = g_StartupInfo.Menu(FMENU_AUTOHIGHLIGHT,
+ int index = g_StartupInfo.Menu(FMENU_AUTOHIGHLIGHT,
g_StartupInfo.GetMsgString(NMessageID::kUpdateSelectArchiverMenuTitle),
NULL, archiverNames, archiverIndex);
if(index >= 0)
@@ -672,8 +673,9 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
screenRestorer.Save();
progressBoxPointer = &progressBox;
- progressBox.Init(g_StartupInfo.GetMsgString(NMessageID::kWaitTitle),
- g_StartupInfo.GetMsgString(NMessageID::kUpdating), 1 << 16);
+ progressBox.Init(
+ // g_StartupInfo.GetMsgString(NMessageID::kWaitTitle),
+ g_StartupInfo.GetMsgString(NMessageID::kUpdating), 48);
NFind::CFileInfoW fileInfo;
@@ -683,7 +685,7 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
CMyComPtr<IInFolderArchive> archiveHandler;
if(NFind::FindFile(fullArchiveName, fileInfo))
{
- if (fileInfo.IsDirectory())
+ if (fileInfo.IsDir())
throw "There is Directory with such name";
CAgent *agentSpec = new CAgent;
@@ -691,8 +693,8 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
// CLSID realClassID;
CMyComBSTR archiveType;
RINOK(agentSpec->Open(
- GetUnicodeString(fullArchiveName, CP_OEMCP),
- // &realClassID,
+ GetUnicodeString(fullArchiveName, CP_OEMCP),
+ // &realClassID,
&archiveType,
NULL));
@@ -730,8 +732,8 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
outArchive->SetFolder(NULL);
// CSysString aCurrentFolder;
// MyGetCurrentDirectory(aCurrentFolder);
- // outArchive->SetFiles(MultiByteToUnicodeString(aCurrentFolder, CP_OEMCP),
- outArchive->SetFiles(L"",
+ // outArchive->SetFiles(MultiByteToUnicodeString(aCurrentFolder, CP_OEMCP),
+ outArchive->SetFiles(L"",
&fileNamePointers.Front(), fileNamePointers.Size());
BYTE actionSetByte[NUpdateArchive::NPairState::kNumValues];
for (i = 0; i < NUpdateArchive::NPairState::kNumValues; i++)
@@ -740,14 +742,14 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
CUpdateCallback100Imp *updateCallbackSpec = new CUpdateCallback100Imp;
CMyComPtr<IFolderArchiveUpdateCallback> updateCallback(updateCallbackSpec );
- updateCallbackSpec->Init(archiveHandler, &progressBox);
+ updateCallbackSpec->Init(/* archiveHandler, */ &progressBox);
RINOK(SetOutProperties(outArchive, compressionInfo.Level));
HRESULT result = outArchive->DoOperation(
codecs, archiverIndex,
- tempFileName, actionSetByte,
+ tempFileName, actionSetByte,
NULL, updateCallback);
updateCallback.Release();
outArchive.Release();
diff --git a/CPP/7zip/UI/Far/ProgressBox.cpp b/CPP/7zip/UI/Far/ProgressBox.cpp
index d708331a..b13b0b51 100755
--- a/CPP/7zip/UI/Far/ProgressBox.cpp
+++ b/CPP/7zip/UI/Far/ProgressBox.cpp
@@ -5,100 +5,108 @@
#include <stdio.h>
#include "ProgressBox.h"
-
+#include "Common/IntToString.h"
#include "FarUtils.h"
-using namespace NFar;
-
-static void CopySpaces(char *destString, int numSpaces)
+static void CopySpaces(char *dest, int numSpaces)
{
int i;
- for(i = 0; i < numSpaces; i++)
- destString[i] = ' ';
- destString[i] = '\0';
+ for (i = 0; i < numSpaces; i++)
+ dest[i] = ' ';
+ dest[i] = '\0';
}
-/////////////////////////////////
-// CMessageBox
+void ConvertUInt64ToStringAligned(UInt64 value, char *s, int alignSize)
+{
+ char temp[32];
+ ConvertUInt64ToString(value, temp);
+ int len = (int)strlen(temp);
+ int numSpaces = 0;
+ if (len < alignSize)
+ {
+ numSpaces = alignSize - len;
+ CopySpaces(s, numSpaces);
+ }
+ strcpy(s + numSpaces, temp);
+}
-const int kNumStringsMax = 10;
-void CMessageBox::Init(const CSysString &title, const CSysString &message,
- int numStrings, int width)
-{
- if (numStrings > kNumStringsMax)
- throw 120620;
- m_NumStrings = numStrings;
- m_Width = width;
+// ---------- CMessageBox ----------
- m_Title = title;
- m_Message = message;
-}
+static const int kMaxLen = 255;
-const int kNumStaticStrings = 2;
+void CMessageBox::Init(const AString &title, int width)
+{
+ _title = title;
+ _width = MyMin(width, kMaxLen);
+}
-void CMessageBox::ShowProcessMessages(const char *messages[])
+void CMessageBox::ShowMessages(const char *strings[], int numStrings)
{
+ const int kNumStaticStrings = 1;
+ const int kNumStringsMax = 10;
+
+ if (numStrings > kNumStringsMax)
+ numStrings = kNumStringsMax;
+
const char *msgItems[kNumStaticStrings + kNumStringsMax];
- msgItems[0] = m_Title;
- msgItems[1] = m_Message;
+ msgItems[0] = _title;
- char formattedMessages[kNumStringsMax][256];
+ char formattedMessages[kNumStringsMax][kMaxLen + 1];
- for (int i = 0; i < m_NumStrings; i++)
+ for (int i = 0; i < numStrings; i++)
{
char *formattedMessage = formattedMessages[i];
- int len = (int)strlen(messages[i]);
- int size = MyMax(m_Width, len);
- int startPos = (size - len) / 2;
- CopySpaces(formattedMessage, startPos);
- MyStringCopy(formattedMessage + startPos, messages[i]);
- CopySpaces(formattedMessage + startPos + len, size - startPos - len);
+ const char *s = strings[i];
+ int len = (int)strlen(s);
+ if (len < kMaxLen)
+ {
+ int size = MyMax(_width, len);
+ int startPos = (size - len) / 2;
+ CopySpaces(formattedMessage, startPos);
+ strcpy(formattedMessage + startPos, s);
+ CopySpaces(formattedMessage + startPos + len, size - startPos - len);
+ }
+ else
+ {
+ strncpy(formattedMessage, s, kMaxLen);
+ formattedMessage[kMaxLen] = 0;
+ }
msgItems[kNumStaticStrings + i] = formattedMessage;
}
-
- g_StartupInfo.ShowMessage(0, NULL, msgItems, kNumStaticStrings + m_NumStrings, 0);
+ NFar::g_StartupInfo.ShowMessage(0, NULL, msgItems, kNumStaticStrings + numStrings, 0);
}
-/////////////////////////////////
-// CProgressBox
-
-void CProgressBox::Init(const CSysString &title, const CSysString &message,
- UInt64 step)
-{
- CMessageBox::Init(title, message, 1, 22);
- m_Step = step;
- m_CompletedPrev = 0;
- m_Total = 0;
-}
-
-
-void CProgressBox::ShowProcessMessage(const char *message)
-{
- CMessageBox::ShowProcessMessages(&message);
-}
-void CProgressBox::PrintPercent(UInt64 percent)
-{
- char valueBuffer[32];
- sprintf(valueBuffer, "%I64u%%", percent);
- ShowProcessMessage(valueBuffer);
-}
+// ---------- CProgressBox ----------
-void CProgressBox::SetTotal(UInt64 total)
+void CProgressBox::Init(const AString &title, int width)
{
- m_Total = total;
+ CMessageBox::Init(title, width);
+ _prevMessage.Empty();
+ _prevPercentMessage.Empty();
+ _wasShown = false;
}
-void CProgressBox::PrintCompeteValue(UInt64 completed)
+void CProgressBox::Progress(const UInt64 *total, const UInt64 *completed, const AString &message)
{
- if (completed >= m_CompletedPrev + m_Step || completed < m_CompletedPrev ||
- completed == 0)
+ AString percentMessage;
+ if (total != 0 && completed != 0)
{
- if (m_Total == 0)
- PrintPercent(0);
- else
- PrintPercent(completed * 100 / m_Total);
- m_CompletedPrev = completed;
+ UInt64 totalVal = *total;
+ if (totalVal == 0)
+ totalVal = 1;
+ char buf[32];
+ ConvertUInt64ToStringAligned(*completed * 100 / totalVal, buf, 3);
+ strcat(buf, "%");
+ percentMessage = buf;
+ }
+ if (message != _prevMessage || percentMessage != _prevPercentMessage || !_wasShown)
+ {
+ _prevMessage = message;
+ _prevPercentMessage = percentMessage;
+ const char *strings[] = { message, percentMessage };
+ ShowMessages(strings, sizeof(strings) / sizeof(strings[0]));
+ _wasShown = true;
}
}
diff --git a/CPP/7zip/UI/Far/ProgressBox.h b/CPP/7zip/UI/Far/ProgressBox.h
index 9e6f671a..2bada8e9 100755
--- a/CPP/7zip/UI/Far/ProgressBox.h
+++ b/CPP/7zip/UI/Far/ProgressBox.h
@@ -6,30 +6,25 @@
#include "Common/MyString.h"
#include "Common/Types.h"
+void ConvertUInt64ToStringAligned(UInt64 value, char *s, int alignSize);
+
class CMessageBox
{
- CSysString m_Title;
- CSysString m_Message;
- int m_NumStrings;
- int m_Width;
+ AString _title;
+ int _width;
public:
- void Init(const CSysString &title,
- const CSysString &message, int numStrings, int width);
- void ShowProcessMessages(const char *messages[]);
+ void Init(const AString &title, int width);
+ void ShowMessages(const char *strings[], int numStrings);
};
class CProgressBox: public CMessageBox
{
- UInt64 m_Total;
- UInt64 m_CompletedPrev;
- UInt64 m_Step;
+ AString _prevMessage;
+ AString _prevPercentMessage;
+ bool _wasShown;
public:
- void Init(const CSysString &title,
- const CSysString &message, UInt64 step);
- void ShowProcessMessage(const char *message);
- void PrintPercent(UInt64 percent);
- void PrintCompeteValue(UInt64 completed);
- void SetTotal(UInt64 total);
+ void Init(const AString &title, int width);
+ void Progress(const UInt64 *total, const UInt64 *completed, const AString &message);
};
#endif
diff --git a/CPP/7zip/UI/Far/UpdateCallback100.cpp b/CPP/7zip/UI/Far/UpdateCallback100.cpp
index ce4fa05e..dc90c810 100755
--- a/CPP/7zip/UI/Far/UpdateCallback100.cpp
+++ b/CPP/7zip/UI/Far/UpdateCallback100.cpp
@@ -15,22 +15,18 @@ STDMETHODIMP CUpdateCallback100Imp::SetNumFiles(UInt64 /* numFiles */)
return S_OK;
}
-STDMETHODIMP CUpdateCallback100Imp::SetTotal(UINT64 aSize)
+STDMETHODIMP CUpdateCallback100Imp::SetTotal(UInt64 size)
{
- if (m_ProgressBox != 0)
- {
- m_ProgressBox->SetTotal(aSize);
- m_ProgressBox->PrintCompeteValue(0);
- }
+ _total = size;
return S_OK;
}
-STDMETHODIMP CUpdateCallback100Imp::SetCompleted(const UINT64 *aCompleteValue)
+STDMETHODIMP CUpdateCallback100Imp::SetCompleted(const UInt64 *completeValue)
{
- if(WasEscPressed())
+ if (WasEscPressed())
return E_ABORT;
- if (m_ProgressBox != 0 && aCompleteValue != NULL)
- m_ProgressBox->PrintCompeteValue(*aCompleteValue);
+ if (_progressBox != 0)
+ _progressBox->Progress(&_total, completeValue, AString());
return S_OK;
}
@@ -44,15 +40,14 @@ STDMETHODIMP CUpdateCallback100Imp::DeleteOperation(const wchar_t* /* name */)
return S_OK;
}
-STDMETHODIMP CUpdateCallback100Imp::OperationResult(INT32 /* operationResult */)
+STDMETHODIMP CUpdateCallback100Imp::OperationResult(Int32 /* opRes */)
{
return S_OK;
}
STDMETHODIMP CUpdateCallback100Imp::UpdateErrorMessage(const wchar_t *message)
{
- CSysString s = UnicodeStringToMultiByte(message, CP_OEMCP);
- if (g_StartupInfo.ShowMessage(s) == -1)
+ if (g_StartupInfo.ShowMessage(UnicodeStringToMultiByte(message, CP_OEMCP)) == -1)
return E_ABORT;
return S_OK;
}
diff --git a/CPP/7zip/UI/Far/UpdateCallback100.h b/CPP/7zip/UI/Far/UpdateCallback100.h
index f12193e9..45f4daea 100755
--- a/CPP/7zip/UI/Far/UpdateCallback100.h
+++ b/CPP/7zip/UI/Far/UpdateCallback100.h
@@ -9,34 +9,25 @@
#include "ProgressBox.h"
-class CUpdateCallback100Imp:
+class CUpdateCallback100Imp:
public IFolderArchiveUpdateCallback,
public CMyUnknownImp
{
+ // CMyComPtr<IInFolderArchive> _archiveHandler;
+ CProgressBox *_progressBox;
+ UInt64 _total;
+
public:
MY_UNKNOWN_IMP
- // IProfress
-
- STDMETHOD(SetTotal)(UINT64 aSize);
- STDMETHOD(SetCompleted)(const UINT64 *aCompleteValue);
+ INTERFACE_IProgress(;)
+ INTERFACE_IFolderArchiveUpdateCallback(;)
- // IUpdateCallBack
- STDMETHOD(CompressOperation)(const wchar_t *aName);
- STDMETHOD(DeleteOperation)(const wchar_t *aName);
- STDMETHOD(OperationResult)(INT32 aOperationResult);
- STDMETHOD(UpdateErrorMessage)(const wchar_t *message);
- STDMETHOD(SetNumFiles)(UInt64 numFiles);
-
-private:
- CMyComPtr<IInFolderArchive> m_ArchiveHandler;
- CProgressBox *m_ProgressBox;
-public:
- void Init(IInFolderArchive *anArchiveHandler,
- CProgressBox *aProgressBox)
+ CUpdateCallback100Imp(): _total(0) {}
+ void Init(/* IInFolderArchive *archiveHandler, */ CProgressBox *progressBox)
{
- m_ArchiveHandler = anArchiveHandler;
- m_ProgressBox = aProgressBox;
+ // _archiveHandler = archiveHandler;
+ _progressBox = progressBox;
}
};
diff --git a/CPP/7zip/UI/Far/makefile b/CPP/7zip/UI/Far/makefile
index 1210e961..2c820077 100755
--- a/CPP/7zip/UI/Far/makefile
+++ b/CPP/7zip/UI/Far/makefile
@@ -39,6 +39,7 @@ WIN_OBJS = \
$O\PropVariantConversions.obj \
$O\Registry.obj \
$O\Synchronization.obj \
+ $O\Time.obj \
7ZIP_COMMON_OBJS = \
$O\FilePathAutoRename.obj \
diff --git a/CPP/7zip/UI/FileManager/AboutDialog.cpp b/CPP/7zip/UI/FileManager/AboutDialog.cpp
index fcdea7e0..a450a765 100755
--- a/CPP/7zip/UI/FileManager/AboutDialog.cpp
+++ b/CPP/7zip/UI/FileManager/AboutDialog.cpp
@@ -7,7 +7,7 @@
#include "HelpUtils.h"
#include "LangUtils.h"
-static CIDLangPair kIDLangPairs[] =
+static CIDLangPair kIDLangPairs[] =
{
{ IDC_ABOUT_STATIC_REGISTER_INFO, 0x01000103 },
{ IDC_ABOUT_BUTTON_SUPPORT, 0x01000104 },
@@ -23,7 +23,7 @@ static LPCTSTR kSupportPageURL = MY_HOME_PAGE TEXT("support.html");
static LPCWSTR kHelpTopic = L"start.htm";
-bool CAboutDialog::OnInit()
+bool CAboutDialog::OnInit()
{
LangSetWindowText(HWND(*this), 0x01000100);
LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
diff --git a/CPP/7zip/UI/FileManager/App.cpp b/CPP/7zip/UI/FileManager/App.cpp
index 4a4dcc96..ec1d2df4 100755
--- a/CPP/7zip/UI/FileManager/App.cpp
+++ b/CPP/7zip/UI/FileManager/App.cpp
@@ -3,22 +3,26 @@
#include "StdAfx.h"
#include "resource.h"
+#include "OverwriteDialogRes.h"
+#include "Common/IntToString.h"
#include "Common/StringConvert.h"
-#include "Windows/FileDir.h"
-#include "Windows/Error.h"
+
#include "Windows/COM.h"
+#include "Windows/Error.h"
+#include "Windows/FileDir.h"
+#include "Windows/PropVariant.h"
+#include "Windows/PropVariantConversions.h"
#include "Windows/Thread.h"
-#include "IFolder.h"
#include "App.h"
-
#include "CopyDialog.h"
-
#include "ExtractCallback.h"
-#include "ViewSettings.h"
-#include "RegistryUtils.h"
+#include "FormatUtils.h"
+#include "IFolder.h"
#include "LangUtils.h"
+#include "RegistryUtils.h"
+#include "ViewSettings.h"
using namespace NWindows;
using namespace NFile;
@@ -27,22 +31,23 @@ using namespace NFind;
extern DWORD g_ComCtl32Version;
extern HINSTANCE g_hInstance;
-static LPCWSTR kTempDirPrefix = L"7zE";
+static LPCWSTR kTempDirPrefix = L"7zE";
void CPanelCallbackImp::OnTab()
{
if (g_App.NumPanels != 1)
- _app->Panels[1 - _index].SetFocusToList();
+ _app->Panels[1 - _index].SetFocusToList();
_app->RefreshTitle();
}
void CPanelCallbackImp::SetFocusToPath(int index)
-{
+{
int newPanelIndex = index;
if (g_App.NumPanels == 1)
newPanelIndex = g_App.LastFocusedPanel;
- _app->Panels[newPanelIndex]._headerComboBox.SetFocus();
_app->RefreshTitle();
+ _app->Panels[newPanelIndex]._headerComboBox.SetFocus();
+ _app->Panels[newPanelIndex]._headerComboBox.ShowDropDown();
}
@@ -69,7 +74,7 @@ void CApp::SetListSettings()
/*
if (ReadSingleClick())
{
- extendedStyle |= LVS_EX_ONECLICKACTIVATE
+ extendedStyle |= LVS_EX_ONECLICKACTIVATE
| LVS_EX_TRACKSELECT;
if (ReadUnderline())
extendedStyle |= LVS_EX_UNDERLINEHOT;
@@ -99,10 +104,10 @@ void CApp::SetShowSystemMenu()
ShowSystemMenu = ReadShowSystemMenu();
}
-void CApp::CreateOnePanel(int panelIndex, const UString &mainPath, bool &archiveIsOpened, bool &encrypted)
+HRESULT CApp::CreateOnePanel(int panelIndex, const UString &mainPath, bool &archiveIsOpened, bool &encrypted)
{
if (PanelsCreated[panelIndex])
- return;
+ return S_OK;
m_PanelCallbackImp[panelIndex].Init(this, panelIndex);
UString path;
if (mainPath.IsEmpty())
@@ -113,9 +118,10 @@ void CApp::CreateOnePanel(int panelIndex, const UString &mainPath, bool &archive
else
path = mainPath;
int id = 1000 + 100 * panelIndex;
- Panels[panelIndex].Create(_window, _window,
- id, path, &m_PanelCallbackImp[panelIndex], &AppState, archiveIsOpened, encrypted);
+ RINOK(Panels[panelIndex].Create(_window, _window,
+ id, path, &m_PanelCallbackImp[panelIndex], &AppState, archiveIsOpened, encrypted));
PanelsCreated[panelIndex] = true;
+ return S_OK;
}
static void CreateToolbar(
@@ -124,27 +130,27 @@ static void CreateToolbar(
NWindows::NControl::CToolBar &toolBar,
bool LargeButtons)
{
- toolBar.Attach(::CreateWindowEx(0,
+ toolBar.Attach(::CreateWindowEx(0,
TOOLBARCLASSNAME,
NULL, 0
| WS_VISIBLE
| TBSTYLE_FLAT
- | TBSTYLE_TOOLTIPS
+ | TBSTYLE_TOOLTIPS
| WS_CHILD
| CCS_NOPARENTALIGN
- | CCS_NORESIZE
+ | CCS_NORESIZE
| CCS_NODIVIDER
// | TBSTYLE_AUTOSIZE
- // | CCS_ADJUSTABLE
+ // | CCS_ADJUSTABLE
,0,0,0,0, parent, NULL, g_hInstance, NULL));
- // TB_BUTTONSTRUCTSIZE message, which is required for
+ // TB_BUTTONSTRUCTSIZE message, which is required for
// backward compatibility.
toolBar.ButtonStructSize();
imageList.Create(
- LargeButtons ? 48: 24,
- LargeButtons ? 36: 24,
+ LargeButtons ? 48: 24,
+ LargeButtons ? 36: 24,
ILC_MASK, 0, 0);
toolBar.SetImageList(0, imageList);
}
@@ -154,20 +160,20 @@ struct CButtonInfo
UINT commandID;
UINT BitmapResID;
UINT Bitmap2ResID;
- UINT StringResID;
+ UINT StringResID;
UINT32 LangID;
UString GetText()const { return LangString(StringResID, LangID); };
};
-static CButtonInfo g_StandardButtons[] =
+static CButtonInfo g_StandardButtons[] =
{
{ IDM_COPY_TO, IDB_COPY, IDB_COPY2, IDS_BUTTON_COPY, 0x03020420},
{ IDM_MOVE_TO, IDB_MOVE, IDB_MOVE2, IDS_BUTTON_MOVE, 0x03020421},
{ IDM_DELETE, IDB_DELETE, IDB_DELETE2, IDS_BUTTON_DELETE, 0x03020422} ,
- { IDM_FILE_PROPERTIES, IDB_INFO, IDB_INFO2, IDS_BUTTON_INFO, 0x03020423}
+ { IDM_FILE_PROPERTIES, IDB_INFO, IDB_INFO2, IDS_BUTTON_INFO, 0x03020423}
};
-static CButtonInfo g_ArchiveButtons[] =
+static CButtonInfo g_ArchiveButtons[] =
{
{ kAddCommand, IDB_ADD, IDB_ADD2, IDS_ADD, 0x03020400},
{ kExtractCommand, IDB_EXTRACT, IDB_EXTRACT2, IDS_EXTRACT, 0x03020401},
@@ -190,37 +196,37 @@ bool SetButtonText(UINT32 commandID, CButtonInfo *buttons, int numButtons, UStri
void SetButtonText(UINT32 commandID, UString &s)
{
- if (SetButtonText(commandID, g_StandardButtons,
+ if (SetButtonText(commandID, g_StandardButtons,
sizeof(g_StandardButtons) / sizeof(g_StandardButtons[0]), s))
return;
- SetButtonText(commandID, g_ArchiveButtons,
+ SetButtonText(commandID, g_ArchiveButtons,
sizeof(g_ArchiveButtons) / sizeof(g_ArchiveButtons[0]), s);
}
static void AddButton(
NControl::CImageList &imageList,
- NControl::CToolBar &toolBar,
+ NControl::CToolBar &toolBar,
CButtonInfo &butInfo,
bool showText,
bool large)
{
- TBBUTTON but;
- but.iBitmap = 0;
- but.idCommand = butInfo.commandID;
- but.fsState = TBSTATE_ENABLED;
+ TBBUTTON but;
+ but.iBitmap = 0;
+ but.idCommand = butInfo.commandID;
+ but.fsState = TBSTATE_ENABLED;
but.fsStyle = BTNS_BUTTON
- // | BTNS_AUTOSIZE
+ // | BTNS_AUTOSIZE
;
but.dwData = 0;
UString s = butInfo.GetText();
but.iString = 0;
if (showText)
- but.iString = (INT_PTR)(LPCWSTR)s;
+ but.iString = (INT_PTR)(LPCWSTR)s;
but.iBitmap = imageList.GetImageCount();
- HBITMAP b = ::LoadBitmap(g_hInstance,
- large ?
+ HBITMAP b = ::LoadBitmap(g_hInstance,
+ large ?
MAKEINTRESOURCE(butInfo.BitmapResID):
MAKEINTRESOURCE(butInfo.Bitmap2ResID));
if (b != 0)
@@ -245,7 +251,7 @@ static void AddBand(NControl::CReBar &reBar, NControl::CToolBar &toolBar)
REBARBANDINFO rbBand;
rbBand.cbSize = sizeof(REBARBANDINFO); // Required
- rbBand.fMask = RBBIM_STYLE
+ rbBand.fMask = RBBIM_STYLE
| RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_SIZE;
rbBand.fStyle = RBBS_CHILDEDGE; // RBBS_NOGRIPPER;
rbBand.cxMinChild = size.cx; // rect.right - rect.left;
@@ -258,7 +264,7 @@ static void AddBand(NControl::CReBar &reBar, NControl::CToolBar &toolBar)
}
void CApp::ReloadToolbars()
-{
+{
if (!_rebar)
return;
HWND parent = _rebar;
@@ -276,7 +282,7 @@ void CApp::ReloadToolbars()
{
CreateToolbar(parent, _archiveButtonsImageList, _archiveToolBar, LargeButtons);
for (int i = 0; i < sizeof(g_ArchiveButtons) / sizeof(g_ArchiveButtons[0]); i++)
- AddButton(_archiveButtonsImageList, _archiveToolBar, g_ArchiveButtons[i],
+ AddButton(_archiveButtonsImageList, _archiveToolBar, g_ArchiveButtons[i],
ShowButtonsLables, LargeButtons);
AddBand(_rebar, _archiveToolBar);
}
@@ -285,7 +291,7 @@ void CApp::ReloadToolbars()
{
CreateToolbar(parent, _standardButtonsImageList, _standardToolBar, LargeButtons);
for (int i = 0; i < sizeof(g_StandardButtons) / sizeof(g_StandardButtons[0]); i++)
- AddButton(_standardButtonsImageList, _standardToolBar, g_StandardButtons[i],
+ AddButton(_standardButtonsImageList, _standardToolBar, g_StandardButtons[i],
ShowButtonsLables, LargeButtons);
AddBand(_rebar, _standardToolBar);
}
@@ -305,16 +311,16 @@ void CApp::ReloadRebar(HWND hwnd)
_rebar.Attach(::CreateWindowEx(WS_EX_TOOLWINDOW,
REBARCLASSNAME,
- NULL,
- WS_VISIBLE
- | WS_BORDER
- | WS_CHILD
- | WS_CLIPCHILDREN
- | WS_CLIPSIBLINGS
- // | CCS_NODIVIDER
+ NULL,
+ WS_VISIBLE
+ | WS_BORDER
+ | WS_CHILD
+ | WS_CLIPCHILDREN
+ | WS_CLIPSIBLINGS
+ // | CCS_NODIVIDER
// | CCS_NOPARENTALIGN // it's bead for moveing of two bands
// | CCS_TOP
- | RBS_VARHEIGHT
+ | RBS_VARHEIGHT
| RBS_BANDBORDERS
// | RBS_AUTOSIZE
,0,0,0,0, hwnd, NULL, g_hInstance, NULL));
@@ -329,7 +335,7 @@ void CApp::ReloadRebar(HWND hwnd)
ReloadToolbars();
}
-void CApp::Create(HWND hwnd, const UString &mainPath, int xSizes[2], bool &archiveIsOpened, bool &encrypted)
+HRESULT CApp::Create(HWND hwnd, const UString &mainPath, int xSizes[2], bool &archiveIsOpened, bool &encrypted)
{
ReadToolbar();
ReloadRebar(hwnd);
@@ -360,7 +366,7 @@ void CApp::Create(HWND hwnd, const UString &mainPath, int xSizes[2], bool &archi
bool archiveIsOpened2 = false;
bool encrypted2 = false;
bool mainPanel = (i == LastFocusedPanel);
- CreateOnePanel(i, mainPanel ? mainPath : L"", archiveIsOpened2, encrypted2);
+ RINOK(CreateOnePanel(i, mainPanel ? mainPath : L"", archiveIsOpened2, encrypted2));
if (mainPanel)
{
archiveIsOpened = archiveIsOpened2;
@@ -369,17 +375,18 @@ void CApp::Create(HWND hwnd, const UString &mainPath, int xSizes[2], bool &archi
}
SetFocusedPanel(LastFocusedPanel);
Panels[LastFocusedPanel].SetFocusToList();
+ return S_OK;
}
extern void MoveSubWindows(HWND hWnd);
-void CApp::SwitchOnOffOnePanel()
+HRESULT CApp::SwitchOnOffOnePanel()
{
if (NumPanels == 1)
{
NumPanels++;
bool archiveIsOpened, encrypted;
- CreateOnePanel(1 - LastFocusedPanel, UString(), archiveIsOpened, encrypted);
+ RINOK(CreateOnePanel(1 - LastFocusedPanel, UString(), archiveIsOpened, encrypted));
Panels[1 - LastFocusedPanel].Enable(true);
Panels[1 - LastFocusedPanel].Show(SW_SHOWNORMAL);
}
@@ -390,6 +397,7 @@ void CApp::SwitchOnOffOnePanel()
Panels[1 - LastFocusedPanel].Show(SW_HIDE);
}
MoveSubWindows(_window);
+ return S_OK;
}
void CApp::Save()
@@ -412,17 +420,17 @@ void CApp::Save()
void CApp::Release()
{
- // It's for unloading COM dll's: don't change it.
+ // It's for unloading COM dll's: don't change it.
for (int i = 0; i < kNumPanelsMax; i++)
Panels[i].Release();
}
static bool IsThereFolderOfPath(const UString &path)
{
- CFileInfoW fileInfo;
- if (!FindFile(path, fileInfo))
+ CFileInfoW fi;
+ if (!FindFile(path, fi))
return false;
- return fileInfo.IsDirectory();
+ return fi.IsDir();
}
// reduces path to part that exists on disk
@@ -470,6 +478,99 @@ static bool IsPathAbsolute(const UString &path)
return false;
}
+extern UString ConvertSizeToString(UInt64 value);
+
+static UString AddSizeValue(UInt64 size)
+{
+ return MyFormatNew(IDS_FILE_SIZE, 0x02000982, ConvertSizeToString(size));
+}
+
+static void AddValuePair1(UINT resourceID, UInt32 langID, UInt64 size, UString &s)
+{
+ s += LangString(resourceID, langID);
+ s += L" ";
+ s += AddSizeValue(size);
+ s += L"\n";
+}
+
+void AddValuePair2(UINT resourceID, UInt32 langID, UInt64 num, UInt64 size, UString &s)
+{
+ if (num == 0)
+ return;
+ s += LangString(resourceID, langID);
+ s += L" ";
+ s += ConvertSizeToString(num);
+
+ if (size != (UInt64)(Int64)-1)
+ {
+ s += L" ( ";
+ s += AddSizeValue(size);
+ s += L" )";
+ }
+ s += L"\n";
+}
+
+static void AddPropValueToSum(IFolderFolder *folder, int index, PROPID propID, UInt64 &sum)
+{
+ if (sum == (UInt64)(Int64)-1)
+ return;
+ NCOM::CPropVariant prop;
+ folder->GetProperty(index, propID, &prop);
+ switch(prop.vt)
+ {
+ case VT_UI4:
+ case VT_UI8:
+ sum += ConvertPropVariantToUInt64(prop);
+ break;
+ default:
+ sum = (UInt64)(Int64)-1;
+ }
+}
+
+UString CPanel::GetItemsInfoString(const CRecordVector<UInt32> &indices)
+{
+ UString info;
+ UInt64 numDirs, numFiles, filesSize, foldersSize;
+ numDirs = numFiles = filesSize = foldersSize = 0;
+ int i;
+ for (i = 0; i < indices.Size(); i++)
+ {
+ int index = indices[i];
+ if (IsItemFolder(index))
+ {
+ AddPropValueToSum(_folder, index, kpidSize, foldersSize);
+ numDirs++;
+ }
+ else
+ {
+ AddPropValueToSum(_folder, index, kpidSize, filesSize);
+ numFiles++;
+ }
+ }
+
+ AddValuePair2(IDS_FOLDERS_COLON, 0x02000321, numDirs, foldersSize, info);
+ AddValuePair2(IDS_FILES_COLON, 0x02000320, numFiles, filesSize, info);
+ int numDefined = ((foldersSize != (UInt64)(Int64)-1) && foldersSize != 0) ? 1: 0;
+ numDefined += ((filesSize != (UInt64)(Int64)-1) && filesSize != 0) ? 1: 0;
+ if (numDefined == 2)
+ AddValuePair1(IDS_SIZE_COLON, 0x02000322, filesSize + foldersSize, info);
+
+ info += L"\n";
+ info += _currentFolderPrefix;
+
+ for (i = 0; i < indices.Size() && i < kCopyDialog_NumInfoLines - 6; i++)
+ {
+ info += L"\n ";
+ int index = indices[i];
+ info += GetItemRelPath(index);
+ if (IsItemFolder(index))
+ info += L'\\';
+ }
+ if (i != indices.Size())
+ info += L"\n ...";
+ return info;
+}
+
void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
{
int destPanelIndex = (NumPanels <= 1) ? srcPanelIndex : (1 - srcPanelIndex);
@@ -481,7 +582,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
if (!srcPanel.DoesItSupportOperations())
{
- srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
+ srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
return;
}
@@ -503,7 +604,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
}
else
{
- srcPanel.GetOperatedItemIndices(indices);
+ srcPanel.GetOperatedIndicesSmart(indices);
if (indices.Size() == 0)
return;
destPath = destPanel._currentFolderPrefix;
@@ -518,13 +619,15 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
copyDialog.Strings = copyFolders;
copyDialog.Value = destPath;
- copyDialog.Title = move ?
+ copyDialog.Title = move ?
LangString(IDS_MOVE, 0x03020202):
LangString(IDS_COPY, 0x03020201);
- copyDialog.Static = move ?
+ copyDialog.Static = move ?
LangString(IDS_MOVE_TO, 0x03020204):
LangString(IDS_COPY_TO, 0x03020203);
+ copyDialog.Info = srcPanel.GetItemsInfoString(indices);
+
if (copyDialog.Create(srcPanel.GetParent()) == IDCANCEL)
return;
@@ -532,7 +635,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
if (destPath.IsEmpty())
{
- srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
+ srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
return;
}
@@ -540,7 +643,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
{
if (!srcPanel.IsFSFolder())
{
- srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
+ srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
return;
}
destPath = srcPanel._currentFolderPrefix + destPath;
@@ -549,11 +652,11 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
if (destPath.Length() > 0 && destPath[0] == '\\')
if (destPath.Length() == 1 || destPath[1] != '\\')
{
- srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
+ srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
return;
}
- if (indices.Size() > 1 || (destPath.Length() > 0 && destPath.ReverseFind('\\') == destPath.Length() - 1) ||
+ if (indices.Size() > 1 || (destPath.Length() > 0 && destPath.ReverseFind('\\') == destPath.Length() - 1) ||
IsThereFolderOfPath(destPath))
{
NDirectory::CreateComplexDirectory(destPath);
@@ -562,7 +665,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
{
if (NumPanels < 2 || destPath != destPanel._currentFolderPrefix || !destPanel.DoesItSupportOperations())
{
- srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
+ srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
return;
}
useDestPanel = true;
@@ -577,7 +680,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
NDirectory::CreateComplexDirectory(prefix);
if (!CheckFolderPath(prefix))
{
- srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
+ srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
return;
}
}
@@ -688,7 +791,7 @@ void CApp::OnSetSubFolder(int srcPanelIndex)
/*
- UString string = srcPanel._currentFolderPrefix +
+ UString string = srcPanel._currentFolderPrefix +
srcPanel.GetItemName(realIndex) + L'\\';
destPanel.BindToFolder(string);
*/
@@ -719,7 +822,7 @@ int CApp::GetFocusedPanelIndex() const
return 0;
for (int i = 0; i < kNumPanelsMax; i++)
{
- if (PanelsCreated[i] &&
+ if (PanelsCreated[i] &&
((HWND)Panels[i] == hwnd || Panels[i]._listView == hwnd))
return i;
}
@@ -745,7 +848,7 @@ void CApp::OnNotify(int /* ctrlID */, LPNMHDR pnmh)
}
return ;
}
- else
+ else
{
if (pnmh->code == TTN_GETDISPINFO)
{
@@ -772,7 +875,7 @@ void CApp::OnNotify(int /* ctrlID */, LPNMHDR pnmh)
}
void CApp::RefreshTitle(bool always)
-{
+{
UString path = GetFocusedPanel()._currentFolderPrefix;
if (path.IsEmpty())
path += LangString(IDS_APP_TITLE, 0x03000000);
@@ -783,7 +886,7 @@ void CApp::RefreshTitle(bool always)
}
void CApp::RefreshTitle(int panelIndex, bool always)
-{
+{
if (panelIndex != GetFocusedPanelIndex())
return;
RefreshTitle(always);
diff --git a/CPP/7zip/UI/FileManager/App.h b/CPP/7zip/UI/FileManager/App.h
index 2479d81e..d30e1151 100755
--- a/CPP/7zip/UI/FileManager/App.h
+++ b/CPP/7zip/UI/FileManager/App.h
@@ -16,7 +16,7 @@ const int kNumPanelsMax = 2;
extern void MoveSubWindows(HWND hWnd);
-enum
+enum
{
kAddCommand = kToolbarStartID,
kExtractCommand,
@@ -28,10 +28,10 @@ class CPanelCallbackImp: public CPanelCallback
CApp *_app;
int _index;
public:
- void Init(CApp *app, int index)
- {
+ void Init(CApp *app, int index)
+ {
_app = app;
- _index = index;
+ _index = index;
}
virtual void OnTab();
virtual void SetFocusToPath(int index);
@@ -42,11 +42,11 @@ public:
virtual void DragBegin();
virtual void DragEnd();
virtual void RefreshTitle(bool always);
-};
+};
class CApp;
-class CDropTarget:
+class CDropTarget:
public IDropTarget,
public CMyUnknownImp
{
@@ -54,7 +54,7 @@ class CDropTarget:
UStringVector m_SourcePaths;
int m_SelectionIndex;
bool m_DropIsAllowed; // = true, if data contain fillist
- bool m_PanelDropIsAllowed; // = false, if current target_panel is source_panel.
+ bool m_PanelDropIsAllowed; // = false, if current target_panel is source_panel.
// check it only if m_DropIsAllowed == true
int m_SubFolderIndex;
UString m_SubFolderName;
@@ -77,22 +77,22 @@ class CDropTarget:
public:
MY_UNKNOWN_IMP1_MT(IDropTarget)
- STDMETHOD(DragEnter)(IDataObject * dataObject, DWORD keyState,
+ STDMETHOD(DragEnter)(IDataObject * dataObject, DWORD keyState,
POINTL pt, DWORD *effect);
STDMETHOD(DragOver)(DWORD keyState, POINTL pt, DWORD * effect);
STDMETHOD(DragLeave)();
- STDMETHOD(Drop)(IDataObject * dataObject, DWORD keyState,
+ STDMETHOD(Drop)(IDataObject * dataObject, DWORD keyState,
POINTL pt, DWORD *effect);
- CDropTarget():
- TargetPanelIndex(-1),
- SrcPanelIndex(-1),
- m_IsAppTarget(false),
- m_Panel(0),
- App(0),
- m_PanelDropIsAllowed(false),
- m_DropIsAllowed(false),
- m_SelectionIndex(-1),
+ CDropTarget():
+ TargetPanelIndex(-1),
+ SrcPanelIndex(-1),
+ m_IsAppTarget(false),
+ m_Panel(0),
+ App(0),
+ m_PanelDropIsAllowed(false),
+ m_DropIsAllowed(false),
+ m_SelectionIndex(-1),
m_SubFolderIndex(-1),
m_SetPathIsOK(false) {}
@@ -138,18 +138,18 @@ public:
void SetFocusedPanel(int index)
{
- LastFocusedPanel = index;
+ LastFocusedPanel = index;
_dropTargetSpec->TargetPanelIndex = LastFocusedPanel;
}
void DragBegin(int panelIndex)
- {
+ {
_dropTargetSpec->TargetPanelIndex = (NumPanels > 1) ? 1 - panelIndex : panelIndex;
_dropTargetSpec->SrcPanelIndex = panelIndex;
}
void DragEnd()
- {
+ {
_dropTargetSpec->TargetPanelIndex = LastFocusedPanel;
_dropTargetSpec->SrcPanelIndex = -1;
}
@@ -159,8 +159,8 @@ public:
void OnSetSameFolder(int srcPanelIndex);
void OnSetSubFolder(int srcPanelIndex);
- void CreateOnePanel(int panelIndex, const UString &mainPath, bool &archiveIsOpened, bool &encrypted);
- void Create(HWND hwnd, const UString &mainPath, int xSizes[2], bool &archiveIsOpened, bool &encrypted);
+ HRESULT CreateOnePanel(int panelIndex, const UString &mainPath, bool &archiveIsOpened, bool &encrypted);
+ HRESULT Create(HWND hwnd, const UString &mainPath, int xSizes[2], bool &archiveIsOpened, bool &encrypted);
void Read();
void Save();
void Release();
@@ -253,7 +253,7 @@ public:
void RefreshView()
{ GetFocusedPanel().OnReload(); }
void RefreshAllPanels()
- {
+ {
for (int i = 0; i < NumPanels; i++)
{
int index = i;
@@ -264,7 +264,7 @@ public:
}
void SetListSettings();
void SetShowSystemMenu();
- void SwitchOnOffOnePanel();
+ HRESULT SwitchOnOffOnePanel();
bool GetFlatMode() { return Panels[LastFocusedPanel].GetFlatMode(); }
void ChangeFlatMode() { Panels[LastFocusedPanel].ChangeFlatMode(); }
@@ -293,41 +293,37 @@ public:
SaveToolbarsMask(mask);
}
void SwitchStandardToolbar()
- {
+ {
ShowStandardToolbar = !ShowStandardToolbar;
SaveToolbar();
ReloadRebar(g_HWND);
MoveSubWindows(_window);
}
void SwitchArchiveToolbar()
- {
+ {
ShowArchiveToolbar = !ShowArchiveToolbar;
SaveToolbar();
ReloadRebar(g_HWND);
MoveSubWindows(_window);
}
void SwitchButtonsLables()
- {
+ {
ShowButtonsLables = !ShowButtonsLables;
SaveToolbar();
ReloadRebar(g_HWND);
MoveSubWindows(_window);
}
void SwitchLargeButtons()
- {
+ {
LargeButtons = !LargeButtons;
SaveToolbar();
ReloadRebar(g_HWND);
MoveSubWindows(_window);
}
-
- void AddToArchive()
- { GetFocusedPanel().AddToArchive(); }
- void ExtractArchives()
- { GetFocusedPanel().ExtractArchives(); }
- void TestArchives()
- { GetFocusedPanel().TestArchives(); }
+ void AddToArchive() { GetFocusedPanel().AddToArchive(); }
+ void ExtractArchives() { GetFocusedPanel().ExtractArchives(); }
+ void TestArchives() { GetFocusedPanel().TestArchives(); }
void OnNotify(int ctrlID, LPNMHDR pnmh);
diff --git a/CPP/7zip/UI/FileManager/AppState.h b/CPP/7zip/UI/FileManager/AppState.h
index 318c0258..2b2a3e84 100755
--- a/CPP/7zip/UI/FileManager/AppState.h
+++ b/CPP/7zip/UI/FileManager/AppState.h
@@ -5,7 +5,7 @@
#include "Windows/Synchronization.h"
-void inline AddUniqueStringToHead(UStringVector &list,
+void inline AddUniqueStringToHead(UStringVector &list,
const UString &string)
{
for(int i = 0; i < list.Size();)
diff --git a/CPP/7zip/UI/FileManager/ClassDefs.cpp b/CPP/7zip/UI/FileManager/ClassDefs.cpp
index 0b4c9093..5b4401a1 100755
--- a/CPP/7zip/UI/FileManager/ClassDefs.cpp
+++ b/CPP/7zip/UI/FileManager/ClassDefs.cpp
@@ -13,5 +13,5 @@
#include "../Agent/Agent.h"
// {23170F69-40C1-278A-1000-000100020000}
-DEFINE_GUID(CLSID_CZipContextMenu,
+DEFINE_GUID(CLSID_CZipContextMenu,
0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00);
diff --git a/CPP/7zip/UI/FileManager/ComboDialog.cpp b/CPP/7zip/UI/FileManager/ComboDialog.cpp
index 83c142ff..807a5dd2 100755
--- a/CPP/7zip/UI/FileManager/ComboDialog.cpp
+++ b/CPP/7zip/UI/FileManager/ComboDialog.cpp
@@ -5,23 +5,23 @@
#include "Windows/Control/Static.h"
-#ifdef LANG
+#ifdef LANG
#include "LangUtils.h"
#endif
using namespace NWindows;
-#ifdef LANG
-static CIDLangPair kIDLangPairs[] =
+#ifdef LANG
+static CIDLangPair kIDLangPairs[] =
{
{ IDOK, 0x02000702 },
{ IDCANCEL, 0x02000710 }
};
#endif
-bool CComboDialog::OnInit()
+bool CComboDialog::OnInit()
{
- #ifdef LANG
+ #ifdef LANG
LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
#endif
_comboBox.Attach(GetItem(IDC_COMBO_COMBO));
diff --git a/CPP/7zip/UI/FileManager/CopyDialog.cpp b/CPP/7zip/UI/FileManager/CopyDialog.cpp
index 77b62ec0..2bf60301 100755
--- a/CPP/7zip/UI/FileManager/CopyDialog.cpp
+++ b/CPP/7zip/UI/FileManager/CopyDialog.cpp
@@ -9,23 +9,23 @@
#include "Windows/Shell.h"
#include "Windows/FileName.h"
-#ifdef LANG
+#ifdef LANG
#include "LangUtils.h"
#endif
using namespace NWindows;
-#ifdef LANG
-static CIDLangPair kIDLangPairs[] =
+#ifdef LANG
+static CIDLangPair kIDLangPairs[] =
{
{ IDOK, 0x02000702 },
{ IDCANCEL, 0x02000710 }
};
#endif
-bool CCopyDialog::OnInit()
+bool CCopyDialog::OnInit()
{
- #ifdef LANG
+ #ifdef LANG
LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
#endif
_path.Attach(GetItem(IDC_COPY_COMBO));
@@ -34,9 +34,10 @@ bool CCopyDialog::OnInit()
NControl::CStatic staticContol;
staticContol.Attach(GetItem(IDC_COPY_STATIC));
staticContol.SetText(Static);
- for(int i = 0; i < Strings.Size(); i++)
+ for (int i = 0; i < Strings.Size(); i++)
_path.AddString(Strings[i]);
_path.SetText(Value);
+ SetItemText(IDC_COPY_INFO, Info);
return CModalDialog::OnInit();
}
@@ -51,13 +52,13 @@ bool CCopyDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
return CModalDialog::OnButtonClicked(buttonID, buttonHWND);
}
-void CCopyDialog::OnButtonSetPath()
+void CCopyDialog::OnButtonSetPath()
{
UString currentPath;
_path.GetText(currentPath);
/*
- #ifdef LANG
+ #ifdef LANG
UString title = LangLoadString(IDS_EXTRACT_SET_FOLDER, 0x02000881);
#else
UString title = MyLoadString(IDS_EXTRACT_SET_FOLDER);
diff --git a/CPP/7zip/UI/FileManager/CopyDialog.h b/CPP/7zip/UI/FileManager/CopyDialog.h
index ed894bf8..55872f1c 100755
--- a/CPP/7zip/UI/FileManager/CopyDialog.h
+++ b/CPP/7zip/UI/FileManager/CopyDialog.h
@@ -7,6 +7,8 @@
#include "Windows/Control/ComboBox.h"
#include "CopyDialogRes.h"
+const int kCopyDialog_NumInfoLines = 11;
+
class CCopyDialog: public NWindows::NControl::CModalDialog
{
NWindows::NControl::CComboBox _path;
@@ -20,6 +22,8 @@ public:
UString Value;
UStringVector Strings;
+ UString Info;
+
INT_PTR Create(HWND parentWindow = 0) { return CModalDialog::Create(IDD_DIALOG_COPY, parentWindow); }
};
diff --git a/CPP/7zip/UI/FileManager/CopyDialog.rc b/CPP/7zip/UI/FileManager/CopyDialog.rc
index bf3aebde..1686adda 100755
--- a/CPP/7zip/UI/FileManager/CopyDialog.rc
+++ b/CPP/7zip/UI/FileManager/CopyDialog.rc
@@ -1,8 +1,11 @@
#include "CopyDialogRes.h"
#include "../../GuiCommon.rc"
+#undef infoSize
+#define infoSize 100
+
#define xSize2 346
-#define ySize2 57
+#define ySize2 (infoSize + 50)
#define xSize (xSize2 + marg + marg)
#define ySize (ySize2 + marg + marg)
@@ -17,12 +20,13 @@ MY_FONT
BEGIN
LTEXT "", IDC_COPY_STATIC, marg, marg, xSize2, 8
COMBOBOX IDC_COPY_COMBO, marg, 20, xSize2 - bDotsSize - 12, 65, CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP
- PUSHBUTTON "...", IDC_COPY_SET_PATH, (xSize - marg - bDotsSize), 20, bDotsSize, 14, WS_GROUP
+ PUSHBUTTON "...", IDC_COPY_SET_PATH, (xSize - marg - bDotsSize), 20, bDotsSize, 14, WS_GROUP
+ LTEXT "", IDC_COPY_INFO, marg, bYPos - (infoSize + 2), xSize2, infoSize, SS_NOPREFIX | SS_LEFTNOWORDWRAP
DEFPUSHBUTTON "OK", IDOK, b2XPos, bYPos, bXSize, bYSize
PUSHBUTTON "Cancel", IDCANCEL, b1XPos, bYPos, bXSize, bYSize
END
-STRINGTABLE DISCARDABLE
+STRINGTABLE DISCARDABLE
BEGIN
IDS_SET_FOLDER "Specify a location for output folder."
END
diff --git a/CPP/7zip/UI/FileManager/CopyDialogRes.h b/CPP/7zip/UI/FileManager/CopyDialogRes.h
index 7ec6162a..900bf29f 100755
--- a/CPP/7zip/UI/FileManager/CopyDialogRes.h
+++ b/CPP/7zip/UI/FileManager/CopyDialogRes.h
@@ -3,5 +3,6 @@
#define IDC_COPY_STATIC 1000
#define IDC_COPY_COMBO 1001
#define IDC_COPY_SET_PATH 1002
+#define IDC_COPY_INFO 1003
#define IDS_SET_FOLDER 210
diff --git a/CPP/7zip/UI/FileManager/EditPage.cpp b/CPP/7zip/UI/FileManager/EditPage.cpp
index 06bde407..69261eb6 100755
--- a/CPP/7zip/UI/FileManager/EditPage.cpp
+++ b/CPP/7zip/UI/FileManager/EditPage.cpp
@@ -18,7 +18,7 @@
using namespace NWindows;
-static CIDLangPair kIDLangPairs[] =
+static CIDLangPair kIDLangPairs[] =
{
{ IDC_EDIT_STATIC_EDITOR, 0x03010201}
};
diff --git a/CPP/7zip/UI/FileManager/EnumFormatEtc.cpp b/CPP/7zip/UI/FileManager/EnumFormatEtc.cpp
index ef9463fb..291ea1f1 100755
--- a/CPP/7zip/UI/FileManager/EnumFormatEtc.cpp
+++ b/CPP/7zip/UI/FileManager/EnumFormatEtc.cpp
@@ -5,7 +5,7 @@
#include "EnumFormatEtc.h"
#include "MyCom2.h"
-class CEnumFormatEtc :
+class CEnumFormatEtc :
public IEnumFORMATETC,
public CMyUnknownImp
{
@@ -13,7 +13,7 @@ public:
MY_UNKNOWN_IMP1_MT(IEnumFORMATETC)
STDMETHOD(Next)(ULONG celt, FORMATETC *rgelt, ULONG *pceltFetched);
- STDMETHOD(Skip)(ULONG celt);
+ STDMETHOD(Skip)(ULONG celt);
STDMETHOD(Reset)(void);
STDMETHOD(Clone)(IEnumFORMATETC **ppEnumFormatEtc);
@@ -73,7 +73,7 @@ STDMETHODIMP CEnumFormatEtc::Next(ULONG celt, FORMATETC *pFormatEtc, ULONG *pcel
copied++;
m_Index++;
}
- if(pceltFetched != 0)
+ if(pceltFetched != 0)
*pceltFetched = copied;
return (copied == celt) ? S_OK : S_FALSE;
}
diff --git a/CPP/7zip/UI/FileManager/ExtractCallback.cpp b/CPP/7zip/UI/FileManager/ExtractCallback.cpp
index 7998d5cc..d5f0e867 100755
--- a/CPP/7zip/UI/FileManager/ExtractCallback.cpp
+++ b/CPP/7zip/UI/FileManager/ExtractCallback.cpp
@@ -4,9 +4,10 @@
#include "ExtractCallback.h"
+#include "Windows/Error.h"
#include "Windows/FileFind.h"
#include "Windows/FileDir.h"
-#include "Windows/Error.h"
+#include "Windows/ResourceString.h"
#include "OverwriteDialog.h"
#ifndef _NO_CRYPTO
@@ -52,7 +53,7 @@ void CExtractCallbackImp::AddErrorMessage(LPCWSTR message)
Messages.Add(message);
}
-STDMETHODIMP CExtractCallbackImp::SetNumFiles(UInt64
+STDMETHODIMP CExtractCallbackImp::SetNumFiles(UInt64
#ifndef _SFX
numFiles
#endif
@@ -72,19 +73,57 @@ STDMETHODIMP CExtractCallbackImp::SetTotal(UInt64 total)
STDMETHODIMP CExtractCallbackImp::SetCompleted(const UInt64 *value)
{
- for (;;)
- {
- if(ProgressDialog.ProgressSynch.GetStopped())
- return E_ABORT;
- if(!ProgressDialog.ProgressSynch.GetPaused())
- break;
- ::Sleep(100);
- }
+ RINOK(ProgressDialog.ProgressSynch.ProcessStopAndPause());
if (value != NULL)
ProgressDialog.ProgressSynch.SetPos(*value);
return S_OK;
}
+HRESULT CExtractCallbackImp::Open_CheckBreak()
+{
+ return ProgressDialog.ProgressSynch.ProcessStopAndPause();
+}
+
+HRESULT CExtractCallbackImp::Open_SetTotal(const UInt64 * /* numFiles */, const UInt64 * /* numBytes */)
+{
+ // if (numFiles != NULL) ProgressDialog.ProgressSynch.SetNumFilesTotal(*numFiles);
+ return S_OK;
+}
+
+HRESULT CExtractCallbackImp::Open_SetCompleted(const UInt64 * /* numFiles */, const UInt64 * /* numBytes */)
+{
+ RINOK(ProgressDialog.ProgressSynch.ProcessStopAndPause());
+ // if (numFiles != NULL) ProgressDialog.ProgressSynch.SetNumFilesCur(*numFiles);
+ return S_OK;
+}
+
+#ifndef _NO_CRYPTO
+
+HRESULT CExtractCallbackImp::Open_CryptoGetTextPassword(BSTR *password)
+{
+ return CryptoGetTextPassword(password);
+}
+
+HRESULT CExtractCallbackImp::Open_GetPasswordIfAny(UString &password)
+{
+ if (PasswordIsDefined)
+ password = Password;
+ return S_OK;
+}
+
+bool CExtractCallbackImp::Open_WasPasswordAsked()
+{
+ return PasswordWasAsked;
+}
+
+void CExtractCallbackImp::Open_ClearPasswordWasAskedFlag()
+{
+ PasswordWasAsked = false;
+}
+
+#endif
+
+
#ifndef _SFX
STDMETHODIMP CExtractCallbackImp::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize)
{
@@ -135,34 +174,20 @@ STDMETHODIMP CExtractCallbackImp::AskOverwrite(
dialog.NewFileInfo.Name = newName;
/*
- NOverwriteDialog::NResult::EEnum writeAnswer =
+ NOverwriteDialog::NResult::EEnum writeAnswer =
NOverwriteDialog::Execute(oldFileInfo, newFileInfo);
*/
- INT_PTR writeAnswer = dialog.Create(NULL); // ParentWindow doesn't work with 7z
+ INT_PTR writeAnswer = dialog.Create(ProgressDialog); // ParentWindow doesn't work with 7z
switch(writeAnswer)
{
- case IDCANCEL:
- return E_ABORT;
- // askResult = NAskOverwriteAnswer::kCancel;
- // break;
- case IDNO:
- *answer = NOverwriteAnswer::kNo;
- break;
- case IDC_BUTTON_OVERWRITE_NO_TO_ALL:
- *answer = NOverwriteAnswer::kNoToAll;
- break;
- case IDC_BUTTON_OVERWRITE_YES_TO_ALL:
- *answer = NOverwriteAnswer::kYesToAll;
- break;
- case IDC_BUTTON_OVERWRITE_AUTO_RENAME:
- *answer = NOverwriteAnswer::kAutoRename;
- break;
- case IDYES:
- *answer = NOverwriteAnswer::kYes;
- break;
- default:
- return E_FAIL;
+ case IDCANCEL: *answer = NOverwriteAnswer::kCancel; return E_ABORT;
+ case IDYES: *answer = NOverwriteAnswer::kYes; break;
+ case IDNO: *answer = NOverwriteAnswer::kNo; break;
+ case IDC_BUTTON_OVERWRITE_YES_TO_ALL: *answer = NOverwriteAnswer::kYesToAll; break;
+ case IDC_BUTTON_OVERWRITE_NO_TO_ALL: *answer = NOverwriteAnswer::kNoToAll; break;
+ case IDC_BUTTON_OVERWRITE_AUTO_RENAME: *answer = NOverwriteAnswer::kAutoRename; break;
+ default: return E_FAIL;
}
return S_OK;
}
@@ -203,13 +228,13 @@ STDMETHODIMP CExtractCallbackImp::SetOperationResult(Int32 operationResult, bool
langID = 0x02000A91;
break;
case NArchive::NExtract::NOperationResult::kDataError:
- messageID = encrypted ?
+ messageID = encrypted ?
IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_DATA_ERROR_ENCRYPTED:
IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_DATA_ERROR;
langID = encrypted ? 0x02000A94 : 0x02000A92;
break;
case NArchive::NExtract::NOperationResult::kCRCError:
- messageID = encrypted ?
+ messageID = encrypted ?
IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_CRC_ENCRYPTED:
IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_CRC;
langID = encrypted ? 0x02000A95 : 0x02000A93;
@@ -223,10 +248,10 @@ STDMETHODIMP CExtractCallbackImp::SetOperationResult(Int32 operationResult, bool
_needWriteArchivePath = false;
}
AddErrorMessage(
- MyFormatNew(messageID,
- #ifdef LANG
- langID,
- #endif
+ MyFormatNew(messageID,
+ #ifdef LANG
+ langID,
+ #endif
_currentFilePath));
}
}
@@ -276,11 +301,32 @@ HRESULT CExtractCallbackImp::OpenResult(const wchar_t *name, HRESULT result, boo
{
if (result != S_OK)
{
- MessageError(MyFormatNew(encrypted ? IDS_CANT_OPEN_ENCRYPTED_ARCHIVE : IDS_CANT_OPEN_ARCHIVE,
+ UString message;
+ if (result == S_FALSE)
+ {
+ message = MyFormatNew(encrypted ? IDS_CANT_OPEN_ENCRYPTED_ARCHIVE : IDS_CANT_OPEN_ARCHIVE,
#ifdef LANG
(encrypted ? 0x0200060A : 0x02000609),
#endif
- name));
+ name);
+ }
+ else
+ {
+ message = name;
+ message += L": ";
+ UString message2;
+ if (result == E_OUTOFMEMORY)
+ message2 =
+ #ifdef LANG
+ LangString(IDS_MEM_ERROR, 0x0200060B);
+ #else
+ MyLoadStringW(IDS_MEM_ERROR);
+ #endif
+ else
+ NError::MyFormatMessage(result, message2);
+ message += message2;
+ }
+ MessageError(message);
NumArchiveErrors++;
}
_currentArchivePath = name;
@@ -314,29 +360,27 @@ HRESULT CExtractCallbackImp::SetPassword(const UString &password)
STDMETHODIMP CExtractCallbackImp::CryptoGetTextPassword(BSTR *password)
{
+ PasswordWasAsked = true;
if (!PasswordIsDefined)
{
CPasswordDialog dialog;
-
- if (dialog.Create(ParentWindow) == IDCANCEL)
+ if (dialog.Create(ProgressDialog) == IDCANCEL)
return E_ABORT;
-
Password = dialog.Password;
PasswordIsDefined = true;
}
CMyComBSTR tempName(Password);
*password = tempName.Detach();
-
return S_OK;
}
// IExtractCallBack3
STDMETHODIMP CExtractCallbackImp::AskWrite(
- const wchar_t *srcPath, Int32 srcIsFolder,
+ const wchar_t *srcPath, Int32 srcIsFolder,
const FILETIME *srcTime, const UInt64 *srcSize,
- const wchar_t *destPath,
- BSTR *destPathResult,
+ const wchar_t *destPath,
+ BSTR *destPathResult,
Int32 *writeAnswer)
{
UString destPathResultTemp = destPath;
@@ -357,7 +401,7 @@ STDMETHODIMP CExtractCallbackImp::AskWrite(
{
if (srcIsFolderSpec)
{
- if (!destFileInfo.IsDirectory())
+ if (!destFileInfo.IsDir())
{
UString message = UString(L"can not replace file \'")
+ destPathSpec +
@@ -368,7 +412,7 @@ STDMETHODIMP CExtractCallbackImp::AskWrite(
*writeAnswer = BoolToInt(false);
return S_OK;
}
- if (destFileInfo.IsDirectory())
+ if (destFileInfo.IsDir())
{
UString message = UString(L"can not replace folder \'")
+ destPathSpec +
@@ -385,10 +429,10 @@ STDMETHODIMP CExtractCallbackImp::AskWrite(
{
Int32 overwiteResult;
RINOK(AskOverwrite(
- destPathSpec,
- &destFileInfo.LastWriteTime, &destFileInfo.Size,
+ destPathSpec,
+ &destFileInfo.MTime, &destFileInfo.Size,
srcPath,
- srcTime, srcSize,
+ srcTime, srcSize,
&overwiteResult));
switch(overwiteResult)
{
@@ -432,7 +476,7 @@ STDMETHODIMP CExtractCallbackImp::AskWrite(
return E_ABORT;
}
}
- CMyComBSTR destPathResultBSTR = destPathResultTemp;
+ CMyComBSTR destPathResultBSTR(destPathResultTemp);
*destPathResult = destPathResultBSTR.Detach();
*writeAnswer = BoolToInt(true);
return S_OK;
diff --git a/CPP/7zip/UI/FileManager/ExtractCallback.h b/CPP/7zip/UI/FileManager/ExtractCallback.h
index 13117871..ee46222a 100755
--- a/CPP/7zip/UI/FileManager/ExtractCallback.h
+++ b/CPP/7zip/UI/FileManager/ExtractCallback.h
@@ -5,6 +5,7 @@
#include "../Agent/IFolderArchive.h"
#include "Common/MyString.h"
+#include "../Common/ArchiveOpenCallback.h"
#ifdef _SFX
#include "ProgressDialog.h"
@@ -14,7 +15,7 @@
#include "Windows/ResourceString.h"
-#ifdef LANG
+#ifdef LANG
#include "LangUtils.h"
#endif
@@ -24,8 +25,9 @@
#include "Common/MyCom.h"
#include "IFolder.h"
-class CExtractCallbackImp:
+class CExtractCallbackImp:
public IExtractCallbackUI,
+ public IOpenCallbackUI,
public IFolderOperationsExtractCallback,
// public IFolderArchiveExtractCallback, // mkultiple from IProgress
#ifndef _SFX
@@ -48,14 +50,13 @@ public:
MY_QUERYINTERFACE_END
MY_ADDREF_RELEASE
- // IProgress
- STDMETHOD(SetTotal)(UInt64 total);
- STDMETHOD(SetCompleted)(const UInt64 *value);
-
#ifndef _SFX
STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize);
#endif
+ INTERFACE_IProgress(;)
+ INTERFACE_IOpenCallbackUI(;)
+
// IFolderArchiveExtractCallback
// STDMETHOD(SetTotalFiles)(UInt64 total);
// STDMETHOD(SetCompletedFiles)(const UInt64 *value);
@@ -81,12 +82,12 @@ public:
// IFolderOperationsExtractCallback
STDMETHOD(AskWrite)(
- const wchar_t *srcPath,
- Int32 srcIsFolder,
- const FILETIME *srcTime,
+ const wchar_t *srcPath,
+ Int32 srcIsFolder,
+ const FILETIME *srcTime,
const UInt64 *srcSize,
- const wchar_t *destPathRequest,
- BSTR *destPathResult,
+ const wchar_t *destPathRequest,
+ BSTR *destPathResult,
Int32 *writeAnswer);
STDMETHOD(ShowMessage)(const wchar_t *message);
STDMETHOD(SetCurrentFilePath)(const wchar_t *filePath);
@@ -128,12 +129,14 @@ public:
#ifndef _NO_CRYPTO
bool PasswordIsDefined;
+ bool PasswordWasAsked;
UString Password;
#endif
- CExtractCallbackImp():
+ CExtractCallbackImp():
#ifndef _NO_CRYPTO
PasswordIsDefined(false),
+ PasswordWasAsked(false),
#endif
OverwriteMode(NExtract::NOverwriteMode::kAskBefore),
ParentWindow(0),
diff --git a/CPP/7zip/UI/FileManager/FM.cpp b/CPP/7zip/UI/FileManager/FM.cpp
index 66e5a086..4e5a3724 100755
--- a/CPP/7zip/UI/FileManager/FM.cpp
+++ b/CPP/7zip/UI/FileManager/FM.cpp
@@ -5,8 +5,8 @@
#include "resource.h"
#include "Panel.h"
-extern "C"
-{
+extern "C"
+{
#include "../../../../C/Alloc.h"
}
@@ -53,6 +53,7 @@ const int kNumDefaultPanels = 1;
const int kSplitterWidth = 4;
int kSplitterRateMax = 1 << 16;
+int kPanelSizeMin = 120;
// bool OnMenuCommand(HWND hWnd, int id);
@@ -77,7 +78,7 @@ class CSplitterPos
int _pos;
int _fullWidth;
void SetRatioFromPos(HWND hWnd)
- { _ratio = (_pos + kSplitterWidth / 2) * kSplitterRateMax /
+ { _ratio = (_pos + kSplitterWidth / 2) * kSplitterRateMax /
MyMax(GetWidth(hWnd), 1); }
public:
int GetPos() const
@@ -89,17 +90,22 @@ public:
return rect.right;
}
void SetRatio(HWND hWnd, int aRatio)
- {
- _ratio = aRatio;
+ {
+ _ratio = aRatio;
SetPosFromRatio(hWnd);
}
void SetPosPure(HWND hWnd, int pos)
{
int posMax = GetWidth(hWnd) - kSplitterWidth;
- if (pos > posMax)
- pos = posMax;
- if (pos < 0)
- pos = 0;
+ if (posMax < kPanelSizeMin * 2)
+ pos = posMax / 2;
+ else
+ {
+ if (pos > posMax - kPanelSizeMin)
+ pos = posMax - kPanelSizeMin;
+ else if (pos < kPanelSizeMin)
+ pos = kPanelSizeMin;
+ }
_pos = pos;
}
void SetPos(HWND hWnd, int pos)
@@ -109,23 +115,23 @@ public:
SetRatioFromPos(hWnd);
}
void SetPosFromRatio(HWND hWnd)
- {
+ {
int fullWidth = GetWidth(hWnd);
- if (_fullWidth != fullWidth)
+ if (_fullWidth != fullWidth && fullWidth != 0)
{
_fullWidth = fullWidth;
- SetPosPure(hWnd, GetWidth(hWnd) * _ratio / kSplitterRateMax - kSplitterWidth / 2);
+ SetPosPure(hWnd, GetWidth(hWnd) * _ratio / kSplitterRateMax - kSplitterWidth / 2);
}
}
};
-bool g_CanChangeSplitter = false;
-UINT32 g_SplitterPos = 0;
-CSplitterPos g_Splitter;
-bool g_PanelsInfoDefined = false;
+static bool g_CanChangeSplitter = false;
+static UINT32 g_SplitterPos = 0;
+static CSplitterPos g_Splitter;
+static bool g_PanelsInfoDefined = false;
-int g_StartCaptureMousePos;
-int g_StartCaptureSplitterPos;
+static int g_StartCaptureMousePos;
+static int g_StartCaptureSplitterPos;
CApp g_App;
@@ -141,7 +147,7 @@ static bool IsItWindowsNT()
{
OSVERSIONINFO versionInfo;
versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
- if (!::GetVersionEx(&versionInfo))
+ if (!::GetVersionEx(&versionInfo))
return false;
return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
}
@@ -164,11 +170,11 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
/*
//If it is already running, then focus on the window
hWnd = FindWindow(windowClass, title);
- if (hWnd)
+ if (hWnd)
{
- SetForegroundWindow ((HWND) (((DWORD)hWnd) | 0x01));
+ SetForegroundWindow ((HWND) (((DWORD)hWnd) | 0x01));
return 0;
- }
+ }
*/
WNDCLASSW wc;
@@ -237,7 +243,7 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
placement.length = sizeof(placement);
if (wnd.GetPlacement(&placement))
{
- if (nCmdShow == SW_SHOWNORMAL || nCmdShow == SW_SHOW ||
+ if (nCmdShow == SW_SHOWNORMAL || nCmdShow == SW_SHOW ||
nCmdShow == SW_SHOWDEFAULT)
{
if (maximized)
@@ -276,7 +282,7 @@ static void GetCommands(const UString &aCommandLine, UString &aCommands)
break;
}
}
- else
+ else
aProgramName += aChar;
}
aCommands = aCommandLine.Mid(i);
@@ -294,7 +300,7 @@ DWORD GetDllVersion(LPCTSTR lpszDllName)
pDllGetVersion = (DLLGETVERSIONPROC) GetProcAddress(hinstDll, "DllGetVersion");
/*Because some DLLs might not implement this function, you
- must test for it explicitly. Depending on the particular
+ must test for it explicitly. Depending on the particular
DLL, the lack of a DllGetVersion function can be a useful
indicator of the version.
*/
@@ -345,7 +351,7 @@ bool IsLargePageSupported()
#else
OSVERSIONINFO versionInfo;
versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
- if (!::GetVersionEx(&versionInfo))
+ if (!::GetVersionEx(&versionInfo))
return false;
if (versionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || versionInfo.dwMajorVersion < 5)
return false;
@@ -382,7 +388,7 @@ enum Enum
}
-static const CSwitchForm kSwitchForms[kNumSwitches] =
+static const CSwitchForm kSwitchForms[kNumSwitches] =
{
{ L"SOA", NSwitchType::kSimple, false },
};
@@ -405,7 +411,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /*
g_ComCtl32Version = ::GetDllVersion(TEXT("comctl32.dll"));
// OleInitialize is required for drag and drop.
- OleInitialize(NULL);
+ OleInitialize(NULL);
// Maybe needs CoInitializeEx also ?
// NCOM::CComInitializer comInitializer;
@@ -429,18 +435,18 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /*
UStringVector commandStrings;
NCommandLineParser::SplitCommandLine(GetCommandLineW(), commandStrings);
NCommandLineParser::CParser parser(kNumSwitches);
- try
- {
- parser.ParseStrings(kSwitchForms, commandStrings);
+ try
+ {
+ parser.ParseStrings(kSwitchForms, commandStrings);
const UStringVector &nonSwitchStrings = parser.NonSwitchStrings;
- if(nonSwitchStrings.Size() > 1)
+ if(nonSwitchStrings.Size() > 1)
{
g_MainPath = nonSwitchStrings[1];
// g_OpenArchive = parser[NKey::kOpenArachive].ThereIs;
CFileInfoW fileInfo;
if (FindFile(g_MainPath, fileInfo))
{
- if (!fileInfo.IsDirectory())
+ if (!fileInfo.IsDir())
g_OpenArchive = true;
}
}
@@ -452,7 +458,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /*
SetMemoryLock();
MSG msg;
- if (!InitInstance (hInstance, nCmdShow))
+ if (!InitInstance (hInstance, nCmdShow))
return FALSE;
MyLoadMenu(g_HWND);
@@ -461,9 +467,9 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /*
if (g_IsNT)
{
HACCEL hAccels = LoadAcceleratorsW(hInstance, MAKEINTRESOURCEW(IDR_ACCELERATOR1));
- while (GetMessageW(&msg, NULL, 0, 0))
+ while (GetMessageW(&msg, NULL, 0, 0))
{
- if (TranslateAcceleratorW(g_HWND, hAccels, &msg) == 0)
+ if (TranslateAcceleratorW(g_HWND, hAccels, &msg) == 0)
{
TranslateMessage(&msg);
DispatchMessageW(&msg);
@@ -474,9 +480,9 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /*
#endif
{
HACCEL hAccels = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDR_ACCELERATOR1));
- while (GetMessage(&msg, NULL, 0, 0))
+ while (GetMessage(&msg, NULL, 0, 0))
{
- if (TranslateAccelerator(g_HWND, hAccels, &msg) == 0)
+ if (TranslateAccelerator(g_HWND, hAccels, &msg) == 0)
{
// if (g_Hwnd != NULL || !IsDialogMessage(g_Hwnd, &msg))
// if (!IsDialogMessage(g_Hwnd, &msg))
@@ -502,9 +508,9 @@ static void SaveWindowInfo(HWND aWnd)
placement.length = sizeof(placement);
if (!::GetWindowPlacement(aWnd, &placement))
return;
- SaveWindowSize(placement.rcNormalPosition,
+ SaveWindowSize(placement.rcNormalPosition,
BOOLToBool(::IsZoomed(aWnd)));
- SavePanelsInfo(g_App.NumPanels, g_App.LastFocusedPanel,
+ SavePanelsInfo(g_App.NumPanels, g_App.LastFocusedPanel,
g_Splitter.GetPos());
}
@@ -527,11 +533,11 @@ void ExecuteCommand(UINT commandID)
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
- switch (message)
+ switch (message)
{
case WM_COMMAND:
- wmId = LOWORD(wParam);
- wmEvent = HIWORD(wParam);
+ wmId = LOWORD(wParam);
+ wmEvent = HIWORD(wParam);
if ((HWND) lParam != NULL && wmEvent != 0)
break;
if (wmId >= kToolbarStartID)
@@ -568,7 +574,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
InitCommonControlsEx(&icex);
// Toolbar buttons used to create the first 4 buttons.
- TBBUTTON tbb [ ] =
+ TBBUTTON tbb [ ] =
{
// {0, 0, TBSTATE_ENABLED, BTNS_SEP, 0L, 0},
// {VIEW_PARENTFOLDER, kParentFolderID, TBSTATE_ENABLED, BTNS_BUTTON, 0L, 0},
@@ -578,11 +584,11 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
int baseID = 100;
NWindows::NControl::CToolBar aToolBar;
- aToolBar.Attach(::CreateToolbarEx (hWnd,
- WS_CHILD | WS_BORDER | WS_VISIBLE | TBSTYLE_TOOLTIPS, // | TBSTYLE_FLAT
- baseID + 2, 11,
- (HINSTANCE)HINST_COMMCTRL, IDB_VIEW_SMALL_COLOR,
- (LPCTBBUTTON)&tbb, sizeof(tbb) / sizeof(tbb[0]),
+ aToolBar.Attach(::CreateToolbarEx (hWnd,
+ WS_CHILD | WS_BORDER | WS_VISIBLE | TBSTYLE_TOOLTIPS, // | TBSTYLE_FLAT
+ baseID + 2, 11,
+ (HINSTANCE)HINST_COMMCTRL, IDB_VIEW_SMALL_COLOR,
+ (LPCTBBUTTON)&tbb, sizeof(tbb) / sizeof(tbb[0]),
0, 0, 100, 30, sizeof (TBBUTTON)));
*/
// HCURSOR cursor = ::LoadCursor(0, IDC_SIZEWE);
@@ -613,18 +619,36 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
NFile::NFind::CFileInfoW fileInfo;
if (NFile::NFind::FindFile(g_MainPath, fileInfo))
- if (!fileInfo.IsDirectory())
+ if (!fileInfo.IsDir())
needOpenFile = true;
}
- g_App.Create(hWnd, g_MainPath, xSizes, archiveIsOpened, encrypted);
+ HRESULT res = g_App.Create(hWnd, g_MainPath, xSizes, archiveIsOpened, encrypted);
- if (needOpenFile && !archiveIsOpened)
+ if (res == E_ABORT)
{
- UString message;
- if (encrypted)
- message = MyFormatNew(IDS_CANT_OPEN_ENCRYPTED_ARCHIVE, 0x0200060A, g_MainPath);
+ return -1;
+ }
+ if (needOpenFile && !archiveIsOpened || res != S_OK)
+ {
+ UString message = L"Error";
+ if (res == S_FALSE || res == S_OK)
+ {
+ if (encrypted)
+ message = MyFormatNew(IDS_CANT_OPEN_ENCRYPTED_ARCHIVE, 0x0200060A, g_MainPath);
+ else
+ message = MyFormatNew(IDS_CANT_OPEN_ARCHIVE, 0x02000609, g_MainPath);
+ }
else
- message = MyFormatNew(IDS_CANT_OPEN_ARCHIVE, 0x02000609, g_MainPath);
+ {
+ if (res != S_OK)
+ {
+ if (res == E_OUTOFMEMORY)
+ message = LangString(IDS_MEM_ERROR, 0x0200060B);
+ else
+ if (!NError::MyFormatMessage(res, message))
+ message = L"Error";
+ }
+ }
MessageBoxW(0, message, L"7-zip", MB_ICONERROR);
return -1;
}
@@ -637,7 +661,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
}
case WM_DESTROY:
{
- // ::DragAcceptFiles(hWnd, FALSE);
+ // ::DragAcceptFiles(hWnd, FALSE);
RevokeDragDrop(hWnd);
g_App._dropTarget.Release();
@@ -663,11 +687,11 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
::ReleaseCapture();
break;
}
- case WM_MOUSEMOVE:
+ case WM_MOUSEMOVE:
{
if ((wParam & MK_LBUTTON) != 0 && ::GetCapture() == hWnd)
{
- g_Splitter.SetPos(hWnd, g_StartCaptureSplitterPos +
+ g_Splitter.SetPos(hWnd, g_StartCaptureSplitterPos +
(short)LOWORD(lParam) - g_StartCaptureMousePos);
MoveSubWindows(hWnd);
}
@@ -704,7 +728,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
/*
case WM_ACTIVATE:
{
- int fActive = LOWORD(wParam);
+ int fActive = LOWORD(wParam);
switch (fActive)
{
case WA_INACTIVE:
@@ -786,6 +810,10 @@ void MoveSubWindows(HWND hWnd)
if (g_App._rebar)
headerSize = Window_GetRealHeight(g_App._rebar);
int ySize = MyMax((int)(rect.bottom - headerSize), 0);
+
+ // It's for such case: Minimize / Close:
+ if (xSize == 0 && ySize == 0)
+ return;
if (g_App.NumPanels > 1)
{
diff --git a/CPP/7zip/UI/FileManager/FM.dsp b/CPP/7zip/UI/FileManager/FM.dsp
index d2284325..8a3ddc83 100755
--- a/CPP/7zip/UI/FileManager/FM.dsp
+++ b/CPP/7zip/UI/FileManager/FM.dsp
@@ -947,6 +947,10 @@ SOURCE=..\..\..\Windows\Thread.h
# End Source File
# Begin Source File
+SOURCE=..\..\..\Windows\Time.cpp
+# End Source File
+# Begin Source File
+
SOURCE=..\..\..\Windows\Time.h
# End Source File
# Begin Source File
diff --git a/CPP/7zip/UI/FileManager/FSDrives.cpp b/CPP/7zip/UI/FileManager/FSDrives.cpp
index 42540287..6fd8d708 100755
--- a/CPP/7zip/UI/FileManager/FSDrives.cpp
+++ b/CPP/7zip/UI/FileManager/FSDrives.cpp
@@ -23,16 +23,16 @@ using namespace NWindows;
using namespace NFile;
using namespace NFind;
-static const STATPROPSTG kProperties[] =
+static const STATPROPSTG kProperties[] =
{
{ NULL, kpidName, VT_BSTR},
- // { NULL, kpidIsFolder, VT_BOOL},
+ // { NULL, kpidIsDir, VT_BOOL},
{ L"Total Size", kpidTotalSize, VT_UI8},
{ L"Free Space", kpidFreeSpace, VT_UI8},
{ NULL, kpidType, VT_BSTR},
{ L"Label", kpidVolumeName, VT_BSTR},
{ L"File system", kpidFileSystem, VT_BSTR},
- { L"Cluster Size", kpidClusterSize, VT_UI8}
+ { L"Cluster Size", kpidClusterSize, VT_UI8}
};
static const wchar_t *kDriveTypes[] =
@@ -54,31 +54,31 @@ STDMETHODIMP CFSDrives::LoadItems()
MyGetLogicalDriveStrings(driveStrings);
for (int i = 0; i < driveStrings.Size(); i++)
{
- CDriveInfo driveInfo;
+ CDriveInfo di;
const UString &driveName = driveStrings[i];
- driveInfo.FullSystemName = driveName;
+ di.FullSystemName = driveName;
- driveInfo.Name = driveInfo.FullSystemName.Left(
- driveInfo.FullSystemName.Length() - 1);
- driveInfo.ClusterSize = 0;
- driveInfo.DriveSize = 0;
- driveInfo.FreeSpace = 0;
+ di.Name = di.FullSystemName.Left(
+ di.FullSystemName.Length() - 1);
+ di.ClusterSize = 0;
+ di.DriveSize = 0;
+ di.FreeSpace = 0;
UINT driveType = NFile::NSystem::MyGetDriveType(driveName);
if (driveType < sizeof(kDriveTypes) / sizeof(kDriveTypes[0]))
{
- driveInfo.Type = kDriveTypes[driveType];
+ di.Type = kDriveTypes[driveType];
}
bool needRead = true;
if (driveType == DRIVE_CDROM || driveType == DRIVE_REMOVABLE)
{
/*
DWORD dwSerialNumber;`
- if (!::GetVolumeInformation(driveInfo.FullSystemName,
- NULL, 0, &dwSerialNumber, NULL, NULL, NULL, 0))
+ if (!::GetVolumeInformation(di.FullSystemName,
+ NULL, 0, &dwSerialNumber, NULL, NULL, NULL, 0))
*/
- driveInfo.KnownSizes = false;
+ di.KnownSizes = false;
{
needRead = false;
}
@@ -87,18 +87,18 @@ STDMETHODIMP CFSDrives::LoadItems()
{
UString volumeName, fileSystemName;
DWORD volumeSerialNumber, maximumComponentLength, fileSystemFlags;
- NFile::NSystem::MyGetVolumeInformation(driveName,
+ NFile::NSystem::MyGetVolumeInformation(driveName,
volumeName,
- &volumeSerialNumber, &maximumComponentLength, &fileSystemFlags,
+ &volumeSerialNumber, &maximumComponentLength, &fileSystemFlags,
fileSystemName);
- driveInfo.VolumeName = volumeName;
- driveInfo.FileSystemName = fileSystemName;
+ di.VolumeName = volumeName;
+ di.FileSystemName = fileSystemName;
NFile::NSystem::MyGetDiskFreeSpace(driveName,
- driveInfo.ClusterSize, driveInfo.DriveSize, driveInfo.FreeSpace);
- driveInfo.KnownSizes = true;
+ di.ClusterSize, di.DriveSize, di.FreeSpace);
+ di.KnownSizes = true;
}
- _drives.Add(driveInfo);
+ _drives.Add(di);
}
return S_OK;
}
@@ -113,39 +113,20 @@ STDMETHODIMP CFSDrives::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT
{
if (itemIndex >= (UInt32)_drives.Size())
return E_INVALIDARG;
- NCOM::CPropVariant propVariant;
- const CDriveInfo &driveInfo = _drives[itemIndex];
+ NCOM::CPropVariant prop;
+ const CDriveInfo &di = _drives[itemIndex];
switch(propID)
{
- case kpidIsFolder:
- propVariant = true;
- break;
- case kpidName:
- propVariant = driveInfo.Name;
- break;
- case kpidTotalSize:
- if (driveInfo.KnownSizes)
- propVariant = driveInfo.DriveSize;
- break;
- case kpidFreeSpace:
- if (driveInfo.KnownSizes)
- propVariant = driveInfo.FreeSpace;
- break;
- case kpidClusterSize:
- if (driveInfo.KnownSizes)
- propVariant = driveInfo.ClusterSize;
- break;
- case kpidType:
- propVariant = driveInfo.Type;
- break;
- case kpidVolumeName:
- propVariant = driveInfo.VolumeName;
- break;
- case kpidFileSystem:
- propVariant = driveInfo.FileSystemName;
- break;
+ case kpidIsDir: prop = true; break;
+ case kpidName: prop = di.Name; break;
+ case kpidTotalSize: if (di.KnownSizes) prop = di.DriveSize; break;
+ case kpidFreeSpace: if (di.KnownSizes) prop = di.FreeSpace; break;
+ case kpidClusterSize: if (di.KnownSizes) prop = di.ClusterSize; break;
+ case kpidType: prop = di.Type; break;
+ case kpidVolumeName: prop = di.VolumeName; break;
+ case kpidFileSystem: prop = di.FileSystemName; break;
}
- propVariant.Detach(value);
+ prop.Detach(value);
return S_OK;
}
@@ -164,17 +145,17 @@ STDMETHODIMP CFSDrives::BindToFolder(UInt32 index, IFolderFolder **resultFolder)
*resultFolder = 0;
if (index >= (UInt32)_drives.Size())
return E_INVALIDARG;
- const CDriveInfo &driveInfo = _drives[index];
+ const CDriveInfo &di = _drives[index];
if (_volumeMode)
{
*resultFolder = 0;
CPhysDriveFolder *folderSpec = new CPhysDriveFolder;
CMyComPtr<IFolderFolder> subFolder = folderSpec;
- RINOK(folderSpec->Init(driveInfo.Name));
+ RINOK(folderSpec->Init(di.Name));
*resultFolder = subFolder.Detach();
return S_OK;
}
- return BindToFolderSpec(driveInfo.FullSystemName, resultFolder);
+ return BindToFolderSpec(di.FullSystemName, resultFolder);
}
STDMETHODIMP CFSDrives::BindToFolder(const wchar_t *name, IFolderFolder **resultFolder)
@@ -194,7 +175,7 @@ STDMETHODIMP CFSDrives::GetNumberOfProperties(UInt32 *numProperties)
return S_OK;
}
-STDMETHODIMP CFSDrives::GetPropertyInfo(UInt32 index,
+STDMETHODIMP CFSDrives::GetPropertyInfo(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType)
{
if (index >= sizeof(kProperties) / sizeof(kProperties[0]))
@@ -224,9 +205,9 @@ STDMETHODIMP CFSDrives::GetFolderProperty(PROPID propID, PROPVARIANT *value)
STDMETHODIMP CFSDrives::GetSystemIconIndex(UInt32 index, INT32 *iconIndex)
{
*iconIndex = 0;
- const CDriveInfo &driveInfo = _drives[index];
+ const CDriveInfo &di = _drives[index];
int iconIndexTemp;
- if (GetRealIconIndex(driveInfo.FullSystemName, 0, iconIndexTemp) != 0)
+ if (GetRealIconIndex(di.FullSystemName, 0, iconIndexTemp) != 0)
{
*iconIndex = iconIndexTemp;
return S_OK;
diff --git a/CPP/7zip/UI/FileManager/FSDrives.h b/CPP/7zip/UI/FileManager/FSDrives.h
index 527c2438..84db5b7e 100755
--- a/CPP/7zip/UI/FileManager/FSDrives.h
+++ b/CPP/7zip/UI/FileManager/FSDrives.h
@@ -24,7 +24,7 @@ struct CDriveInfo
UString FileSystemName;
};
-class CFSDrives:
+class CFSDrives:
public IFolderFolder,
public IFolderGetSystemIconIndex,
public CMyUnknownImp
diff --git a/CPP/7zip/UI/FileManager/FSFolder.cpp b/CPP/7zip/UI/FileManager/FSFolder.cpp
index aeb3b333..a3e4787a 100755
--- a/CPP/7zip/UI/FileManager/FSFolder.cpp
+++ b/CPP/7zip/UI/FileManager/FSFolder.cpp
@@ -32,16 +32,16 @@ using namespace NFind;
namespace NFsFolder {
-static STATPROPSTG kProperties[] =
+static STATPROPSTG kProperties[] =
{
{ NULL, kpidName, VT_BSTR},
- // { NULL, kpidIsFolder, VT_BOOL},
+ // { NULL, kpidIsDir, VT_BOOL},
{ NULL, kpidSize, VT_UI8},
- { NULL, kpidLastWriteTime, VT_FILETIME},
- { NULL, kpidCreationTime, VT_FILETIME},
- { NULL, kpidLastAccessTime, VT_FILETIME},
- { NULL, kpidAttributes, VT_UI4},
- { NULL, kpidPackedSize, VT_UI8},
+ { NULL, kpidMTime, VT_FILETIME},
+ { NULL, kpidCTime, VT_FILETIME},
+ { NULL, kpidATime, VT_FILETIME},
+ { NULL, kpidAttrib, VT_UI4},
+ { NULL, kpidPackSize, VT_UI8},
{ NULL, kpidComment, VT_BSTR},
{ NULL, kpidPrefix, VT_BSTR}
};
@@ -51,8 +51,8 @@ HRESULT CFSFolder::Init(const UString &path, IFolderFolder *parentFolder)
_parentFolder = parentFolder;
_path = path;
- _findChangeNotification.FindFirst(_path, false,
- FILE_NOTIFY_CHANGE_FILE_NAME |
+ _findChangeNotification.FindFirst(_path, false,
+ FILE_NOTIFY_CHANGE_FILE_NAME |
FILE_NOTIFY_CHANGE_DIR_NAME |
FILE_NOTIFY_CHANGE_ATTRIBUTES |
FILE_NOTIFY_CHANGE_SIZE |
@@ -79,7 +79,7 @@ HRESULT GetFolderSize(const UString &path, UInt64 &numFolders, UInt64 &numFiles,
CFileInfoW fileInfo;
while (enumerator.Next(fileInfo))
{
- if (fileInfo.IsDirectory())
+ if (fileInfo.IsDir())
{
UInt64 subFolders, subFiles, subSize;
RINOK(GetFolderSize(path + UString(L"\\") + fileInfo.Name, subFolders, subFiles, subSize, progress));
@@ -106,11 +106,11 @@ HRESULT CFSFolder::LoadSubItems(CDirItem &dirItem, const UString &path)
{
fileInfo.CompressedSizeIsDefined = false;
/*
- if (!GetCompressedFileSize(_path + fileInfo.Name,
+ if (!GetCompressedFileSize(_path + fileInfo.Name,
fileInfo.CompressedSize))
fileInfo.CompressedSize = fileInfo.Size;
*/
- if (fileInfo.IsDirectory())
+ if (fileInfo.IsDir())
{
// fileInfo.Size = GetFolderSize(_path + fileInfo.Name);
fileInfo.Size = 0;
@@ -124,7 +124,7 @@ HRESULT CFSFolder::LoadSubItems(CDirItem &dirItem, const UString &path)
for (int i = 0; i < dirItem.Files.Size(); i++)
{
CDirItem &item = dirItem.Files[i];
- if (item.IsDirectory())
+ if (item.IsDir())
LoadSubItems(item, path + item.Name + L'\\');
}
return S_OK;
@@ -144,7 +144,7 @@ void CFSFolder::AddRefs(CDirItem &dirItem)
for (i = 0; i < dirItem.Files.Size(); i++)
{
CDirItem &item = dirItem.Files[i];
- if (item.IsDirectory())
+ if (item.IsDir())
AddRefs(item);
}
}
@@ -233,7 +233,7 @@ STDMETHODIMP CFSFolder::GetNumberOfSubFolders(UInt32 *numSubFolders)
{
UInt32 numSubFoldersLoc = 0;
for (int i = 0; i < _files.Size(); i++)
- if (_files[i].IsDirectory())
+ if (_files[i].IsDir())
numSubFoldersLoc++;
*numSubFolders = numSubFoldersLoc;
return S_OK;
@@ -262,61 +262,47 @@ bool MyGetCompressedFileSizeW(LPCWSTR fileName, UInt64 &size)
STDMETHODIMP CFSFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT *value)
{
- NCOM::CPropVariant propVariant;
+ NCOM::CPropVariant prop;
if (itemIndex >= (UInt32)_refs.Size())
return E_INVALIDARG;
CDirItem &fileInfo = *_refs[itemIndex];
switch(propID)
{
- case kpidIsFolder:
- propVariant = fileInfo.IsDirectory();
- break;
- case kpidName:
- propVariant = fileInfo.Name;
- break;
- case kpidSize:
- propVariant = fileInfo.Size;
- break;
- case kpidPackedSize:
+ case kpidIsDir: prop = fileInfo.IsDir(); break;
+ case kpidName: prop = fileInfo.Name; break;
+ case kpidSize: if (!fileInfo.IsDir()) prop = fileInfo.Size; break;
+ case kpidPackSize:
if (!fileInfo.CompressedSizeIsDefined)
{
fileInfo.CompressedSizeIsDefined = true;
- if (fileInfo.IsDirectory () ||
+ if (fileInfo.IsDir () ||
!MyGetCompressedFileSizeW(_path + GetRelPath(fileInfo), fileInfo.CompressedSize))
fileInfo.CompressedSize = fileInfo.Size;
}
- propVariant = fileInfo.CompressedSize;
- break;
- case kpidAttributes:
- propVariant = (UInt32)fileInfo.Attributes;
- break;
- case kpidCreationTime:
- propVariant = fileInfo.CreationTime;
- break;
- case kpidLastAccessTime:
- propVariant = fileInfo.LastAccessTime;
- break;
- case kpidLastWriteTime:
- propVariant = fileInfo.LastWriteTime;
+ prop = fileInfo.CompressedSize;
break;
+ case kpidAttrib: prop = (UInt32)fileInfo.Attrib; break;
+ case kpidCTime: prop = fileInfo.CTime; break;
+ case kpidATime: prop = fileInfo.ATime; break;
+ case kpidMTime: prop = fileInfo.MTime; break;
case kpidComment:
{
LoadComments();
UString comment;
if (_comments.GetValue(GetRelPath(fileInfo), comment))
- propVariant = comment;
+ prop = comment;
break;
}
case kpidPrefix:
{
if (_flatMode)
{
- propVariant = GetPrefix(fileInfo);
+ prop = GetPrefix(fileInfo);
}
break;
}
}
- propVariant.Detach(value);
+ prop.Detach(value);
return S_OK;
}
@@ -351,7 +337,7 @@ STDMETHODIMP CFSFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolder)
{
*resultFolder = 0;
const CDirItem &fileInfo = *_refs[index];
- if (!fileInfo.IsDirectory())
+ if (!fileInfo.IsDir())
return E_INVALIDARG;
return BindToFolderSpec(GetRelPath(fileInfo), resultFolder);
}
@@ -414,7 +400,7 @@ STDMETHODIMP CFSFolder::GetNumberOfProperties(UInt32 *numProperties)
return S_OK;
}
-STDMETHODIMP CFSFolder::GetPropertyInfo(UInt32 index,
+STDMETHODIMP CFSFolder::GetPropertyInfo(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType)
{
if (index >= sizeof(kProperties) / sizeof(kProperties[0]))
@@ -459,7 +445,7 @@ STDMETHODIMP CFSFolder::WasChanged(INT32 *wasChanged)
_findChangeNotification.FindNext();
wasChangedMain = true;
}
- else
+ else
break;
}
*wasChanged = BoolToInt(wasChangedMain);
@@ -475,7 +461,7 @@ STDMETHODIMP CFSFolder::Clone(IFolderFolder **resultFolder)
return S_OK;
}
-HRESULT CFSFolder::GetItemsFullSize(const UInt32 *indices, UInt32 numItems,
+HRESULT CFSFolder::GetItemsFullSize(const UInt32 *indices, UInt32 numItems,
UInt64 &numFolders, UInt64 &numFiles, UInt64 &size, IProgress *progress)
{
numFiles = numFolders = size = 0;
@@ -486,7 +472,7 @@ HRESULT CFSFolder::GetItemsFullSize(const UInt32 *indices, UInt32 numItems,
if (index >= _refs.Size())
return E_INVALIDARG;
const CDirItem &fileInfo = *_refs[index];
- if (fileInfo.IsDirectory())
+ if (fileInfo.IsDir())
{
UInt64 subFolders, subFiles, subSize;
RINOK(GetFolderSize(_path + GetRelPath(fileInfo), subFolders, subFiles, subSize, progress));
@@ -507,7 +493,7 @@ HRESULT CFSFolder::GetItemsFullSize(const UInt32 *indices, UInt32 numItems,
HRESULT CFSFolder::GetItemFullSize(int index, UInt64 &size, IProgress *progress)
{
const CDirItem &fileInfo = *_refs[index];
- if (fileInfo.IsDirectory())
+ if (fileInfo.IsDir())
{
/*
CMyComPtr<IFolderFolder> subFolder;
@@ -516,7 +502,7 @@ HRESULT CFSFolder::GetItemFullSize(int index, UInt64 &size, IProgress *progress)
subFolder.QueryInterface(&aFolderReload);
aFolderReload->Reload();
UInt32 numItems;
- RINOK(subFolder->GetNumberOfItems(&numItems));
+ RINOK(subFolder->GetNumberOfItems(&numItems));
CMyComPtr<IFolderGetItemFullSize> aGetItemFullSize;
subFolder.QueryInterface(&aGetItemFullSize);
for (UInt32 i = 0; i < numItems; i++)
@@ -535,13 +521,13 @@ HRESULT CFSFolder::GetItemFullSize(int index, UInt64 &size, IProgress *progress)
STDMETHODIMP CFSFolder::GetItemFullSize(UInt32 index, PROPVARIANT *value, IProgress *progress)
{
- NCOM::CPropVariant propVariant;
+ NCOM::CPropVariant prop;
if (index >= (UInt32)_refs.Size())
return E_INVALIDARG;
UInt64 size = 0;
HRESULT result = GetItemFullSize(index, size, progress);
- propVariant = size;
- propVariant.Detach(value);
+ prop = size;
+ prop.Detach(value);
return result;
}
@@ -603,7 +589,7 @@ STDMETHODIMP CFSFolder::Delete(const UInt32 *indices, UInt32 numItems,IProgress
const CDirItem &fileInfo = *_refs[indices[i]];
const UString fullPath = _path + GetRelPath(fileInfo);
bool result;
- if (fileInfo.IsDirectory())
+ if (fileInfo.IsDir())
result = NDirectory::RemoveDirectoryWithSubItems(fullPath);
else
result = NDirectory::DeleteFileAlways(fullPath);
@@ -615,7 +601,7 @@ STDMETHODIMP CFSFolder::Delete(const UInt32 *indices, UInt32 numItems,IProgress
return S_OK;
}
-STDMETHODIMP CFSFolder::SetProperty(UInt32 index, PROPID propID,
+STDMETHODIMP CFSFolder::SetProperty(UInt32 index, PROPID propID,
const PROPVARIANT *value, IProgress * /* progress */)
{
if (index >= (UInt32)_refs.Size())
@@ -661,7 +647,7 @@ STDMETHODIMP CFSFolder::GetSystemIconIndex(UInt32 index, INT32 *iconIndex)
const CDirItem &fileInfo = *_refs[index];
*iconIndex = 0;
int iconIndexTemp;
- if (GetRealIconIndex(_path + GetRelPath(fileInfo), fileInfo.Attributes, iconIndexTemp) != 0)
+ if (GetRealIconIndex(_path + GetRelPath(fileInfo), fileInfo.Attrib, iconIndexTemp) != 0)
{
*iconIndex = iconIndexTemp;
return S_OK;
diff --git a/CPP/7zip/UI/FileManager/FSFolder.h b/CPP/7zip/UI/FileManager/FSFolder.h
index d938969f..ca229055 100755
--- a/CPP/7zip/UI/FileManager/FSFolder.h
+++ b/CPP/7zip/UI/FileManager/FSFolder.h
@@ -37,7 +37,7 @@ struct CDirItem: public CFileInfoEx
}
};
-class CFSFolder:
+class CFSFolder:
public IFolderFolder,
public IFolderWasChanged,
public IFolderOperations,
@@ -87,7 +87,7 @@ private:
NWindows::NFile::NFind::CFindChangeNotification _findChangeNotification;
- HRESULT GetItemsFullSize(const UInt32 *indices, UInt32 numItems,
+ HRESULT GetItemsFullSize(const UInt32 *indices, UInt32 numItems,
UInt64 &numFolders, UInt64 &numFiles, UInt64 &size, IProgress *progress);
HRESULT GetItemFullSize(int index, UInt64 &size, IProgress *progress);
HRESULT GetComplexName(const wchar_t *name, UString &resultPath);
diff --git a/CPP/7zip/UI/FileManager/FSFolderCopy.cpp b/CPP/7zip/UI/FileManager/FSFolderCopy.cpp
index 32823fb9..8818b6a9 100755
--- a/CPP/7zip/UI/FileManager/FSFolderCopy.cpp
+++ b/CPP/7zip/UI/FileManager/FSFolderCopy.cpp
@@ -27,7 +27,7 @@ static bool IsItWindows2000orHigher()
{
OSVERSIONINFO versionInfo;
versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
- if (!::GetVersionEx(&versionInfo))
+ if (!::GetVersionEx(&versionInfo))
return false;
return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) &&
(versionInfo.dwMajorVersion >= 5);
@@ -78,7 +78,7 @@ typedef BOOL (WINAPI * CopyFileExPointerW)(
);
#ifndef _UNICODE
-static inline UINT GetCurrentCodePage() { return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
+static inline UINT GetCurrentCodePage() { return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
static CSysString GetSysPath(LPCWSTR sysPath)
{ return UnicodeStringToMultiByte(sysPath, GetCurrentCodePage()); }
#endif
@@ -194,7 +194,7 @@ static HRESULT MyCopyFile(
RINOK(callback->AskWrite(
srcPath,
BoolToInt(false),
- &srcFileInfo.LastWriteTime, &srcFileInfo.Size,
+ &srcFileInfo.MTime, &srcFileInfo.Size,
destPath,
&destPathResult,
&writeAskResult));
@@ -205,8 +205,8 @@ static HRESULT MyCopyFile(
if (!MyCopyFile(srcPath, destPathNew, callback, completedSize))
{
UString message = NError::MyFormatMessageW(GetLastError()) +
- UString(L" \'") +
- UString(destPathNew) +
+ UString(L" \'") +
+ UString(destPathNew) +
UString(L"\'");
RINOK(callback->ShowMessage(message));
return E_ABORT;
@@ -230,7 +230,7 @@ static HRESULT CopyFolder(
{
if (destPath.Length() == len || destPath[len] == L'\\')
{
- UString message = UString(L"can not copy folder \'") +
+ UString message = UString(L"can not copy folder \'") +
destPath + UString(L"\' onto itself");
RINOK(callback->ShowMessage(message));
return E_ABORT;
@@ -249,7 +249,7 @@ static HRESULT CopyFolder(
{
const UString srcPath2 = srcPath + UString(L"\\") + fileInfo.Name;
const UString destPath2 = destPath + UString(L"\\") + fileInfo.Name;
- if (fileInfo.IsDirectory())
+ if (fileInfo.IsDir())
{
RINOK(CopyFolder(srcPath2, destPath2, callback, completedSize));
}
@@ -261,7 +261,7 @@ static HRESULT CopyFolder(
return S_OK;
}
-STDMETHODIMP CFSFolder::CopyTo(const UInt32 *indices, UInt32 numItems,
+STDMETHODIMP CFSFolder::CopyTo(const UInt32 *indices, UInt32 numItems,
const wchar_t *path, IFolderOperationsExtractCallback *callback)
{
if (numItems == 0)
@@ -287,7 +287,7 @@ STDMETHODIMP CFSFolder::CopyTo(const UInt32 *indices, UInt32 numItems,
if (!NDirectory::CreateComplexDirectory(destPath)))
{
DWORD lastError = ::GetLastError();
- UString message = UString(L"can not create folder ") +
+ UString message = UString(L"can not create folder ") +
destPath;
RINOK(callback->ShowMessage(message));
return E_ABORT;
@@ -303,7 +303,7 @@ STDMETHODIMP CFSFolder::CopyTo(const UInt32 *indices, UInt32 numItems,
if (!directName)
destPath2 += fileInfo.Name;
UString srcPath = _path + GetPrefix(fileInfo) + fileInfo.Name;
- if (fileInfo.IsDirectory())
+ if (fileInfo.IsDir())
{
RINOK(CopyFolder(srcPath, destPath2, callback, completedSize));
}
@@ -340,8 +340,8 @@ HRESULT MyMoveFile(
RINOK(callback->AskWrite(
srcPath,
BoolToInt(false),
- &srcFileInfo.LastWriteTime, &srcFileInfo.Size,
- destPath,
+ &srcFileInfo.MTime, &srcFileInfo.Size,
+ destPath,
&destPathResult,
&writeAskResult));
if (IntToBool(writeAskResult))
@@ -371,7 +371,7 @@ HRESULT MyMoveFolder(
{
if (destPath.Length() == len || destPath[len] == L'\\')
{
- UString message = UString(L"can not move folder \'") +
+ UString message = UString(L"can not move folder \'") +
destPath + UString(L"\' onto itself");
RINOK(callback->ShowMessage(message));
return E_ABORT;
@@ -394,7 +394,7 @@ HRESULT MyMoveFolder(
{
const UString srcPath2 = srcPath + UString(L"\\") + fileInfo.Name;
const UString destPath2 = destPath + UString(L"\\") + fileInfo.Name;
- if (fileInfo.IsDirectory())
+ if (fileInfo.IsDir())
{
RINOK(MyMoveFolder(srcPath2, destPath2, callback, completedSize));
}
@@ -414,8 +414,8 @@ HRESULT MyMoveFolder(
}
STDMETHODIMP CFSFolder::MoveTo(
- const UInt32 *indices,
- UInt32 numItems,
+ const UInt32 *indices,
+ UInt32 numItems,
const wchar_t *path,
IFolderOperationsExtractCallback *callback)
{
@@ -439,7 +439,7 @@ STDMETHODIMP CFSFolder::MoveTo(
else
if (!NDirectory::CreateComplexDirectory(destPath))
{
- UString message = UString(L"can not create folder ") +
+ UString message = UString(L"can not create folder ") +
destPath;
RINOK(callback->ShowMessage(message));
return E_ABORT;
@@ -454,7 +454,7 @@ STDMETHODIMP CFSFolder::MoveTo(
if (!directName)
destPath2 += fileInfo.Name;
UString srcPath = _path + GetPrefix(fileInfo) + fileInfo.Name;
- if (fileInfo.IsDirectory())
+ if (fileInfo.IsDir())
{
RINOK(MyMoveFolder(srcPath, destPath2, callback, completedSize));
}
@@ -480,7 +480,7 @@ STDMETHODIMP CFSFolder::CopyFrom(const wchar_t * /* fromFolderPath */,
CFileInfoW fileInfo;
if (!FindFile(path, fileInfo))
return ::GetLastError();
- if (fileInfo.IsDirectory())
+ if (fileInfo.IsDir())
{
UInt64 subFolders, subFiles, subSize;
RINOK(GetFolderSize(path + UString(L"\\") + fileInfo.Name, subFolders, subFiles, subSize, progress));
diff --git a/CPP/7zip/UI/FileManager/FileFolderPluginOpen.cpp b/CPP/7zip/UI/FileManager/FileFolderPluginOpen.cpp
index a3a19414..f93c0943 100755
--- a/CPP/7zip/UI/FileManager/FileFolderPluginOpen.cpp
+++ b/CPP/7zip/UI/FileManager/FileFolderPluginOpen.cpp
@@ -2,11 +2,14 @@
#include "StdAfx.h"
+#include "resource.h"
+
#include "Common/StringConvert.h"
#include "Windows/Defs.h"
#include "Windows/FileDir.h"
#include "Windows/FileName.h"
#include "Windows/DLL.h"
+#include "Windows/Thread.h"
#include "IFolder.h"
#include "RegistryAssociations.h"
@@ -14,12 +17,37 @@
#include "OpenCallback.h"
#include "PluginLoader.h"
+#include "LangUtils.h"
#include "../Agent/Agent.h"
using namespace NWindows;
using namespace NRegistryAssociations;
-static int FindPlugin(const CObjectVector<CPluginInfo> &plugins,
+struct CThreadArchiveOpen
+{
+ UString Path;
+ CMyComPtr<IFolderManager> FolderManager;
+ CMyComPtr<IProgress> OpenCallback;
+ COpenArchiveCallback *OpenCallbackSpec;
+
+ CMyComPtr<IFolderFolder> Folder;
+ HRESULT Result;
+
+ void Process()
+ {
+ OpenCallbackSpec->ProgressDialog.WaitCreating();
+ Result = FolderManager->OpenFolderFile(Path, &Folder, OpenCallback);
+ OpenCallbackSpec->ProgressDialog.MyClose();
+ }
+
+ static THREAD_FUNC_DECL MyThreadFunction(void *param)
+ {
+ ((CThreadArchiveOpen *)param)->Process();
+ return 0;
+ }
+};
+
+static int FindPlugin(const CObjectVector<CPluginInfo> &plugins,
const UString &pluginName)
{
for (int i = 0; i < plugins.Size(); i++)
@@ -29,13 +57,12 @@ static int FindPlugin(const CObjectVector<CPluginInfo> &plugins,
}
HRESULT OpenFileFolderPlugin(
- const UString &path,
+ const UString &path,
HMODULE *module,
- IFolderFolder **resultFolder,
- HWND parentWindow,
- bool &encrypted)
+ IFolderFolder **resultFolder,
+ HWND parentWindow,
+ bool &encrypted, UString &password)
{
- encrypted = false;
CObjectVector<CPluginInfo> plugins;
ReadFileFolderPluginInfoList(plugins);
@@ -82,33 +109,50 @@ HRESULT OpenFileFolderPlugin(
if (!plugin.ClassIDDefined)
continue;
CPluginLibrary library;
- CMyComPtr<IFolderManager> folderManager;
- CMyComPtr<IFolderFolder> folder;
+
+ CThreadArchiveOpen t;
+
if (plugin.FilePath.IsEmpty())
- folderManager = new CArchiveFolderManager;
- else if (library.LoadAndCreateManager(plugin.FilePath, plugin.ClassID, &folderManager) != S_OK)
+ t.FolderManager = new CArchiveFolderManager;
+ else if (library.LoadAndCreateManager(plugin.FilePath, plugin.ClassID, &t.FolderManager) != S_OK)
continue;
- COpenArchiveCallback *openCallbackSpec = new COpenArchiveCallback;
- CMyComPtr<IProgress> openCallback = openCallbackSpec;
- openCallbackSpec->PasswordIsDefined = false;
- openCallbackSpec->ParentWindow = parentWindow;
- openCallbackSpec->LoadFileInfo(dirPrefix, fileName);
- HRESULT result = folderManager->OpenFolderFile(path, &folder, openCallback);
- if (openCallbackSpec->PasswordWasAsked)
- encrypted = true;
- if (result == S_OK)
+ t.OpenCallbackSpec = new COpenArchiveCallback;
+ t.OpenCallback = t.OpenCallbackSpec;
+ t.OpenCallbackSpec->PasswordIsDefined = encrypted;
+ t.OpenCallbackSpec->Password = password;
+ t.OpenCallbackSpec->ParentWindow = parentWindow;
+ t.OpenCallbackSpec->LoadFileInfo(dirPrefix, fileName);
+
+ t.Path = path;
+
+ UString progressTitle = LangString(IDS_OPENNING, 0x03020283);
+ t.OpenCallbackSpec->ProgressDialog.MainWindow = parentWindow;
+ t.OpenCallbackSpec->ProgressDialog.MainTitle = LangString(IDS_APP_TITLE, 0x03000000);
+ t.OpenCallbackSpec->ProgressDialog.MainAddTitle = progressTitle + UString(L" ");
+
+ NWindows::CThread thread;
+ if (thread.Create(CThreadArchiveOpen::MyThreadFunction, &t) != S_OK)
+ throw 271824;
+ t.OpenCallbackSpec->StartProgressDialog(progressTitle);
+
+ if (t.Result == E_ABORT)
+ return t.Result;
+
+ if (t.Result == S_OK)
{
+ // if (openCallbackSpec->PasswordWasAsked)
+ {
+ encrypted = t.OpenCallbackSpec->PasswordIsDefined;
+ password = t.OpenCallbackSpec->Password;
+ }
*module = library.Detach();
- *resultFolder = folder.Detach();
+ *resultFolder = t.Folder.Detach();
return S_OK;
}
- continue;
-
- /*
- if (result != S_FALSE)
- return result;
- */
+
+ if (t.Result != S_FALSE)
+ return t.Result;
}
return S_FALSE;
} \ No newline at end of file
diff --git a/CPP/7zip/UI/FileManager/FileFolderPluginOpen.h b/CPP/7zip/UI/FileManager/FileFolderPluginOpen.h
index 295048a9..9e5c66c7 100755
--- a/CPP/7zip/UI/FileManager/FileFolderPluginOpen.h
+++ b/CPP/7zip/UI/FileManager/FileFolderPluginOpen.h
@@ -3,7 +3,7 @@
#ifndef __FILEFOLDERPLUGINOPEN_H
#define __FILEFOLDERPLUGINOPEN_H
-HRESULT OpenFileFolderPlugin(const UString &path,
- HMODULE *module, IFolderFolder **resultFolder, HWND parentWindow, bool &encrypted);
+HRESULT OpenFileFolderPlugin(const UString &path,
+ HMODULE *module, IFolderFolder **resultFolder, HWND parentWindow, bool &encrypted, UString &password);
#endif
diff --git a/CPP/7zip/UI/FileManager/FilePlugins.cpp b/CPP/7zip/UI/FileManager/FilePlugins.cpp
index 1812312e..173eeffa 100755
--- a/CPP/7zip/UI/FileManager/FilePlugins.cpp
+++ b/CPP/7zip/UI/FileManager/FilePlugins.cpp
@@ -57,7 +57,7 @@ void CExtDatabase::Read()
if (pluginInfo.FilePath.IsEmpty())
folderManager = new CArchiveFolderManager;
- else if (pluginLibrary.LoadAndCreateManager(pluginInfo.FilePath,
+ else if (pluginLibrary.LoadAndCreateManager(pluginInfo.FilePath,
pluginInfo.ClassID, &folderManager) != S_OK)
continue;
CMyComBSTR extBSTR;
diff --git a/CPP/7zip/UI/FileManager/FormatUtils.cpp b/CPP/7zip/UI/FileManager/FormatUtils.cpp
index 553d8bcd..98bb043e 100755
--- a/CPP/7zip/UI/FileManager/FormatUtils.cpp
+++ b/CPP/7zip/UI/FileManager/FormatUtils.cpp
@@ -24,17 +24,17 @@ UString MyFormatNew(const UString &format, const UString &argument)
return result;
}
-UString MyFormatNew(UINT resourceID,
+UString MyFormatNew(UINT resourceID,
#ifdef LANG
- UInt32 langID,
+ UInt32 langID,
#endif
const UString &argument)
{
return MyFormatNew(
#ifdef LANG
- LangString(resourceID, langID),
+ LangString(resourceID, langID),
#else
- NWindows::MyLoadStringW(resourceID),
+ NWindows::MyLoadStringW(resourceID),
#endif
argument);
}
diff --git a/CPP/7zip/UI/FileManager/FormatUtils.h b/CPP/7zip/UI/FileManager/FormatUtils.h
index 35536871..70a44434 100755
--- a/CPP/7zip/UI/FileManager/FormatUtils.h
+++ b/CPP/7zip/UI/FileManager/FormatUtils.h
@@ -9,9 +9,9 @@
UString NumberToString(UInt64 number);
UString MyFormatNew(const UString &format, const UString &argument);
-UString MyFormatNew(UINT resourceID,
+UString MyFormatNew(UINT resourceID,
#ifdef LANG
- UInt32 langID,
+ UInt32 langID,
#endif
const UString &argument);
diff --git a/CPP/7zip/UI/FileManager/IFolder.h b/CPP/7zip/UI/FileManager/IFolder.h
index fdd9fa3c..6709cd1e 100755
--- a/CPP/7zip/UI/FileManager/IFolder.h
+++ b/CPP/7zip/UI/FileManager/IFolder.h
@@ -10,7 +10,7 @@
namespace NPlugin
{
- enum
+ enum
{
kName = 0,
kType,
@@ -45,12 +45,12 @@ FOLDER_INTERFACE_SUB(IFolderOperationsExtractCallback, IProgress, 0x0B)
// STDMETHOD(SetTotalFiles)(UInt64 total) PURE;
// STDMETHOD(SetCompletedFiles)(const UInt64 *completedValue) PURE;
STDMETHOD(AskWrite)(
- const wchar_t *srcPath,
- Int32 srcIsFolder,
- const FILETIME *srcTime,
+ const wchar_t *srcPath,
+ Int32 srcIsFolder,
+ const FILETIME *srcTime,
const UInt64 *srcSize,
- const wchar_t *destPathRequest,
- BSTR *destPathResult,
+ const wchar_t *destPathRequest,
+ BSTR *destPathResult,
Int32 *writeAnswer) PURE;
STDMETHOD(ShowMessage)(const wchar_t *message) PURE;
STDMETHOD(SetCurrentFilePath)(const wchar_t *filePath) PURE;
diff --git a/CPP/7zip/UI/FileManager/LangPage.cpp b/CPP/7zip/UI/FileManager/LangPage.cpp
index 3300213b..264872f6 100755
--- a/CPP/7zip/UI/FileManager/LangPage.cpp
+++ b/CPP/7zip/UI/FileManager/LangPage.cpp
@@ -12,7 +12,7 @@
#include "HelpUtils.h"
#include "LangUtils.h"
-static CIDLangPair kIDLangPairs[] =
+static CIDLangPair kIDLangPairs[] =
{
{ IDC_LANG_STATIC_LANG, 0x01000401}
};
@@ -40,7 +40,7 @@ bool CLangPage::OnInit()
for (int i = 0; i < langs.Size(); i++)
{
const CLangEx &lang = langs[i];
- UString name;
+ UString name;
UString englishName, nationalName;
if (lang.Lang.GetMessage(0x00000000, englishName))
name = englishName;
diff --git a/CPP/7zip/UI/FileManager/LangPage.h b/CPP/7zip/UI/FileManager/LangPage.h
index b28d6984..64825b8e 100755
--- a/CPP/7zip/UI/FileManager/LangPage.h
+++ b/CPP/7zip/UI/FileManager/LangPage.h
@@ -9,7 +9,7 @@
class CLangPage: public NWindows::NControl::CPropertyPage
{
NWindows::NControl::CComboBox _langCombo;
- UStringVector _paths;
+ UStringVector _paths;
public:
bool _langWasChanged;
virtual bool OnInit();
diff --git a/CPP/7zip/UI/FileManager/LangUtils.cpp b/CPP/7zip/UI/FileManager/LangUtils.cpp
index bf75df00..0591c73c 100755
--- a/CPP/7zip/UI/FileManager/LangUtils.cpp
+++ b/CPP/7zip/UI/FileManager/LangUtils.cpp
@@ -27,13 +27,13 @@ void ReloadLang()
if (!g_LangID.IsEmpty() && g_LangID != L"-")
{
UString langPath = g_LangID;
- if (langPath.Find('\\') < 0)
+ if (langPath.Find(WCHAR_PATH_SEPARATOR) < 0)
{
- if (langPath.Find('.') < 0)
+ if (langPath.Find(L'.') < 0)
langPath += L".txt";
UString folderPath;
if (GetProgramFolderPath(folderPath))
- langPath = folderPath + UString(L"Lang\\") + langPath;
+ langPath = folderPath + UString(L"Lang" WSTRING_PATH_SEPARATOR) + langPath;
}
g_Lang.Open(langPath);
}
@@ -94,12 +94,12 @@ void LoadLangs(CObjectVector<CLangEx> &langs)
UString folderPath;
if (!::GetProgramFolderPath(folderPath))
return;
- folderPath += L"Lang\\";
+ folderPath += L"Lang" WSTRING_PATH_SEPARATOR;
NWindows::NFile::NFind::CEnumeratorW enumerator(folderPath + L"*.txt");
NWindows::NFile::NFind::CFileInfoW fileInfo;
while (enumerator.Next(fileInfo))
{
- if (fileInfo.IsDirectory())
+ if (fileInfo.IsDir())
continue;
CLangEx lang;
UString filePath = folderPath + fileInfo.Name;
diff --git a/CPP/7zip/UI/FileManager/ListViewDialog.cpp b/CPP/7zip/UI/FileManager/ListViewDialog.cpp
index 67423501..7a78fcde 100755
--- a/CPP/7zip/UI/FileManager/ListViewDialog.cpp
+++ b/CPP/7zip/UI/FileManager/ListViewDialog.cpp
@@ -3,18 +3,18 @@
#include "StdAfx.h"
#include "ListViewDialog.h"
-#ifdef LANG
+#ifdef LANG
#include "LangUtils.h"
-static CIDLangPair kIDLangPairs[] =
+static CIDLangPair kIDLangPairs[] =
{
{ IDOK, 0x02000702 },
{ IDCANCEL, 0x02000710 }
};
#endif
-bool CListViewDialog::OnInit()
+bool CListViewDialog::OnInit()
{
- #ifdef LANG
+ #ifdef LANG
LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
#endif
_listView.Attach(GetItem(IDC_LISTVIEW_LIST));
@@ -28,15 +28,9 @@ bool CListViewDialog::OnInit()
_listView.InsertColumn(0, &columnInfo);
- for(int i = 0; i < Strings.Size(); i++)
- {
- LVITEMW item;
- item.mask = LVIF_TEXT;
- item.iItem = i;
- item.pszText = (LPWSTR)(LPCWSTR)Strings[i];
- item.iSubItem = 0;
- _listView.InsertItem(&item);
- }
+ for (int i = 0; i < Strings.Size(); i++)
+ _listView.InsertItem(i, Strings[i]);
+
if (Strings.Size() > 0)
_listView.SetItemState(0, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED);
StringsWereChanged = false;
diff --git a/CPP/7zip/UI/FileManager/ListViewDialog.rc b/CPP/7zip/UI/FileManager/ListViewDialog.rc
index e83f3330..cb456534 100755
--- a/CPP/7zip/UI/FileManager/ListViewDialog.rc
+++ b/CPP/7zip/UI/FileManager/ListViewDialog.rc
@@ -16,7 +16,7 @@ IDD_DIALOG_LISTVIEW DIALOG 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE
CAPTION "ListView"
MY_FONT
BEGIN
- CONTROL "List1", IDC_LISTVIEW_LIST, "SysListView32", LVS_REPORT | LVS_SHOWSELALWAYS |
+ CONTROL "List1", IDC_LISTVIEW_LIST, "SysListView32", LVS_REPORT | LVS_SHOWSELALWAYS |
LVS_AUTOARRANGE | LVS_NOCOLUMNHEADER | WS_BORDER | WS_TABSTOP,
marg, marg, xSize2, ySize2 - bYSize - 10
DEFPUSHBUTTON "OK", IDOK, b2XPos, bYPos, bXSize, bYSize
diff --git a/CPP/7zip/UI/FileManager/MessagesDialog.cpp b/CPP/7zip/UI/FileManager/MessagesDialog.cpp
index 57879d64..201c0bae 100755
--- a/CPP/7zip/UI/FileManager/MessagesDialog.cpp
+++ b/CPP/7zip/UI/FileManager/MessagesDialog.cpp
@@ -6,14 +6,14 @@
#include "Common/IntToString.h"
#include "Windows/ResourceString.h"
-#ifdef LANG
+#ifdef LANG
#include "LangUtils.h"
#endif
using namespace NWindows;
-#ifdef LANG
-static CIDLangPair kIDLangPairs[] =
+#ifdef LANG
+static CIDLangPair kIDLangPairs[] =
{
{ IDOK, 0x02000713 }
};
@@ -22,20 +22,10 @@ static CIDLangPair kIDLangPairs[] =
void CMessagesDialog::AddMessageDirect(LPCWSTR message)
{
int itemIndex = _messageList.GetItemCount();
- LVITEMW item;
- item.mask = LVIF_TEXT;
- item.iItem = itemIndex;
-
wchar_t sz[32];
ConvertInt64ToString(itemIndex, sz);
-
- item.pszText = sz;
- item.iSubItem = 0;
- _messageList.InsertItem(&item);
-
- item.pszText = (LPWSTR)message;
- item.iSubItem = 1;
- _messageList.SetItem(&item);
+ _messageList.InsertItem(itemIndex, sz);
+ _messageList.SetSubItem(itemIndex, 1, message);
}
void CMessagesDialog::AddMessage(LPCWSTR message)
@@ -52,39 +42,25 @@ void CMessagesDialog::AddMessage(LPCWSTR message)
AddMessageDirect(s);
}
-bool CMessagesDialog::OnInit()
+bool CMessagesDialog::OnInit()
{
- #ifdef LANG
+ #ifdef LANG
LangSetWindowText(HWND(*this), 0x02000A00);
LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
#endif
_messageList.Attach(GetItem(IDC_MESSAGE_LIST));
_messageList.SetUnicodeFormat(true);
- LVCOLUMNW columnInfo;
- columnInfo.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;
- columnInfo.fmt = LVCFMT_LEFT;
- columnInfo.pszText = L"#";
- columnInfo.iSubItem = 0;
- columnInfo.cx = 30;
-
- _messageList.InsertColumn(0, &columnInfo);
-
-
- columnInfo.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;
- columnInfo.fmt = LVCFMT_LEFT;
- UString s =
- #ifdef LANG
- LangString(IDS_MESSAGES_DIALOG_MESSAGE_COLUMN, 0x02000A80);
- #else
- MyLoadStringW(IDS_MESSAGES_DIALOG_MESSAGE_COLUMN);
- #endif
+ _messageList.InsertColumn(0, L"#", 30);
- columnInfo.pszText = (LPWSTR)(LPCWSTR)s;
- columnInfo.iSubItem = 1;
- columnInfo.cx = 600;
+ const UString s =
+ #ifdef LANG
+ LangString(IDS_MESSAGES_DIALOG_MESSAGE_COLUMN, 0x02000A80);
+ #else
+ MyLoadStringW(IDS_MESSAGES_DIALOG_MESSAGE_COLUMN);
+ #endif
- _messageList.InsertColumn(1, &columnInfo);
+ _messageList.InsertColumn(1, s, 600);
for(int i = 0; i < Messages->Size(); i++)
AddMessage((*Messages)[i]);
diff --git a/CPP/7zip/UI/FileManager/MessagesDialog.rc b/CPP/7zip/UI/FileManager/MessagesDialog.rc
index fdefb172..bf1c56b0 100755
--- a/CPP/7zip/UI/FileManager/MessagesDialog.rc
+++ b/CPP/7zip/UI/FileManager/MessagesDialog.rc
@@ -15,7 +15,7 @@ MY_FONT
BEGIN
DEFPUSHBUTTON "&Close", IDOK, bXPos, bYPos, bXSize, bYSize
CONTROL "List1",IDC_MESSAGE_LIST,"SysListView32",
- LVS_REPORT | LVS_SHOWSELALWAYS | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,
+ LVS_REPORT | LVS_SHOWSELALWAYS | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,
marg, marg, xSize2, ySize2 - bYSize - 6
END
diff --git a/CPP/7zip/UI/FileManager/MyLoadMenu.cpp b/CPP/7zip/UI/FileManager/MyLoadMenu.cpp
index 4ad152b1..c6f57f9e 100755
--- a/CPP/7zip/UI/FileManager/MyLoadMenu.cpp
+++ b/CPP/7zip/UI/FileManager/MyLoadMenu.cpp
@@ -41,7 +41,7 @@ struct CStringLangPair
UINT32 LangID;
};
-static CStringLangPair kStringLangPairs[] =
+static CStringLangPair kStringLangPairs[] =
{
{ L"&File", 0x03000102 },
{ L"&Edit", 0x03000103 },
@@ -57,7 +57,7 @@ UINT32 kToolbarsLangID = 0x03000451;
/*
static int FindStringLangItem(const UString &anItem)
{
- for (int i = 0; i < sizeof(kStringLangPairs) /
+ for (int i = 0; i < sizeof(kStringLangPairs) /
sizeof(kStringLangPairs[0]); i++)
if (anItem.CompareNoCase(kStringLangPairs[i].String) == 0)
return i;
@@ -65,7 +65,7 @@ static int FindStringLangItem(const UString &anItem)
}
*/
-static CIDLangPair kIDLangPairs[] =
+static CIDLangPair kIDLangPairs[] =
{
// File
{ IDM_FILE_OPEN, 0x03000210 },
@@ -151,9 +151,9 @@ public:
g_IsNew_fMask = false;
OSVERSIONINFO vi;
vi.dwOSVersionInfoSize = sizeof(vi);
- if (::GetVersionEx(&vi))
+ if (::GetVersionEx(&vi))
{
- g_IsNew_fMask = (vi.dwMajorVersion > 4 ||
+ g_IsNew_fMask = (vi.dwMajorVersion > 4 ||
(vi.dwMajorVersion == 4 && vi.dwMinorVersion > 0));
}
g_IsNew_fMask = false;
@@ -217,7 +217,7 @@ static void MyChangeMenu(HMENU menuLoc, int level, int menuIndex)
}
else
{
- if (level == 0 && i < sizeof(kStringLangPairs) /
+ if (level == 0 && i < sizeof(kStringLangPairs) /
sizeof(kStringLangPairs[0]))
newString = LangString(kStringLangPairs[i].LangID);
else
@@ -339,7 +339,7 @@ void OnMenuActivating(HWND /* hWnd */, HMENU hMenu, int position)
// View;
CMenu menu;
menu.Attach(hMenu);
- menu.CheckRadioItem(IDM_VIEW_LARGE_ICONS, IDM_VIEW_DETAILS,
+ menu.CheckRadioItem(IDM_VIEW_LARGE_ICONS, IDM_VIEW_DETAILS,
IDM_VIEW_LARGE_ICONS + g_App.GetListViewMode(), MF_BYCOMMAND);
menu.CheckItem(IDM_VIEW_TWO_PANELS, MF_BYCOMMAND |
((g_App.NumPanels == 2) ? MF_CHECKED : MF_UNCHECKED));
@@ -413,7 +413,8 @@ void OnMenuUnActivating(HWND hWnd)
*/
-void LoadFileMenu(HMENU hMenu, int startPos, bool /* forFileMode */, bool programMenu)
+void LoadFileMenu(HMENU hMenu, int startPos, bool programMenu,
+ bool isFsFolder, int numItems, bool allAreFiles)
{
{
CMenu srcMenu;
@@ -439,6 +440,10 @@ void LoadFileMenu(HMENU hMenu, int startPos, bool /* forFileMode */, bool progra
if (!programMenu)
if (item.wID == IDCLOSE)
continue;
+ bool isOneFsFile = (isFsFolder && numItems == 1 && allAreFiles);
+ if ((item.wID == IDM_FILE_SPLIT || item.wID == IDM_FILE_COMBINE) && !isOneFsFile)
+ item.fState |= MFS_DISABLED;
+
/*
bool createItem = (item.wID == IDM_CREATE_FOLDER || item.wID == IDM_CREATE_FILE);
if (forFileMode)
@@ -538,7 +543,7 @@ bool ExecuteFileCommand(int id)
break;
default:
return false;
- }
+ }
return true;
}
@@ -607,7 +612,7 @@ bool OnMenuCommand(HWND hWnd, int id)
/*
CMenu menu;
menu.Attach(::GetSubMenu(::GetMenu(hWnd), kViewMenuIndex));
- menu.CheckRadioItem(IDM_VIEW_LARGE_ICONS, IDM_VIEW_DETAILS,
+ menu.CheckRadioItem(IDM_VIEW_LARGE_ICONS, IDM_VIEW_DETAILS,
id, MF_BYCOMMAND);
*/
}
@@ -625,7 +630,7 @@ bool OnMenuCommand(HWND hWnd, int id)
}
case IDM_VIEW_ARANGE_BY_DATE:
{
- g_App.SortItemsWithPropID(kpidLastWriteTime);
+ g_App.SortItemsWithPropID(kpidMTime);
break;
}
case IDM_VIEW_ARANGE_BY_SIZE:
diff --git a/CPP/7zip/UI/FileManager/MyLoadMenu.h b/CPP/7zip/UI/FileManager/MyLoadMenu.h
index 490dc6d8..83c1d24f 100755
--- a/CPP/7zip/UI/FileManager/MyLoadMenu.h
+++ b/CPP/7zip/UI/FileManager/MyLoadMenu.h
@@ -10,7 +10,8 @@ void OnMenuActivating(HWND hWnd, HMENU hMenu, int position);
void MyLoadMenu(HWND hWnd);
bool OnMenuCommand(HWND hWnd, int id);
void MyLoadMenu();
-void LoadFileMenu(HMENU hMenu, int startPos, bool forFileMode, bool programMenu);
+void LoadFileMenu(HMENU hMenu, int startPos, bool programMenu,
+ bool isFsFolder, int numItems, bool allAreFiles);
bool ExecuteFileCommand(int id);
#endif
diff --git a/CPP/7zip/UI/FileManager/NetFolder.cpp b/CPP/7zip/UI/FileManager/NetFolder.cpp
index 7bd5d2e5..e03a06c5 100755
--- a/CPP/7zip/UI/FileManager/NetFolder.cpp
+++ b/CPP/7zip/UI/FileManager/NetFolder.cpp
@@ -16,7 +16,7 @@
using namespace NWindows;
using namespace NNet;
-static const STATPROPSTG kProperties[] =
+static const STATPROPSTG kProperties[] =
{
{ NULL, kpidName, VT_BSTR},
{ NULL, kpidLocalName, VT_BSTR},
@@ -63,7 +63,7 @@ void CNetFolder::Init(const UString &path)
return;
}
-void CNetFolder::Init(const NWindows::NNet::CResourceW *netResource,
+void CNetFolder::Init(const NWindows::NNet::CResourceW *netResource,
IFolderFolder *parentFolder, const UString &path)
{
_path = path;
@@ -105,7 +105,7 @@ STDMETHODIMP CNetFolder::LoadItems()
}
for (;;)
- {
+ {
CResourceEx resource;
DWORD result = enumerator.Next(resource);
if (result == NO_ERROR)
@@ -123,7 +123,7 @@ STDMETHODIMP CNetFolder::LoadItems()
}
else if (result == ERROR_NO_MORE_ITEMS)
break;
- else
+ else
return result;
}
@@ -162,31 +162,20 @@ STDMETHODIMP CNetFolder::GetNumberOfItems(UInt32 *numItems)
STDMETHODIMP CNetFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT *value)
{
- NCOM::CPropVariant propVariant;
+ NCOM::CPropVariant prop;
const CResourceEx &item = _items[itemIndex];
switch(propID)
{
- case kpidIsFolder:
- propVariant = true;
- break;
+ case kpidIsDir: prop = true; break;
case kpidName:
// if (item.RemoteNameIsDefined)
- propVariant = item.Name;
- break;
- case kpidLocalName:
- if (item.LocalNameIsDefined)
- propVariant = item.LocalName;
- break;
- case kpidComment:
- if (item.CommentIsDefined)
- propVariant = item.Comment;
- break;
- case kpidProvider:
- if (item.ProviderIsDefined)
- propVariant = item.Provider;
+ prop = item.Name;
break;
+ case kpidLocalName: if (item.LocalNameIsDefined) prop = item.LocalName; break;
+ case kpidComment: if (item.CommentIsDefined) prop = item.Comment; break;
+ case kpidProvider: if (item.ProviderIsDefined) prop = item.Provider; break;
}
- propVariant.Detach(value);
+ prop.Detach(value);
return S_OK;
}
@@ -194,7 +183,7 @@ STDMETHODIMP CNetFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolder
{
*resultFolder = 0;
const CResourceEx &resource = _items[index];
- if (resource.Usage == RESOURCEUSAGE_CONNECTABLE ||
+ if (resource.Usage == RESOURCEUSAGE_CONNECTABLE ||
resource.DisplayType == RESOURCEDISPLAYTYPE_SHARE)
{
NFsFolder::CFSFolder *fsFolderSpec = new NFsFolder::CFSFolder;
@@ -249,7 +238,7 @@ STDMETHODIMP CNetFolder::GetNumberOfProperties(UInt32 *numProperties)
return S_OK;
}
-STDMETHODIMP CNetFolder::GetPropertyInfo(UInt32 index,
+STDMETHODIMP CNetFolder::GetPropertyInfo(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType)
{
if (index >= sizeof(kProperties) / sizeof(kProperties[0]))
@@ -280,7 +269,7 @@ STDMETHODIMP CNetFolder::GetSystemIconIndex(UInt32 index, INT32 *iconIndex)
*iconIndex = 0;
const CResourceW &resource = _items[index];
int iconIndexTemp;
- if (resource.DisplayType == RESOURCEDISPLAYTYPE_SERVER ||
+ if (resource.DisplayType == RESOURCEDISPLAYTYPE_SERVER ||
resource.Usage == RESOURCEUSAGE_CONNECTABLE)
{
if (GetRealIconIndex(resource.RemoteName, 0, iconIndexTemp))
diff --git a/CPP/7zip/UI/FileManager/NetFolder.h b/CPP/7zip/UI/FileManager/NetFolder.h
index 0214cfdb..92471ec6 100755
--- a/CPP/7zip/UI/FileManager/NetFolder.h
+++ b/CPP/7zip/UI/FileManager/NetFolder.h
@@ -16,7 +16,7 @@ struct CResourceEx: public NWindows::NNet::CResourceW
UString Name;
};
-class CNetFolder:
+class CNetFolder:
public IFolderFolder,
public IFolderGetSystemIconIndex,
public CMyUnknownImp
@@ -41,7 +41,7 @@ private:
public:
void Init(const UString &path);
- void Init(const NWindows::NNet::CResourceW *netResource,
+ void Init(const NWindows::NNet::CResourceW *netResource,
IFolderFolder *parentFolder, const UString &path);
CNetFolder(): _netResourcePointer(0) {}
};
diff --git a/CPP/7zip/UI/FileManager/OpenCallback.cpp b/CPP/7zip/UI/FileManager/OpenCallback.cpp
index 70ec3f39..be40fc1c 100755
--- a/CPP/7zip/UI/FileManager/OpenCallback.cpp
+++ b/CPP/7zip/UI/FileManager/OpenCallback.cpp
@@ -11,69 +11,80 @@
#include "PasswordDialog.h"
-STDMETHODIMP COpenArchiveCallback::SetTotal(const UINT64 * /* numFiles */, const UINT64 * /* numBytes */)
+STDMETHODIMP COpenArchiveCallback::SetTotal(const UInt64 *numFiles, const UInt64 *numBytes)
{
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
+ _numFilesTotalDefined = (numFiles != NULL);
+ _numBytesTotalDefined = (numBytes != NULL);
+ if (_numFilesTotalDefined)
+ {
+ ProgressDialog.ProgressSynch.SetNumFilesTotal(*numFiles);
+ ProgressDialog.ProgressSynch.SetProgress(*numFiles, 0);
+ }
+ else if (_numBytesTotalDefined)
+ ProgressDialog.ProgressSynch.SetProgress(*numBytes, 0);
+ }
return S_OK;
}
-STDMETHODIMP COpenArchiveCallback::SetCompleted(const UINT64 * /* numFiles */, const UINT64 * /* numBytes */)
+STDMETHODIMP COpenArchiveCallback::SetCompleted(const UInt64 *numFiles, const UInt64 *numBytes)
{
+ NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
+ RINOK(ProgressDialog.ProgressSynch.ProcessStopAndPause());
+ if (numFiles != NULL)
+ {
+ ProgressDialog.ProgressSynch.SetNumFilesCur(*numFiles);
+ if (_numFilesTotalDefined)
+ ProgressDialog.ProgressSynch.SetPos(*numFiles);
+ }
+ if (numBytes != NULL && _numBytesTotalDefined)
+ ProgressDialog.ProgressSynch.SetPos(*numBytes);
return S_OK;
}
-STDMETHODIMP COpenArchiveCallback::SetTotal(const UINT64 /* total */)
+STDMETHODIMP COpenArchiveCallback::SetTotal(const UInt64 total)
{
+ ProgressDialog.ProgressSynch.SetProgress(total, 0);
return S_OK;
}
-STDMETHODIMP COpenArchiveCallback::SetCompleted(const UINT64 * /* completed */)
+STDMETHODIMP COpenArchiveCallback::SetCompleted(const UInt64 *completed)
{
+ RINOK(ProgressDialog.ProgressSynch.ProcessStopAndPause());
+ if (completed != NULL)
+ ProgressDialog.ProgressSynch.SetPos(*completed);
return S_OK;
}
STDMETHODIMP COpenArchiveCallback::GetProperty(PROPID propID, PROPVARIANT *value)
{
- NWindows::NCOM::CPropVariant propVariant;
+ NWindows::NCOM::CPropVariant prop;
if (_subArchiveMode)
{
switch(propID)
{
- case kpidName:
- propVariant = _subArchiveName;
- break;
+ case kpidName: prop = _subArchiveName; break;
}
- propVariant.Detach(value);
- return S_OK;
}
- switch(propID)
+ else
{
- case kpidName:
- propVariant = _fileInfo.Name;
- break;
- case kpidIsFolder:
- propVariant = _fileInfo.IsDirectory();
- break;
- case kpidSize:
- propVariant = _fileInfo.Size;
- break;
- case kpidAttributes:
- propVariant = (UINT32)_fileInfo.Attributes;
- break;
- case kpidLastAccessTime:
- propVariant = _fileInfo.LastAccessTime;
- break;
- case kpidCreationTime:
- propVariant = _fileInfo.CreationTime;
- break;
- case kpidLastWriteTime:
- propVariant = _fileInfo.LastWriteTime;
- break;
+ switch(propID)
+ {
+ case kpidName: prop = _fileInfo.Name; break;
+ case kpidIsDir: prop = _fileInfo.IsDir(); break;
+ case kpidSize: prop = _fileInfo.Size; break;
+ case kpidAttrib: prop = (UInt32)_fileInfo.Attrib; break;
+ case kpidCTime: prop = _fileInfo.CTime; break;
+ case kpidATime: prop = _fileInfo.ATime; break;
+ case kpidMTime: prop = _fileInfo.MTime; break;
+ }
}
- propVariant.Detach(value);
+ prop.Detach(value);
return S_OK;
}
-STDMETHODIMP COpenArchiveCallback::GetStream(const wchar_t *name,
+STDMETHODIMP COpenArchiveCallback::GetStream(const wchar_t *name,
IInStream **inStream)
{
*inStream = NULL;
@@ -86,7 +97,7 @@ STDMETHODIMP COpenArchiveCallback::GetStream(const wchar_t *name,
if (!NWindows::NFile::NFind::FindFile(fullPath, fileInfo))
return S_FALSE;
_fileInfo = fileInfo;
- if (_fileInfo.IsDirectory())
+ if (_fileInfo.IsDir())
return S_FALSE;
CInFileStream *inFile = new CInFileStream;
CMyComPtr<IInStream> inStreamTemp = inFile;
@@ -103,7 +114,7 @@ STDMETHODIMP COpenArchiveCallback::CryptoGetTextPassword(BSTR *password)
{
CPasswordDialog dialog;
- if (dialog.Create(ParentWindow) == IDCANCEL)
+ if (dialog.Create(ProgressDialog) == IDCANCEL)
return E_ABORT;
Password = dialog.Password;
diff --git a/CPP/7zip/UI/FileManager/OpenCallback.h b/CPP/7zip/UI/FileManager/OpenCallback.h
index 15b50168..168f171b 100755
--- a/CPP/7zip/UI/FileManager/OpenCallback.h
+++ b/CPP/7zip/UI/FileManager/OpenCallback.h
@@ -11,7 +11,15 @@
#include "../../Archive/IArchive.h"
-class COpenArchiveCallback:
+
+#ifdef _SFX
+#include "ProgressDialog.h"
+#else
+#include "ProgressDialog2.h"
+#endif
+
+
+class COpenArchiveCallback:
public IArchiveOpenCallback,
public IArchiveOpenVolumeCallback,
public IArchiveOpenSetSubArchiveName,
@@ -21,6 +29,11 @@ class COpenArchiveCallback:
{
UString _folderPrefix;
NWindows::NFile::NFind::CFileInfoW _fileInfo;
+
+ bool _numFilesTotalDefined;
+ bool _numBytesTotalDefined;
+ NWindows::NSynchronization::CCriticalSection _criticalSection;
+
public:
bool PasswordIsDefined;
UString Password;
@@ -31,6 +44,8 @@ public:
UString _subArchiveName;
public:
+ CProgressDialog ProgressDialog;
+
MY_UNKNOWN_IMP5(
IArchiveOpenCallback,
IArchiveOpenVolumeCallback,
@@ -38,17 +53,9 @@ public:
IProgress,
ICryptoGetTextPassword)
- // IProgress
- STDMETHOD(SetTotal)(UINT64 total);
- STDMETHOD(SetCompleted)(const UINT64 *completeValue);
-
- // IArchiveOpenCallback
- STDMETHOD(SetTotal)(const UINT64 *numFiles, const UINT64 *numBytes);
- STDMETHOD(SetCompleted)(const UINT64 *numFiles, const UINT64 *numBytes);
-
- // IArchiveOpenVolumeCallback
- STDMETHOD(GetProperty)(PROPID propID, PROPVARIANT *value);
- STDMETHOD(GetStream)(const wchar_t *name, IInStream **inStream);
+ INTERFACE_IProgress(;)
+ INTERFACE_IArchiveOpenCallback(;)
+ INTERFACE_IArchiveOpenVolumeCallback(;)
// ICryptoGetTextPassword
STDMETHOD(CryptoGetTextPassword)(BSTR *password);
@@ -60,8 +67,12 @@ public:
return S_OK;
}
- COpenArchiveCallback()
+ COpenArchiveCallback():
+ ParentWindow(0)
{
+ _numFilesTotalDefined = false;
+ _numBytesTotalDefined = false;
+
_subArchiveMode = false;
PasswordIsDefined = false;
PasswordWasAsked = false;
@@ -79,7 +90,13 @@ public:
if (!NWindows::NFile::NFind::FindFile(_folderPrefix + fileName, _fileInfo))
throw 1;
}
- void ShowMessage(const UINT64 *completed);
+ void ShowMessage(const UInt64 *completed);
+
+ INT_PTR StartProgressDialog(const UString &title)
+ {
+ return ProgressDialog.Create(title, ParentWindow);
+ }
+
};
#endif
diff --git a/CPP/7zip/UI/FileManager/OverwriteDialog.cpp b/CPP/7zip/UI/FileManager/OverwriteDialog.cpp
index 442df929..42c63266 100755
--- a/CPP/7zip/UI/FileManager/OverwriteDialog.cpp
+++ b/CPP/7zip/UI/FileManager/OverwriteDialog.cpp
@@ -15,14 +15,14 @@
// #include "../resource.h"
-#ifdef LANG
+#ifdef LANG
#include "LangUtils.h"
#endif
using namespace NWindows;
-#ifdef LANG
-static CIDLangPair kIDLangPairs[] =
+#ifdef LANG
+static CIDLangPair kIDLangPairs[] =
{
{ IDC_STATIC_OVERWRITE_HEADER, 0x02000901},
{ IDC_STATIC_OVERWRITE_QUESTION_BEGIN, 0x02000902 },
@@ -36,14 +36,14 @@ static CIDLangPair kIDLangPairs[] =
};
#endif
-void COverwriteDialog::SetFileInfoControl(int textID, int iconID,
- const NOverwriteDialog::CFileInfo &fileInfo)
+void COverwriteDialog::SetFileInfoControl(int textID, int iconID,
+ const NOverwriteDialog::CFileInfo &fileInfo)
{
UString sizeString;
if (fileInfo.SizeIsDefined)
- sizeString = MyFormatNew(IDS_FILE_SIZE,
- #ifdef LANG
- 0x02000982,
+ sizeString = MyFormatNew(IDS_FILE_SIZE,
+ #ifdef LANG
+ 0x02000982,
#endif
NumberToString(fileInfo.Size));
@@ -64,13 +64,13 @@ void COverwriteDialog::SetFileInfoControl(int textID, int iconID,
if (fileInfo.TimeIsDefined)
{
UString timeString;
- FILETIME localFileTime;
+ FILETIME localFileTime;
if (!FileTimeToLocalFileTime(&fileInfo.Time, &localFileTime))
throw 4190402;
timeString = ConvertFileTimeToString(localFileTime);
- fullString +=
- #ifdef LANG
+ fullString +=
+ #ifdef LANG
LangString(IDS_FILE_MODIFIED, 0x02000983);
#else
MyLoadStringW(IDS_FILE_MODIFIED);
@@ -86,8 +86,8 @@ void COverwriteDialog::SetFileInfoControl(int textID, int iconID,
SHFILEINFO shellFileInfo;
if (::SHGetFileInfo(
- GetSystemString(fileInfo.Name), FILE_ATTRIBUTE_NORMAL, &shellFileInfo,
- sizeof(shellFileInfo), SHGFI_ICON | SHGFI_USEFILEATTRIBUTES | SHGFI_LARGEICON))
+ GetSystemString(fileInfo.Name), FILE_ATTRIBUTE_NORMAL, &shellFileInfo,
+ sizeof(shellFileInfo), SHGFI_ICON | SHGFI_USEFILEATTRIBUTES | SHGFI_LARGEICON))
{
NControl::CStatic staticContol;
staticContol.Attach(GetItem(iconID));
@@ -95,21 +95,21 @@ void COverwriteDialog::SetFileInfoControl(int textID, int iconID,
}
}
-bool COverwriteDialog::OnInit()
+bool COverwriteDialog::OnInit()
{
- #ifdef LANG
+ #ifdef LANG
LangSetWindowText(HWND(*this), 0x02000900);
LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
#endif
- SetFileInfoControl(IDC_STATIC_OVERWRITE_OLD_FILE_SIZE_TIME,
+ SetFileInfoControl(IDC_STATIC_OVERWRITE_OLD_FILE_SIZE_TIME,
IDC_STATIC_OVERWRITE_OLD_FILE_ICON, OldFileInfo);
- SetFileInfoControl(IDC_STATIC_OVERWRITE_NEW_FILE_SIZE_TIME,
+ SetFileInfoControl(IDC_STATIC_OVERWRITE_NEW_FILE_SIZE_TIME,
IDC_STATIC_OVERWRITE_NEW_FILE_ICON, NewFileInfo);
return CModalDialog::OnInit();
}
-bool COverwriteDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
-{
+bool COverwriteDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
+{
switch(buttonID)
{
case IDYES:
diff --git a/CPP/7zip/UI/FileManager/OverwriteDialog.h b/CPP/7zip/UI/FileManager/OverwriteDialog.h
index fd7444eb..d206fb01 100755
--- a/CPP/7zip/UI/FileManager/OverwriteDialog.h
+++ b/CPP/7zip/UI/FileManager/OverwriteDialog.h
@@ -20,7 +20,7 @@ namespace NOverwriteDialog
class COverwriteDialog: public NWindows::NControl::CModalDialog
{
- void SetFileInfoControl(int textID, int iconID,
+ void SetFileInfoControl(int textID, int iconID,
const NOverwriteDialog::CFileInfo &fileInfo);
virtual bool OnInit();
bool OnButtonClicked(int buttonID, HWND buttonHWND);
diff --git a/CPP/7zip/UI/FileManager/Panel.cpp b/CPP/7zip/UI/FileManager/Panel.cpp
index 9807b958..e0ed7b50 100755
--- a/CPP/7zip/UI/FileManager/Panel.cpp
+++ b/CPP/7zip/UI/FileManager/Panel.cpp
@@ -21,6 +21,7 @@
#include "ExtractCallback.h"
#include "resource.h"
+#include "..\GUI\ExtractRes.h"
#include "../Agent/IFolderArchive.h"
@@ -28,6 +29,7 @@
#include "../Common/ArchiveName.h"
using namespace NWindows;
+using namespace NControl;
#ifndef _UNICODE
extern bool g_IsNT;
@@ -36,9 +38,6 @@ extern bool g_IsNT;
static const UINT_PTR kTimerID = 1;
static const UINT kTimerElapse = 1000;
-static LPCWSTR kSelectOneFile = L"Select one file";
-static LPCWSTR kSelectFiles = L"Select files";
-
static DWORD kStyles[4] = { LVS_ICON, LVS_SMALLICON, LVS_LIST, LVS_REPORT };
// static const int kCreateFolderID = 101;
@@ -49,7 +48,7 @@ extern DWORD g_ComCtl32Version;
void CPanel::Release()
{
- // It's for unloading COM dll's: don't change it.
+ // It's for unloading COM dll's: don't change it.
CloseOpenFolders();
_sevenZipContextMenu.Release();
_systemContextMenu.Release();
@@ -60,11 +59,17 @@ CPanel::~CPanel()
CloseOpenFolders();
}
+HWND CPanel::GetParent()
+{
+ HWND h = CWindow2::GetParent();
+ return (h == 0) ? _mainWindow : h;
+}
+
static LPCWSTR kClassName = L"7-Zip::Panel";
-LRESULT CPanel::Create(HWND mainWindow, HWND parentWindow, UINT id,
- const UString &currentFolderPrefix, CPanelCallback *panelCallback, CAppState *appState,
+HRESULT CPanel::Create(HWND mainWindow, HWND parentWindow, UINT id,
+ const UString &currentFolderPrefix, CPanelCallback *panelCallback, CAppState *appState,
bool &archiveIsOpened, bool &encrypted)
{
_mainWindow = mainWindow;
@@ -84,10 +89,10 @@ LRESULT CPanel::Create(HWND mainWindow, HWND parentWindow, UINT id,
if (currentFolderPrefix[0] == L'.')
if (!NFile::NDirectory::MyGetFullPathName(currentFolderPrefix, cfp))
cfp = currentFolderPrefix;
- BindToPath(cfp, archiveIsOpened, encrypted);
+ RINOK(BindToPath(cfp, archiveIsOpened, encrypted));
- if (!CreateEx(0, kClassName, 0, WS_CHILD | WS_VISIBLE,
- 0, 0, _xSize, 260,
+ if (!CreateEx(0, kClassName, 0, WS_CHILD | WS_VISIBLE,
+ 0, 0, _xSize, 260,
parentWindow, (HMENU)(UINT_PTR)id, g_hInstance))
return E_FAIL;
return S_OK;
@@ -127,14 +132,14 @@ LRESULT CPanel::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
return CWindow2::OnMessage(message, wParam, lParam);
}
-static LRESULT APIENTRY ListViewSubclassProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
-{
+static LRESULT APIENTRY ListViewSubclassProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
CWindow tempDialog(hwnd);
CMyListView *w = (CMyListView *)(tempDialog.GetUserDataLongPtr());
if (w == NULL)
return 0;
return w->OnMessage(message, wParam, lParam);
-}
+}
LRESULT CMyListView::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
{
@@ -158,7 +163,7 @@ LRESULT CMyListView::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
// For Alt+Enter Beep disabling
UINT scanCode = (UINT)(lParam >> 16) & 0xFF;
UINT virtualKey = MapVirtualKey(scanCode, 1);
- if (virtualKey == VK_RETURN || virtualKey == VK_MULTIPLY ||
+ if (virtualKey == VK_RETURN || virtualKey == VK_MULTIPLY ||
virtualKey == VK_ADD || virtualKey == VK_SUBTRACT)
return 0;
}
@@ -208,48 +213,48 @@ LRESULT CMyListView::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
_panel->_lastFocusedIsList = true;
_panel->_panelCallback->PanelWasFocused();
}
- #ifndef _UNICODE
+ #ifndef _UNICODE
if (g_IsNT)
- return CallWindowProcW(_origWindowProc, *this, message, wParam, lParam);
+ return CallWindowProcW(_origWindowProc, *this, message, wParam, lParam);
else
#endif
- return CallWindowProc(_origWindowProc, *this, message, wParam, lParam);
+ return CallWindowProc(_origWindowProc, *this, message, wParam, lParam);
}
/*
-static LRESULT APIENTRY ComboBoxSubclassProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
-{
+static LRESULT APIENTRY ComboBoxSubclassProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
CWindow tempDialog(hwnd);
CMyComboBox *w = (CMyComboBox *)(tempDialog.GetUserDataLongPtr());
if (w == NULL)
return 0;
return w->OnMessage(message, wParam, lParam);
-}
+}
LRESULT CMyComboBox::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
{
- return CallWindowProc(_origWindowProc, *this, message, wParam, lParam);
+ return CallWindowProc(_origWindowProc, *this, message, wParam, lParam);
}
*/
-static LRESULT APIENTRY ComboBoxEditSubclassProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
-{
+static LRESULT APIENTRY ComboBoxEditSubclassProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
CWindow tempDialog(hwnd);
CMyComboBoxEdit *w = (CMyComboBoxEdit *)(tempDialog.GetUserDataLongPtr());
if (w == NULL)
return 0;
return w->OnMessage(message, wParam, lParam);
-}
+}
LRESULT CMyComboBoxEdit::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
{
// See MSDN / Subclassing a Combo Box / Creating a Combo-box Toolbar
- switch (message)
- {
- case WM_SYSKEYDOWN:
- switch (wParam)
- {
- case VK_F1:
- case VK_F2:
+ switch (message)
+ {
+ case WM_SYSKEYDOWN:
+ switch (wParam)
+ {
+ case VK_F1:
+ case VK_F2:
{
// check ALT
if ((lParam & (1<<29)) == 0)
@@ -260,20 +265,20 @@ LRESULT CMyComboBoxEdit::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
if (alt && !ctrl && !shift)
{
_panel->_panelCallback->SetFocusToPath(wParam == VK_F1 ? 0 : 1);
- return 0;
+ return 0;
}
- break;
+ break;
}
}
break;
- case WM_KEYDOWN:
- switch (wParam)
- {
- case VK_TAB:
- // SendMessage(hwndMain, WM_ENTER, 0, 0);
+ case WM_KEYDOWN:
+ switch (wParam)
+ {
+ case VK_TAB:
+ // SendMessage(hwndMain, WM_ENTER, 0, 0);
_panel->SetFocusToList();
- return 0;
- case VK_F9:
+ return 0;
+ case VK_F9:
{
bool alt = (::GetKeyState(VK_MENU) & 0x8000) != 0;
bool ctrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0;
@@ -281,26 +286,35 @@ LRESULT CMyComboBoxEdit::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
if (!alt && !ctrl && !shift)
{
g_App.SwitchOnOffOnePanel();;
- return 0;
+ return 0;
}
- break;
+ break;
}
}
break;
- case WM_CHAR:
- switch (wParam)
- {
- case VK_TAB:
- case VK_ESCAPE:
- return 0;
- }
+ case WM_CHAR:
+ switch (wParam)
+ {
+ case VK_TAB:
+ case VK_ESCAPE:
+ return 0;
+ }
}
- #ifndef _UNICODE
+ #ifndef _UNICODE
if (g_IsNT)
- return CallWindowProcW(_origWindowProc, *this, message, wParam, lParam);
+ return CallWindowProcW(_origWindowProc, *this, message, wParam, lParam);
else
#endif
- return CallWindowProc(_origWindowProc, *this, message, wParam, lParam);
+ return CallWindowProc(_origWindowProc, *this, message, wParam, lParam);
+}
+
+static HIMAGELIST GetSysImageList(bool smallIcons)
+{
+ SHFILEINFO shellInfo;
+ return (HIMAGELIST)SHGetFileInfo(TEXT(""),
+ FILE_ATTRIBUTE_NORMAL |FILE_ATTRIBUTE_DIRECTORY,
+ &shellInfo, sizeof(shellInfo),
+ SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX | (smallIcons ? SHGFI_SMALLICON : SHGFI_ICON));
}
bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */)
@@ -322,8 +336,8 @@ bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */)
if (_ListViewMode >= kNumListModes)
_ListViewMode = kNumListModes - 1;
- style |= kStyles[_ListViewMode]
- | WS_TABSTOP
+ style |= kStyles[_ListViewMode]
+ | WS_TABSTOP
| LVS_EDITLABELS;
if (_mySelectMode)
style |= LVS_SINGLESEL;
@@ -336,7 +350,7 @@ bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */)
DWORD exStyle;
exStyle = WS_EX_CLIENTEDGE;
- if (!_listView.CreateEx(exStyle, style, 0, 0, 116, 260,
+ if (!_listView.CreateEx(exStyle, style, 0, 0, 116, 260,
HWND(*this), (HMENU)(UINT_PTR)(_baseID + 1), g_hInstance, NULL))
return false;
@@ -347,32 +361,15 @@ bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */)
#ifndef _UNICODE
if(g_IsNT)
- _listView._origWindowProc =
+ _listView._origWindowProc =
(WNDPROC)_listView.SetLongPtrW(GWLP_WNDPROC, LONG_PTR(ListViewSubclassProc));
else
#endif
- _listView._origWindowProc =
+ _listView._origWindowProc =
(WNDPROC)_listView.SetLongPtr(GWLP_WNDPROC, LONG_PTR(ListViewSubclassProc));
- SHFILEINFO shellInfo;
- HIMAGELIST imageList = (HIMAGELIST)SHGetFileInfo(TEXT(""),
- FILE_ATTRIBUTE_NORMAL |
- FILE_ATTRIBUTE_DIRECTORY,
- &shellInfo, sizeof(shellInfo),
- SHGFI_USEFILEATTRIBUTES |
- SHGFI_SYSICONINDEX |
- SHGFI_SMALLICON
- );
- _listView.SetImageList(imageList, LVSIL_SMALL);
- imageList = (HIMAGELIST)SHGetFileInfo(TEXT(""),
- FILE_ATTRIBUTE_NORMAL |
- FILE_ATTRIBUTE_DIRECTORY,
- &shellInfo, sizeof(shellInfo),
- SHGFI_USEFILEATTRIBUTES |
- SHGFI_SYSICONINDEX |
- SHGFI_ICON
- );
- _listView.SetImageList(imageList, LVSIL_NORMAL);
+ _listView.SetImageList(GetSysImageList(true), LVSIL_SMALL);
+ _listView.SetImageList(GetSysImageList(false), LVSIL_NORMAL);
// _exStyle |= LVS_EX_HEADERDRAGDROP;
// DWORD extendedStyle = _listView.GetExtendedListViewStyle();
@@ -384,14 +381,14 @@ bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */)
_listView.InvalidateRect(NULL, true);
_listView.Update();
- // Ensure that the common control DLL is loaded.
+ // Ensure that the common control DLL is loaded.
INITCOMMONCONTROLSEX icex;
icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
icex.dwICC = ICC_BAR_CLASSES;
InitCommonControlsEx(&icex);
- TBBUTTON tbb [ ] =
+ TBBUTTON tbb [ ] =
{
// {0, 0, TBSTATE_ENABLED, BTNS_SEP, 0L, 0},
{VIEW_PARENTFOLDER, kParentFolderID, TBSTATE_ENABLED, BTNS_BUTTON, 0L, 0},
@@ -407,12 +404,12 @@ bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */)
_headerReBar.Attach(::CreateWindowEx(WS_EX_TOOLWINDOW,
REBARCLASSNAME,
- NULL, WS_VISIBLE | WS_BORDER | WS_CHILD |
- WS_CLIPCHILDREN | WS_CLIPSIBLINGS
- | CCS_NODIVIDER
- | CCS_NOPARENTALIGN
+ NULL, WS_VISIBLE | WS_BORDER | WS_CHILD |
+ WS_CLIPCHILDREN | WS_CLIPSIBLINGS
+ | CCS_NODIVIDER
+ | CCS_NOPARENTALIGN
| CCS_TOP
- | RBS_VARHEIGHT
+ | RBS_VARHEIGHT
| RBS_BANDBORDERS
,0,0,0,0, HWND(*this), NULL, g_hInstance, NULL));
}
@@ -421,8 +418,8 @@ bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */)
if (_headerReBar)
{
toolbarStyle |= 0
- // | WS_CLIPCHILDREN
- // | WS_CLIPSIBLINGS
+ // | WS_CLIPCHILDREN
+ // | WS_CLIPSIBLINGS
| TBSTYLE_TOOLTIPS
| CCS_NODIVIDER
@@ -431,11 +428,11 @@ bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */)
;
}
- _headerToolBar.Attach(::CreateToolbarEx ((*this), toolbarStyle,
- _baseID + 2, 11,
- (HINSTANCE)HINST_COMMCTRL,
- IDB_VIEW_SMALL_COLOR,
- (LPCTBBUTTON)&tbb, sizeof(tbb) / sizeof(tbb[0]),
+ _headerToolBar.Attach(::CreateToolbarEx ((*this), toolbarStyle,
+ _baseID + 2, 11,
+ (HINSTANCE)HINST_COMMCTRL,
+ IDB_VIEW_SMALL_COLOR,
+ (LPCTBBUTTON)&tbb, sizeof(tbb) / sizeof(tbb[0]),
0, 0, 0, 0, sizeof (TBBUTTON)));
icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
@@ -444,19 +441,20 @@ bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */)
_headerComboBox.CreateEx(0, WC_COMBOBOXEXW, NULL,
WS_BORDER | WS_VISIBLE |WS_CHILD | CBS_DROPDOWN | CBS_AUTOHSCROLL,
- 0, 0, 100, 20,
+ 0, 0, 100, 520,
((_headerReBar == 0) ? HWND(*this) : _headerToolBar),
(HMENU)(UINT_PTR)(_comboBoxID),
g_hInstance, NULL);
- // _headerComboBox.SendMessage(CBEM_SETUNICODEFORMAT, (WPARAM)(BOOL)TRUE, 0);
+ _headerComboBox.SendMessage(CBEM_SETUNICODEFORMAT, (WPARAM)(BOOL)TRUE, 0);
+ _headerComboBox.SetImageList(GetSysImageList(true));
_headerComboBox.SetExtendedStyle(CBES_EX_PATHWORDBREAKPROC, CBES_EX_PATHWORDBREAKPROC);
/*
_headerComboBox.SetUserDataLongPtr(LONG_PTR(&_headerComboBox));
_headerComboBox._panel = this;
- _headerComboBox._origWindowProc =
+ _headerComboBox._origWindowProc =
(WNDPROC)_headerComboBox.SetLongPtr(GWLP_WNDPROC,
LONG_PTR(ComboBoxSubclassProc));
*/
@@ -468,15 +466,13 @@ bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */)
_comboBoxEdit._panel = this;
#ifndef _UNICODE
if(g_IsNT)
- _comboBoxEdit._origWindowProc =
+ _comboBoxEdit._origWindowProc =
(WNDPROC)_comboBoxEdit.SetLongPtrW(GWLP_WNDPROC, LONG_PTR(ComboBoxEditSubclassProc));
else
#endif
- _comboBoxEdit._origWindowProc =
+ _comboBoxEdit._origWindowProc =
(WNDPROC)_comboBoxEdit.SetLongPtr(GWLP_WNDPROC, LONG_PTR(ComboBoxEditSubclassProc));
-
-
if (_headerReBar)
{
REBARINFO rbi;
@@ -485,9 +481,9 @@ bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */)
rbi.himl = (HIMAGELIST)NULL;
_headerReBar.SetBarInfo(&rbi);
- // Send the TB_BUTTONSTRUCTSIZE message, which is required for
- // backward compatibility.
- // _headerToolBar.SendMessage(TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0);
+ // Send the TB_BUTTONSTRUCTSIZE message, which is required for
+ // backward compatibility.
+ // _headerToolBar.SendMessage(TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0);
SIZE size;
_headerToolBar.GetMaxSize(&size);
@@ -540,7 +536,7 @@ void CPanel::OnDestroy()
CWindow2::OnDestroy();
}
-void CPanel::ChangeWindowSize(int xSize, int ySize)
+void CPanel::ChangeWindowSize(int xSize, int ySize)
{
int kHeaderSize;
int kStatusBarSize;
@@ -567,7 +563,7 @@ void CPanel::ChangeWindowSize(int xSize, int ySize)
else
{
_headerToolBar.Move(0, 0, xSize, 0);
- _headerComboBox.Move(kStartXPos, 2,
+ _headerComboBox.Move(kStartXPos, 2,
MyMax(xSize - kStartXPos - 10, kStartXPos), 0);
}
_listView.Move(0, kHeaderSize, xSize, yListViewSize);
@@ -577,7 +573,7 @@ void CPanel::ChangeWindowSize(int xSize, int ySize)
// _statusBar2.MoveWindow(0, 200, xSize, kStatusBar2Size);
}
-bool CPanel::OnSize(WPARAM /* wParam */, int xSize, int ySize)
+bool CPanel::OnSize(WPARAM /* wParam */, int xSize, int ySize)
{
if (_headerReBar)
_headerReBar.Move(0, 0, xSize, 0);
@@ -611,7 +607,7 @@ bool CPanel::OnNotify(UINT /* controlID */, LPNMHDR header, LRESULT &result)
// if (header->hwndFrom == _listView)
else if (header->hwndFrom == _listView)
return OnNotifyList(header, result);
- else if (::GetParent(header->hwndFrom) == _listView &&
+ else if (::GetParent(header->hwndFrom) == _listView &&
header->code == NM_RCLICK)
return OnRightClick((LPNMITEMACTIVATE)header, result);
return false;
@@ -635,7 +631,8 @@ bool CPanel::OnCommand(int code, int itemID, LPARAM lParam, LRESULT &result)
*/
if (itemID == _comboBoxID)
{
- OnComboBoxCommand(code, lParam);
+ if (OnComboBoxCommand(code, lParam, result))
+ return true;
}
return CWindow2::OnCommand(code, itemID, lParam, result);
}
@@ -649,7 +646,16 @@ void CPanel::MessageBox(LPCWSTR message)
void CPanel::MessageBoxMyError(LPCWSTR message)
{ MessageBox(message, L"Error"); }
void CPanel::MessageBoxError(HRESULT errorCode, LPCWSTR caption)
- { MessageBox(NError::MyFormatMessageW(errorCode), caption); }
+{
+ UString message;
+ if (errorCode == E_OUTOFMEMORY)
+ message = LangString(IDS_MEM_ERROR, 0x0200060B);
+ else
+ if (!NError::MyFormatMessage(errorCode, message))
+ message = L"Error";
+ MessageBox(message, caption);
+}
+
void CPanel::MessageBoxError(HRESULT errorCode)
{ MessageBoxError(errorCode, L"7-Zip"); }
void CPanel::MessageBoxLastError(LPCWSTR caption)
@@ -657,6 +663,10 @@ void CPanel::MessageBoxLastError(LPCWSTR caption)
void CPanel::MessageBoxLastError()
{ MessageBoxLastError(L"Error"); }
+void CPanel::MessageBoxErrorLang(UINT resourceID, UInt32 langID)
+ { MessageBox(LangString(resourceID, langID)); }
+
+
void CPanel::SetFocusToList()
{
_listView.SetFocus();
@@ -761,12 +771,12 @@ void CPanel::AddToArchive()
GetOperatedItemIndices(indices);
if (!IsFSFolder())
{
- MessageBox(L"Compress operation is not supported for that folder");
+ MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
return;
}
if (indices.Size() == 0)
{
- MessageBox(kSelectFiles);
+ MessageBoxErrorLang(IDS_SELECT_FILES, 0x03020A03);
return;
}
UStringVector names;
@@ -781,9 +791,9 @@ void CPanel::AddToArchive()
if (res != S_OK)
{
if (_currentFolderPrefix.Length() >= MAX_PATH)
- MessageBox(L"Can't call this operation for file with long path");
+ MessageBoxErrorLang(IDS_MESSAGE_UNSUPPORTED_OPERATION_FOR_LONG_PATH_FOLDER, 0x03020A01);
else
- MessageBoxError(res, L"Error");
+ MessageBoxError(res);
}
// KillSelection();
}
@@ -799,6 +809,25 @@ static UString GetSubFolderNameForExtract(const UString &archiveName)
return res;
}
+void CPanel::GetFilePaths(const CRecordVector<UInt32> &indices, UStringVector &paths)
+{
+ for (int i = 0; i < indices.Size(); i++)
+ {
+ int index = indices[i];
+ if (IsItemFolder(index))
+ {
+ paths.Clear();
+ break;
+ }
+ paths.Add(_currentFolderPrefix + GetItemRelPath(index));
+ }
+ if (paths.Size() == 0)
+ {
+ MessageBoxErrorLang(IDS_SELECT_FILES, 0x03020A03);
+ return;
+ }
+}
+
void CPanel::ExtractArchives()
{
if (_parentFolders.Size() > 0)
@@ -809,22 +838,9 @@ void CPanel::ExtractArchives()
CRecordVector<UInt32> indices;
GetOperatedItemIndices(indices);
UStringVector paths;
- if (indices.Size() == 0)
- {
- // GetAllItemIndices(indices);
- MessageBox(kSelectOneFile);
+ GetFilePaths(indices, paths);
+ if (paths.IsEmpty())
return;
- }
- for (int i = 0; i < indices.Size(); i++)
- {
- int index = indices[i];
- if (IsItemFolder(index))
- {
- MessageBox(kSelectOneFile);
- return;
- }
- paths.Add(_currentFolderPrefix + GetItemRelPath(index));
- }
UString folderName;
if (indices.Size() == 1)
folderName = GetSubFolderNameForExtract(GetItemRelPath(indices[0]));
@@ -841,28 +857,28 @@ struct CThreadTest
CMyComPtr<IArchiveFolder> ArchiveFolder;
HRESULT Result;
- DWORD Test()
+ void Test()
{
ExtractCallbackSpec->ProgressDialog.WaitCreating();
- Result = ArchiveFolder->Extract(&Indices[0], Indices.Size(),
- NExtract::NPathMode::kFullPathnames, NExtract::NOverwriteMode::kAskBefore,
+ Result = ArchiveFolder->Extract(&Indices[0], Indices.Size(),
+ NExtract::NPathMode::kFullPathnames, NExtract::NOverwriteMode::kAskBefore,
NULL, BoolToInt(true), ExtractCallback);
ExtractCallbackSpec->ProgressDialog.MyClose();
- return 0;
}
static THREAD_FUNC_DECL MyThreadFunction(void *param)
{
- return ((CThreadTest*)param)->Test();
+ ((CThreadTest*)param)->Test();
+ return 0;
}
};
-static void AddValuePair(UINT resourceID, UInt32 langID, UInt64 values, UString &s)
+static void AddValuePair(UINT resourceID, UInt32 langID, UInt64 value, UString &s)
{
wchar_t sz[32];
s += LangString(resourceID, langID);
s += L" ";
- ConvertUInt64ToString(values, sz);
+ ConvertUInt64ToString(value, sz);
s += sz;
s += L"\n";
}
@@ -886,7 +902,7 @@ static void AddSizePair(UINT resourceID, UInt32 langID, UInt64 value, UString &s
void CPanel::TestArchives()
{
CRecordVector<UInt32> indices;
- GetOperatedItemIndices(indices);
+ GetOperatedIndicesSmart(indices);
CMyComPtr<IArchiveFolder> archiveFolder;
_folder.QueryInterface(IID_IArchiveFolder, &archiveFolder);
if (archiveFolder)
@@ -901,8 +917,6 @@ void CPanel::TestArchives()
extracter.ExtractCallbackSpec->ShowMessages = true;
if (indices.IsEmpty())
- GetAllItemIndices(indices);
- if (indices.IsEmpty())
return;
extracter.Indices = indices;
@@ -946,25 +960,13 @@ void CPanel::TestArchives()
if (!IsFSFolder())
{
- MessageBox(L"Test archive operation is not supported for that folder");
+ MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
return;
}
UStringVector paths;
- if (indices.Size() == 0)
- {
- MessageBox(kSelectOneFile);
+ GetFilePaths(indices, paths);
+ if (paths.IsEmpty())
return;
- }
- for (int i = 0; i < indices.Size(); i++)
- {
- int index = indices[i];
- if (IsItemFolder(index))
- {
- MessageBox(kSelectOneFile);
- return;
- }
- paths.Add(_currentFolderPrefix + GetItemRelPath(index));
- }
::TestArchives(paths);
}
diff --git a/CPP/7zip/UI/FileManager/Panel.h b/CPP/7zip/UI/FileManager/Panel.h
index a9c6a304..86f3dc25 100755
--- a/CPP/7zip/UI/FileManager/Panel.h
+++ b/CPP/7zip/UI/FileManager/Panel.h
@@ -92,6 +92,11 @@ struct CFolderLink: public CTempFileInfo
{
NWindows::NDLL::CLibrary Library;
CMyComPtr<IFolderFolder> ParentFolder;
+ bool UsePassword;
+ UString Password;
+
+ UString VirtualPath;
+ CFolderLink(): UsePassword(false) {}
};
enum MyMessages
@@ -141,10 +146,8 @@ struct CSelectedState
CSelectedState(): FocusedItem(-1), SelectFocused(false) {}
};
-class CPanel:public NWindows::NControl::CWindow2
+class CPanel: public NWindows::NControl::CWindow2
{
- HWND _mainWindow;
-
CExtToIconMap _extToIconMap;
UINT _baseID;
int _comboBoxID;
@@ -158,7 +161,12 @@ class CPanel:public NWindows::NControl::CWindow2
virtual bool OnSize(WPARAM wParam, int xSize, int ySize);
virtual void OnDestroy();
virtual bool OnNotify(UINT controlID, LPNMHDR lParam, LRESULT &result);
- void OnComboBoxCommand(UINT code, LPARAM &aParam);
+
+ void AddComboBoxItem(const UString &name, int iconIndex, int indent, bool addToList);
+
+ bool OnComboBoxCommand(UINT code, LPARAM param, LRESULT &result);
+
+ LRESULT OnNotifyComboBoxEnter(const UString &s);
bool OnNotifyComboBoxEndEdit(PNMCBEENDEDITW info, LRESULT &result);
#ifndef _UNICODE
bool OnNotifyComboBoxEndEdit(PNMCBEENDEDIT info, LRESULT &result);
@@ -175,6 +183,7 @@ class CPanel:public NWindows::NControl::CWindow2
bool OnCustomDraw(LPNMLVCUSTOMDRAW lplvcd, LRESULT &result);
public:
+ HWND _mainWindow;
CPanelCallback *_panelCallback;
void DeleteItems(bool toRecycleBin);
@@ -217,6 +226,7 @@ public:
NWindows::NControl::CReBar _headerReBar;
NWindows::NControl::CToolBar _headerToolBar;
NWindows::NControl::CComboBoxEx _headerComboBox;
+ UStringVector ComboBoxPaths;
// CMyComboBox _headerComboBox;
CMyComboBoxEdit _comboBoxEdit;
CMyListView _listView;
@@ -235,6 +245,8 @@ public:
CSelectedState _selectedState;
+ HWND GetParent();
+
UInt32 GetRealIndex(const LVITEMW &item) const
{
/*
@@ -256,7 +268,7 @@ public:
}
UInt32 _ListViewMode;
- int _xSize;
+ int _xSize;
bool _flatMode;
@@ -287,7 +299,7 @@ public:
// PanelFolderChange.cpp
void SetToRootFolder();
- HRESULT BindToPath(const UString &fullPath, bool &archiveIsOpened, bool &encrypted); // can be prefix
+ HRESULT BindToPath(const UString &fullPath, bool &archiveIsOpened, bool &encrypted); // can be prefix
HRESULT BindToPathAndRefresh(const UString &path);
void OpenDrivesFolder();
@@ -302,9 +314,9 @@ public:
void OpenRootFolder();
- LRESULT Create(HWND mainWindow, HWND parentWindow,
+ HRESULT Create(HWND mainWindow, HWND parentWindow,
UINT id,
- const UString &currentFolderPrefix,
+ const UString &currentFolderPrefix,
CPanelCallback *panelCallback,
CAppState *appState, bool &archiveIsOpened, bool &encrypted);
void SetFocusToList();
@@ -314,13 +326,13 @@ public:
void ReadListViewInfo();
void SaveListViewInfo();
- CPanel() :
+ CPanel() :
// _virtualMode(flase),
_exStyle(0),
_showDots(false),
_showRealFileIcons(false),
- _needSaveInfo(false),
- _startGroupSelect(0),
+ _needSaveInfo(false),
+ _startGroupSelect(0),
_selectionIsDefined(false),
_ListViewMode(3),
_flatMode(false),
@@ -328,7 +340,7 @@ public:
_mySelectMode(false),
_enableItemChangeNotify(true),
_dontShowMode(false)
- {}
+ {}
void SetExtendedStyle()
{
@@ -361,19 +373,19 @@ public:
HRESULT CreateShellContextMenu(
const CRecordVector<UInt32> &operatedIndices,
CMyComPtr<IContextMenu> &systemContextMenu);
- void CreateSystemMenu(HMENU menu,
+ void CreateSystemMenu(HMENU menu,
const CRecordVector<UInt32> &operatedIndices,
CMyComPtr<IContextMenu> &systemContextMenu);
- void CreateSevenZipMenu(HMENU menu,
+ void CreateSevenZipMenu(HMENU menu,
const CRecordVector<UInt32> &operatedIndices,
CMyComPtr<IContextMenu> &sevenZipContextMenu);
- void CreateFileMenu(HMENU menu,
+ void CreateFileMenu(HMENU menu,
CMyComPtr<IContextMenu> &sevenZipContextMenu,
CMyComPtr<IContextMenu> &systemContextMenu,
bool programMenu);
void CreateFileMenu(HMENU menu);
bool InvokePluginCommand(int id);
- bool InvokePluginCommand(int id, IContextMenu *sevenZipContextMenu,
+ bool InvokePluginCommand(int id, IContextMenu *sevenZipContextMenu,
IContextMenu *systemContextMenu);
void InvokeSystemCommand(const char *command);
@@ -395,6 +407,7 @@ public:
void GetSelectedItemsIndices(CRecordVector<UInt32> &indices) const;
void GetOperatedItemIndices(CRecordVector<UInt32> &indices) const;
void GetAllItemIndices(CRecordVector<UInt32> &indices) const;
+ void GetOperatedIndicesSmart(CRecordVector<UInt32> &indices) const;
// void GetOperatedListViewIndices(CRecordVector<UInt32> &indices) const;
void KillSelection();
@@ -419,24 +432,24 @@ public:
CPanel &_panel;
public:
- CDisableTimerProcessing(CPanel &panel): _panel(panel)
- {
+ CDisableTimerProcessing(CPanel &panel): _panel(panel)
+ {
Disable();
}
void Disable()
{
_processTimerMem = _panel._processTimer;
_processNotifyMem = _panel._processNotify;
- _panel._processTimer = false;
- _panel._processNotify = false;
+ _panel._processTimer = false;
+ _panel._processNotify = false;
}
void Restore()
{
- _panel._processTimer = _processTimerMem;
- _panel._processNotify = _processNotifyMem;
+ _panel._processTimer = _processTimerMem;
+ _panel._processNotify = _processNotifyMem;
}
- ~CDisableTimerProcessing()
- {
+ ~CDisableTimerProcessing()
+ {
Restore();
}
CDisableTimerProcessing& operator=(const CDisableTimerProcessing &) {; }
@@ -456,6 +469,7 @@ public:
void MessageBoxLastError(LPCWSTR caption);
void MessageBoxLastError();
+ void MessageBoxErrorLang(UINT resourceID, UInt32 langID);
void OpenFocusedItemAsInternal();
void OpenSelectedItems(bool internal);
@@ -464,14 +478,16 @@ public:
void OpenFolder(int index);
HRESULT OpenParentArchiveFolder();
- HRESULT OpenItemAsArchive(const UString &name,
+ HRESULT OpenItemAsArchive(const UString &name,
const UString &folderPath,
- const UString &filePath, bool &encrypted);
- HRESULT OpenItemAsArchive(const UString &aName);
+ const UString &filePath,
+ const UString &virtualFilePath,
+ bool &encrypted);
+ HRESULT OpenItemAsArchive(const UString &name);
HRESULT OpenItemAsArchive(int index);
void OpenItemInArchive(int index, bool tryInternal, bool tryExternal,
bool editMode);
- HRESULT OnOpenItemChanged(const UString &folderPath, const UString &itemName);
+ HRESULT OnOpenItemChanged(const UString &folderPath, const UString &itemName, bool usePassword, const UString &password);
LRESULT OnOpenItemChanged(LPARAM lParam);
void OpenItem(int index, bool tryInternal, bool tryExternal);
@@ -491,13 +507,30 @@ public:
void OnRefreshStatusBar();
void AddToArchive();
+
+ void GetFilePaths(const CRecordVector<UInt32> &indices, UStringVector &paths);
void ExtractArchives();
void TestArchives();
- HRESULT CopyTo(const CRecordVector<UInt32> &indices, const UString &folder,
- bool moveMode, bool showErrorMessages, UStringVector *messages);
+ HRESULT CopyTo(const CRecordVector<UInt32> &indices, const UString &folder,
+ bool moveMode, bool showErrorMessages, UStringVector *messages,
+ bool &usePassword, UString &password);
+
+ HRESULT CopyTo(const CRecordVector<UInt32> &indices, const UString &folder,
+ bool moveMode, bool showErrorMessages, UStringVector *messages)
+ {
+ bool usePassword = false;
+ UString password;
+ if (_parentFolders.Size() > 0)
+ {
+ const CFolderLink &fl = _parentFolders.Back();
+ usePassword = fl.UsePassword;
+ password = fl.Password;
+ }
+ return CopyTo(indices, folder, moveMode, showErrorMessages, messages, usePassword, password);
+ }
- HRESULT CopyFrom(const UString &folderPrefix, const UStringVector &filePaths,
+ HRESULT CopyFrom(const UString &folderPrefix, const UStringVector &filePaths,
bool showErrorMessages, UStringVector *messages);
void CopyFromNoAsk(const UStringVector &filePaths);
@@ -511,6 +544,8 @@ public:
void RefreshTitle(bool always = false) { _panelCallback->RefreshTitle(always); }
void RefreshTitleAlways() { RefreshTitle(true); }
+
+ UString GetItemsInfoString(const CRecordVector<UInt32> &indices);
};
#endif
diff --git a/CPP/7zip/UI/FileManager/PanelCopy.cpp b/CPP/7zip/UI/FileManager/PanelCopy.cpp
index c5745010..8ad3d4c9 100755
--- a/CPP/7zip/UI/FileManager/PanelCopy.cpp
+++ b/CPP/7zip/UI/FileManager/PanelCopy.cpp
@@ -3,7 +3,7 @@
#include "StdAfx.h"
#include "Panel.h"
-#include "resource.h"
+#include "resource.h"
#include "LangUtils.h"
#include "ExtractCallback.h"
#include "Windows/Thread.h"
@@ -29,10 +29,10 @@ struct CThreadExtractInArchive2
{
ExtractCallbackSpec->ProgressDialog.WaitCreating();
if (MoveMode)
- Result = FolderOperations->MoveTo(&Indices.Front(), Indices.Size(),
+ Result = FolderOperations->MoveTo(&Indices.Front(), Indices.Size(),
DestPath, ExtractCallback);
else
- Result = FolderOperations->CopyTo(&Indices.Front(), Indices.Size(),
+ Result = FolderOperations->CopyTo(&Indices.Front(), Indices.Size(),
DestPath, ExtractCallback);
ExtractCallbackSpec->ProgressDialog.MyClose();
return 0;
@@ -44,8 +44,9 @@ struct CThreadExtractInArchive2
}
};
-HRESULT CPanel::CopyTo(const CRecordVector<UInt32> &indices, const UString &folder,
- bool moveMode, bool showErrorMessages, UStringVector *messages)
+HRESULT CPanel::CopyTo(const CRecordVector<UInt32> &indices, const UString &folder,
+ bool moveMode, bool showErrorMessages, UStringVector *messages,
+ bool &usePassword, UString &password)
{
CMyComPtr<IFolderOperations> folderOperations;
if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
@@ -68,7 +69,7 @@ HRESULT CPanel::CopyTo(const CRecordVector<UInt32> &indices, const UString &fold
extracter.ExtractCallbackSpec->ShowMessages = showErrorMessages;
extracter.ExtractCallbackSpec->ProgressDialog.CompressingMode = false;
- UString title = moveMode ?
+ UString title = moveMode ?
LangString(IDS_MOVING, 0x03020206):
LangString(IDS_COPYING, 0x03020205);
UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000);
@@ -83,6 +84,9 @@ HRESULT CPanel::CopyTo(const CRecordVector<UInt32> &indices, const UString &fold
extracter.DestPath = folder;
extracter.FolderOperations = folderOperations;
extracter.MoveMode = moveMode;
+
+ extracter.ExtractCallbackSpec->PasswordIsDefined = usePassword;
+ extracter.ExtractCallbackSpec->Password = password;
NWindows::CThread extractThread;
RINOK(extractThread.Create(CThreadExtractInArchive2::MyThreadFunction, &extracter));
@@ -90,7 +94,13 @@ HRESULT CPanel::CopyTo(const CRecordVector<UInt32> &indices, const UString &fold
if (messages != 0)
*messages = extracter.ExtractCallbackSpec->Messages;
- res = extracter.Result;
+ res = extracter.Result;
+
+ if (res == S_OK && extracter.ExtractCallbackSpec->Messages.IsEmpty())
+ {
+ usePassword = extracter.ExtractCallbackSpec->PasswordIsDefined;
+ password = extracter.ExtractCallbackSpec->Password;
+ }
}
RefreshTitleAlways();
return res;
@@ -126,7 +136,7 @@ struct CThreadUpdate
};
-HRESULT CPanel::CopyFrom(const UString &folderPrefix, const UStringVector &filePaths,
+HRESULT CPanel::CopyFrom(const UString &folderPrefix, const UStringVector &filePaths,
bool showErrorMessages, UStringVector *messages)
{
CMyComPtr<IFolderOperations> folderOperations;
diff --git a/CPP/7zip/UI/FileManager/PanelCrc.cpp b/CPP/7zip/UI/FileManager/PanelCrc.cpp
index 4ce435da..61490b57 100755
--- a/CPP/7zip/UI/FileManager/PanelCrc.cpp
+++ b/CPP/7zip/UI/FileManager/PanelCrc.cpp
@@ -4,8 +4,8 @@
#include "resource.h"
-extern "C"
-{
+extern "C"
+{
#include "../../../../C/Alloc.h"
#include "../../../../C/7zCrc.h"
}
@@ -93,7 +93,7 @@ bool CDirEnumerator::GetNextFile(NFind::CFileInfoW &fileInfo, bool &filled, UStr
Prefixes.DeleteBack();
}
resPath += fileInfo.Name;
- if (!FlatMode && fileInfo.IsDirectory())
+ if (!FlatMode && fileInfo.IsDir())
{
UString prefix = resPath + (UString)(wchar_t)kDirDelimiter;
Enumerators.Add(NFind::CEnumeratorW(BasePrefix + prefix + (UString)(wchar_t)kAnyStringWildcard));
@@ -171,7 +171,7 @@ struct CThreadCrc
}
if (!filled)
break;
- if (!fileInfo.IsDirectory())
+ if (!fileInfo.IsDir())
totalSize += fileInfo.Size;
ProgressDialog->ProgressSynch.SetCurrentFileName(scanningStr + resPath);
ProgressDialog->ProgressSynch.SetProgress(totalSize, 0);
@@ -199,7 +199,7 @@ struct CThreadCrc
break;
UInt32 crc = CRC_INIT_VAL;
- if (fileInfo.IsDirectory())
+ if (fileInfo.IsDir())
NumFolders++;
else
{
@@ -276,7 +276,7 @@ void CApp::CalculateCrc()
CPanel &srcPanel = Panels[srcPanelIndex];
if (!srcPanel.IsFSFolder())
{
- srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
+ srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
return;
}
CRecordVector<UInt32> indices;
diff --git a/CPP/7zip/UI/FileManager/PanelDrag.cpp b/CPP/7zip/UI/FileManager/PanelDrag.cpp
index f242c8a1..25cbbc38 100755
--- a/CPP/7zip/UI/FileManager/PanelDrag.cpp
+++ b/CPP/7zip/UI/FileManager/PanelDrag.cpp
@@ -22,12 +22,12 @@ using namespace NWindows;
extern bool g_IsNT;
#endif
-static wchar_t *kTempDirPrefix = L"7zE";
-static LPCTSTR kSvenZipSetFolderFormat = TEXT("7-Zip::SetTargetFolder");
+static wchar_t *kTempDirPrefix = L"7zE";
+static LPCTSTR kSvenZipSetFolderFormat = TEXT("7-Zip::SetTargetFolder");
////////////////////////////////////////////////////////
-class CDataObject:
+class CDataObject:
public IDataObject,
public CMyUnknownImp
{
@@ -61,7 +61,7 @@ public:
CDataObject::CDataObject()
{
- m_SetFolderFormat = RegisterClipboardFormat(kSvenZipSetFolderFormat);
+ m_SetFolderFormat = RegisterClipboardFormat(kSvenZipSetFolderFormat);
m_Etc.cfFormat = CF_HDROP;
m_Etc.ptd = NULL;
m_Etc.dwAspect = DVASPECT_CONTENT;
@@ -70,13 +70,13 @@ CDataObject::CDataObject()
}
STDMETHODIMP CDataObject::SetData(LPFORMATETC etc, STGMEDIUM *medium, BOOL /* release */)
-{
- if (etc->cfFormat == m_SetFolderFormat && etc->tymed == TYMED_HGLOBAL &&
+{
+ if (etc->cfFormat == m_SetFolderFormat && etc->tymed == TYMED_HGLOBAL &&
etc->dwAspect == DVASPECT_CONTENT && medium->tymed == TYMED_HGLOBAL)
{
Path.Empty();
if (medium->hGlobal == 0)
- return S_OK;
+ return S_OK;
size_t size = GlobalSize(medium->hGlobal) / sizeof(wchar_t);
const wchar_t *src = (const wchar_t *)GlobalLock(medium->hGlobal);
if (src != 0)
@@ -89,10 +89,10 @@ STDMETHODIMP CDataObject::SetData(LPFORMATETC etc, STGMEDIUM *medium, BOOL /* re
Path += c;
}
GlobalUnlock(medium->hGlobal);
- return S_OK;
+ return S_OK;
}
}
- return E_NOTIMPL;
+ return E_NOTIMPL;
}
static HGLOBAL DuplicateGlobalMem(HGLOBAL srcGlobal)
@@ -156,7 +156,7 @@ STDMETHODIMP CDataObject::EnumFormatEtc(DWORD direction, LPENUMFORMATETC FAR* en
////////////////////////////////////////////////////////
-class CDropSource:
+class CDropSource:
public IDropSource,
public CMyUnknownImp
{
@@ -199,8 +199,8 @@ STDMETHODIMP CDropSource::QueryContinueDrag(BOOL escapePressed, DWORD keyState)
}
if (needExtract)
{
- Result = Panel->CopyTo(Indices, Folder,
- false, // moveMode,
+ Result = Panel->CopyTo(Indices, Folder,
+ false, // moveMode,
false, // showMessages
&Messages);
if (Result != S_OK || !Messages.IsEmpty())
@@ -300,7 +300,7 @@ void CPanel::OnDrag(LPNMLISTVIEW /* nmListView */)
// CSelectedState selState;
// SaveSelectedState(selState);
- UString dirPrefix;
+ UString dirPrefix;
NFile::NDirectory::CTempDirectoryW tempDirectory;
bool isFSFolder = IsFSFolder();
@@ -358,8 +358,8 @@ void CPanel::OnDrag(LPNMLISTVIEW /* nmListView */)
if (!dataObjectSpec->Path.IsEmpty())
{
NFile::NName::NormalizeDirPathPrefix(dataObjectSpec->Path);
- res = CopyTo(indices, dataObjectSpec->Path,
- (effect == DROPEFFECT_MOVE),// dropSourceSpec->MoveMode,
+ res = CopyTo(indices, dataObjectSpec->Path,
+ (effect == DROPEFFECT_MOVE),// dropSourceSpec->MoveMode,
false, // showErrorMessages
&dropSourceSpec->Messages);
}
@@ -433,7 +433,7 @@ void CDropTarget::PositionCursor(POINTL ptl)
for (int i = 0; i < kNumPanelsMax; i++)
if (App->IsPanelVisible(i))
if (App->Panels[i].IsEnabled())
- if (ChildWindowFromPointEx(App->_window, pt2,
+ if (ChildWindowFromPointEx(App->_window, pt2,
CWP_SKIPINVISIBLE | CWP_SKIPDISABLED) == (HWND)App->Panels[i])
{
m_Panel = &App->Panels[i];
@@ -475,7 +475,7 @@ void CDropTarget::PositionCursor(POINTL ptl)
if (realIndex == kParentIndex)
return;
if (!m_Panel->IsItemFolder(realIndex))
- return;
+ return;
m_SubFolderIndex = realIndex;
m_SubFolderName = m_Panel->GetItemName(m_SubFolderIndex);
MySetDropHighlighted(m_Panel->_listView, index, true);
@@ -604,9 +604,9 @@ DWORD CDropTarget::GetEffect(DWORD keyState, POINTL /* pt */, DWORD allowedEffec
effect = allowedEffect & DROPEFFECT_MOVE;
if(effect == 0)
{
- if(allowedEffect & DROPEFFECT_COPY)
+ if(allowedEffect & DROPEFFECT_COPY)
effect = DROPEFFECT_COPY;
- if(allowedEffect & DROPEFFECT_MOVE)
+ if(allowedEffect & DROPEFFECT_MOVE)
{
if (IsItSameDrive())
effect = DROPEFFECT_MOVE;
@@ -634,7 +634,7 @@ UString CDropTarget::GetTargetPath() const
bool CDropTarget::SetPath(bool enablePath) const
{
- UINT setFolderFormat = RegisterClipboardFormat(kSvenZipSetFolderFormat);
+ UINT setFolderFormat = RegisterClipboardFormat(kSvenZipSetFolderFormat);
FORMATETC etc = { (CLIPFORMAT)setFolderFormat, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
STGMEDIUM medium;
@@ -666,7 +666,7 @@ bool CDropTarget::SetPath()
return m_SetPathIsOK;
}
-STDMETHODIMP CDropTarget::DragEnter(IDataObject * dataObject, DWORD keyState,
+STDMETHODIMP CDropTarget::DragEnter(IDataObject * dataObject, DWORD keyState,
POINTL pt, DWORD *effect)
{
GetNamesFromDataObject(dataObject, m_SourcePaths);
@@ -696,7 +696,7 @@ STDMETHODIMP CDropTarget::DragLeave()
// We suppose that there was ::DragOver for same POINTL_pt before ::Drop
// So SetPath() is same as in Drop.
-STDMETHODIMP CDropTarget::Drop(IDataObject *dataObject, DWORD keyState,
+STDMETHODIMP CDropTarget::Drop(IDataObject *dataObject, DWORD keyState,
POINTL pt, DWORD * effect)
{
QueryGetData(dataObject);
@@ -770,7 +770,7 @@ void CPanel::CompressDropFiles(const UStringVector &fileNames, const UString &fo
{
if (fileNames.Size() == 0)
return;
- const UString archiveName = CreateArchiveName(fileNames.Front(),
+ const UString archiveName = CreateArchiveName(fileNames.Front(),
(fileNames.Size() > 1), false);
bool createNewArchive = true;
if (!IsFSFolder())
@@ -785,7 +785,7 @@ void CPanel::CompressDropFiles(const UStringVector &fileNames, const UString &fo
if (IsFolderInTemp(folderPath2))
folderPath2 = L"C:\\"; // fix it
}
- CompressFiles(folderPath2, archiveName, L"", fileNames,
+ CompressFiles(folderPath2, archiveName, L"", fileNames,
false, // email
true, // showDialog
AreThereNamesFromTemp(fileNames) // waitFinish
diff --git a/CPP/7zip/UI/FileManager/PanelFolderChange.cpp b/CPP/7zip/UI/FileManager/PanelFolderChange.cpp
index d6fdcc98..47363ef4 100755
--- a/CPP/7zip/UI/FileManager/PanelFolderChange.cpp
+++ b/CPP/7zip/UI/FileManager/PanelFolderChange.cpp
@@ -34,6 +34,37 @@ HRESULT CPanel::BindToPath(const UString &fullPath, bool &archiveIsOpened, bool
archiveIsOpened = false;
encrypted = false;
CDisableTimerProcessing disableTimerProcessing1(*this);
+
+ if (_parentFolders.Size() > 0)
+ {
+ const UString &virtPath = _parentFolders.Back().VirtualPath;
+ if (fullPath.Left(virtPath.Length()) == virtPath)
+ {
+ for (;;)
+ {
+ CMyComPtr<IFolderFolder> newFolder;
+ HRESULT res = _folder->BindToParentFolder(&newFolder);
+ if (!newFolder || res != S_OK)
+ break;
+ _folder = newFolder;
+ }
+ UStringVector parts;
+ SplitPathToParts(fullPath.Mid(virtPath.Length()), parts);
+ for (int i = 0; i < parts.Size(); i++)
+ {
+ const UString &s = parts[i];
+ if ((i == 0 || i == parts.Size() - 1) && s.IsEmpty())
+ continue;
+ CMyComPtr<IFolderFolder> newFolder;
+ HRESULT res = _folder->BindToFolder(s, &newFolder);
+ if (!newFolder || res != S_OK)
+ break;
+ _folder = newFolder;
+ }
+ return S_OK;
+ }
+ }
+
CloseOpenFolders();
UString sysPath = fullPath;
CFileInfoW fileInfo;
@@ -59,7 +90,7 @@ HRESULT CPanel::BindToPath(const UString &fullPath, bool &archiveIsOpened, bool
if (_folder->BindToFolder(fullPath, &newFolder) == S_OK)
_folder = newFolder;
}
- else if (fileInfo.IsDirectory())
+ else if (fileInfo.IsDir())
{
NName::NormalizeDirPathPrefix(sysPath);
if (_folder->BindToFolder(sysPath, &newFolder) == S_OK)
@@ -77,8 +108,20 @@ HRESULT CPanel::BindToPath(const UString &fullPath, bool &archiveIsOpened, bool
UString fileName;
if (NDirectory::GetOnlyName(sysPath, fileName))
{
- if (OpenItemAsArchive(fileName, _currentFolderPrefix,
- _currentFolderPrefix + fileName, encrypted) == S_OK)
+ HRESULT res =
+ OpenItemAsArchive(fileName, _currentFolderPrefix,
+ _currentFolderPrefix + fileName,
+ _currentFolderPrefix + fileName,
+ encrypted);
+ if (res != S_FALSE)
+ {
+ RINOK(res);
+ }
+ /*
+ if (res == E_ABORT)
+ return res;
+ */
+ if (res == S_OK)
{
archiveIsOpened = true;
for (int i = reducedParts.Size() - 1; i >= 0; i--)
@@ -138,56 +181,79 @@ void CPanel::LoadFullPath()
_currentFolderPrefix += GetFolderPath(_folder);
}
+static int GetRealIconIndex(LPCWSTR path, DWORD attributes)
+{
+ int index = -1;
+ if (GetRealIconIndex(path, attributes, index) != 0)
+ return index;
+ return -1;
+}
+
void CPanel::LoadFullPathAndShow()
-{
+{
LoadFullPath();
_appState->FolderHistory.AddString(_currentFolderPrefix);
- // _headerComboBox.SendMessage(CB_RESETCONTENT, 0, 0);
- _headerComboBox.SetText(_currentFolderPrefix);
+ _headerComboBox.SetText(_currentFolderPrefix);
+ COMBOBOXEXITEM item;
+ item.mask = 0;
+
+ UString path = _currentFolderPrefix;
+ if (path.Length() > 3 && path[path.Length() - 1] == L'\\')
+ path.Delete(path.Length() - 1);
+
+ CFileInfoW info;
+ DWORD attrib = FILE_ATTRIBUTE_DIRECTORY;
+ if (NFile::NFind::FindFile(path, info))
+ attrib = info.Attrib;
+
+ item.iImage = GetRealIconIndex(path, attrib);
+
+ if (item.iImage >= 0)
+ {
+ item.iSelectedImage = item.iImage;
+ item.mask |= (CBEIF_IMAGE | CBEIF_SELECTEDIMAGE);
+ }
+ item.iItem = -1;
+ _headerComboBox.SetItem(&item);
+
RefreshTitle();
+}
- /*
- for (int i = 0; i < g_Folders.m_Strings.Size(); i++)
+LRESULT CPanel::OnNotifyComboBoxEnter(const UString &s)
+{
+ if (BindToPathAndRefresh(GetUnicodeString(s)) == S_OK)
{
- UString string = g_Folders.m_Strings[i];
- COMBOBOXEXITEM item;
- item.mask = CBEIF_TEXT;
- item.iItem = i;
- item.pszText = (LPTSTR)(LPCTSTR)string;
- _headerComboBox.InsertItem(&item);
+ PostMessage(kSetFocusToListView);
+ return TRUE;
}
- */
+ return FALSE;
}
bool CPanel::OnNotifyComboBoxEndEdit(PNMCBEENDEDITW info, LRESULT &result)
{
if (info->iWhy == CBENF_ESCAPE)
{
- _headerComboBox.SetText(_currentFolderPrefix);
+ _headerComboBox.SetText(_currentFolderPrefix);
PostMessage(kSetFocusToListView);
result = FALSE;
return true;
}
+
+ /*
if (info->iWhy == CBENF_DROPDOWN)
{
result = FALSE;
return true;
}
+ */
if (info->iWhy == CBENF_RETURN)
{
+ // When we use Edit control and press Enter.
UString s;
_headerComboBox.GetText(s);
- // length of NMCBEENDEDITW.szText is limited by MAX_PATH
- // if (BindToPathAndRefresh(info->szText) != S_OK)
- if (BindToPathAndRefresh(s) != S_OK)
- {
- result = TRUE;
- return true;
- }
- result = FALSE;
- PostMessage(kSetFocusToListView);
+ result = OnNotifyComboBoxEnter(s);
return true;
}
return false;
@@ -198,52 +264,144 @@ bool CPanel::OnNotifyComboBoxEndEdit(PNMCBEENDEDIT info, LRESULT &result)
{
if (info->iWhy == CBENF_ESCAPE)
{
- _headerComboBox.SetText(_currentFolderPrefix);
+ _headerComboBox.SetText(_currentFolderPrefix);
PostMessage(kSetFocusToListView);
result = FALSE;
return true;
}
+ /*
if (info->iWhy == CBENF_DROPDOWN)
{
result = FALSE;
return true;
}
+ */
if (info->iWhy == CBENF_RETURN)
{
- if (BindToPathAndRefresh(GetUnicodeString(info->szText)) != S_OK)
- {
- result = TRUE;
- return true;
- }
- result = FALSE;
- PostMessage(kSetFocusToListView);
+ UString s;
+ _headerComboBox.GetText(s);
+ // GetUnicodeString(info->szText)
+ result = OnNotifyComboBoxEnter(s);
return true;
}
return false;
}
#endif
-void CPanel::OnComboBoxCommand(UINT /* code */, LPARAM & /* param */)
+void CPanel::AddComboBoxItem(const UString &name, int iconIndex, int indent, bool addToList)
{
- /*
- if (code == CBN_SELENDOK)
+ COMBOBOXEXITEMW item;
+ item.mask = CBEIF_TEXT | CBEIF_INDENT;
+ item.iSelectedImage = item.iImage = iconIndex;
+ if (iconIndex >= 0)
+ item.mask |= (CBEIF_IMAGE | CBEIF_SELECTEDIMAGE);
+ item.iItem = -1;
+ item.iIndent = indent;
+ item.pszText = (LPWSTR)(LPCWSTR)name;
+ _headerComboBox.InsertItem(&item);
+ if (addToList)
+ ComboBoxPaths.Add(name);
+}
+
+extern UString RootFolder_GetName_Computer(int &iconIndex);
+extern UString RootFolder_GetName_Network(int &iconIndex);
+extern UString RootFolder_GetName_Documents(int &iconIndex);
+
+bool CPanel::OnComboBoxCommand(UINT code, LPARAM /* param */, LRESULT &result)
+{
+ result = FALSE;
+ switch(code)
{
- UString path;
- if (!_headerComboBox.GetText(path))
- return;
- CRootFolder *rootFolderSpec = new CRootFolder;
- CMyComPtr<IFolderFolder> rootFolder = rootFolderSpec;
- rootFolderSpec->Init();
- CMyComPtr<IFolderFolder> newFolder;
- if (rootFolder->BindToFolder(path, &newFolder) != S_OK)
- return;
- _folder = newFolder;
- SetCurrentPathText();
- RefreshListCtrl(UString(), -1, UStringVector());
- PostMessage(kSetFocusToListView);
+ case CBN_DROPDOWN:
+ {
+ ComboBoxPaths.Clear();
+ _headerComboBox.ResetContent();
+
+ int iconIndex;
+ UString name;
+
+ int i;
+ UStringVector pathParts;
+
+ SplitPathToParts(_currentFolderPrefix, pathParts);
+ UString sumPass;
+ for (i = 0; i < pathParts.Size(); i++)
+ {
+ UString name = pathParts[i];
+ if (name.IsEmpty())
+ continue;
+ sumPass += name;
+ UString curName = sumPass;
+ if (i == 0)
+ curName += L"\\";
+ CFileInfoW info;
+ DWORD attrib = FILE_ATTRIBUTE_DIRECTORY;
+ if (NFile::NFind::FindFile(sumPass, info))
+ attrib = info.Attrib;
+ sumPass += L"\\";
+ AddComboBoxItem(name, GetRealIconIndex(curName, attrib), i, false);
+ ComboBoxPaths.Add(sumPass);
+ }
+
+ name = RootFolder_GetName_Documents(iconIndex);
+ AddComboBoxItem(name, iconIndex, 0, true);
+
+ name = RootFolder_GetName_Computer(iconIndex);
+ AddComboBoxItem(name, iconIndex, 0, true);
+
+ UStringVector driveStrings;
+ MyGetLogicalDriveStrings(driveStrings);
+ for (i = 0; i < driveStrings.Size(); i++)
+ {
+ UString s = driveStrings[i];
+ ComboBoxPaths.Add(s);
+ int iconIndex = GetRealIconIndex(s, 0);
+ if (s.Length() > 0 && s[s.Length() - 1] == '\\')
+ s.Delete(s.Length() - 1);
+ AddComboBoxItem(s, iconIndex, 1, false);
+ }
+
+ name = RootFolder_GetName_Network(iconIndex);
+ AddComboBoxItem(name, iconIndex, 0, true);
+
+ // UStringVector strings; _appState->FolderHistory.GetList(strings);
+
+ return false;
+ }
+
+ case CBN_SELENDOK:
+ {
+ code = code;
+ int index = _headerComboBox.GetCurSel();
+ if (index >= 0)
+ {
+ UString pass = ComboBoxPaths[index];
+ _headerComboBox.SetCurSel(-1);
+ _headerComboBox.SetText(pass); // it's fix for seclecting by mouse.
+ if (BindToPathAndRefresh(pass) == S_OK)
+ {
+ PostMessage(kSetFocusToListView);
+ return true;
+ }
+ }
+ return false;
+ }
+ /*
+ case CBN_CLOSEUP:
+ {
+ LoadFullPathAndShow();
+ true;
+
+ }
+ case CBN_SELCHANGE:
+ {
+ // LoadFullPathAndShow();
+ return true;
+ }
+ */
}
- */
+ return false;
}
bool CPanel::OnNotifyComboBox(LPNMHDR header, LRESULT &result)
@@ -254,6 +412,7 @@ bool CPanel::OnNotifyComboBox(LPNMHDR header, LRESULT &result)
{
_lastFocusedIsList = false;
_panelCallback->PanelWasFocused();
+ break;
}
#ifndef _UNICODE
case CBEN_ENDEDIT:
diff --git a/CPP/7zip/UI/FileManager/PanelItemOpen.cpp b/CPP/7zip/UI/FileManager/PanelItemOpen.cpp
index bf746282..afb376d0 100755
--- a/CPP/7zip/UI/FileManager/PanelItemOpen.cpp
+++ b/CPP/7zip/UI/FileManager/PanelItemOpen.cpp
@@ -2,9 +2,9 @@
#include "StdAfx.h"
-#include "resource.h"
+#include "resource.h"
-#include "Common/StringConvert.h"
+#include "Common/StringConvert.h"
#include "Common/Random.h"
#include "Common/StringConvert.h"
#include "Common/AutoPtr.h"
@@ -14,14 +14,15 @@
#include "Windows/Thread.h"
#include "Windows/Synchronization.h"
#include "Windows/Error.h"
-// #include "Windows/COM.h"
#include "ExtractCallback.h"
+#include "UpdateCallback100.h"
#include "IFolder.h"
#include "FileFolderPluginOpen.h"
#include "FormatUtils.h"
#include "Panel.h"
#include "RegistryUtils.h"
+#include "LangUtils.h"
using namespace NWindows;
using namespace NSynchronization;
@@ -33,9 +34,8 @@ extern HWND g_HWND;
extern bool g_IsNT;
#endif
-static wchar_t *kTempDirPrefix = L"7zO";
+static wchar_t *kTempDirPrefix = L"7zO";
-static const wchar_t *virusMessage = L"File looks like virus (file name has long spaces in name). 7-Zip will not open it";
static bool IsNameVirus(const UString &name)
{
@@ -47,6 +47,9 @@ struct CTmpProcessInfo: public CTempFileInfo
HANDLE ProcessHandle;
HWND Window;
UString FullPathFolderPrefix;
+ bool UsePassword;
+ UString Password;
+ CTmpProcessInfo(): UsePassword(false) {}
};
class CTmpProcessInfoRelease
@@ -63,18 +66,21 @@ public:
}
};
-HRESULT CPanel::OpenItemAsArchive(const UString &name,
- const UString &folderPath, const UString &filePath, bool &encrypted)
+HRESULT CPanel::OpenItemAsArchive(const UString &name,
+ const UString &folderPath, const UString &filePath,
+ const UString &virtualFilePath,
+ bool &encrypted)
{
encrypted = false;
CFolderLink folderLink;
if (!NFile::NFind::FindFile(filePath, folderLink.FileInfo))
return E_FAIL;
- if (folderLink.FileInfo.IsDirectory())
+ if (folderLink.FileInfo.IsDir())
return S_FALSE;
folderLink.FilePath = filePath;
folderLink.FolderPath = folderPath;
+ folderLink.VirtualPath = virtualFilePath;
CMyComPtr<IFolderFolder> newFolder;
@@ -82,8 +88,13 @@ HRESULT CPanel::OpenItemAsArchive(const UString &name,
// _password.Empty();
NDLL::CLibrary library;
- RINOK(OpenFileFolderPlugin(filePath, &library, &newFolder, GetParent(), encrypted));
+
+ UString password;
+ RINOK(OpenFileFolderPlugin(filePath, &library, &newFolder, GetParent(), encrypted, password));
+ folderLink.Password = password;
+ folderLink.UsePassword = encrypted;
+
folderLink.ParentFolder = _folder;
folderLink.ItemName = name;
_parentFolders.Add(folderLink);
@@ -100,7 +111,10 @@ HRESULT CPanel::OpenItemAsArchive(const UString &name,
HRESULT CPanel::OpenItemAsArchive(const UString &name)
{
bool encrypted;
- return OpenItemAsArchive(name, _currentFolderPrefix, _currentFolderPrefix + name, encrypted);
+ return OpenItemAsArchive(name, _currentFolderPrefix,
+ _currentFolderPrefix + name,
+ _currentFolderPrefix + name,
+ encrypted);
}
HRESULT CPanel::OpenItemAsArchive(int index)
@@ -120,17 +134,17 @@ HRESULT CPanel::OpenParentArchiveFolder()
NFind::CFileInfoW newFileInfo;
if (NFind::FindFile(folderLink.FilePath, newFileInfo))
{
- if (newFileInfo.Size != folderLink.FileInfo.Size ||
- CompareFileTime(&newFileInfo.LastWriteTime,
- &folderLink.FileInfo.LastWriteTime) != 0)
+ if (newFileInfo.Size != folderLink.FileInfo.Size ||
+ CompareFileTime(&newFileInfo.MTime, &folderLink.FileInfo.MTime) != 0)
{
- UString message = MyFormatNew(IDS_WANT_UPDATE_MODIFIED_FILE,
+ UString message = MyFormatNew(IDS_WANT_UPDATE_MODIFIED_FILE,
0x03020280, folderLink.ItemName);
if (::MessageBoxW(HWND(*this), message, L"7-Zip", MB_OKCANCEL | MB_ICONQUESTION) == IDOK)
{
- if (OnOpenItemChanged(folderLink.FolderPath, folderLink.ItemName) != S_OK)
+ if (OnOpenItemChanged(folderLink.FolderPath, folderLink.ItemName,
+ folderLink.UsePassword, folderLink.Password) != S_OK)
{
- ::MessageBoxW(HWND(*this), MyFormatNew(IDS_CANNOT_UPDATE_FILE,
+ ::MessageBoxW(HWND(*this), MyFormatNew(IDS_CANNOT_UPDATE_FILE,
0x03020281, folderLink.FilePath), L"7-Zip", MB_OK | MB_ICONSTOP);
return S_OK;
}
@@ -141,17 +155,17 @@ HRESULT CPanel::OpenParentArchiveFolder()
return S_OK;
}
-static const wchar_t *kStartExtensions[] =
+static const wchar_t *kStartExtensions[] =
{
L"exe", L"bat", L"com",
L"chm",
L"msi", L"doc", L"xls", L"ppt", L"pps", L"wps", L"wpt", L"wks", L"xlr", L"wdb",
- L"docx", L"docm", L"dotx", L"dotm", L"xlsx", L"xlsm", L"xltx", L"xltm", L"xlsb",
- L"xlam", L"pptx", L"pptm", L"potx", L"potm", L"ppam", L"ppsx", L"ppsm", L"xsn",
+ L"docx", L"docm", L"dotx", L"dotm", L"xlsx", L"xlsm", L"xltx", L"xltm", L"xlsb",
+ L"xlam", L"pptx", L"pptm", L"potx", L"potm", L"ppam", L"ppsx", L"ppsm", L"xsn",
L"odt", L"ods",
- L"wb3",
+ L"wb3",
L"pdf"
};
@@ -198,7 +212,7 @@ static HANDLE StartEditApplication(const UString &path, HWND window)
startupInfo.cbReserved2 = 0;
startupInfo.lpReserved2 = 0;
- result = ::CreateProcessA(NULL, (CHAR *)(const CHAR *)GetSystemString(command),
+ result = ::CreateProcessA(NULL, (CHAR *)(const CHAR *)GetSystemString(command),
NULL, NULL, FALSE, 0, NULL, NULL, &startupInfo, &processInformation);
}
else
@@ -213,7 +227,7 @@ static HANDLE StartEditApplication(const UString &path, HWND window)
startupInfo.cbReserved2 = 0;
startupInfo.lpReserved2 = 0;
- result = ::CreateProcessW(NULL, (WCHAR *)(const WCHAR *)command,
+ result = ::CreateProcessW(NULL, (WCHAR *)(const WCHAR *)command,
NULL, NULL, FALSE, 0, NULL, NULL, &startupInfo, &processInformation);
}
@@ -222,7 +236,7 @@ static HANDLE StartEditApplication(const UString &path, HWND window)
::CloseHandle(processInformation.hThread);
return processInformation.hProcess;
}
- ::MessageBoxW(window, LangString(IDS_CANNOT_START_EDITOR, 0x03020282),
+ ::MessageBoxW(window, LangString(IDS_CANNOT_START_EDITOR, 0x03020282),
L"7-Zip", MB_OK | MB_ICONSTOP);
return 0;
}
@@ -279,7 +293,7 @@ static HANDLE StartApplication(const UString &path, HWND window)
switch(result)
{
case SE_ERR_NOASSOC:
- ::MessageBoxW(window,
+ ::MessageBoxW(window,
NError::MyFormatMessageW(::GetLastError()),
// L"There is no application associated with the given file name extension",
L"7-Zip", MB_OK | MB_ICONSTOP);
@@ -318,29 +332,39 @@ void CPanel::OpenItem(int index, bool tryInternal, bool tryExternal)
UString name = GetItemRelPath(index);
if (IsNameVirus(name))
{
- MessageBoxMyError(virusMessage);
+ MessageBoxErrorLang(IDS_VIRUS, 0x03020284);
return;
}
UString fullPath = _currentFolderPrefix + name;
if (tryInternal)
if (!tryExternal || !DoItemAlwaysStart(name))
- if (OpenItemAsArchive(index) == S_OK)
+ {
+ HRESULT res = OpenItemAsArchive(index);
+ if (res == S_OK || res == E_ABORT)
return;
+ if (res != S_FALSE)
+ {
+ MessageBoxError(res);
+ return;
+ }
+ }
if (tryExternal)
{
- NDirectory::MySetCurrentDirectory(_currentFolderPrefix);
+ // SetCurrentDirectory opens HANDLE to folder!!!
+ // NDirectory::MySetCurrentDirectory(_currentFolderPrefix);
HANDLE hProcess = StartApplication(fullPath, (HWND)*this);
if (hProcess != 0)
::CloseHandle(hProcess);
}
}
-
-HRESULT CPanel::OnOpenItemChanged(const UString &folderPath, const UString &itemName)
+
+HRESULT CPanel::OnOpenItemChanged(const UString &folderPath, const UString &itemName,
+ bool usePassword, const UString &password)
{
CMyComPtr<IFolderOperations> folderOperations;
if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
{
- MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
+ MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
return E_FAIL;
}
UStringVector fileNames;
@@ -350,7 +374,12 @@ HRESULT CPanel::OnOpenItemChanged(const UString &folderPath, const UString &item
UString pathPrefix = folderPath;
NName::NormalizeDirPathPrefix(pathPrefix);
- return folderOperations->CopyFrom(pathPrefix, &fileNamePointers.Front(),fileNamePointers.Size(), NULL);
+
+ CUpdateCallback100Imp *callbackSpec = new CUpdateCallback100Imp;
+ CMyComPtr<IProgress> callback = callbackSpec;
+ callbackSpec->Init((HWND)*this, usePassword, password);
+
+ return folderOperations->CopyFrom(pathPrefix, &fileNamePointers.Front(), fileNamePointers.Size(), callback);
}
LRESULT CPanel::OnOpenItemChanged(LPARAM lParam)
@@ -363,7 +392,8 @@ LRESULT CPanel::OnOpenItemChanged(LPARAM lParam)
CSelectedState state;
SaveSelectedState(state);
- HRESULT result = OnOpenItemChanged(tmpProcessInfo.FolderPath, tmpProcessInfo.ItemName);
+ HRESULT result = OnOpenItemChanged(tmpProcessInfo.FolderPath, tmpProcessInfo.ItemName,
+ tmpProcessInfo.UsePassword, tmpProcessInfo.Password);
if (result != S_OK)
return 0;
RefreshListCtrl(state);
@@ -407,17 +437,16 @@ static THREAD_FUNC_DECL MyThreadFunction(void *param)
NFind::CFileInfoW newFileInfo;
if (NFind::FindFile(tmpProcessInfo->FilePath, newFileInfo))
{
- if (newFileInfo.Size != tmpProcessInfo->FileInfo.Size ||
- CompareFileTime(&newFileInfo.LastWriteTime,
- &tmpProcessInfo->FileInfo.LastWriteTime) != 0)
+ if (newFileInfo.Size != tmpProcessInfo->FileInfo.Size ||
+ CompareFileTime(&newFileInfo.MTime, &tmpProcessInfo->FileInfo.MTime) != 0)
{
- UString message = MyFormatNew(IDS_WANT_UPDATE_MODIFIED_FILE,
+ UString message = MyFormatNew(IDS_WANT_UPDATE_MODIFIED_FILE,
0x03020280, tmpProcessInfo->ItemName);
if (::MessageBoxW(g_HWND, message, L"7-Zip", MB_OKCANCEL | MB_ICONQUESTION) == IDOK)
{
if (SendMessage(tmpProcessInfo->Window, kOpenItemChanged, 0, (LONG_PTR)tmpProcessInfo) != 1)
{
- ::MessageBoxW(g_HWND, MyFormatNew(IDS_CANNOT_UPDATE_FILE,
+ ::MessageBoxW(g_HWND, MyFormatNew(IDS_CANNOT_UPDATE_FILE,
0x03020281, tmpProcessInfo->FilePath), L"7-Zip", MB_OK | MB_ICONSTOP);
return 0;
}
@@ -428,20 +457,19 @@ static THREAD_FUNC_DECL MyThreadFunction(void *param)
return 0;
}
-void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal,
- bool editMode)
+void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bool editMode)
{
const UString name = GetItemName(index);
if (IsNameVirus(name))
{
- MessageBoxMyError(virusMessage);
+ MessageBoxErrorLang(IDS_VIRUS, 0x03020284);
return;
}
CMyComPtr<IFolderOperations> folderOperations;
if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
{
- MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
+ MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
return;
}
@@ -455,7 +483,24 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal,
indices.Add(index);
UStringVector messages;
- HRESULT result = CopyTo(indices, tempDirNorm, false, true, &messages);
+
+ bool usePassword = false;
+ UString password;
+ if (_parentFolders.Size() > 0)
+ {
+ const CFolderLink &fl = _parentFolders.Back();
+ usePassword = fl.UsePassword;
+ password = fl.Password;
+ }
+
+ HRESULT result = CopyTo(indices, tempDirNorm, false, true, &messages, usePassword, password);
+
+ if (_parentFolders.Size() > 0)
+ {
+ CFolderLink &fl = _parentFolders.Back();
+ fl.UsePassword = usePassword;
+ fl.Password = password;
+ }
if (!messages.IsEmpty())
return;
@@ -472,6 +517,9 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal,
CTmpProcessInfo *tmpProcessInfo = tmpProcessInfoPtr.get();
tmpProcessInfo->FolderPath = tempDir;
tmpProcessInfo->FilePath = tempFilePath;
+ tmpProcessInfo->UsePassword = usePassword;
+ tmpProcessInfo->Password = password;
+
if (!NFind::FindFile(tempFilePath, tmpProcessInfo->FileInfo))
return;
@@ -480,7 +528,8 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal,
if (!tryExternal || !DoItemAlwaysStart(name))
{
bool encrypted;
- if (OpenItemAsArchive(name, tempDir, tempFilePath, encrypted) == S_OK)
+ if (OpenItemAsArchive(name, tempDir, tempFilePath,
+ _currentFolderPrefix + name, encrypted) == S_OK)
{
RefreshListCtrl();
return;
@@ -530,21 +579,18 @@ void DeleteOldTempFiles()
if(!NFile::NDirectory::MyGetTempPath(tempPath))
throw 1;
- SYSTEMTIME systemTime;
- ::GetSystemTime(&systemTime);
UINT64 currentFileTime;
- if(!::SystemTimeToFileTime(&systemTime, (FILETIME *)&currentFileTime))
- throw 2;
+ NTime::GetCurUtcFileTime(currentFileTime);
UString searchWildCard = tempPath + kTempDirPrefix + L"*.tmp";
searchWildCard += WCHAR(NName::kAnyStringWildcard);
NFind::CEnumeratorW enumerator(searchWildCard);
NFind::CFileInfoW fileInfo;
while(enumerator.Next(fileInfo))
{
- if (!fileInfo.IsDirectory())
+ if (!fileInfo.IsDir())
continue;
- const UINT64 &creationTime = *(const UINT64 *)(&fileInfo.CreationTime);
- if(CheckDeleteItem(creationTime, currentFileTime))
+ const UINT64 &cTime = *(const UINT64 *)(&fileInfo.CTime);
+ if(CheckDeleteItem(cTime, currentFileTime))
RemoveDirectoryWithSubItems(tempPath + fileInfo.Name);
}
}
diff --git a/CPP/7zip/UI/FileManager/PanelItems.cpp b/CPP/7zip/UI/FileManager/PanelItems.cpp
index 41ef45dd..89b47ec7 100755
--- a/CPP/7zip/UI/FileManager/PanelItems.cpp
+++ b/CPP/7zip/UI/FileManager/PanelItems.cpp
@@ -4,19 +4,18 @@
#include "Common/StringConvert.h"
+#include "Windows/Menu.h"
#include "Windows/PropVariant.h"
#include "Windows/PropVariantConversions.h"
-#include "Windows/Menu.h"
#include "../../PropID.h"
-#include "Panel.h"
#include "resource.h"
-#include "RootFolder.h"
-
-#include "PropertyName.h"
#include "LangUtils.h"
+#include "Panel.h"
+#include "PropertyName.h"
+#include "RootFolder.h"
extern "C"
{
@@ -29,9 +28,9 @@ static int GetColumnAlign(PROPID propID, VARTYPE varType)
{
switch(propID)
{
- case kpidCreationTime:
- case kpidLastAccessTime:
- case kpidLastWriteTime:
+ case kpidCTime:
+ case kpidATime:
+ case kpidMTime:
return LVCFMT_LEFT;
}
switch(varType)
@@ -45,7 +44,7 @@ static int GetColumnAlign(PROPID propID, VARTYPE varType)
case VT_UINT:
case VT_I8:
case VT_UI8:
- case VT_BOOL:
+ case VT_BOOL:
return LVCFMT_RIGHT;
case VT_EMPTY:
@@ -84,7 +83,7 @@ void CPanel::InitColumns()
_needSaveInfo = true;
UInt32 numProperties;
- _folder->GetNumberOfProperties(&numProperties);
+ _folder->GetNumberOfProperties(&numProperties);
int i;
for (i = 0; i < (int)numProperties; i++)
{
@@ -95,24 +94,17 @@ void CPanel::InitColumns()
if (_folder->GetPropertyInfo(i, &name, &propID, &varType) != S_OK)
throw 1;
- CItemProperty destProperty;
- destProperty.Type = varType;
- destProperty.ID = propID;
- if (propID == kpidIsFolder)
+ if (propID == kpidIsDir)
continue;
- {
- if (name != NULL)
- destProperty.Name = name;
- else
- destProperty.Name = L"Error";
- }
- UString propName = GetNameOfProperty(propID);
- if (!propName.IsEmpty())
- destProperty.Name = propName;
- destProperty.Order = -1;
- destProperty.IsVisible = true;
- destProperty.Width = 100;
- _properties.Add(destProperty);
+
+ CItemProperty prop;
+ prop.Type = varType;
+ prop.ID = propID;
+ prop.Name = GetNameOfProperty(propID, name);
+ prop.Order = -1;
+ prop.IsVisible = true;
+ prop.Width = 100;
+ _properties.Add(prop);
}
// InitColumns2(sortID);
@@ -177,10 +169,7 @@ void CPanel::InsertColumn(int index)
column.fmt = GetColumnAlign(property.ID, property.Type);
column.iOrder = property.Order;
column.iSubItem = index;
- UString propertyName = GetNameOfProperty(property.ID);
- if (propertyName.IsEmpty())
- propertyName = property.Name;
- column.pszText = (wchar_t *)(const wchar_t *)propertyName;
+ column.pszText = (wchar_t *)(const wchar_t *)property.Name;
_listView.InsertColumn(index, &column);
}
@@ -338,7 +327,7 @@ void CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool se
_listView.SetItemCount(numItems + (showDots ? 1 : 0));
_selectedStatusVector.Reserve(numItems);
- int cursorIndex = -1;
+ int cursorIndex = -1;
CMyComPtr<IFolderGetSystemIconIndex> folderGetSystemIconIndex;
if (!IsFSFolder() || _showRealFileIcons)
@@ -414,7 +403,7 @@ void CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool se
item.pszText = (wchar_t *)(const wchar_t *)itemName;
NCOM::CPropVariant propVariant;
- _folder->GetProperty(i, kpidAttributes, &propVariant);
+ _folder->GetProperty(i, kpidAttrib, &propVariant);
UInt32 attributes = 0;
if (propVariant.vt == VT_UI4)
attributes = propVariant.ulVal;
@@ -459,7 +448,7 @@ void CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool se
{
if (focusedPos >= _listView.GetItemCount())
focusedPos = _listView.GetItemCount() - 1;
- SetFocusedSelectedItem(focusedPos, true);
+ SetFocusedSelectedItem(focusedPos, showDots);
}
// m_RedrawEnabled = true;
_listView.EnsureVisible(_listView.GetFocusedItem(), false);
@@ -517,6 +506,13 @@ void CPanel::GetAllItemIndices(CRecordVector<UInt32> &indices) const
indices.Add(i);
}
+void CPanel::GetOperatedIndicesSmart(CRecordVector<UInt32> &indices) const
+{
+ GetOperatedItemIndices(indices);
+ if (indices.IsEmpty() || (indices.Size() == 1 && indices[0] == (UInt32)(Int32)-1))
+ GetAllItemIndices(indices);
+}
+
/*
void CPanel::GetOperatedListViewIndices(CRecordVector<UInt32> &indices) const
{
@@ -568,7 +564,7 @@ void CPanel::OpenSelectedItems(bool tryInternal)
GetOperatedItemIndices(indices);
if (indices.Size() > 20)
{
- MessageBox(LangString(IDS_TOO_MANY_ITEMS, 0x02000606));
+ MessageBoxErrorLang(IDS_TOO_MANY_ITEMS, 0x02000606);
return;
}
@@ -640,7 +636,7 @@ bool CPanel::IsItemFolder(int itemIndex) const
if (itemIndex == kParentIndex)
return true;
NCOM::CPropVariant propVariant;
- if (_folder->GetProperty(itemIndex, kpidIsFolder, &propVariant) != S_OK)
+ if (_folder->GetProperty(itemIndex, kpidIsDir, &propVariant) != S_OK)
throw 2723400;
if (propVariant.vt == VT_BOOL)
return VARIANT_BOOLToBool(propVariant.boolVal);
@@ -745,7 +741,7 @@ bool CPanel::OnRightClick(LPNMITEMACTIVATE itemActiveate, LRESULT &result)
flags |= MF_GRAYED;
menu.AppendItem(flags, kCommandStart + i, GetSystemString(property.Name));
}
- int menuResult = menu.Track(TPM_LEFTALIGN | TPM_RETURNCMD | TPM_NONOTIFY,
+ int menuResult = menu.Track(TPM_LEFTALIGN | TPM_RETURNCMD | TPM_NONOTIFY,
point.x, point.y, _listView);
if (menuResult >= kCommandStart && menuResult <= kCommandStart + _properties.Size())
{
diff --git a/CPP/7zip/UI/FileManager/PanelKey.cpp b/CPP/7zip/UI/FileManager/PanelKey.cpp
index 218476ed..8e3eaaa1 100755
--- a/CPP/7zip/UI/FileManager/PanelKey.cpp
+++ b/CPP/7zip/UI/FileManager/PanelKey.cpp
@@ -16,11 +16,11 @@ struct CVKeyPropIDPair
PROPID PropID;
};
-static CVKeyPropIDPair g_VKeyPropIDPairs[] =
+static CVKeyPropIDPair g_VKeyPropIDPairs[] =
{
{ VK_F3, kpidName },
{ VK_F4, kpidExtension },
- { VK_F5, kpidLastWriteTime },
+ { VK_F5, kpidMTime },
{ VK_F6, kpidSize },
{ VK_F7, kpidNoProperty }
};
@@ -48,7 +48,7 @@ bool CPanel::OnKeyDown(LPNMLVKEYDOWN keyDownInfo, LRESULT &result)
bool shift = (::GetKeyState(VK_SHIFT) & 0x8000) != 0;
result = 0;
- if (keyDownInfo->wVKey >= '0' && keyDownInfo->wVKey <= '9' &&
+ if (keyDownInfo->wVKey >= '0' && keyDownInfo->wVKey <= '9' &&
(rightCtrl || alt))
{
int index = keyDownInfo->wVKey - '0';
@@ -64,7 +64,7 @@ bool CPanel::OnKeyDown(LPNMLVKEYDOWN keyDownInfo, LRESULT &result)
}
}
- if ((keyDownInfo->wVKey == VK_F2 ||
+ if ((keyDownInfo->wVKey == VK_F2 ||
keyDownInfo->wVKey == VK_F1) && alt && !ctrl && !shift)
{
_panelCallback->SetFocusToPath(keyDownInfo->wVKey == VK_F1 ? 0 : 1);
diff --git a/CPP/7zip/UI/FileManager/PanelListNotify.cpp b/CPP/7zip/UI/FileManager/PanelListNotify.cpp
index 572118d0..21600a68 100755
--- a/CPP/7zip/UI/FileManager/PanelListNotify.cpp
+++ b/CPP/7zip/UI/FileManager/PanelListNotify.cpp
@@ -51,7 +51,7 @@ static UString ConvertSizeToStringShort(UInt64 value)
return s;
}
-static UString ConvertSizeToString(UInt64 value)
+UString ConvertSizeToString(UInt64 value)
{
wchar_t s[32];
ConvertUInt64ToString(value, s);
@@ -90,22 +90,16 @@ LRESULT CPanel::SetItemText(LVITEMW &item)
if (!defined)
{
NCOM::CPropVariant prop;
- _folder->GetProperty(index, kpidAttributes, &prop);
- UINT32 attributes = 0;
+ _folder->GetProperty(index, kpidAttrib, &prop);
+ UINT32 attrib = 0;
if (prop.vt == VT_UI4)
- attributes = prop.ulVal;
- else
- {
- if (IsItemFolder(index))
- attributes |= FILE_ATTRIBUTE_DIRECTORY;
- }
+ attrib = prop.ulVal;
+ else if (IsItemFolder(index))
+ attrib |= FILE_ATTRIBUTE_DIRECTORY;
if (_currentFolderPrefix.IsEmpty())
- {
throw 1;
- }
else
- item.iImage = _extToIconMap.GetIconIndex(attributes,
- GetSystemString(GetItemName(index)));
+ item.iImage = _extToIconMap.GetIconIndex(attrib, GetSystemString(GetItemName(index)));
}
// item.iImage = 1;
}
@@ -156,8 +150,8 @@ LRESULT CPanel::SetItemText(LVITEMW &item)
if (_folder->GetProperty(realIndex, propID, &prop) != S_OK)
throw 2723407;
- if ((propID == kpidSize || propID == kpidPackedSize || propID == kpidClusterSize ||
- propID == kpidNumSubFolders || propID == kpidNumSubFiles) &&
+ if ((propID == kpidSize || propID == kpidPackSize || propID == kpidClusterSize ||
+ propID == kpidNumSubDirs || propID == kpidNumSubFiles) &&
(prop.vt == VT_UI8 || prop.vt == VT_UI4))
s = ConvertSizeToString(ConvertPropVariantToUInt64(prop));
else if ((propID == kpidTotalSize || propID == kpidFreeSpace) &&
@@ -166,8 +160,8 @@ LRESULT CPanel::SetItemText(LVITEMW &item)
else
{
s = ConvertPropertyToString(prop, propID, false);
- s.Replace(wchar_t(0xA), L' ');
- s.Replace(wchar_t(0xD), L' ');
+ s.Replace(wchar_t(0xA), L' ');
+ s.Replace(wchar_t(0xD), L' ');
}
int size = item.cchTextMax;
if(size > 0)
@@ -224,7 +218,7 @@ bool CPanel::OnNotifyList(LPNMHDR header, LRESULT &result)
//is the sub-item information being requested?
- if((dispInfo->item.mask & LVIF_TEXT) != 0 ||
+ if((dispInfo->item.mask & LVIF_TEXT) != 0 ||
(dispInfo->item.mask & LVIF_IMAGE) != 0)
SetItemText(dispInfo->item);
return false;
@@ -327,7 +321,7 @@ bool CPanel::OnNotifyList(LPNMHDR header, LRESULT &result)
bool CPanel::OnCustomDraw(LPNMLVCUSTOMDRAW lplvcd, LRESULT &result)
{
- switch(lplvcd->nmcd.dwDrawStage)
+ switch(lplvcd->nmcd.dwDrawStage)
{
case CDDS_PREPAINT :
result = CDRF_NOTIFYITEMDRAW;
@@ -410,8 +404,8 @@ void CPanel::OnRefreshStatusBar()
{
sizeString = ConvertSizeToString(GetItemSize(realIndex));
NCOM::CPropVariant prop;
- if (_folder->GetProperty(realIndex, kpidLastWriteTime, &prop) == S_OK)
- dateString = ConvertPropertyToString(prop, kpidLastWriteTime, false);
+ if (_folder->GetProperty(realIndex, kpidMTime, &prop) == S_OK)
+ dateString = ConvertPropertyToString(prop, kpidMTime, false);
}
}
_statusBar.SetText(2, sizeString);
diff --git a/CPP/7zip/UI/FileManager/PanelMenu.cpp b/CPP/7zip/UI/FileManager/PanelMenu.cpp
index 8ebbc8ac..c881d8b8 100755
--- a/CPP/7zip/UI/FileManager/PanelMenu.cpp
+++ b/CPP/7zip/UI/FileManager/PanelMenu.cpp
@@ -5,6 +5,7 @@
#include "Windows/COM.h"
#include "Windows/PropVariant.h"
#include "Windows/Clipboard.h"
+#include "Windows/PropVariantConversions.h"
#include "../Common/PropIDUtils.h"
#include "../../PropID.h"
@@ -20,7 +21,7 @@
using namespace NWindows;
// {23170F69-40C1-278A-1000-000100020000}
-DEFINE_GUID(CLSID_CZipContextMenu,
+DEFINE_GUID(CLSID_CZipContextMenu,
0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00);
static const UINT kSevenZipStartMenuID = kPluginMenuStartID ;
@@ -50,18 +51,30 @@ void CPanel::InvokeSystemCommand(const char *command)
static const wchar_t *kSeparator = L"--------------------------------------\n";
static const wchar_t *kPropValueSeparator = L": ";
-static void AddPropertyString(PROPID propID, const wchar_t *nameBSTR,
+extern UString ConvertSizeToString(UInt64 value);
+
+static void AddPropertyString(PROPID propID, const wchar_t *nameBSTR,
const NCOM::CPropVariant &prop, UString &s)
{
if (prop.vt != VT_EMPTY)
{
- UString name = GetNameOfProperty(propID);
- if (name.IsEmpty() && nameBSTR != NULL)
- name = nameBSTR;
- if (name.IsEmpty())
- name = L"?";
-
- const UString val = ConvertPropertyToString(prop, propID);
+ const UString name = GetNameOfProperty(propID, nameBSTR);
+ UString val;
+
+ if ((
+ propID == kpidSize ||
+ propID == kpidPackSize ||
+ propID == kpidNumSubDirs ||
+ propID == kpidNumSubFiles ||
+ propID == kpidNumBlocks ||
+ propID == kpidPhySize ||
+ propID == kpidHeadersSize ||
+ propID == kpidClusterSize
+ ) && (prop.vt == VT_UI8 || prop.vt == VT_UI4))
+ val = ConvertSizeToString(ConvertPropVariantToUInt64(prop));
+ else
+ val = ConvertPropertyToString(prop, propID);
+
if (!val.IsEmpty())
{
s += name;
@@ -77,7 +90,7 @@ static void AddPropertyString(PROPID propID, const wchar_t *nameBSTR,
}
void CPanel::Properties()
-{
+{
CMyComPtr<IGetFolderArchiveProperties> getFolderArchiveProperties;
_folder.QueryInterface(IID_IGetFolderArchiveProperties, &getFolderArchiveProperties);
if (!getFolderArchiveProperties)
@@ -224,7 +237,7 @@ void CPanel::EditPaste()
s += names[i];
}
- MessageBoxW(0, s, L"", 0);
+ MessageBoxW(0, s, L"", 0);
*/
// InvokeSystemCommand("paste");
@@ -239,7 +252,7 @@ HRESULT CPanel::CreateShellContextMenu(
CMyComPtr<IShellFolder> desktopFolder;
RINOK(::SHGetDesktopFolder(&desktopFolder));
- if (!desktopFolder)
+ if (!desktopFolder)
{
// ShowMessage("Failed to get Desktop folder.");
return E_FAIL;
@@ -253,7 +266,7 @@ HRESULT CPanel::CreateShellContextMenu(
LPITEMIDLIST parentPidl;
DWORD eaten;
RINOK(desktopFolder->ParseDisplayName(
- GetParent(), 0, (wchar_t *)(const wchar_t *)folderPath,
+ GetParent(), 0, (wchar_t *)(const wchar_t *)folderPath,
&eaten, &parentPidl, 0));
// Get an IShellFolder for the folder
@@ -261,7 +274,7 @@ HRESULT CPanel::CreateShellContextMenu(
CMyComPtr<IShellFolder> parentFolder;
RINOK(desktopFolder->BindToObject(parentPidl,
0, IID_IShellFolder, (void**)&parentFolder));
- if (!parentFolder)
+ if (!parentFolder)
{
// ShowMessage("Invalid file name.");
return E_FAIL;
@@ -276,7 +289,7 @@ HRESULT CPanel::CreateShellContextMenu(
UString fileName = GetItemRelPath(operatedIndices[i]);
if (IsFSDrivesFolder())
fileName += L'\\';
- RINOK(parentFolder->ParseDisplayName(GetParent(), 0,
+ RINOK(parentFolder->ParseDisplayName(GetParent(), 0,
(wchar_t *)(const wchar_t *)fileName, &eaten, &pidl, 0));
pidls.Add(pidl);
}
@@ -287,7 +300,7 @@ HRESULT CPanel::CreateShellContextMenu(
temp.mkid.cb = 0;
/*
LPITEMIDLIST pidl;
- HRESULT result = parentFolder->ParseDisplayName(GetParent(), 0,
+ HRESULT result = parentFolder->ParseDisplayName(GetParent(), 0,
L".\\", &eaten, &pidl, 0);
if (result != NOERROR)
return;
@@ -297,9 +310,9 @@ HRESULT CPanel::CreateShellContextMenu(
// Get the IContextMenu for the file.
CMyComPtr<IContextMenu> cm;
- RINOK( parentFolder->GetUIObjectOf(GetParent(), pidls.Size(),
+ RINOK( parentFolder->GetUIObjectOf(GetParent(), pidls.Size(),
(LPCITEMIDLIST *)&pidls.Front(), IID_IContextMenu, 0, (void**)&cm));
- if (!cm)
+ if (!cm)
{
// ShowMessage("Unable to get context menu interface.");
return E_FAIL;
@@ -308,7 +321,7 @@ HRESULT CPanel::CreateShellContextMenu(
return S_OK;
}
-void CPanel::CreateSystemMenu(HMENU menuSpec,
+void CPanel::CreateSystemMenu(HMENU menuSpec,
const CRecordVector<UInt32> &operatedIndices,
CMyComPtr<IContextMenu> &systemContextMenu)
{
@@ -326,7 +339,7 @@ void CPanel::CreateSystemMenu(HMENU menuSpec,
ci.hwnd = GetParent();
/*
- if (Sender == GoBtn)
+ if (Sender == GoBtn)
{
// Verbs that can be used are cut, paste,
// properties, delete, and so on.
@@ -346,8 +359,8 @@ void CPanel::CreateSystemMenu(HMENU menuSpec,
ShowMessage(
"Error copying file to clipboard.");
- }
- else
+ }
+ else
*/
{
// HMENU hMenu = CreatePopupMenu();
@@ -381,7 +394,7 @@ void CPanel::CreateSystemMenu(HMENU menuSpec,
menu.InsertItem(0, true, menuItem);
}
/*
- if (Cmd < 100 && Cmd != 0)
+ if (Cmd < 100 && Cmd != 0)
{
ci.lpVerb = MAKEINTRESOURCE(Cmd - 1);
ci.lpParameters = "";
@@ -393,7 +406,7 @@ void CPanel::CreateSystemMenu(HMENU menuSpec,
// inserted menu items.
else
// Find the menu item.
- for (int i = 0; i < popupMenu1->Items->Count; i++)
+ for (int i = 0; i < popupMenu1->Items->Count; i++)
{
TMenuItem* menu = popupMenu1->Items->Items[i];
// Call its OnClick handler.
@@ -411,7 +424,7 @@ void CPanel::CreateFileMenu(HMENU menuSpec)
CreateFileMenu(menuSpec, _sevenZipContextMenu, _systemContextMenu, true);
}
-void CPanel::CreateSevenZipMenu(HMENU menuSpec,
+void CPanel::CreateSevenZipMenu(HMENU menuSpec,
const CRecordVector<UInt32> &operatedIndices,
CMyComPtr<IContextMenu> &sevenZipContextMenu)
{
@@ -443,7 +456,7 @@ void CPanel::CreateSevenZipMenu(HMENU menuSpec,
if (initContextMenu->InitContextMenu(currentFolderUnicode, &namePointers.Front(),
operatedIndices.Size()) == S_OK)
{
- HRESULT res = contextMenu->QueryContextMenu(menu, 0, kSevenZipStartMenuID,
+ HRESULT res = contextMenu->QueryContextMenu(menu, 0, kSevenZipStartMenuID,
kSystemStartMenuID - 1, 0);
sevenZipMenuCreated = (HRESULT_SEVERITY(res) == SEVERITY_SUCCESS);
if (sevenZipMenuCreated)
@@ -454,7 +467,7 @@ void CPanel::CreateSevenZipMenu(HMENU menuSpec,
}
}
-void CPanel::CreateFileMenu(HMENU menuSpec,
+void CPanel::CreateFileMenu(HMENU menuSpec,
CMyComPtr<IContextMenu> &sevenZipContextMenu,
CMyComPtr<IContextMenu> &systemContextMenu,
bool programMenu)
@@ -475,7 +488,13 @@ void CPanel::CreateFileMenu(HMENU menuSpec,
if (menu.GetItemCount() > 0)
menu.AppendItem(MF_SEPARATOR, 0, (LPCTSTR)0);
- LoadFileMenu(menu, menu.GetItemCount(), !operatedIndices.IsEmpty(), programMenu);
+ int i;
+ for (i = 0; i < operatedIndices.Size(); i++)
+ if (IsItemFolder(operatedIndices[i]))
+ break;
+ bool allAreFiles = (i == operatedIndices.Size());
+ LoadFileMenu(menu, menu.GetItemCount(), programMenu,
+ IsFSFolder(), operatedIndices.Size(), allAreFiles);
}
bool CPanel::InvokePluginCommand(int id)
@@ -483,7 +502,7 @@ bool CPanel::InvokePluginCommand(int id)
return InvokePluginCommand(id, _sevenZipContextMenu, _systemContextMenu);
}
-bool CPanel::InvokePluginCommand(int id,
+bool CPanel::InvokePluginCommand(int id,
IContextMenu *sevenZipContextMenu, IContextMenu *systemContextMenu)
{
UInt32 offset;
@@ -576,7 +595,7 @@ bool CPanel::OnContextMenu(HANDLE windowHandle, int xPos, int yPos)
CMyComPtr<IContextMenu> systemContextMenu;
CreateFileMenu(menu, sevenZipContextMenu, systemContextMenu, false);
- int result = menu.Track(TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD | TPM_NONOTIFY,
+ int result = menu.Track(TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD | TPM_NONOTIFY,
xPos, yPos, _listView);
if (result == 0)
diff --git a/CPP/7zip/UI/FileManager/PanelOperations.cpp b/CPP/7zip/UI/FileManager/PanelOperations.cpp
index 2cdabdc1..76de0c1a 100755
--- a/CPP/7zip/UI/FileManager/PanelOperations.cpp
+++ b/CPP/7zip/UI/FileManager/PanelOperations.cpp
@@ -28,51 +28,88 @@ using namespace NFile;
extern bool g_IsNT;
#endif
-struct CThreadDelete
+enum EFolderOpType
{
- CMyComPtr<IFolderOperations> FolderOperations;
+ FOLDER_TYPE_CREATE_FOLDER = 0,
+ FOLDER_TYPE_DELETE = 1,
+ FOLDER_TYPE_RENAME = 2
+};
+
+struct CThreadFolderOperations
+{
+ EFolderOpType OpType;
+ UString Name;
+ UInt32 Index;
CRecordVector<UInt32> Indices;
+
+ CMyComPtr<IFolderOperations> FolderOperations;
CMyComPtr<IProgress> UpdateCallback;
CUpdateCallback100Imp *UpdateCallbackSpec;
HRESULT Result;
- DWORD Process()
+ CThreadFolderOperations(EFolderOpType opType);
+
+ void Process()
{
NCOM::CComInitializer comInitializer;
UpdateCallbackSpec->ProgressDialog.WaitCreating();
- Result = FolderOperations->Delete(&Indices.Front(), Indices.Size(), UpdateCallback);
+
+ switch(OpType)
+ {
+ case FOLDER_TYPE_CREATE_FOLDER:
+ Result = FolderOperations->CreateFolder(Name, UpdateCallback);
+ break;
+ case FOLDER_TYPE_DELETE:
+ Result = FolderOperations->Delete(&Indices.Front(), Indices.Size(), UpdateCallback);
+ break;
+ case FOLDER_TYPE_RENAME:
+ Result = FolderOperations->Rename(Index, Name, UpdateCallback);
+ break;
+ default:
+ Result = E_FAIL;
+ }
UpdateCallbackSpec->ProgressDialog.MyClose();
- return 0;
}
static THREAD_FUNC_DECL MyThreadFunction(void *param)
{
- return ((CThreadDelete *)param)->Process();
+ ((CThreadFolderOperations *)param)->Process();
+ return 0;
}
};
-struct CThreadCreateFolder
+CThreadFolderOperations::CThreadFolderOperations(EFolderOpType opType): OpType(opType) {};
+
+static void DoOperation(CThreadFolderOperations &op, CPanel &panel, const UString &progressTitle)
{
- CMyComPtr<IFolderOperations> FolderOperations;
- UString Name;
- CMyComPtr<IProgress> UpdateCallback;
- CUpdateCallback100Imp *UpdateCallbackSpec;
- HRESULT Result;
-
- DWORD Process()
- {
- NCOM::CComInitializer comInitializer;
- UpdateCallbackSpec->ProgressDialog.WaitCreating();
- Result = FolderOperations->CreateFolder(Name, UpdateCallback);
- UpdateCallbackSpec->ProgressDialog.MyClose();
- return 0;
- }
-
- static THREAD_FUNC_DECL MyThreadFunction(void *param)
+ op.UpdateCallbackSpec = new CUpdateCallback100Imp;
+ op.UpdateCallback = op.UpdateCallbackSpec;
+
+ bool usePassword = false;
+ UString password;
+ if (panel._parentFolders.Size() > 0)
{
- return ((CThreadCreateFolder *)param)->Process();
+ const CFolderLink &fl = panel._parentFolders.Back();
+ usePassword = fl.UsePassword;
+ password = fl.Password;
}
-};
+
+ op.UpdateCallbackSpec->Init(panel.GetParent(), usePassword, password);
+
+ op.UpdateCallbackSpec->ProgressDialog.MainWindow = panel._mainWindow;
+ op.UpdateCallbackSpec->ProgressDialog.MainTitle = LangString(IDS_APP_TITLE, 0x03000000);
+ op.UpdateCallbackSpec->ProgressDialog.MainAddTitle = progressTitle + UString(L" ");
+
+ // op.FolderOperations = folderOperations;
+ // op.Index = realIndex;
+ // op.Name = newName;
+ // HRESULT result = folderOperations->Rename(realIndex, newName, 0);
+
+ NWindows::CThread thread;
+ if (thread.Create(CThreadFolderOperations::MyThreadFunction, &op) != S_OK)
+ throw 271824;
+ op.UpdateCallbackSpec->StartProgressDialog(progressTitle);
+}
#ifndef _UNICODE
typedef int (WINAPI * SHFileOperationWP)(LPSHFILEOPSTRUCTW lpFileOp);
@@ -87,7 +124,7 @@ void CPanel::DeleteItems(bool toRecycleBin)
return;
CSelectedState state;
SaveSelectedState(state);
- bool useInternalDelete = false;
+ bool useInternalDelete = false;
if (IsFSFolder() && toRecycleBin)
{
#ifndef _UNICODE
@@ -143,7 +180,7 @@ void CPanel::DeleteItems(bool toRecycleBin)
{
if (toRecycleBin)
{
- MessageBoxMyError(L"You can't send file with long path to Recycle Bin");
+ MessageBoxErrorLang(IDS_ERROR_LONG_PATH_TO_RECYCLE, 0x03020218);
return;
}
useInternalDelete = true;
@@ -190,7 +227,7 @@ void CPanel::DeleteItemsInternal(CRecordVector<UInt32> &indices)
CMyComPtr<IFolderOperations> folderOperations;
if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
{
- MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
+ MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
return;
}
@@ -214,35 +251,19 @@ void CPanel::DeleteItemsInternal(CRecordVector<UInt32> &indices)
else
{
title = LangString(IDS_CONFIRM_ITEMS_DELETE, 0x03020212);
- message = MyFormatNew(IDS_WANT_TO_DELETE_ITEMS, 0x03020215,
+ message = MyFormatNew(IDS_WANT_TO_DELETE_ITEMS, 0x03020215,
NumberToString(indices.Size()));
}
if (::MessageBoxW(GetParent(), message, title, MB_OKCANCEL | MB_ICONQUESTION) != IDOK)
return;
{
- CThreadDelete deleter;
- deleter.UpdateCallbackSpec = new CUpdateCallback100Imp;
- deleter.UpdateCallback = deleter.UpdateCallbackSpec;
- deleter.UpdateCallbackSpec->Init(GetParent(), false, L"");
-
- UString progressTitle = LangString(IDS_DELETING, 0x03020216);
-
- deleter.UpdateCallbackSpec->ProgressDialog.MainWindow = _mainWindow;
- deleter.UpdateCallbackSpec->ProgressDialog.MainTitle = LangString(IDS_APP_TITLE, 0x03000000);
- deleter.UpdateCallbackSpec->ProgressDialog.MainAddTitle = progressTitle + UString(L" ");
-
- deleter.FolderOperations = folderOperations;
- deleter.Indices = indices;
-
- NWindows::CThread thread;
- if (thread.Create(CThreadDelete::MyThreadFunction, &deleter) != S_OK)
- throw 271824;
- deleter.UpdateCallbackSpec->StartProgressDialog(progressTitle);
-
- HRESULT result = deleter.Result;
- if (result != S_OK)
- MessageBoxError(result, LangString(IDS_ERROR_DELETING, 0x03020217));
+ CThreadFolderOperations op(FOLDER_TYPE_DELETE);
+ op.FolderOperations = folderOperations;
+ op.Indices = indices;
+ DoOperation(op, *this, LangString(IDS_DELETING, 0x03020216));
+ if (op.Result != S_OK)
+ MessageBoxError(op.Result, LangString(IDS_ERROR_DELETING, 0x03020217));
}
RefreshTitleAlways();
}
@@ -265,7 +286,7 @@ BOOL CPanel::OnEndLabelEdit(LV_DISPINFOW * lpnmh)
CMyComPtr<IFolderOperations> folderOperations;
if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
{
- MessageBoxMyError(L"Renaming is not supported");
+ MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
return FALSE;
}
const UString newName = lpnmh->item.pszText;
@@ -277,12 +298,21 @@ BOOL CPanel::OnEndLabelEdit(LV_DISPINFOW * lpnmh)
if (realIndex == kParentIndex)
return FALSE;
const UString prefix = GetItemPrefix(realIndex);
- HRESULT result = folderOperations->Rename(realIndex, newName, 0);
- if (result != S_OK)
+
+
{
- MessageBoxError(result, LangString(IDS_ERROR_RENAMING, 0x03020221));
- return FALSE;
+ CThreadFolderOperations op(FOLDER_TYPE_RENAME);
+ op.FolderOperations = folderOperations;
+ op.Index = realIndex;
+ op.Name = newName;
+ DoOperation(op, *this, LangString(IDS_RENAMING, 0x03020220));
+ if (op.Result != S_OK)
+ {
+ MessageBoxError(op.Result, LangString(IDS_ERROR_RENAMING, 0x03020221));
+ return FALSE;
+ }
}
+
// Can't use RefreshListCtrl here.
// RefreshListCtrlSaveFocused();
_selectedState.FocusedName = prefix + newName;
@@ -291,7 +321,7 @@ BOOL CPanel::OnEndLabelEdit(LV_DISPINFOW * lpnmh)
// We need clear all items to disable GetText before Reload:
// number of items can change.
// _listView.DeleteAllItems();
- // But seems it can still call GetText (maybe for current item)
+ // But seems it can still call GetText (maybe for current item)
// so we can't delete items.
_dontShowMode = true;
@@ -305,7 +335,7 @@ void CPanel::CreateFolder()
CMyComPtr<IFolderOperations> folderOperations;
if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
{
- MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
+ MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
return;
}
CPanel::CDisableTimerProcessing disableTimerProcessing2(*this);
@@ -320,34 +350,17 @@ void CPanel::CreateFolder()
UString newName = comboDialog.Value;
- // HRESULT result = folderOperations->CreateFolder(newName, 0);
-
{
- CThreadCreateFolder upd;
- upd.UpdateCallbackSpec = new CUpdateCallback100Imp;
- upd.UpdateCallback = upd.UpdateCallbackSpec;
- upd.UpdateCallbackSpec->Init(GetParent(), false, L"");
-
- UString progressTitle = LangString(IDS_CREATE_FOLDER, 0x03020230);
-
- upd.UpdateCallbackSpec->ProgressDialog.MainWindow = _mainWindow;
- upd.UpdateCallbackSpec->ProgressDialog.MainTitle = LangString(IDS_APP_TITLE, 0x03000000);
- upd.UpdateCallbackSpec->ProgressDialog.MainAddTitle = progressTitle + UString(L" ");
-
- upd.FolderOperations = folderOperations;
- upd.Name = newName;
-
- NWindows::CThread thread;
- if (thread.Create(CThreadCreateFolder::MyThreadFunction, &upd) != S_OK)
- throw 271824;
- upd.UpdateCallbackSpec->StartProgressDialog(progressTitle);
+ CThreadFolderOperations op(FOLDER_TYPE_CREATE_FOLDER);
+ op.FolderOperations = folderOperations;
+ op.Name = newName;
+ DoOperation(op, *this, LangString(IDS_CREATE_FOLDER, 0x03020230));
- HRESULT result = upd.Result;
-
- if (result != S_OK)
- {
- MessageBoxError(result, LangString(IDS_CREATE_FOLDER_ERROR, 0x03020233));
- return;
+ if (op.Result != S_OK)
+ {
+ MessageBoxError(op.Result, LangString(IDS_CREATE_FOLDER_ERROR, 0x03020233));
+ return;
+ }
}
int pos = newName.Find(L'\\');
if (pos >= 0)
@@ -356,7 +369,6 @@ void CPanel::CreateFolder()
state.SelectedNames.Clear();
state.FocusedName = newName;
state.SelectFocused = true;
- }
RefreshTitleAlways();
RefreshListCtrl(state);
}
@@ -366,7 +378,7 @@ void CPanel::CreateFile()
CMyComPtr<IFolderOperations> folderOperations;
if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
{
- MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
+ MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
return;
}
CPanel::CDisableTimerProcessing disableTimerProcessing2(*this);
@@ -416,11 +428,11 @@ void CPanel::ChangeComment()
CMyComPtr<IFolderOperations> folderOperations;
if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
{
- MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
+ MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
return;
}
- UString comment;
+ UString comment;
{
NCOM::CPropVariant propVariant;
if (_folder->GetProperty(realIndex, kpidComment, &propVariant) != S_OK)
diff --git a/CPP/7zip/UI/FileManager/PanelSelect.cpp b/CPP/7zip/UI/FileManager/PanelSelect.cpp
index 4b726b1e..bbd4a187 100755
--- a/CPP/7zip/UI/FileManager/PanelSelect.cpp
+++ b/CPP/7zip/UI/FileManager/PanelSelect.cpp
@@ -97,7 +97,7 @@ void CPanel::OnInsert()
int nextIndex = focusedItem + 1;
if (nextIndex < _listView.GetItemCount())
{
- _listView.SetItemState(nextIndex, LVIS_FOCUSED | LVIS_SELECTED,
+ _listView.SetItemState(nextIndex, LVIS_FOCUSED | LVIS_SELECTED,
LVIS_FOCUSED | LVIS_SELECTED);
_listView.EnsureVisible(nextIndex, false);
}
@@ -151,7 +151,7 @@ void CPanel::UpdateSelection()
void CPanel::SelectSpec(bool selectMode)
{
CComboDialog comboDialog;
- comboDialog.Title = selectMode ?
+ comboDialog.Title = selectMode ?
LangString(IDS_SELECT, 0x03020250):
LangString(IDS_DESELECT, 0x03020251);
comboDialog.Static = LangString(IDS_SELECT_MASK, 0x03020252);
@@ -279,7 +279,7 @@ void CPanel::OnLeftClick(LPNMITEMACTIVATE itemActivate)
}
}
}
- else
+ else
{
_startGroupSelect = indexInList;
if ((itemActivate->uKeyFlags & LVKF_CONTROL) != 0)
diff --git a/CPP/7zip/UI/FileManager/PanelSort.cpp b/CPP/7zip/UI/FileManager/PanelSort.cpp
index c5fddcd6..7eabc9ef 100755
--- a/CPP/7zip/UI/FileManager/PanelSort.cpp
+++ b/CPP/7zip/UI/FileManager/PanelSort.cpp
@@ -20,7 +20,7 @@ static UString GetExtension(const UString &name)
int CALLBACK CompareItems2(LPARAM lParam1, LPARAM lParam2, LPARAM lpData)
{
- if(lpData == NULL)
+ if (lpData == NULL)
return 0;
CPanel *panel = (CPanel*)lpData;
@@ -55,7 +55,7 @@ int CALLBACK CompareItems2(LPARAM lParam1, LPARAM lParam2, LPARAM lpData)
/*
if (panel->_sortIndex == 1)
return MyCompare(file1.Size, file2.Size);
- return ::CompareFileTime(&file1.LastWriteTime, &file2.LastWriteTime);
+ return ::CompareFileTime(&file1.MTime, &file2.MTime);
*/
// PROPID propID = panel->_properties[panel->_sortIndex].ID;
@@ -65,7 +65,7 @@ int CALLBACK CompareItems2(LPARAM lParam1, LPARAM lParam2, LPARAM lpData)
// Name must be first property
panel->_folder->GetProperty((UINT32)lParam1, propID, &propVariant1);
panel->_folder->GetProperty((UINT32)lParam2, propID, &propVariant2);
- if(propVariant1.vt != propVariant2.vt)
+ if (propVariant1.vt != propVariant2.vt)
return 0; // It means some BUG
if (propVariant1.vt == VT_BSTR)
{
@@ -77,22 +77,17 @@ int CALLBACK CompareItems2(LPARAM lParam1, LPARAM lParam2, LPARAM lpData)
int CALLBACK CompareItems(LPARAM lParam1, LPARAM lParam2, LPARAM lpData)
{
- if(lpData == NULL)
- return 0;
- if (lParam1 == kParentIndex)
- return -1;
- if (lParam2 == kParentIndex)
- return 1;
+ if (lpData == NULL) return 0;
+ if (lParam1 == kParentIndex) return -1;
+ if (lParam2 == kParentIndex) return 1;
CPanel *panel = (CPanel*)lpData;
- bool isDirectory1 = panel->IsItemFolder((int)lParam1);
- bool isDirectory2 = panel->IsItemFolder((int)lParam2);
+ bool isDir1 = panel->IsItemFolder((int)lParam1);
+ bool isDir2 = panel->IsItemFolder((int)lParam2);
- if(isDirectory1 && (!isDirectory2))
- return -1;
- if((!isDirectory1) && isDirectory2)
- return 1;
+ if (isDir1 && !isDir2) return -1;
+ if (isDir2 && !isDir1) return 1;
int result = CompareItems2(lParam1, lParam2, lpData);
return panel->_ascending ? result: (-result);
@@ -102,7 +97,7 @@ int CALLBACK CompareItems(LPARAM lParam1, LPARAM lParam2, LPARAM lpData)
/*
void CPanel::SortItems(int index)
{
- if(index == _sortIndex)
+ if (index == _sortIndex)
_ascending = !_ascending;
else
{
@@ -112,9 +107,9 @@ void CPanel::SortItems(int index)
{
case kpidSize:
case kpidPackedSize:
- case kpidCreationTime:
- case kpidLastAccessTime:
- case kpidLastWriteTime:
+ case kpidCTime:
+ case kpidATime:
+ case kpidMTime:
_ascending = false;
break;
}
@@ -131,7 +126,7 @@ void CPanel::SortItemsWithPropID(PROPID propID)
*/
void CPanel::SortItemsWithPropID(PROPID propID)
{
- if(propID == _sortID)
+ if (propID == _sortID)
_ascending = !_ascending;
else
{
@@ -140,11 +135,11 @@ void CPanel::SortItemsWithPropID(PROPID propID)
switch (propID)
{
case kpidSize:
- case kpidPackedSize:
- case kpidCreationTime:
- case kpidLastAccessTime:
- case kpidLastWriteTime:
- _ascending = false;
+ case kpidPackSize:
+ case kpidCTime:
+ case kpidATime:
+ case kpidMTime:
+ _ascending = false;
break;
}
}
diff --git a/CPP/7zip/UI/FileManager/PanelSplitFile.cpp b/CPP/7zip/UI/FileManager/PanelSplitFile.cpp
index cbfc6c25..36146d7a 100755
--- a/CPP/7zip/UI/FileManager/PanelSplitFile.cpp
+++ b/CPP/7zip/UI/FileManager/PanelSplitFile.cpp
@@ -4,8 +4,8 @@
#include "resource.h"
-extern "C"
-{
+extern "C"
+{
#include "../../../../C/Alloc.h"
}
@@ -48,7 +48,7 @@ public:
struct CVolSeqName
{
UString UnchangedPart;
- UString ChangedPart;
+ UString ChangedPart;
CVolSeqName(): ChangedPart(L"000") {};
bool ParseName(const UString &name)
@@ -69,7 +69,7 @@ struct CVolSeqName
UString GetNextName()
{
- UString newName;
+ UString newName;
int i;
int numLetters = ChangedPart.Length();
for (i = numLetters - 1; i >= 0; i--)
@@ -172,18 +172,18 @@ struct CThreadSplit
return;
}
}
- DWORD Process()
+ void Process()
{
try { Process2(); }
catch(const wchar_t *s) { Error = s; }
catch(...) { Error = L"Error"; }
ProgressDialog->MyClose();
- return 0;
}
static THREAD_FUNC_DECL MyThreadFunction(void *param)
{
- return ((CThreadSplit *)param)->Process();
+ ((CThreadSplit *)param)->Process();
+ return 0;
}
};
@@ -193,7 +193,7 @@ void CApp::Split()
CPanel &srcPanel = Panels[srcPanelIndex];
if (!srcPanel.IsFSFolder())
{
- srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
+ srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
return;
}
CRecordVector<UInt32> indices;
@@ -202,13 +202,13 @@ void CApp::Split()
return;
if (indices.Size() != 1)
{
- srcPanel.MessageBox(L"Select one file");
+ srcPanel.MessageBoxErrorLang(IDS_SELECT_ONE_FILE, 0x03020A02);
return;
}
int index = indices[0];
if (srcPanel.IsItemFolder(index))
{
- srcPanel.MessageBox(L"Select one file");
+ srcPanel.MessageBoxErrorLang(IDS_SELECT_ONE_FILE, 0x03020A02);
return;
}
const UString itemName = srcPanel.GetItemName(index);
@@ -234,7 +234,7 @@ void CApp::Split()
}
if (fileInfo.Size <= splitDialog.VolumeSizes.Front())
{
- srcPanel.MessageBoxMyError(LangString(IDS_SPLIT_VOL_MUST_BE_SMALLER, 0x03020522));
+ srcPanel.MessageBoxErrorLang(IDS_SPLIT_VOL_MUST_BE_SMALLER, 0x03020522);
return;
}
const UInt64 numVolumes = GetNumberOfVolumes(fileInfo.Size, splitDialog.VolumeSizes);
@@ -242,8 +242,8 @@ void CApp::Split()
{
wchar_t s[32];
ConvertUInt64ToString(numVolumes, s);
- if (::MessageBoxW(srcPanel, MyFormatNew(IDS_SPLIT_CONFIRM_MESSAGE, 0x03020521, s),
- LangString(IDS_SPLIT_CONFIRM_TITLE, 0x03020520),
+ if (::MessageBoxW(srcPanel, MyFormatNew(IDS_SPLIT_CONFIRM_MESSAGE, 0x03020521, s),
+ LangString(IDS_SPLIT_CONFIRM_TITLE, 0x03020520),
MB_YESNOCANCEL | MB_ICONQUESTION | MB_TASKMODAL) != IDYES)
return;
}
@@ -301,117 +301,91 @@ void CApp::Split()
struct CThreadCombine
{
CProgressDialog *ProgressDialog;
+
UString InputDirPrefix;
- UString FirstVolumeName;
- UString OutputDirPrefix;
+ UStringVector Names;
+ UString OutputPath;
+ UInt64 TotalSize;
+
UString Error;
+ HRESULT Res;
void Process2()
{
- // NCOM::CComInitializer comInitializer;
- ProgressDialog->WaitCreating();
-
- CVolSeqName volSeqName;
- if (!volSeqName.ParseName(FirstVolumeName))
- throw L"Can not detect file as splitted file";
-
- UString nextName = InputDirPrefix + FirstVolumeName;
- UInt64 totalSize = 0;
- for (;;)
+ NFile::NIO::COutFile outFile;
+ if (!outFile.Create(OutputPath, false))
{
- NFile::NFind::CFileInfoW fileInfo;
- if (!NFile::NFind::FindFile(nextName, fileInfo))
- break;
- if (fileInfo.IsDirectory())
- break;
- totalSize += fileInfo.Size;
- nextName = InputDirPrefix + volSeqName.GetNextName();
+ Error = L"Can create open output file:\n" + OutputPath;
+ return;
}
- if (totalSize == 0)
- throw L"no data";
- ProgressDialog->ProgressSynch.SetProgress(totalSize, 0);
-
- if (!volSeqName.ParseName(FirstVolumeName))
- throw L"Can not detect file as splitted file";
- UString outName = volSeqName.UnchangedPart;
- while(!outName.IsEmpty())
- {
- int lastIndex = outName.Length() - 1;
- if (outName[lastIndex] != L'.')
- break;
- outName.Delete(lastIndex);
- }
- if (outName.IsEmpty())
- outName = L"file";
- NFile::NIO::COutFile outFile;
- if (!outFile.Create(OutputDirPrefix + outName, false))
- throw L"Can create open output file";
+ ProgressDialog->ProgressSynch.SetProgress(TotalSize, 0);
- NFile::NIO::CInFile inFile;
CMyBuffer bufferObject;
if (!bufferObject.Allocate(kBufSize))
throw L"Can not allocate buffer";
Byte *buffer = (Byte *)(void *)bufferObject;
UInt64 pos = 0;
- nextName = InputDirPrefix + FirstVolumeName;
- bool needOpen = true;
- for (;;)
+ for (int i = 0; i < Names.Size(); i++)
{
- if (needOpen)
+ NFile::NIO::CInFile inFile;
+ const UString nextName = InputDirPrefix + Names[i];
+ if (!inFile.Open(nextName))
{
- NFile::NFind::CFileInfoW fileInfo;
- if (!NFile::NFind::FindFile(nextName, fileInfo))
- break;
- if (fileInfo.IsDirectory())
- break;
- if (!inFile.Open(nextName))
- throw L"Can not open file";
- ProgressDialog->ProgressSynch.SetCurrentFileName(fileInfo.Name);
- nextName = InputDirPrefix + volSeqName.GetNextName();
- needOpen = false;
+ Error = L"Can not open input file:\n" + nextName;
+ return;
}
- UInt32 processedSize;
- if (!inFile.Read(buffer, kBufSize, processedSize))
- throw L"Can not read input file";
- if (processedSize == 0)
+ ProgressDialog->ProgressSynch.SetCurrentFileName(nextName);
+ for (;;)
{
- needOpen = true;
- continue;
+ UInt32 processedSize;
+ if (!inFile.Read(buffer, kBufSize, processedSize))
+ throw L"Can not read input file";
+ if (processedSize == 0)
+ break;
+ UInt32 needSize = processedSize;
+ if (!outFile.Write(buffer, needSize, processedSize) || needSize != processedSize)
+ throw L"Can not write output file";
+ pos += processedSize;
+ Res = ProgressDialog->ProgressSynch.SetPosAndCheckPaused(pos);
+ if (Res != S_OK)
+ return;
}
- UInt32 needSize = processedSize;
- if (!outFile.Write(buffer, needSize, processedSize))
- throw L"Can not write output file";
- if (needSize != processedSize)
- throw L"Can not write output file";
- pos += processedSize;
- HRESULT res = ProgressDialog->ProgressSynch.SetPosAndCheckPaused(pos);
- if (res != S_OK)
- return;
}
}
- DWORD Process()
+
+ void Process()
{
+ Res = S_OK;
+ ProgressDialog->WaitCreating();
try { Process2(); }
catch(const wchar_t *s) { Error = s; }
catch(...) { Error = L"Error";}
ProgressDialog->MyClose();
- return 0;
}
static THREAD_FUNC_DECL MyThreadFunction(void *param)
{
- return ((CThreadCombine *)param)->Process();
+ ((CThreadCombine *)param)->Process();
+ return 0;
}
};
+extern void AddValuePair2(UINT resourceID, UInt32 langID, UInt64 num, UInt64 size, UString &s);
+
+static void AddInfoFileName(const UString &name, UString &dest)
+{
+ dest += L"\n ";
+ dest += name;
+}
+
void CApp::Combine()
{
int srcPanelIndex = GetFocusedPanelIndex();
CPanel &srcPanel = Panels[srcPanelIndex];
if (!srcPanel.IsFSFolder())
{
- srcPanel.MessageBox(LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208));
+ srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
return;
}
CRecordVector<UInt32> indices;
@@ -421,7 +395,7 @@ void CApp::Combine()
int index = indices[0];
if (indices.Size() != 1 || srcPanel.IsItemFolder(index))
{
- srcPanel.MessageBox(LangString(IDS_COMBINE_SELECT_ONE_FILE, 0x03020620));
+ srcPanel.MessageBoxErrorLang(IDS_COMBINE_SELECT_ONE_FILE, 0x03020620);
return;
}
const UString itemName = srcPanel.GetItemName(index);
@@ -433,49 +407,115 @@ void CApp::Combine()
if (NumPanels > 1)
if (destPanel.IsFSFolder())
path = destPanel._currentFolderPrefix;
- CCopyDialog copyDialog;
- copyDialog.Value = path;
- copyDialog.Title = LangString(IDS_COMBINE, 0x03020600);
- copyDialog.Title += ' ';
- copyDialog.Title += srcPanel.GetItemRelPath(index);
-
- copyDialog.Static = LangString(IDS_COMBINE_TO, 0x03020601);;
- if (copyDialog.Create(srcPanel.GetParent()) == IDCANCEL)
- return;
+ CVolSeqName volSeqName;
+ if (!volSeqName.ParseName(itemName))
+ {
+ srcPanel.MessageBoxErrorLang(IDS_COMBINE_CANT_DETECT_SPLIT_FILE, 0x03020621);
+ return;
+ }
+
CThreadCombine combiner;
- // combiner.Panel = this;
-
+
+ UString nextName = itemName;
+ combiner.TotalSize = 0;
+ for (;;)
{
- CProgressDialog progressDialog;
- combiner.ProgressDialog = &progressDialog;
-
- UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000);
- UString title = LangString(IDS_COMBINING, 0x03020610);
-
- progressDialog.MainWindow = _window;
- progressDialog.MainTitle = progressWindowTitle;
- progressDialog.MainAddTitle = title + UString(L" ");
+ NFile::NFind::CFileInfoW fileInfo;
+ if (!NFile::NFind::FindFile(srcPath + nextName, fileInfo) || fileInfo.IsDir())
+ break;
+ combiner.Names.Add(nextName);
+ combiner.TotalSize += fileInfo.Size;
+ nextName = volSeqName.GetNextName();
+ }
+ if (combiner.Names.Size() == 1)
+ {
+ srcPanel.MessageBoxErrorLang(IDS_COMBINE_CANT_FIND_MORE_THAN_ONE_PART, 0x03020622);
+ return;
+ }
+
+ if (combiner.TotalSize == 0)
+ {
+ srcPanel.MessageBoxMyError(L"No data");
+ return;
+ }
+
+ UString info;
+ AddValuePair2(IDS_FILES_COLON, 0x02000320, combiner.Names.Size(), combiner.TotalSize, info);
+
+ info += L"\n";
+ info += srcPath;
+
+ int i;
+ for (i = 0; i < combiner.Names.Size() && i < 2; i++)
+ AddInfoFileName(combiner.Names[i], info);
+ if (i != combiner.Names.Size())
+ {
+ if (i + 1 != combiner.Names.Size())
+ AddInfoFileName(L"...", info);
+ AddInfoFileName(combiner.Names.Back(), info);
+ }
+
+ {
+ CCopyDialog copyDialog;
+ copyDialog.Value = path;
+ copyDialog.Title = LangString(IDS_COMBINE, 0x03020600);
+ copyDialog.Title += ' ';
+ copyDialog.Title += srcPanel.GetItemRelPath(index);
+ copyDialog.Static = LangString(IDS_COMBINE_TO, 0x03020601);
+ copyDialog.Info = info;
+ if (copyDialog.Create(srcPanel.GetParent()) == IDCANCEL)
+ return;
+ path = copyDialog.Value;
+ }
- path = copyDialog.Value;
NFile::NName::NormalizeDirPathPrefix(path);
if (!NFile::NDirectory::CreateComplexDirectory(path))
{
srcPanel.MessageBoxMyError(MyFormatNew(IDS_CANNOT_CREATE_FOLDER, 0x02000603, path));
return;
}
-
- combiner.InputDirPrefix = srcPath;
- combiner.FirstVolumeName = itemName;
- combiner.OutputDirPrefix = path;
-
- // CPanel::CDisableTimerProcessing disableTimerProcessing1(srcPanel);
- // CPanel::CDisableTimerProcessing disableTimerProcessing2(destPanel);
-
- NWindows::CThread thread;
- if (thread.Create(CThreadCombine::MyThreadFunction, &combiner) != S_OK)
- throw 271824;
- progressDialog.Create(title, _window);
+
+ UString outName = volSeqName.UnchangedPart;
+ while (!outName.IsEmpty())
+ {
+ int lastIndex = outName.Length() - 1;
+ if (outName[lastIndex] != L'.')
+ break;
+ outName.Delete(lastIndex);
+ }
+ if (outName.IsEmpty())
+ outName = L"file";
+
+ NFile::NFind::CFileInfoW fileInfo;
+ UString destFilePath = path + outName;
+ combiner.OutputPath = destFilePath;
+ if (NFile::NFind::FindFile(destFilePath, fileInfo))
+ {
+ srcPanel.MessageBoxMyError(MyFormatNew(IDS_FILE_EXIST, 0x03020A04, destFilePath));
+ return;
+ }
+
+ {
+ CProgressDialog progressDialog;
+ combiner.ProgressDialog = &progressDialog;
+
+ UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000);
+ UString title = LangString(IDS_COMBINING, 0x03020610);
+
+ progressDialog.MainWindow = _window;
+ progressDialog.MainTitle = progressWindowTitle;
+ progressDialog.MainAddTitle = title + UString(L" ");
+
+ combiner.InputDirPrefix = srcPath;
+
+ // CPanel::CDisableTimerProcessing disableTimerProcessing1(srcPanel);
+ // CPanel::CDisableTimerProcessing disableTimerProcessing2(destPanel);
+
+ NWindows::CThread thread;
+ if (thread.Create(CThreadCombine::MyThreadFunction, &combiner) != S_OK)
+ throw 271824;
+ progressDialog.Create(title, _window);
}
RefreshTitleAlways();
diff --git a/CPP/7zip/UI/FileManager/PasswordDialog.cpp b/CPP/7zip/UI/FileManager/PasswordDialog.cpp
index a366a61e..94e8219d 100755
--- a/CPP/7zip/UI/FileManager/PasswordDialog.cpp
+++ b/CPP/7zip/UI/FileManager/PasswordDialog.cpp
@@ -3,12 +3,12 @@
#include "StdAfx.h"
#include "PasswordDialog.h"
-#ifdef LANG
+#ifdef LANG
#include "LangUtils.h"
#endif
-#ifdef LANG
-static CIDLangPair kIDLangPairs[] =
+#ifdef LANG
+static CIDLangPair kIDLangPairs[] =
{
{ IDC_STATIC_PASSWORD_HEADER, 0x02000B01 },
{ IDC_CHECK_PASSWORD_SHOW, 0x02000B02 },
@@ -17,9 +17,9 @@ static CIDLangPair kIDLangPairs[] =
#endif
-bool CPasswordDialog::OnInit()
+bool CPasswordDialog::OnInit()
{
- #ifdef LANG
+ #ifdef LANG
LangSetWindowText(HWND(*this), 0x02000B00);
LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
#endif
diff --git a/CPP/7zip/UI/FileManager/PhysDriveFolder.cpp b/CPP/7zip/UI/FileManager/PhysDriveFolder.cpp
index d611e096..eb6674b3 100755
--- a/CPP/7zip/UI/FileManager/PhysDriveFolder.cpp
+++ b/CPP/7zip/UI/FileManager/PhysDriveFolder.cpp
@@ -2,8 +2,8 @@
#include "StdAfx.h"
-extern "C"
-{
+extern "C"
+{
#include "../../../../C/Alloc.h"
}
@@ -18,7 +18,7 @@ using namespace NWindows;
static const UInt32 kBufferSize = (4 << 20);
-static STATPROPSTG kProperties[] =
+static STATPROPSTG kProperties[] =
{
{ NULL, kpidName, VT_BSTR},
{ NULL, kpidSize, VT_UI8}
@@ -56,22 +56,16 @@ STDMETHODIMP CPhysDriveFolder::GetNumberOfItems(UInt32 *numItems)
STDMETHODIMP CPhysDriveFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT *value)
{
- NCOM::CPropVariant propVariant;
+ NCOM::CPropVariant prop;
if (itemIndex >= 1)
return E_INVALIDARG;
switch(propID)
{
- case kpidIsFolder:
- propVariant = false;
- break;
- case kpidName:
- propVariant = _name;
- break;
- case kpidSize:
- propVariant = _length;
- break;
+ case kpidIsDir: prop = false; break;
+ case kpidName: prop = _name; break;
+ case kpidSize: prop = _length; break;
}
- propVariant.Detach(value);
+ prop.Detach(value);
return S_OK;
}
@@ -93,7 +87,7 @@ STDMETHODIMP CPhysDriveFolder::GetNumberOfProperties(UInt32 *numProperties)
return S_OK;
}
-STDMETHODIMP CPhysDriveFolder::GetPropertyInfo(UInt32 index,
+STDMETHODIMP CPhysDriveFolder::GetPropertyInfo(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType)
{
if (index >= sizeof(kProperties) / sizeof(kProperties[0]))
@@ -136,13 +130,13 @@ STDMETHODIMP CPhysDriveFolder::Clone(IFolderFolder **resultFolder)
STDMETHODIMP CPhysDriveFolder::GetItemFullSize(UInt32 index, PROPVARIANT *value, IProgress * /* progress */)
{
- NCOM::CPropVariant propVariant;
+ NCOM::CPropVariant prop;
if (index >= 1)
return E_INVALIDARG;
UInt64 size = 0;
HRESULT result = GetLength(size);
- propVariant = size;
- propVariant.Detach(value);
+ prop = size;
+ prop.Detach(value);
return result;
}
@@ -235,7 +229,7 @@ HRESULT CopyFileSpec(LPCWSTR fromPath, LPCWSTR toPath, bool writeToDisk, UInt64
return S_OK;
}
-STDMETHODIMP CPhysDriveFolder::CopyTo(const UInt32 * /* indices */, UInt32 numItems,
+STDMETHODIMP CPhysDriveFolder::CopyTo(const UInt32 * /* indices */, UInt32 numItems,
const wchar_t *path, IFolderOperationsExtractCallback *callback)
{
if (numItems == 0)
@@ -260,7 +254,7 @@ STDMETHODIMP CPhysDriveFolder::CopyTo(const UInt32 * /* indices */, UInt32 numIt
Int32 writeAskResult;
CMyComBSTR destPathResult;
- RINOK(callback->AskWrite(GetFullPath(), BoolToInt(false), NULL, &fileSize,
+ RINOK(callback->AskWrite(GetFullPath(), BoolToInt(false), NULL, &fileSize,
destPath, &destPathResult, &writeAskResult));
if (!IntToBool(writeAskResult))
return S_OK;
@@ -275,8 +269,8 @@ STDMETHODIMP CPhysDriveFolder::CopyTo(const UInt32 * /* indices */, UInt32 numIt
// Move Operations
STDMETHODIMP CPhysDriveFolder::MoveTo(
- const UInt32 * /* indices */,
- UInt32 /* numItems */,
+ const UInt32 * /* indices */,
+ UInt32 /* numItems */,
const wchar_t * /* path */,
IFolderOperationsExtractCallback * /* callback */)
{
diff --git a/CPP/7zip/UI/FileManager/PhysDriveFolder.h b/CPP/7zip/UI/FileManager/PhysDriveFolder.h
index 996dda13..1f327966 100755
--- a/CPP/7zip/UI/FileManager/PhysDriveFolder.h
+++ b/CPP/7zip/UI/FileManager/PhysDriveFolder.h
@@ -1,14 +1,14 @@
// PhysDriveFolder.h
-#ifndef __PHYSDRIVEFOLDER_H
-#define __PHYSDRIVEFOLDER_H
+#ifndef __PHYSDRIVEFOLDER_H
+#define __PHYSDRIVEFOLDER_H
#include "Common/MyString.h"
#include "Common/MyCom.h"
#include "IFolder.h"
-class CPhysDriveFolder:
+class CPhysDriveFolder:
public IFolderFolder,
public IFolderWasChanged,
public IFolderOperations,
diff --git a/CPP/7zip/UI/FileManager/PluginInterface.h b/CPP/7zip/UI/FileManager/PluginInterface.h
index 7bef6950..905aff9a 100755
--- a/CPP/7zip/UI/FileManager/PluginInterface.h
+++ b/CPP/7zip/UI/FileManager/PluginInterface.h
@@ -6,36 +6,36 @@
#include "Common/MyString.h"
// {23170F69-40C1-278D-0000-000100010000}
-DEFINE_GUID(IID_IInitContextMenu,
+DEFINE_GUID(IID_IInitContextMenu,
0x23170F69, 0x40C1, 0x278D, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00);
MIDL_INTERFACE("23170F69-40C1-278D-0000-000100010000")
IInitContextMenu: public IUnknown
{
public:
- STDMETHOD(InitContextMenu)(const wchar_t *aFolder, const wchar_t **aNames, UINT32 aNumFiles) PURE;
+ STDMETHOD(InitContextMenu)(const wchar_t *aFolder, const wchar_t **aNames, UINT32 aNumFiles) PURE;
};
// {23170F69-40C1-278D-0000-000100020100}
-DEFINE_GUID(IID_IPluginOptionsCallback,
+DEFINE_GUID(IID_IPluginOptionsCallback,
0x23170F69, 0x40C1, 0x278D, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00);
MIDL_INTERFACE("23170F69-40C1-278D-0000-000100020000")
IPluginOptionsCallback: public IUnknown
{
public:
- STDMETHOD(GetProgramFolderPath)(BSTR *value) PURE;
- STDMETHOD(GetProgramPath)(BSTR *value) PURE;
- STDMETHOD(GetRegistryCUPath)(BSTR *value) PURE;
+ STDMETHOD(GetProgramFolderPath)(BSTR *value) PURE;
+ STDMETHOD(GetProgramPath)(BSTR *value) PURE;
+ STDMETHOD(GetRegistryCUPath)(BSTR *value) PURE;
};
// {23170F69-40C1-278D-0000-000100020000}
-DEFINE_GUID(IID_IPluginOptions,
+DEFINE_GUID(IID_IPluginOptions,
0x23170F69, 0x40C1, 0x278D, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00);
MIDL_INTERFACE("23170F69-40C1-278D-0000-000100020000")
IPluginOptions: public IUnknown
{
public:
- STDMETHOD(PluginOptions)(HWND hWnd, IPluginOptionsCallback *callback) PURE;
+ STDMETHOD(PluginOptions)(HWND hWnd, IPluginOptionsCallback *callback) PURE;
// STDMETHOD(GetFileExtensions)(BSTR *extensions) PURE;
};
diff --git a/CPP/7zip/UI/FileManager/PluginLoader.h b/CPP/7zip/UI/FileManager/PluginLoader.h
index 598a874b..f48c9e97 100755
--- a/CPP/7zip/UI/FileManager/PluginLoader.h
+++ b/CPP/7zip/UI/FileManager/PluginLoader.h
@@ -6,11 +6,11 @@
#include "Windows/DLL.h"
typedef UINT32 (WINAPI * CreateObjectPointer)(
- const GUID *clsID,
- const GUID *interfaceID,
+ const GUID *clsID,
+ const GUID *interfaceID,
void **outObject);
-class CPluginLibrary: public NWindows::NDLL::CLibrary
+class CPluginLibrary: public NWindows::NDLL::CLibrary
{
public:
HRESULT CreateManager(REFGUID clsID, IFolderManager **manager)
diff --git a/CPP/7zip/UI/FileManager/PluginsPage.cpp b/CPP/7zip/UI/FileManager/PluginsPage.cpp
index 3be15b18..3b205ce3 100755
--- a/CPP/7zip/UI/FileManager/PluginsPage.cpp
+++ b/CPP/7zip/UI/FileManager/PluginsPage.cpp
@@ -19,7 +19,7 @@
#include "PluginInterface.h"
-static CIDLangPair kIDLangPairs[] =
+static CIDLangPair kIDLangPairs[] =
{
{ IDC_PLUGINS_STATIC_PLUGINS, 0x03010101},
{ IDC_PLUGINS_BUTTON_OPTIONS, 0x03010110}
@@ -36,14 +36,7 @@ bool CPluginsPage::OnInit()
UINT32 newFlags = /*LVS_EX_CHECKBOXES | */ LVS_EX_FULLROWSELECT;
_listView.SetExtendedListViewStyle(newFlags, newFlags);
- UString title = L"Plugins";
- LVCOLUMNW column;
- column.mask = LVCF_WIDTH | LVCF_TEXT | LVCF_FMT | LVCF_SUBITEM;
- column.cx = 160;
- column.fmt = LVCFMT_LEFT;
- column.pszText = (LPWSTR)(LPCWSTR)title;
- column.iSubItem = 0;
- _listView.InsertColumn(0, &column);
+ _listView.InsertColumn(0, L"Plugins", 160);
ReadFileFolderPluginInfoList(_plugins);
@@ -104,7 +97,7 @@ bool CPluginsPage::OnButtonClicked(int buttonID, HWND buttonHWND)
return true;
}
-class CPluginOptionsCallback:
+class CPluginOptionsCallback:
public IPluginOptionsCallback,
public CMyUnknownImp
{
@@ -112,9 +105,9 @@ class CPluginOptionsCallback:
public:
MY_UNKNOWN_IMP
- STDMETHOD(GetProgramFolderPath)(BSTR *value);
- STDMETHOD(GetProgramPath)(BSTR *Value);
- STDMETHOD(GetRegistryCUPath)(BSTR *Value);
+ STDMETHOD(GetProgramFolderPath)(BSTR *value);
+ STDMETHOD(GetProgramPath)(BSTR *Value);
+ STDMETHOD(GetRegistryCUPath)(BSTR *Value);
void Init(const UString &pluginName)
{ _pluginName = pluginName; }
};
@@ -192,8 +185,8 @@ void CPluginsPage::OnButtonOptions()
pluginOptions->PluginOptions(HWND(*this), callback);
}
-bool CPluginsPage::OnNotify(UINT controlID, LPNMHDR lParam)
-{
+bool CPluginsPage::OnNotify(UINT controlID, LPNMHDR lParam)
+{
if (lParam->hwndFrom == HWND(_listView) && lParam->code == LVN_ITEMCHANGED)
{
const NMLISTVIEW *aNMListView = (const NMLISTVIEW *)lParam;
@@ -206,7 +199,7 @@ bool CPluginsPage::OnNotify(UINT controlID, LPNMHDR lParam)
}
return true;
}
- return CPropertyPage::OnNotify(controlID, lParam);
+ return CPropertyPage::OnNotify(controlID, lParam);
}
/*
diff --git a/CPP/7zip/UI/FileManager/PluginsPage.rc b/CPP/7zip/UI/FileManager/PluginsPage.rc
index 5a1f48ec..b4868aa3 100755
--- a/CPP/7zip/UI/FileManager/PluginsPage.rc
+++ b/CPP/7zip/UI/FileManager/PluginsPage.rc
@@ -12,8 +12,8 @@ CAPTION "Plugins"
MY_FONT
BEGIN
LTEXT "&Plugins:", IDC_PLUGINS_STATIC_PLUGINS, marg, marg, xSize2, 8
- CONTROL "List1", IDC_PLUGINS_LIST, "SysListView32", LVS_REPORT | LVS_SHOWSELALWAYS |
- LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,
+ CONTROL "List1", IDC_PLUGINS_LIST, "SysListView32", LVS_REPORT | LVS_SHOWSELALWAYS |
+ LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,
marg, 20, xSize2 - bXSize - 12, ySize2 - 12
PUSHBUTTON "Options...", IDC_PLUGINS_BUTTON_OPTIONS, (xSize - marg - bXSize), 20, bXSize, bYSize
END
diff --git a/CPP/7zip/UI/FileManager/ProgressDialog.cpp b/CPP/7zip/UI/FileManager/ProgressDialog.cpp
index b185868b..5be77a8f 100755
--- a/CPP/7zip/UI/FileManager/ProgressDialog.cpp
+++ b/CPP/7zip/UI/FileManager/ProgressDialog.cpp
@@ -11,17 +11,30 @@ using namespace NWindows;
static const UINT_PTR kTimerID = 3;
static const UINT kTimerElapse = 50;
-#ifdef LANG
+#ifdef LANG
#include "LangUtils.h"
#endif
-#ifdef LANG
-static CIDLangPair kIDLangPairs[] =
+#ifdef LANG
+static CIDLangPair kIDLangPairs[] =
{
{ IDCANCEL, 0x02000711 }
};
#endif
+HRESULT CProgressSynch::ProcessStopAndPause()
+{
+ for (;;)
+ {
+ if (GetStopped())
+ return E_ABORT;
+ if (!GetPaused())
+ break;
+ ::Sleep(100);
+ }
+ return S_OK;
+}
+
#ifndef _SFX
CProgressDialog::~CProgressDialog()
{
@@ -36,12 +49,12 @@ void CProgressDialog::AddToTitle(LPCWSTR s)
-bool CProgressDialog::OnInit()
+bool CProgressDialog::OnInit()
{
_range = UINT64(-1);
_prevPercentValue = -1;
- #ifdef LANG
+ #ifdef LANG
// LangSetWindowText(HWND(*this), 0x02000C00);
LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
#endif
@@ -53,7 +66,7 @@ bool CProgressDialog::OnInit()
return CModalDialog::OnInit();
}
-void CProgressDialog::OnCancel()
+void CProgressDialog::OnCancel()
{
ProgressSynch.SetStopped(true);
}
@@ -96,7 +109,7 @@ bool CProgressDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */)
total = 1;
int percentValue = (int)(completed * 100 / total);
- if (percentValue != _prevPercentValue)
+ if (percentValue != _prevPercentValue)
{
wchar_t s[64];
ConvertUInt64ToString(percentValue, s);
@@ -154,16 +167,16 @@ bool CProgressDialog::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
return CModalDialog::OnMessage(message, wParam, lParam);
}
-bool CProgressDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
-{
+bool CProgressDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
+{
switch(buttonID)
{
case IDCANCEL:
{
bool paused = ProgressSynch.GetPaused();;
ProgressSynch.SetPaused(true);
- int res = ::MessageBoxW(HWND(*this),
- L"Are you sure you want to cancel?",
+ int res = ::MessageBoxW(HWND(*this),
+ L"Are you sure you want to cancel?",
_title, MB_YESNOCANCEL);
ProgressSynch.SetPaused(paused);
if (res == IDCANCEL || res == IDNO)
diff --git a/CPP/7zip/UI/FileManager/ProgressDialog.h b/CPP/7zip/UI/FileManager/ProgressDialog.h
index 0ef2dc99..201aead7 100755
--- a/CPP/7zip/UI/FileManager/ProgressDialog.h
+++ b/CPP/7zip/UI/FileManager/ProgressDialog.h
@@ -19,6 +19,7 @@ class CProgressSynch
public:
CProgressSynch(): _stopped(false), _paused(false), _total(1), _completed(0) {}
+ HRESULT ProcessStopAndPause();
bool GetStopped()
{
NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
@@ -103,7 +104,7 @@ public:
CProgressDialog(): _timer(0)
#ifndef _SFX
- ,MainWindow(0)
+ ,MainWindow(0)
#endif
{
if (_dialogCreatedEvent.Create() != S_OK)
@@ -114,9 +115,9 @@ public:
INT_PTR Create(const UString &title, HWND wndParent = 0)
- {
+ {
_title = title;
- return CModalDialog::Create(IDD_DIALOG_PROGRESS, wndParent);
+ return CModalDialog::Create(IDD_DIALOG_PROGRESS, wndParent);
}
static const UINT kCloseMessage;
diff --git a/CPP/7zip/UI/FileManager/ProgressDialog2.cpp b/CPP/7zip/UI/FileManager/ProgressDialog2.cpp
index ae4752ef..0e24f187 100755
--- a/CPP/7zip/UI/FileManager/ProgressDialog2.cpp
+++ b/CPP/7zip/UI/FileManager/ProgressDialog2.cpp
@@ -10,12 +10,12 @@ using namespace NWindows;
static const UINT_PTR kTimerID = 3;
static const UINT kTimerElapse = 100;
-#ifdef LANG
+#ifdef LANG
#include "LangUtils.h"
#endif
-#ifdef LANG
-static CIDLangPair kIDLangPairs[] =
+#ifdef LANG
+static CIDLangPair kIDLangPairs[] =
{
{ IDCANCEL, 0x02000C00 },
{ IDC_PROGRESS_ELAPSED, 0x02000C01 },
@@ -33,16 +33,22 @@ static CIDLangPair kIDLangPairs[] =
};
#endif
-HRESULT CProgressSynch::SetPosAndCheckPaused(UInt64 completed)
+HRESULT CProgressSynch::ProcessStopAndPause()
{
for (;;)
{
- if(GetStopped())
+ if (GetStopped())
return E_ABORT;
- if(!GetPaused())
+ if (!GetPaused())
break;
::Sleep(100);
}
+ return S_OK;
+}
+
+HRESULT CProgressSynch::SetPosAndCheckPaused(UInt64 completed)
+{
+ RINOK(ProcessStopAndPause());
SetPos(completed);
return S_OK;
}
@@ -62,7 +68,7 @@ void CProgressDialog::AddToTitle(LPCWSTR s)
}
static const int kTitleFileNameSizeLimit = 36;
-static const int kCurrentFileNameSizeLimit = 68;
+static const int kCurrentFileNameSizeLimit = 70;
static void ReduceString(UString &s, int size)
{
@@ -71,7 +77,7 @@ static void ReduceString(UString &s, int size)
}
#endif
-bool CProgressDialog::OnInit()
+bool CProgressDialog::OnInit()
{
_range = (UInt64)(Int64)(-1);
_prevPercentValue = UInt32(-1);
@@ -83,7 +89,7 @@ bool CProgressDialog::OnInit()
_elapsedTime = 0;
_foreground = true;
- #ifdef LANG
+ #ifdef LANG
// LangSetWindowText(HWND(*this), 0x02000C00);
LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
#endif
@@ -110,7 +116,7 @@ bool CProgressDialog::OnInit()
return CModalDialog::OnInit();
}
-void CProgressDialog::OnCancel()
+void CProgressDialog::OnCancel()
{
ProgressSynch.SetStopped(true);
}
@@ -161,9 +167,9 @@ void CProgressDialog::SetPos(UInt64 pos)
static void GetTimeString(UInt64 timeValue, TCHAR *s)
{
- wsprintf(s, TEXT("%02d:%02d:%02d"),
+ wsprintf(s, TEXT("%02d:%02d:%02d"),
UInt32(timeValue / 3600),
- UInt32((timeValue / 60) % 60),
+ UInt32((timeValue / 60) % 60),
UInt32(timeValue % 60));
}
@@ -235,7 +241,8 @@ bool CProgressDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */)
}
// if (elapsedChanged)
{
- UInt64 speedB = (completed * 1000) / _elapsedTime;
+ UInt32 elapsedTime = (_elapsedTime == 0) ? 1 : _elapsedTime;
+ UInt64 speedB = (completed * 1000) / elapsedTime;
UInt64 speedKB = speedB / 1024;
UInt64 speedMB = speedKB / 1024;
const UInt32 kLimit1 = 10;
@@ -263,7 +270,7 @@ bool CProgressDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */)
needRedraw = true;
}
}
- else
+ else
{
if (_prevMode != kSpeedBytes || speedB != _prevSpeed)
{
@@ -284,7 +291,7 @@ bool CProgressDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */)
UInt32 percentValue = (UInt32)(completed * 100 / total);
UString titleName;
ProgressSynch.GetTitleFileName(titleName);
- if (percentValue != _prevPercentValue || _prevTitleName != titleName)
+ if (percentValue != _prevPercentValue || _prevTitleName != titleName)
{
_prevPercentValue = percentValue;
SetTitleText();
@@ -329,8 +336,19 @@ bool CProgressDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */)
ProgressSynch.GetCurrentFileName(fileName);
if (_prevFileName != fileName)
{
- ReduceString(fileName, kCurrentFileNameSizeLimit);
- SetItemText(IDC_PROGRESS_FILE_NAME, fileName);
+ int slashPos = fileName.ReverseFind(L'\\');
+ UString s1, s2;
+ if (slashPos >= 0)
+ {
+ s1 = fileName.Left(slashPos + 1);
+ s2 = fileName.Mid(slashPos + 1);
+ }
+ else
+ s2 = fileName;
+ ReduceString(s1, kCurrentFileNameSizeLimit);
+ ReduceString(s2, kCurrentFileNameSizeLimit);
+ UString s = s1 + L"\n" + s2;
+ SetItemText(IDC_PROGRESS_FILE_NAME, s);
_prevFileName == fileName;
}
@@ -418,7 +436,7 @@ void CProgressDialog::SetTitleText()
void CProgressDialog::SetPauseText()
{
- SetItemText(IDC_BUTTON_PAUSE, ProgressSynch.GetPaused() ?
+ SetItemText(IDC_BUTTON_PAUSE, ProgressSynch.GetPaused() ?
continueString : pauseString);
SetTitleText();
}
@@ -436,8 +454,8 @@ void CProgressDialog::OnPauseButton()
void CProgressDialog::SetPriorityText()
{
- SetItemText(IDC_BUTTON_PROGRESS_PRIORITY, _foreground ?
- backgroundString :
+ SetItemText(IDC_BUTTON_PROGRESS_PRIORITY, _foreground ?
+ backgroundString :
foregroundString);
SetTitleText();
}
@@ -450,8 +468,8 @@ void CProgressDialog::OnPriorityButton()
SetPriorityText();
}
-bool CProgressDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
-{
+bool CProgressDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
+{
switch(buttonID)
{
case IDCANCEL:
@@ -460,8 +478,8 @@ bool CProgressDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
// ProgressSynch.SetPaused(true);
if (!paused)
OnPauseButton();
- int res = ::MessageBoxW(HWND(*this),
- LangString(IDS_PROGRESS_ASK_CANCEL, 0x02000C30),
+ int res = ::MessageBoxW(HWND(*this),
+ LangString(IDS_PROGRESS_ASK_CANCEL, 0x02000C30),
_title, MB_YESNOCANCEL);
// ProgressSynch.SetPaused(paused);
if (!paused)
diff --git a/CPP/7zip/UI/FileManager/ProgressDialog2.h b/CPP/7zip/UI/FileManager/ProgressDialog2.h
index 9acaf9de..e838ae25 100755
--- a/CPP/7zip/UI/FileManager/ProgressDialog2.h
+++ b/CPP/7zip/UI/FileManager/ProgressDialog2.h
@@ -25,11 +25,11 @@ class CProgressSynch
UString TitleFileName;
UString CurrentFileName;
public:
- CProgressSynch():
- _stopped(false), _paused(false),
- _total((UInt64)(Int64)-1),
+ CProgressSynch():
+ _stopped(false), _paused(false),
+ _total((UInt64)(Int64)-1),
_completed(0),
- _totalFiles((UInt64)(Int64)-1),
+ _totalFiles((UInt64)(Int64)-1),
_completedFiles(0),
_inSize((UInt64)(Int64)-1),
_outSize((UInt64)(Int64)-1)
@@ -84,9 +84,10 @@ public:
NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
_completedFiles = value;
}
+ HRESULT ProcessStopAndPause();
HRESULT SetPosAndCheckPaused(UInt64 completed);
- void GetProgress(UInt64 &total, UInt64 &completed,
- UInt64 &totalFiles, UInt64 &completedFiles,
+ void GetProgress(UInt64 &total, UInt64 &completed,
+ UInt64 &totalFiles, UInt64 &completedFiles,
UInt64 &inSize, UInt64 &outSize)
{
NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
@@ -211,9 +212,9 @@ public:
INT_PTR Create(const UString &title, HWND wndParent = 0)
- {
+ {
_title = title;
- return CModalDialog::Create(IDD_DIALOG_PROGRESS, wndParent);
+ return CModalDialog::Create(IDD_DIALOG_PROGRESS, wndParent);
}
static const UINT kCloseMessage;
diff --git a/CPP/7zip/UI/FileManager/ProgressDialog2.rc b/CPP/7zip/UI/FileManager/ProgressDialog2.rc
index 58cdec36..92b970f6 100755
--- a/CPP/7zip/UI/FileManager/ProgressDialog2.rc
+++ b/CPP/7zip/UI/FileManager/ProgressDialog2.rc
@@ -2,7 +2,7 @@
#include "../../GuiCommon.rc"
#define xSize2 320
-#define ySize2 98
+#define ySize2 110
#define xSize (xSize2 + marg + marg)
#define ySize (ySize2 + marg + marg)
@@ -36,7 +36,7 @@
#define y3 (y2 + 11)
-IDD_DIALOG_PROGRESS DIALOG 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE | WS_MINIMIZEBOX
+IDD_DIALOG_PROGRESS DIALOG 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE | WS_MINIMIZEBOX
CAPTION "Progress"
MY_FONT
BEGIN
@@ -63,12 +63,12 @@ BEGIN
RTEXT "", IDC_PROGRESS_UNPACKED_VALUE, x3, y2, x3Size, 8
RTEXT "", IDC_PROGRESS_PACKED_VALUE, x3, y3, x3Size, 8
- LTEXT "", IDC_PROGRESS_FILE_NAME, marg, bYPos - 30, xSize2, 8, SS_NOPREFIX
+ LTEXT "", IDC_PROGRESS_FILE_NAME, marg, bYPos - 42, xSize2, 21, SS_NOPREFIX | SS_LEFTNOWORDWRAP
CONTROL "Progress1", IDC_PROGRESS1, "msctls_progress32", PBS_SMOOTH | WS_BORDER, marg, bYPos - 20, xSize2, 13
END
-STRINGTABLE DISCARDABLE
+STRINGTABLE DISCARDABLE
BEGIN
IDS_PROGRESS_PAUSED "Paused"
IDS_PROGRESS_FOREGROUND "&Foreground"
diff --git a/CPP/7zip/UI/FileManager/PropertyName.cpp b/CPP/7zip/UI/FileManager/PropertyName.cpp
index fb8f707e..cb4edfc2 100755
--- a/CPP/7zip/UI/FileManager/PropertyName.cpp
+++ b/CPP/7zip/UI/FileManager/PropertyName.cpp
@@ -2,32 +2,35 @@
#include "StdAfx.h"
-#include "../../PropID.h"
+#include "Common/IntToString.h"
#include "Windows/ResourceString.h"
+
+#include "../../PropID.h"
+
#include "resource.h"
-#include "PropertyName.h"
#include "PropertyNameRes.h"
#include "LangUtils.h"
+#include "PropertyName.h"
struct CPropertyIDNamePair
{
PROPID PropID;
UINT ResourceID;
- UINT LangID;
+ UInt32 LangID;
};
-static CPropertyIDNamePair kPropertyIDNamePairs[] =
+static CPropertyIDNamePair kPropertyIDNamePairs[] =
{
{ kpidPath, IDS_PROPERTY_PATH, 0x02000203 },
{ kpidName, IDS_PROPERTY_NAME, 0x02000204 },
- // { kpidExtension, L"Extension" },
- { kpidIsFolder, IDS_PROPERTY_IS_FOLDER, 0x02000206},
+ { kpidExtension, IDS_PROPERTY_EXTENSION, 0x02000205 },
+ { kpidIsDir, IDS_PROPERTY_IS_FOLDER, 0x02000206},
{ kpidSize, IDS_PROPERTY_SIZE, 0x02000207},
- { kpidPackedSize, IDS_PROPERTY_PACKED_SIZE, 0x02000208 },
- { kpidAttributes, IDS_PROPERTY_ATTRIBUTES, 0x02000209 },
- { kpidCreationTime, IDS_PROPERTY_CREATION_TIME, 0x0200020A },
- { kpidLastAccessTime, IDS_PROPERTY_LAST_ACCESS_TIME, 0x0200020B },
- { kpidLastWriteTime, IDS_PROPERTY_LAST_WRITE_TIME, 0x0200020C },
+ { kpidPackSize, IDS_PROPERTY_PACKED_SIZE, 0x02000208 },
+ { kpidAttrib, IDS_PROPERTY_ATTRIBUTES, 0x02000209 },
+ { kpidCTime, IDS_PROPERTY_CTIME, 0x0200020A },
+ { kpidATime, IDS_PROPERTY_ATIME, 0x0200020B },
+ { kpidMTime, IDS_PROPERTY_MTIME, 0x0200020C },
{ kpidSolid, IDS_PROPERTY_SOLID, 0x0200020D },
{ kpidCommented, IDS_PROPERTY_C0MMENTED, 0x0200020E },
{ kpidEncrypted, IDS_PROPERTY_ENCRYPTED, 0x0200020F },
@@ -46,7 +49,7 @@ static CPropertyIDNamePair kPropertyIDNamePairs[] =
{ kpidComment, IDS_PROPERTY_COMMENT, 0x0200021C },
{ kpidPosition, IDS_PROPERTY_POSITION, 0x0200021D },
{ kpidPrefix, IDS_PROPERTY_PREFIX, 0x0200021E },
- { kpidNumSubFolders, IDS_PROPERTY_FOLDERS, 0x0200021F },
+ { kpidNumSubDirs, IDS_PROPERTY_FOLDERS, 0x0200021F },
{ kpidNumSubFiles, IDS_PROPERTY_FILES, 0x02000220 },
{ kpidUnpackVer, IDS_PROPERTY_VERSION, 0x02000221},
{ kpidVolume, IDS_PROPERTY_VOLUME, 0x02000222},
@@ -56,8 +59,17 @@ static CPropertyIDNamePair kPropertyIDNamePairs[] =
{ kpidNumBlocks, IDS_PROPERTY_NUM_BLOCKS, 0x02000226},
{ kpidNumVolumes, IDS_PROPERTY_NUM_VOLUMES, 0x02000227},
+ { kpidBit64, IDS_PROPERTY_BIT64, 0x02000229},
+ { kpidBigEndian, IDS_PROPERTY_BIG_ENDIAN, 0x0200022A},
+ { kpidCpu, IDS_PROPERTY_CPU, 0x0200022B},
+ { kpidPhySize, IDS_PROPERTY_PHY_SIZE, 0x0200022C},
+ { kpidHeadersSize, IDS_PROPERTY_HEADERS_SIZE, 0x0200022D},
+ { kpidChecksum, IDS_PROPERTY_CHECKSUM, 0x0200022E},
+ { kpidCharacts, IDS_PROPERTY_CHARACTS, 0x0200022F},
+ { kpidVa, IDS_PROPERTY_VA, 0x02000230},
+
{ kpidTotalSize, IDS_PROPERTY_TOTAL_SIZE, 0x03031100 },
- { kpidFreeSpace, IDS_PROPERTY_FREE_SPACE, 0x03031101 },
+ { kpidFreeSpace, IDS_PROPERTY_FREE_SPACE, 0x03031101 },
{ kpidClusterSize, IDS_PROPERTY_CLUSTER_SIZE, 0x03031102},
{ kpidVolumeName, IDS_PROPERTY_VOLUME_NAME, 0x03031103 },
@@ -68,16 +80,22 @@ static CPropertyIDNamePair kPropertyIDNamePairs[] =
int FindProperty(PROPID propID)
{
for (int i = 0; i < sizeof(kPropertyIDNamePairs) / sizeof(kPropertyIDNamePairs[0]); i++)
- if(kPropertyIDNamePairs[i].PropID == propID)
+ if (kPropertyIDNamePairs[i].PropID == propID)
return i;
return -1;
}
-UString GetNameOfProperty(PROPID propID)
+UString GetNameOfProperty(PROPID propID, const wchar_t *name)
{
int index = FindProperty(propID);
if (index < 0)
- return UString();
+ {
+ if (name)
+ return name;
+ wchar_t s[32];
+ ConvertUInt64ToString(propID, s);
+ return s;
+ }
const CPropertyIDNamePair &pair = kPropertyIDNamePairs[index];
return LangString(pair.ResourceID, pair.LangID);
}
diff --git a/CPP/7zip/UI/FileManager/PropertyName.h b/CPP/7zip/UI/FileManager/PropertyName.h
index 413d2343..95e9dc9b 100755
--- a/CPP/7zip/UI/FileManager/PropertyName.h
+++ b/CPP/7zip/UI/FileManager/PropertyName.h
@@ -5,6 +5,6 @@
#include "Common/MyString.h"
-UString GetNameOfProperty(PROPID propID);
+UString GetNameOfProperty(PROPID propID, const wchar_t *name);
#endif
diff --git a/CPP/7zip/UI/FileManager/PropertyName.rc b/CPP/7zip/UI/FileManager/PropertyName.rc
index 94171ee3..ad8a9012 100755
--- a/CPP/7zip/UI/FileManager/PropertyName.rc
+++ b/CPP/7zip/UI/FileManager/PropertyName.rc
@@ -11,9 +11,9 @@ BEGIN
IDS_PROPERTY_SIZE "Size"
IDS_PROPERTY_PACKED_SIZE "Packed Size"
IDS_PROPERTY_ATTRIBUTES "Attributes"
- IDS_PROPERTY_CREATION_TIME "Created"
- IDS_PROPERTY_LAST_ACCESS_TIME "Accessed"
- IDS_PROPERTY_LAST_WRITE_TIME "Modified"
+ IDS_PROPERTY_CTIME "Created"
+ IDS_PROPERTY_ATIME "Accessed"
+ IDS_PROPERTY_MTIME "Modified"
IDS_PROPERTY_SOLID "Solid"
IDS_PROPERTY_C0MMENTED "Commented"
IDS_PROPERTY_ENCRYPTED "Encrypted"
@@ -42,4 +42,12 @@ BEGIN
IDS_PROPERTY_NUM_BLOCKS "Blocks"
IDS_PROPERTY_NUM_VOLUMES "Volumes"
+ IDS_PROPERTY_BIT64 "64-bit"
+ IDS_PROPERTY_BIG_ENDIAN "Big-endian"
+ IDS_PROPERTY_CPU "CPU"
+ IDS_PROPERTY_PHY_SIZE "Physical Size"
+ IDS_PROPERTY_HEADERS_SIZE "Headers Size"
+ IDS_PROPERTY_CHECKSUM "Checksum"
+ IDS_PROPERTY_CHARACTS "Characteristics"
+ IDS_PROPERTY_VA "Va"
END
diff --git a/CPP/7zip/UI/FileManager/PropertyNameRes.h b/CPP/7zip/UI/FileManager/PropertyNameRes.h
index 80c9637f..74d535ac 100755
--- a/CPP/7zip/UI/FileManager/PropertyNameRes.h
+++ b/CPP/7zip/UI/FileManager/PropertyNameRes.h
@@ -5,9 +5,9 @@
#define IDS_PROPERTY_SIZE 7
#define IDS_PROPERTY_PACKED_SIZE 8
#define IDS_PROPERTY_ATTRIBUTES 9
-#define IDS_PROPERTY_CREATION_TIME 10
-#define IDS_PROPERTY_LAST_ACCESS_TIME 11
-#define IDS_PROPERTY_LAST_WRITE_TIME 12
+#define IDS_PROPERTY_CTIME 10
+#define IDS_PROPERTY_ATIME 11
+#define IDS_PROPERTY_MTIME 12
#define IDS_PROPERTY_SOLID 13
#define IDS_PROPERTY_C0MMENTED 14
#define IDS_PROPERTY_ENCRYPTED 15
@@ -35,3 +35,12 @@
#define IDS_PROPERTY_LINKS 37
#define IDS_PROPERTY_NUM_BLOCKS 38
#define IDS_PROPERTY_NUM_VOLUMES 39
+
+#define IDS_PROPERTY_BIT64 41
+#define IDS_PROPERTY_BIG_ENDIAN 42
+#define IDS_PROPERTY_CPU 43
+#define IDS_PROPERTY_PHY_SIZE 44
+#define IDS_PROPERTY_HEADERS_SIZE 45
+#define IDS_PROPERTY_CHECKSUM 46
+#define IDS_PROPERTY_CHARACTS 47
+#define IDS_PROPERTY_VA 48
diff --git a/CPP/7zip/UI/FileManager/RegistryAssociations.cpp b/CPP/7zip/UI/FileManager/RegistryAssociations.cpp
index a03762ef..72153f9d 100755
--- a/CPP/7zip/UI/FileManager/RegistryAssociations.cpp
+++ b/CPP/7zip/UI/FileManager/RegistryAssociations.cpp
@@ -37,7 +37,7 @@ bool ReadInternalAssociation(const wchar_t *ext, CExtInfo &extInfo)
{
NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
CKey key;
- if(key.Open(HKEY_CURRENT_USER, GetAssociationsPath() + CSysString('\\') +
+ if(key.Open(HKEY_CURRENT_USER, GetAssociationsPath() + CSysString('\\') +
CSysString(GetSystemString(ext)), KEY_READ) != ERROR_SUCCESS)
return false;
UString pluginsString;
@@ -94,7 +94,7 @@ void WriteInternalAssociations(const CObjectVector<CExtInfo> &items)
}
///////////////////////////////////
-// External
+// External
static const TCHAR *kShellNewKeyName = TEXT("ShellNew");
static const TCHAR *kShellNewDataValueName = TEXT("Data");
@@ -187,8 +187,8 @@ void DeleteShellExtensionInfo(const CSysString &extension)
}
void AddShellExtensionInfo(const CSysString &extension,
- const UString &programTitle,
- const UString &programOpenCommand,
+ const UString &programTitle,
+ const UString &programOpenCommand,
const UString &iconPath, int iconIndex,
const void *shellNewData, int shellNewDataSize)
{
@@ -243,7 +243,7 @@ void AddShellExtensionInfo(const CSysString &extension,
/*
static const TCHAR *kContextMenuKeyName = TEXT("\\shellex\\ContextMenuHandlers\\7-ZIP");
-static const TCHAR *kContextMenuHandlerCLASSIDValue =
+static const TCHAR *kContextMenuHandlerCLASSIDValue =
TEXT("{23170F69-40C1-278A-1000-000100020000}");
static const TCHAR *kRootKeyNameForFile = TEXT("*");
static const TCHAR *kRootKeyNameForFolder = TEXT("Folder");
@@ -265,7 +265,7 @@ static bool CheckContextMenuHandlerCommon(const CSysString &aKeyName)
}
bool CheckContextMenuHandler()
-{
+{
return CheckContextMenuHandlerCommon(kRootKeyNameForFile) &&
CheckContextMenuHandlerCommon(kRootKeyNameForFolder);
}
@@ -279,8 +279,8 @@ static void DeleteContextMenuHandlerCommon(const CSysString &aKeyName)
}
void DeleteContextMenuHandler()
-{
- DeleteContextMenuHandlerCommon(kRootKeyNameForFile);
+{
+ DeleteContextMenuHandlerCommon(kRootKeyNameForFile);
DeleteContextMenuHandlerCommon(kRootKeyNameForFolder);
}
@@ -294,8 +294,8 @@ static void AddContextMenuHandlerCommon(const CSysString &aKeyName)
}
void AddContextMenuHandler()
-{
- AddContextMenuHandlerCommon(kRootKeyNameForFile);
+{
+ AddContextMenuHandlerCommon(kRootKeyNameForFile);
AddContextMenuHandlerCommon(kRootKeyNameForFolder);
}
*/
diff --git a/CPP/7zip/UI/FileManager/RegistryAssociations.h b/CPP/7zip/UI/FileManager/RegistryAssociations.h
index c1a64c96..2516fd2b 100755
--- a/CPP/7zip/UI/FileManager/RegistryAssociations.h
+++ b/CPP/7zip/UI/FileManager/RegistryAssociations.h
@@ -19,12 +19,12 @@ namespace NRegistryAssociations {
bool CheckShellExtensionInfo(const CSysString &extension, UString &iconPath, int &iconIndex);
- // void ReadCompressionInfo(NZipSettings::NCompression::CInfo &anInfo,
+ // void ReadCompressionInfo(NZipSettings::NCompression::CInfo &anInfo,
void DeleteShellExtensionInfo(const CSysString &extension);
void AddShellExtensionInfo(const CSysString &extension,
- const UString &programTitle,
- const UString &programOpenCommand,
+ const UString &programTitle,
+ const UString &programOpenCommand,
const UString &iconPath, int iconIndex,
const void *shellNewData, int shellNewDataSize);
diff --git a/CPP/7zip/UI/FileManager/RegistryPlugins.cpp b/CPP/7zip/UI/FileManager/RegistryPlugins.cpp
index 771166ca..a0bfec05 100755
--- a/CPP/7zip/UI/FileManager/RegistryPlugins.cpp
+++ b/CPP/7zip/UI/FileManager/RegistryPlugins.cpp
@@ -28,7 +28,7 @@ static const TCHAR *kPluginsTypeValue = TEXT("Type");
static CSysString GetFileFolderPluginsKeyName()
{
- return CSysString(kLMBasePath) + CSysString(TEXT('\\')) +
+ return CSysString(kLMBasePath) + CSysString(TEXT('\\')) +
CSysString(kPluginsKeyName);
}
@@ -115,7 +115,7 @@ void ReadPluginInfoList(CObjectVector<CPluginInfo> &plugins)
NFind::CFileInfoW fileInfo;
while (enumerator.Next(fileInfo))
{
- if (fileInfo.IsDirectory())
+ if (fileInfo.IsDir())
continue;
CPluginInfo pluginInfo;
pluginInfo.FilePath = folderPath + fileInfo.Name;
diff --git a/CPP/7zip/UI/FileManager/RegistryPlugins.h b/CPP/7zip/UI/FileManager/RegistryPlugins.h
index 90bab7b5..77055ac7 100755
--- a/CPP/7zip/UI/FileManager/RegistryPlugins.h
+++ b/CPP/7zip/UI/FileManager/RegistryPlugins.h
@@ -5,7 +5,7 @@
#include "Common/MyString.h"
-enum EPluginType
+enum EPluginType
{
kPluginTypeFF = 0
};
diff --git a/CPP/7zip/UI/FileManager/RootFolder.cpp b/CPP/7zip/UI/FileManager/RootFolder.cpp
index 5c8e0e28..3f3c67ef 100755
--- a/CPP/7zip/UI/FileManager/RootFolder.cpp
+++ b/CPP/7zip/UI/FileManager/RootFolder.cpp
@@ -20,7 +20,7 @@
using namespace NWindows;
-static const STATPROPSTG kProperties[] =
+static const STATPROPSTG kProperties[] =
{
{ NULL, kpidName, VT_BSTR}
};
@@ -28,10 +28,33 @@ static const STATPROPSTG kProperties[] =
// static const wchar_t *kMyComputerTitle = L"Computer";
// static const wchar_t *kMyNetworkTitle = L"Network";
-void CRootFolder::Init()
+UString RootFolder_GetName_Computer(int &iconIndex)
{
- _computerName = LangString(IDS_COMPUTER, 0x03020300);
- _networkName = LangString(IDS_NETWORK, 0x03020301);
+ iconIndex = GetIconIndexForCSIDL(CSIDL_DRIVES);
+ return LangString(IDS_COMPUTER, 0x03020300);
+}
+
+UString RootFolder_GetName_Network(int &iconIndex)
+{
+ iconIndex = GetIconIndexForCSIDL(CSIDL_NETWORK);
+ return LangString(IDS_NETWORK, 0x03020301);
+}
+
+UString RootFolder_GetName_Documents(int &iconIndex)
+{
+ iconIndex = GetIconIndexForCSIDL(CSIDL_PERSONAL);
+ return LangString(IDS_DOCUMENTS, 0x03020302); ;
+}
+
+const int ROOT_INDEX_COMPUTER = 0;
+const int ROOT_INDEX_DOCUMENTS = 1;
+const int ROOT_INDEX_NETWORK = 2;
+
+void CRootFolder::Init()
+{
+ _names[ROOT_INDEX_COMPUTER] = RootFolder_GetName_Computer(_iconIndices[ROOT_INDEX_COMPUTER]);
+ _names[ROOT_INDEX_DOCUMENTS] = RootFolder_GetName_Documents(_iconIndices[ROOT_INDEX_DOCUMENTS]);
+ _names[ROOT_INDEX_NETWORK] = RootFolder_GetName_Network(_iconIndices[ROOT_INDEX_NETWORK]);
};
STDMETHODIMP CRootFolder::LoadItems()
@@ -42,50 +65,78 @@ STDMETHODIMP CRootFolder::LoadItems()
STDMETHODIMP CRootFolder::GetNumberOfItems(UInt32 *numItems)
{
- *numItems = 2;
+ *numItems = kNumRootFolderItems;
return S_OK;
}
STDMETHODIMP CRootFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT *value)
{
- NCOM::CPropVariant propVariant;
+ NCOM::CPropVariant prop;
switch(propID)
{
- case kpidIsFolder:
- propVariant = true;
- break;
- case kpidName:
- if (itemIndex == 0)
- propVariant = _computerName;
- else if (itemIndex == 1)
- propVariant = _networkName;
- break;
+ case kpidIsDir: prop = true; break;
+ case kpidName: prop = _names[itemIndex]; break;
}
- propVariant.Detach(value);
+ prop.Detach(value);
return S_OK;
}
+UString GetMyDocsPath()
+{
+ UString us;
+ WCHAR s[MAX_PATH + 1];
+ if (SHGetSpecialFolderPathW(0, s, CSIDL_PERSONAL, FALSE))
+ us = s;
+ #ifndef _UNICODE
+ else
+ {
+ CHAR s2[MAX_PATH + 1];
+ if (SHGetSpecialFolderPathA(0, s2, CSIDL_PERSONAL, FALSE))
+ us = GetUnicodeString(s2);
+ }
+ #endif
+ if (us.Length() > 0 && us[us.Length() - 1] != L'\\')
+ us += L'\\';
+ return us;
+}
+
STDMETHODIMP CRootFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolder)
{
- if (index == 0)
+ if (index == ROOT_INDEX_COMPUTER)
{
CFSDrives *fsDrivesSpec = new CFSDrives;
CMyComPtr<IFolderFolder> subFolder = fsDrivesSpec;
fsDrivesSpec->Init();
*resultFolder = subFolder.Detach();
}
- else if (index == 1)
+ else if (index == ROOT_INDEX_NETWORK)
{
CNetFolder *netFolderSpec = new CNetFolder;
CMyComPtr<IFolderFolder> subFolder = netFolderSpec;
- netFolderSpec->Init(0, 0, _networkName + L'\\');
+ netFolderSpec->Init(0, 0, _names[ROOT_INDEX_NETWORK] + L'\\');
*resultFolder = subFolder.Detach();
}
+ else if (index == ROOT_INDEX_DOCUMENTS)
+ {
+ UString s = GetMyDocsPath();
+ if (!s.IsEmpty())
+ {
+ NFsFolder::CFSFolder *fsFolderSpec = new NFsFolder::CFSFolder;
+ CMyComPtr<IFolderFolder> subFolder = fsFolderSpec;
+ RINOK(fsFolderSpec->Init(s, NULL));
+ *resultFolder = subFolder.Detach();
+ }
+ }
else
return E_INVALIDARG;
return S_OK;
}
+static bool AreEqualNames(const UString &name1, const UString &name2)
+{
+ return (name1 == name2 || name1 == (name2 + UString(L'\\')));
+}
+
STDMETHODIMP CRootFolder::BindToFolder(const wchar_t *name, IFolderFolder **resultFolder)
{
*resultFolder = 0;
@@ -99,12 +150,15 @@ STDMETHODIMP CRootFolder::BindToFolder(const wchar_t *name, IFolderFolder **resu
*resultFolder = rootFolder.Detach();
return S_OK;
}
- if (name2 == _computerName ||
- name2 == (_computerName + UString(L'\\')))
- return BindToFolder(UInt32(0), resultFolder);
- if (name2 == _networkName ||
- name2 == (_networkName + UString(L'\\')))
- return BindToFolder(UInt32(1), resultFolder);
+ for (int i = 0; i < kNumRootFolderItems; i++)
+ if (AreEqualNames(name2, _names[i]))
+ return BindToFolder((UInt32)i, resultFolder);
+ if (AreEqualNames(name2, L"My Documents") ||
+ AreEqualNames(name2, L"Documents"))
+ return BindToFolder((UInt32)ROOT_INDEX_DOCUMENTS, resultFolder);
+ if (AreEqualNames(name2, L"My Computer") ||
+ AreEqualNames(name2, L"Computer"))
+ return BindToFolder((UInt32)ROOT_INDEX_COMPUTER, resultFolder);
if (name2 == UString(L'\\'))
{
CMyComPtr<IFolderFolder> subFolder = this;
@@ -157,7 +211,7 @@ STDMETHODIMP CRootFolder::GetNumberOfProperties(UInt32 *numProperties)
return S_OK;
}
-STDMETHODIMP CRootFolder::GetPropertyInfo(UInt32 index,
+STDMETHODIMP CRootFolder::GetPropertyInfo(UInt32 index,
BSTR *name, PROPID *propID, VARTYPE *varType)
{
if (index >= sizeof(kProperties) / sizeof(kProperties[0]))
@@ -183,12 +237,7 @@ STDMETHODIMP CRootFolder::GetFolderProperty(PROPID propID, PROPVARIANT *value)
STDMETHODIMP CRootFolder::GetSystemIconIndex(UInt32 index, INT32 *iconIndex)
{
- int aCSIDL;
- if (index == 0)
- aCSIDL = CSIDL_DRIVES;
- else
- aCSIDL = CSIDL_NETWORK;
- *iconIndex = GetIconIndexForCSIDL(aCSIDL);
+ *iconIndex = _iconIndices[index];
return S_OK;
}
diff --git a/CPP/7zip/UI/FileManager/RootFolder.h b/CPP/7zip/UI/FileManager/RootFolder.h
index 7dad969d..f17a0783 100755
--- a/CPP/7zip/UI/FileManager/RootFolder.h
+++ b/CPP/7zip/UI/FileManager/RootFolder.h
@@ -9,7 +9,9 @@
#include "FSFolder.h"
-class CRootFolder:
+const int kNumRootFolderItems = 3;
+
+class CRootFolder:
public IFolderFolder,
public IFolderGetSystemIconIndex,
public CMyUnknownImp
@@ -25,8 +27,8 @@ public:
void Init();
private:
- UString _computerName;
- UString _networkName;
+ UString _names[kNumRootFolderItems];
+ int _iconIndices[kNumRootFolderItems];
};
#endif
diff --git a/CPP/7zip/UI/FileManager/SettingsPage.cpp b/CPP/7zip/UI/FileManager/SettingsPage.cpp
index 4ce2919d..8b2eb836 100755
--- a/CPP/7zip/UI/FileManager/SettingsPage.cpp
+++ b/CPP/7zip/UI/FileManager/SettingsPage.cpp
@@ -16,7 +16,7 @@
using namespace NWindows;
-static CIDLangPair kIDLangPairs[] =
+static CIDLangPair kIDLangPairs[] =
{
{ IDC_SETTINGS_SHOW_DOTS, 0x03010401},
{ IDC_SETTINGS_SHOW_REAL_FILE_ICONS, 0x03010402},
@@ -91,7 +91,7 @@ void CSettingsPage::OnNotifyHelp()
}
bool CSettingsPage::OnButtonClicked(int buttonID, HWND buttonHWND)
-{
+{
switch(buttonID)
{
/*
diff --git a/CPP/7zip/UI/FileManager/SettingsPage.rc b/CPP/7zip/UI/FileManager/SettingsPage.rc
index ddd0911b..1d0e709b 100755
--- a/CPP/7zip/UI/FileManager/SettingsPage.rc
+++ b/CPP/7zip/UI/FileManager/SettingsPage.rc
@@ -13,23 +13,23 @@ MY_FONT
BEGIN
CONTROL "Show "".."" item", IDC_SETTINGS_SHOW_DOTS, "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
marg, marg, xSize2, 10
- CONTROL "Show real file &icons", IDC_SETTINGS_SHOW_REAL_FILE_ICONS, "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
+ CONTROL "Show real file &icons", IDC_SETTINGS_SHOW_REAL_FILE_ICONS, "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
marg, 21, xSize2, 10
- CONTROL "Show system &menu", IDC_SETTINGS_SHOW_SYSTEM_MENU, "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
+ CONTROL "Show system &menu", IDC_SETTINGS_SHOW_SYSTEM_MENU, "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
marg, 35, xSize2, 10
- CONTROL "&Full row select", IDC_SETTINGS_FULL_ROW, "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
+ CONTROL "&Full row select", IDC_SETTINGS_FULL_ROW, "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
marg, 63, xSize2, 10
- CONTROL "Show &grid lines", IDC_SETTINGS_SHOW_GRID, "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
+ CONTROL "Show &grid lines", IDC_SETTINGS_SHOW_GRID, "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
marg, 77, xSize2, 10
- CONTROL "&Single-click to open an item", IDC_SETTINGS_SINGLE_CLICK, "Button", BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP,
+ CONTROL "&Single-click to open an item", IDC_SETTINGS_SINGLE_CLICK, "Button", BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP,
marg, 91, xSize2, 10
- CONTROL "&Underline current name", IDC_SETTINGS_UNDERLINE, "Button", BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP,
+ CONTROL "&Underline current name", IDC_SETTINGS_UNDERLINE, "Button", BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP,
marg + 12, 105, xSize2 - 12, 10
- CONTROL "&Alternative selection mode", IDC_SETTINGS_ALTERNATIVE_SELECTION, "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
+ CONTROL "&Alternative selection mode", IDC_SETTINGS_ALTERNATIVE_SELECTION, "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
marg, 122, xSize2, 10
- CONTROL "Use &large memory pages", IDC_SETTINGS_LARGE_PAGES, "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
+ CONTROL "Use &large memory pages", IDC_SETTINGS_LARGE_PAGES, "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
marg, 142, xSize2, 10
END
diff --git a/CPP/7zip/UI/FileManager/SplitDialog.cpp b/CPP/7zip/UI/FileManager/SplitDialog.cpp
index 1a3770ee..bab319d1 100755
--- a/CPP/7zip/UI/FileManager/SplitDialog.cpp
+++ b/CPP/7zip/UI/FileManager/SplitDialog.cpp
@@ -8,7 +8,7 @@
#include "Windows/FileName.h"
#include "SplitUtils.h"
-#ifdef LANG
+#ifdef LANG
#include "LangUtils.h"
#endif
@@ -16,8 +16,8 @@
using namespace NWindows;
-#ifdef LANG
-static CIDLangPair kIDLangPairs[] =
+#ifdef LANG
+static CIDLangPair kIDLangPairs[] =
{
{ IDC_STATIC_SPLIT_PATH, 0x03020501 },
{ IDC_STATIC_SPLIT_VOLUME, 0x02000D40 },
@@ -25,9 +25,9 @@ static CIDLangPair kIDLangPairs[] =
#endif
-bool CSplitDialog::OnInit()
+bool CSplitDialog::OnInit()
{
- #ifdef LANG
+ #ifdef LANG
LangSetWindowText(HWND(*this), 0x03020500);
LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
#endif
@@ -59,7 +59,7 @@ bool CSplitDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
return CModalDialog::OnButtonClicked(buttonID, buttonHWND);
}
-void CSplitDialog::OnButtonSetPath()
+void CSplitDialog::OnButtonSetPath()
{
UString currentPath;
_pathCombo.GetText(currentPath);
@@ -82,7 +82,7 @@ void CSplitDialog::OnOK()
volumeString.Trim();
if (!ParseVolumeSizes(volumeString, VolumeSizes) || VolumeSizes.Size() == 0)
{
- ::MessageBoxW(*this, LangString(IDS_COMPRESS_INCORRECT_VOLUME_SIZE, 0x02000D41), L"7-Zip", 0);
+ ::MessageBoxW(*this, LangString(IDS_COMPRESS_INCORRECT_VOLUME_SIZE, 0x02000D41), L"7-Zip", 0);
return;
}
CModalDialog::OnOK();
diff --git a/CPP/7zip/UI/FileManager/StringUtils.cpp b/CPP/7zip/UI/FileManager/StringUtils.cpp
index 63eebdba..bddaa971 100755
--- a/CPP/7zip/UI/FileManager/StringUtils.cpp
+++ b/CPP/7zip/UI/FileManager/StringUtils.cpp
@@ -23,7 +23,7 @@ void SplitStringToTwoStrings(const UString &src, UString &dest1, UString &dest2)
break;
}
}
- else
+ else
dest1 += c;
}
dest2 = src.Mid(i);
diff --git a/CPP/7zip/UI/FileManager/SysIconUtils.cpp b/CPP/7zip/UI/FileManager/SysIconUtils.cpp
index 0d337550..5af6f850 100755
--- a/CPP/7zip/UI/FileManager/SysIconUtils.cpp
+++ b/CPP/7zip/UI/FileManager/SysIconUtils.cpp
@@ -11,21 +11,21 @@
extern bool g_IsNT;
#endif
-int GetIconIndexForCSIDL(int aCSIDL)
+int GetIconIndexForCSIDL(int csidl)
{
- LPITEMIDLIST pidlMyComputer = 0;
- SHGetSpecialFolderLocation(NULL, aCSIDL, &pidlMyComputer);
- if (pidlMyComputer)
+ LPITEMIDLIST pidl = 0;
+ SHGetSpecialFolderLocation(NULL, csidl, &pidl);
+ if (pidl)
{
SHFILEINFO shellInfo;
- SHGetFileInfo(LPCTSTR(pidlMyComputer), FILE_ATTRIBUTE_NORMAL,
- &shellInfo, sizeof(shellInfo),
+ SHGetFileInfo(LPCTSTR(pidl), FILE_ATTRIBUTE_NORMAL,
+ &shellInfo, sizeof(shellInfo),
SHGFI_PIDL | SHGFI_SYSICONINDEX);
IMalloc *pMalloc;
SHGetMalloc(&pMalloc);
if(pMalloc)
{
- pMalloc->Free(pidlMyComputer);
+ pMalloc->Free(pidl);
pMalloc->Release();
}
return shellInfo.iIcon;
@@ -33,10 +33,10 @@ int GetIconIndexForCSIDL(int aCSIDL)
return 0;
}
-DWORD_PTR GetRealIconIndex(LPCTSTR path, UINT32 attributes, int &iconIndex)
+DWORD_PTR GetRealIconIndex(LPCTSTR path, DWORD attributes, int &iconIndex)
{
SHFILEINFO shellInfo;
- DWORD_PTR res = ::SHGetFileInfo(path, FILE_ATTRIBUTE_NORMAL | attributes, &shellInfo,
+ DWORD_PTR res = ::SHGetFileInfo(path, FILE_ATTRIBUTE_NORMAL | attributes, &shellInfo,
sizeof(shellInfo), SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX);
iconIndex = shellInfo.iIcon;
return res;
@@ -70,13 +70,13 @@ DWORD_PTR MySHGetFileInfoW(LPCWSTR pszPath, DWORD dwFileAttributes, SHFILEINFOW
}
#ifndef _UNICODE
-// static inline UINT GetCurrentCodePage() { return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
-DWORD_PTR GetRealIconIndex(LPCWSTR path, UINT32 attributes, int &iconIndex)
+// static inline UINT GetCurrentCodePage() { return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
+DWORD_PTR GetRealIconIndex(LPCWSTR path, DWORD attributes, int &iconIndex)
{
if(g_IsNT)
{
SHFILEINFOW shellInfo;
- DWORD_PTR res = ::MySHGetFileInfoW(path, FILE_ATTRIBUTE_NORMAL | attributes, &shellInfo,
+ DWORD_PTR res = ::MySHGetFileInfoW(path, FILE_ATTRIBUTE_NORMAL | attributes, &shellInfo,
sizeof(shellInfo), SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX);
iconIndex = shellInfo.iIcon;
return res;
@@ -86,7 +86,7 @@ DWORD_PTR GetRealIconIndex(LPCWSTR path, UINT32 attributes, int &iconIndex)
}
#endif
-DWORD_PTR GetRealIconIndex(const UString &fileName, UINT32 attributes,
+DWORD_PTR GetRealIconIndex(const UString &fileName, DWORD attributes,
int &iconIndex, UString &typeName)
{
#ifndef _UNICODE
@@ -94,8 +94,8 @@ DWORD_PTR GetRealIconIndex(const UString &fileName, UINT32 attributes,
{
SHFILEINFO shellInfo;
shellInfo.szTypeName[0] = 0;
- DWORD_PTR res = ::SHGetFileInfoA(GetSystemString(fileName), FILE_ATTRIBUTE_NORMAL | attributes, &shellInfo,
- sizeof(shellInfo), SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX
+ DWORD_PTR res = ::SHGetFileInfoA(GetSystemString(fileName), FILE_ATTRIBUTE_NORMAL | attributes, &shellInfo,
+ sizeof(shellInfo), SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX
| SHGFI_TYPENAME);
typeName = GetUnicodeString(shellInfo.szTypeName);
iconIndex = shellInfo.iIcon;
@@ -106,8 +106,8 @@ DWORD_PTR GetRealIconIndex(const UString &fileName, UINT32 attributes,
{
SHFILEINFOW shellInfo;
shellInfo.szTypeName[0] = 0;
- DWORD_PTR res = ::MySHGetFileInfoW(fileName, FILE_ATTRIBUTE_NORMAL | attributes, &shellInfo,
- sizeof(shellInfo), SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX
+ DWORD_PTR res = ::MySHGetFileInfoW(fileName, FILE_ATTRIBUTE_NORMAL | attributes, &shellInfo,
+ sizeof(shellInfo), SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX
| SHGFI_TYPENAME);
typeName = shellInfo.szTypeName;
iconIndex = shellInfo.iIcon;
diff --git a/CPP/7zip/UI/FileManager/SysIconUtils.h b/CPP/7zip/UI/FileManager/SysIconUtils.h
index 3b6c6c2e..a90d28bc 100755
--- a/CPP/7zip/UI/FileManager/SysIconUtils.h
+++ b/CPP/7zip/UI/FileManager/SysIconUtils.h
@@ -32,7 +32,7 @@ class CExtToIconMap
CObjectVector<CExtIconPair> _map;
public:
CExtToIconMap(): _dirIconIndex(-1), _noExtIconIndex(-1) {}
- void Clear()
+ void Clear()
{
_dirIconIndex = -1;
_noExtIconIndex = -1;
@@ -42,10 +42,10 @@ public:
int GetIconIndex(UINT32 attributes, const UString &fileName);
};
-DWORD_PTR GetRealIconIndex(LPCTSTR path, UINT32 attributes, int &iconIndex);
+DWORD_PTR GetRealIconIndex(LPCTSTR path, DWORD attributes, int &iconIndex);
#ifndef _UNICODE
-DWORD_PTR GetRealIconIndex(LPCWSTR path, UINT32 attributes, int &iconIndex);
+DWORD_PTR GetRealIconIndex(LPCWSTR path, DWORD attributes, int &iconIndex);
#endif
-int GetIconIndexForCSIDL(int aCSIDL);
+int GetIconIndexForCSIDL(int csidl);
#endif
diff --git a/CPP/7zip/UI/FileManager/SystemPage.cpp b/CPP/7zip/UI/FileManager/SystemPage.cpp
index 40da5cb3..f8605ea8 100755
--- a/CPP/7zip/UI/FileManager/SystemPage.cpp
+++ b/CPP/7zip/UI/FileManager/SystemPage.cpp
@@ -26,7 +26,7 @@ using namespace NRegistryAssociations;
const int kRefreshpluginsListMessage = WM_USER + 1;
const int kUpdateDatabase = kRefreshpluginsListMessage + 1;
-static CIDLangPair kIDLangPairs[] =
+static CIDLangPair kIDLangPairs[] =
{
{ IDC_SYSTEM_STATIC_ASSOCIATE, 0x03010302},
{ IDC_SYSTEM_SELECT_ALL, 0x03000330}
@@ -44,7 +44,7 @@ bool CSystemPage::OnInit()
_listViewPlugins.Attach(GetItem(IDC_SYSTEM_LIST_PLUGINS));
/*
- CheckButton(IDC_SYSTEM_INTEGRATE_TO_CONTEXT_MENU,
+ CheckButton(IDC_SYSTEM_INTEGRATE_TO_CONTEXT_MENU,
NRegistryAssociations::CheckContextMenuHandler());
*/
@@ -52,26 +52,11 @@ bool CSystemPage::OnInit()
_listViewExt.SetExtendedListViewStyle(newFlags, newFlags);
_listViewPlugins.SetExtendedListViewStyle(newFlags, newFlags);
- UString s = LangString(IDS_PROPERTY_EXTENSION, 0x02000205);
- LVCOLUMNW column;
- column.mask = LVCF_WIDTH | LVCF_TEXT | LVCF_FMT | LVCF_SUBITEM;
- column.cx = 70;
- column.fmt = LVCFMT_LEFT;
- column.pszText = (LPWSTR)(LPCWSTR)s;
- column.iSubItem = 0;
- _listViewExt.InsertColumn(0, &column);
-
- s = LangString(IDS_PLUGIN, 0x03010310);
- column.cx = 70;
- column.pszText = (LPWSTR)(LPCWSTR)s;
- column.iSubItem = 1;
- _listViewExt.InsertColumn(1, &column);
-
- s = LangString(IDS_PLUGIN, 0x03010310);
- column.cx = 70;
- column.pszText = (LPWSTR)(LPCWSTR)s;
- column.iSubItem = 0;
- _listViewPlugins.InsertColumn(0, &column);
+ _listViewExt.InsertColumn(0, LangString(IDS_PROPERTY_EXTENSION, 0x02000205), 70);
+ const UString s = LangString(IDS_PLUGIN, 0x03010310);
+ _listViewExt.InsertColumn(1, s, 70);
+
+ _listViewPlugins.InsertColumn(0, s, 70);
_extDatabase.Read();
@@ -79,13 +64,7 @@ bool CSystemPage::OnInit()
{
CExtInfoBig &extInfo = _extDatabase.ExtBigItems[i];
- LVITEMW item;
- item.iItem = i;
- item.mask = LVIF_TEXT | LVIF_PARAM;
- item.lParam = i;
- item.pszText = (LPWSTR)(LPCWSTR)extInfo.Ext;
- item.iSubItem = 0;
- int itemIndex = _listViewExt.InsertItem(&item);
+ int itemIndex = _listViewExt.InsertItem(i, (LPCWSTR)extInfo.Ext);
UString iconPath;
int iconIndex;
@@ -111,13 +90,7 @@ bool CSystemPage::OnInit()
void CSystemPage::SetMainPluginText(int itemIndex, int indexInDatabase)
{
- LVITEMW item;
- item.iItem = itemIndex;
- item.mask = LVIF_TEXT;
- UString mainPlugin = _extDatabase.GetMainPluginNameForExtItem(indexInDatabase);
- item.pszText = (WCHAR *)(const WCHAR *)mainPlugin;
- item.iSubItem = 1;
- _listViewExt.SetItem(&item);
+ _listViewExt.SetSubItem(itemIndex, 1, _extDatabase.GetMainPluginNameForExtItem(indexInDatabase));
}
static UString GetProgramCommand()
@@ -181,7 +154,7 @@ LONG CSystemPage::OnApply()
const CPluginInfo &plugin = _extDatabase.Plugins[extInfo.PluginsPairs[0].Index];
iconPath = GetIconPath(plugin.FilePath, plugin.ClassID, extInfo.Ext, iconIndex);
}
- NRegistryAssociations::AddShellExtensionInfo(GetSystemString(extInfo.Ext),
+ NRegistryAssociations::AddShellExtensionInfo(GetSystemString(extInfo.Ext),
title, command, iconPath, iconIndex, NULL, 0);
}
else
@@ -203,7 +176,7 @@ void CSystemPage::OnNotifyHelp()
}
void CSystemPage::SelectAll()
-{
+{
int count = _listViewExt.GetItemCount();
for (int i = 0; i < count; i++)
_listViewExt.SetCheckState(i, true);
@@ -211,7 +184,7 @@ void CSystemPage::SelectAll()
}
bool CSystemPage::OnButtonClicked(int buttonID, HWND buttonHWND)
-{
+{
switch(buttonID)
{
case IDC_SYSTEM_SELECT_ALL:
@@ -224,8 +197,8 @@ bool CSystemPage::OnButtonClicked(int buttonID, HWND buttonHWND)
return CPropertyPage::OnButtonClicked(buttonID, buttonHWND);
}
-bool CSystemPage::OnNotify(UINT controlID, LPNMHDR lParam)
-{
+bool CSystemPage::OnNotify(UINT controlID, LPNMHDR lParam)
+{
if (lParam->hwndFrom == HWND(_listViewExt))
{
switch(lParam->code)
@@ -241,7 +214,7 @@ bool CSystemPage::OnNotify(UINT controlID, LPNMHDR lParam)
PostMessage(kUpdateDatabase, 0);
break;
}
- }
+ }
else if (lParam->hwndFrom == HWND(_listViewPlugins))
{
switch(lParam->code)
@@ -268,7 +241,7 @@ bool CSystemPage::OnNotify(UINT controlID, LPNMHDR lParam)
}
}
}
- return CPropertyPage::OnNotify(controlID, lParam);
+ return CPropertyPage::OnNotify(controlID, lParam);
}
bool CSystemPage::OnPluginsKeyDown(LPNMLVKEYDOWN keyDownInfo)
@@ -394,14 +367,7 @@ void CSystemPage::RefreshPluginsList(int selectIndex)
for (int i = 0; i < extInfo.PluginsPairs.Size(); i++)
{
CPluginEnabledPair pluginPair = extInfo.PluginsPairs[i];
- UString pluginName = _extDatabase.Plugins[pluginPair.Index].Name;
- LVITEMW item;
- item.iItem = i;
- item.mask = LVIF_TEXT | LVIF_PARAM;
- item.lParam = i;
- item.pszText = (LPWSTR)(LPCWSTR)pluginName;
- item.iSubItem = 0;
- int itemIndex = _listViewPlugins.InsertItem(&item);
+ int itemIndex = _listViewPlugins.InsertItem(i, _extDatabase.Plugins[pluginPair.Index].Name);
_listViewPlugins.SetCheckState(itemIndex, pluginPair.Enabled);
}
if(_listViewPlugins.GetItemCount() > 0)
diff --git a/CPP/7zip/UI/FileManager/SystemPage.rc b/CPP/7zip/UI/FileManager/SystemPage.rc
index f881f612..1cf9405f 100755
--- a/CPP/7zip/UI/FileManager/SystemPage.rc
+++ b/CPP/7zip/UI/FileManager/SystemPage.rc
@@ -15,7 +15,7 @@ CAPTION "System"
MY_FONT
BEGIN
LTEXT "Associate 7-Zip with:", IDC_SYSTEM_STATIC_ASSOCIATE, marg, marg, xSize2, 8
- CONTROL "List1", IDC_SYSTEM_LIST_ASSOCIATE, "SysListView32",
+ CONTROL "List1", IDC_SYSTEM_LIST_ASSOCIATE, "SysListView32",
LVS_LIST | LVS_SHOWSELALWAYS | LVS_SORTASCENDING | WS_BORDER | WS_TABSTOP,
marg, 20, g0Size, gYSize
PUSHBUTTON "Select all", IDC_SYSTEM_SELECT_ALL, marg, (ySize - marg - bYSize), 90, bYSize
diff --git a/CPP/7zip/UI/FileManager/TextPairs.cpp b/CPP/7zip/UI/FileManager/TextPairs.cpp
index a149fe37..74df1c62 100755
--- a/CPP/7zip/UI/FileManager/TextPairs.cpp
+++ b/CPP/7zip/UI/FileManager/TextPairs.cpp
@@ -38,8 +38,8 @@ static UString GetIDString(const wchar_t *srcString, int &finishPos)
break;
finishPos++;
bool isSeparatorChar = IsSeparatorChar(c);
- if (c == kNewLineChar || (isSeparatorChar && !quotes)
- || (c == kQuoteChar && quotes))
+ if (c == kNewLineChar || (isSeparatorChar && !quotes)
+ || (c == kQuoteChar && quotes))
break;
else if (c == kQuoteChar)
quotes = true;
@@ -60,7 +60,7 @@ static UString GetValueString(const wchar_t *srcString, int &finishPos)
if (c == kEndOfLine)
break;
finishPos++;
- if (c == kNewLineChar)
+ if (c == kNewLineChar)
break;
result += c;
}
@@ -131,7 +131,7 @@ void CPairsStorage::Sort()
int CPairsStorage::FindID(const UString &id, int &insertPos)
{
- int left = 0, right = Pairs.Size();
+ int left = 0, right = Pairs.Size();
while (left != right)
{
UINT32 mid = (left + right) / 2;
diff --git a/CPP/7zip/UI/FileManager/UpdateCallback100.cpp b/CPP/7zip/UI/FileManager/UpdateCallback100.cpp
index 927d3cd5..376e7647 100755
--- a/CPP/7zip/UI/FileManager/UpdateCallback100.cpp
+++ b/CPP/7zip/UI/FileManager/UpdateCallback100.cpp
@@ -42,14 +42,7 @@ STDMETHODIMP CUpdateCallback100Imp::SetTotal(UInt64 size)
STDMETHODIMP CUpdateCallback100Imp::SetCompleted(const UInt64 *completeValue)
{
- for (;;)
- {
- if(ProgressDialog.ProgressSynch.GetStopped())
- return E_ABORT;
- if(!ProgressDialog.ProgressSynch.GetPaused())
- break;
- ::Sleep(100);
- }
+ RINOK(ProgressDialog.ProgressSynch.ProcessStopAndPause());
if (completeValue != NULL)
ProgressDialog.ProgressSynch.SetPos(*completeValue);
return S_OK;
@@ -104,3 +97,23 @@ STDMETHODIMP CUpdateCallback100Imp::CryptoGetTextPassword2(Int32 *passwordIsDefi
*password = tempName.Detach();
return S_OK;
}
+
+STDMETHODIMP CUpdateCallback100Imp::SetTotal(const UInt64 * /* files */, const UInt64 * /* bytes */)
+{
+ return S_OK;
+}
+
+STDMETHODIMP CUpdateCallback100Imp::SetCompleted(const UInt64 * /* files */, const UInt64 * /* bytes */)
+{
+ return ProgressDialog.ProgressSynch.ProcessStopAndPause();
+}
+
+STDMETHODIMP CUpdateCallback100Imp::CryptoGetTextPassword(BSTR *password)
+{
+ if (!_passwordIsDefined)
+ return S_FALSE;
+ CMyComBSTR tempName = _password;
+ *password = tempName.Detach();
+ return S_OK;
+}
+
diff --git a/CPP/7zip/UI/FileManager/UpdateCallback100.h b/CPP/7zip/UI/FileManager/UpdateCallback100.h
index fd75bf2f..5ae194a2 100755
--- a/CPP/7zip/UI/FileManager/UpdateCallback100.h
+++ b/CPP/7zip/UI/FileManager/UpdateCallback100.h
@@ -10,35 +10,33 @@
#include "ProgressDialog2.h"
#include "../../IPassword.h"
-#ifdef LANG
+#ifdef LANG
#include "LangUtils.h"
#endif
-class CUpdateCallback100Imp:
+class CUpdateCallback100Imp:
public IFolderArchiveUpdateCallback,
public ICryptoGetTextPassword2,
+ public ICryptoGetTextPassword,
+ public IArchiveOpenCallback,
public ICompressProgressInfo,
public CMyUnknownImp
{
public:
- MY_UNKNOWN_IMP3(
- IFolderArchiveUpdateCallback,
+ MY_UNKNOWN_IMP5(
+ IFolderArchiveUpdateCallback,
ICryptoGetTextPassword2,
+ ICryptoGetTextPassword,
+ IArchiveOpenCallback,
ICompressProgressInfo)
- // IProgress
+ INTERFACE_IProgress(;)
+ INTERFACE_IArchiveOpenCallback(;)
+ INTERFACE_IFolderArchiveUpdateCallback(;)
- STDMETHOD(SetTotal)(UInt64 size);
- STDMETHOD(SetCompleted)(const UInt64 *completeValue);
STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize);
- // IUpdateCallBack
- STDMETHOD(CompressOperation)(const wchar_t *name);
- STDMETHOD(DeleteOperation)(const wchar_t *name);
- STDMETHOD(OperationResult)(Int32 operationResult);
- STDMETHOD(UpdateErrorMessage)(const wchar_t *message);
- STDMETHOD(SetNumFiles)(UInt64 numFiles);
-
+ STDMETHOD(CryptoGetTextPassword)(BSTR *password);
STDMETHOD(CryptoGetTextPassword2)(Int32 *passwordIsDefined, BSTR *password);
private:
bool _passwordIsDefined;
@@ -56,7 +54,7 @@ public:
UInt64 NumFolders;
UInt64 NumFiles;
- void Init(HWND parentWindow,
+ void Init(HWND parentWindow,
bool passwordIsDefined, const UString &password)
{
_passwordIsDefined = passwordIsDefined;
diff --git a/CPP/7zip/UI/FileManager/ViewSettings.cpp b/CPP/7zip/UI/FileManager/ViewSettings.cpp
index 9102cc4e..34d01229 100755
--- a/CPP/7zip/UI/FileManager/ViewSettings.cpp
+++ b/CPP/7zip/UI/FileManager/ViewSettings.cpp
@@ -416,7 +416,7 @@ void SaveCopyHistory(const UStringVector &folders)
void ReadCopyHistory(UStringVector &folders)
{ ReadStringList(kCopyHistoryValueName, folders); }
-void AddUniqueStringToHeadOfList(UStringVector &list,
+void AddUniqueStringToHeadOfList(UStringVector &list,
const UString &string)
{
for(int i = 0; i < list.Size();)
diff --git a/CPP/7zip/UI/FileManager/ViewSettings.h b/CPP/7zip/UI/FileManager/ViewSettings.h
index 4af0b991..2500ce7b 100755
--- a/CPP/7zip/UI/FileManager/ViewSettings.h
+++ b/CPP/7zip/UI/FileManager/ViewSettings.h
@@ -13,13 +13,13 @@ struct CColumnInfo
};
inline bool operator==(const CColumnInfo &a1, const CColumnInfo &a2)
-{
- return (a1.PropID == a2.PropID) &&
- (a1.IsVisible == a2.IsVisible) && (a1.Width == a2.Width);
+{
+ return (a1.PropID == a2.PropID) &&
+ (a1.IsVisible == a2.IsVisible) && (a1.Width == a2.Width);
}
inline bool operator!=(const CColumnInfo &a1, const CColumnInfo &a2)
-{
+{
return !(a1 == a2);
}
@@ -44,11 +44,11 @@ struct CListViewInfo
return -1;
}
- bool IsEqual(const CListViewInfo &aNewInfo) const
+ bool IsEqual(const CListViewInfo &aNewInfo) const
{
if (Columns.Size() != aNewInfo.Columns.Size() ||
- // SortIndex != aNewInfo.SortIndex ||
- SortID != aNewInfo.SortID ||
+ // SortIndex != aNewInfo.SortIndex ||
+ SortID != aNewInfo.SortID ||
Ascending != aNewInfo.Ascending)
return false;
for (int i = 0; i < Columns.Size(); i++)
@@ -92,7 +92,7 @@ void ReadFastFolders(UStringVector &folders);
void SaveCopyHistory(const UStringVector &folders);
void ReadCopyHistory(UStringVector &folders);
-void AddUniqueStringToHeadOfList(UStringVector &list,
+void AddUniqueStringToHeadOfList(UStringVector &list,
const UString &string);
#endif
diff --git a/CPP/7zip/UI/FileManager/makefile b/CPP/7zip/UI/FileManager/makefile
index 0b815ad9..78921b90 100755
--- a/CPP/7zip/UI/FileManager/makefile
+++ b/CPP/7zip/UI/FileManager/makefile
@@ -102,6 +102,7 @@ WIN_OBJS = \
$O\Security.obj \
$O\Shell.obj \
$O\Synchronization.obj \
+ $O\Time.obj \
$O\Window.obj \
WIN_CTRL_OBJS = \
diff --git a/CPP/7zip/UI/FileManager/resource.h b/CPP/7zip/UI/FileManager/resource.h
index 864c066b..edd351b6 100755
--- a/CPP/7zip/UI/FileManager/resource.h
+++ b/CPP/7zip/UI/FileManager/resource.h
@@ -42,7 +42,7 @@
#define IDM_OPEN_PARENT_FOLDER 431
#define IDM_FOLDERS_HISTORY 432
#define IDM_VIEW_REFRESH 440
-#define IDM_VIEW_FLAT_VIEW 449
+#define IDM_VIEW_FLAT_VIEW 449
#define IDM_VIEW_TWO_PANELS 450
#define IDM_VIEW_TOOLBARS 451
#define IDM_VIEW_STANDARD_TOOLBAR 460
@@ -86,6 +86,7 @@
#define IDS_WANT_TO_DELETE_ITEMS 2215
#define IDS_DELETING 2216
#define IDS_ERROR_DELETING 2217
+#define IDS_ERROR_LONG_PATH_TO_RECYCLE 2218
#define IDS_RENAMING 2220
#define IDS_ERROR_RENAMING 2221
@@ -116,8 +117,10 @@
#define IDS_CANNOT_UPDATE_FILE 2281
#define IDS_CANNOT_START_EDITOR 2282
#define IDS_OPENNING 2283
+#define IDS_VIRUS 2284
#define IDS_COMPUTER 2300
#define IDS_NETWORK 2301
+#define IDS_DOCUMENTS 2302
#define IDS_ADD 2400
#define IDS_EXTRACT 2401
#define IDS_TEST 2402
@@ -145,6 +148,8 @@
#define IDS_COMBINE_TO 4031
#define IDS_COMBINING 4032
#define IDS_COMBINE_SELECT_ONE_FILE 4033
+#define IDS_COMBINE_CANT_DETECT_SPLIT_FILE 4034
+#define IDS_COMBINE_CANT_FIND_MORE_THAN_ONE_PART 4035
#define IDS_CHECKSUM_CALCULATING 4040
#define IDS_CHECKSUM_INFORMATION 4041
@@ -157,3 +162,7 @@
#define IDS_PROGRESS_TESTING 4100
#define IDS_MESSAGE_NO_ERRORS 4200
+#define IDS_MESSAGE_UNSUPPORTED_OPERATION_FOR_LONG_PATH_FOLDER 4301
+#define IDS_SELECT_ONE_FILE 4302
+#define IDS_SELECT_FILES 4303
+#define IDS_FILE_EXIST 4304
diff --git a/CPP/7zip/UI/FileManager/resource.rc b/CPP/7zip/UI/FileManager/resource.rc
index b8664cbe..3ec3bb32 100755
--- a/CPP/7zip/UI/FileManager/resource.rc
+++ b/CPP/7zip/UI/FileManager/resource.rc
@@ -5,7 +5,7 @@
MY_VERSION_INFO_APP("7-Zip File Manager", "7zFM")
-IDR_ACCELERATOR1 ACCELERATORS
+IDR_ACCELERATOR1 ACCELERATORS
BEGIN
"N", IDM_CREATE_FILE, VIRTKEY, CONTROL, NOINVERT
VK_F1, IDM_HELP_CONTENTS, VIRTKEY, NOINVERT
@@ -42,10 +42,10 @@ BEGIN
END
POPUP "&Edit"
BEGIN
- MENUITEM "Cu&t\tCtrl+X", IDM_EDIT_CUT, GRAYED
- MENUITEM "&Copy\tCtrl+C", IDM_EDIT_COPY, GRAYED
- MENUITEM "&Paste\tCtrl+V", IDM_EDIT_PASTE, GRAYED
- MENUITEM SEPARATOR
+ // MENUITEM "Cu&t\tCtrl+X", IDM_EDIT_CUT, GRAYED
+ // MENUITEM "&Copy\tCtrl+C", IDM_EDIT_COPY, GRAYED
+ // MENUITEM "&Paste\tCtrl+V", IDM_EDIT_PASTE, GRAYED
+ // MENUITEM SEPARATOR
MENUITEM "Select &All\tShift+[Grey +]", IDM_SELECT_ALL
MENUITEM "Deselect All\tShift+[Grey -]", IDM_DESELECT_ALL
MENUITEM "&Invert Selection\tGrey *", IDM_INVERT_SELECTION
@@ -126,7 +126,7 @@ IDB_DELETE2 BITMAP "Delete2.bmp"
IDB_INFO2 BITMAP "Info2.bmp"
-STRINGTABLE
+STRINGTABLE
BEGIN
IDS_APP_TITLE "7-Zip File Manager"
IDS_COPY "Copy"
@@ -144,7 +144,9 @@ BEGIN
IDS_COMBINE "Combine Files"
IDS_COMBINE_TO "&Combine to:"
IDS_COMBINING "Combining..."
- IDS_COMBINE_SELECT_ONE_FILE "Select only first file"
+ IDS_COMBINE_SELECT_ONE_FILE "Select only first part of split file"
+ IDS_COMBINE_CANT_DETECT_SPLIT_FILE "Can not detect file as split file"
+ IDS_COMBINE_CANT_FIND_MORE_THAN_ONE_PART "Can not find more than one part of split file"
IDS_CHECKSUM_CALCULATING "Checksum calculating..."
IDS_CHECKSUM_INFORMATION "Checksum information"
@@ -165,6 +167,7 @@ BEGIN
IDS_WANT_TO_DELETE_ITEMS "Are you sure you want to delete these {0} items?"
IDS_DELETING "Deleting..."
IDS_ERROR_DELETING "Error Deleting File or Folder"
+ IDS_ERROR_LONG_PATH_TO_RECYCLE "The system cannot move a file with long path to the Recycle Bin"
IDS_RENAMING "Renaming..."
IDS_ERROR_RENAMING "Error Renaming File or Folder"
IDS_CONFIRM_FILE_COPY "Confirm File Copy"
@@ -202,6 +205,7 @@ BEGIN
IDS_CANNOT_UPDATE_FILE "Can not update file\n'{0}'"
IDS_CANNOT_START_EDITOR "Cannot start editor."
IDS_OPENNING "Opening..."
+ IDS_VIRUS "The file looks like a virus (the file name contains long spaces in name)."
IDS_ADD "Add"
IDS_EXTRACT "Extract"
IDS_TEST "Test"
@@ -212,9 +216,14 @@ BEGIN
IDS_BOOKMARK "Bookmark"
IDS_COMPUTER "Computer"
IDS_NETWORK "Network"
+ IDS_DOCUMENTS "Documents"
IDS_PROGRESS_TESTING "Testing"
IDS_MESSAGE_NO_ERRORS "There are no errors"
+ IDS_MESSAGE_UNSUPPORTED_OPERATION_FOR_LONG_PATH_FOLDER "The operation cannot be called from a folder that has a long path."
+ IDS_SELECT_ONE_FILE "You must select one file"
+ IDS_SELECT_FILES "You must select one or more files"
+ IDS_FILE_EXIST "File {0} is already exist"
END
diff --git a/CPP/7zip/UI/GUI/BenchmarkDialog.cpp b/CPP/7zip/UI/GUI/BenchmarkDialog.cpp
index 3177bb06..c7a1cc5b 100755
--- a/CPP/7zip/UI/GUI/BenchmarkDialog.cpp
+++ b/CPP/7zip/UI/GUI/BenchmarkDialog.cpp
@@ -21,14 +21,14 @@ static LPCWSTR kHelpTopic = L"fm/benchmark.htm";
static const UINT_PTR kTimerID = 4;
static const UINT kTimerElapse = 1000;
-#ifdef LANG
+#ifdef LANG
#include "../FileManager/LangUtils.h"
#endif
using namespace NWindows;
-#ifdef LANG
-static CIDLangPair kIDLangPairs[] =
+#ifdef LANG
+static CIDLangPair kIDLangPairs[] =
{
{ IDC_BENCHMARK_DICTIONARY, 0x02000D0C },
{ IDC_BENCHMARK_MEMORY, 0x03080001 },
@@ -69,16 +69,16 @@ const LPCTSTR kKBs = TEXT(" KB/s");
static const int kMinDicLogSize = 21;
static const UInt32 kMinDicSize = (1 << kMinDicLogSize);
-static const UInt32 kMaxDicSize =
+static const UInt32 kMaxDicSize =
#ifdef _WIN64
(1 << 30);
#else
(1 << 27);
#endif
-bool CBenchmarkDialog::OnInit()
+bool CBenchmarkDialog::OnInit()
{
- #ifdef LANG
+ #ifdef LANG
LangSetWindowText(HWND(*this), 0x03080000);
LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
#endif
@@ -177,7 +177,7 @@ UInt32 CBenchmarkDialog::OnChangeDictionary()
return dictionary;
}
-static const UInt32 g_IDs[] =
+static const UInt32 g_IDs[] =
{
IDC_BENCHMARK_COMPRESSING_USAGE,
IDC_BENCHMARK_COMPRESSING_USAGE2,
@@ -231,12 +231,12 @@ void CBenchmarkDialog::OnStopButton()
_syncInfo.Pause();
}
-void CBenchmarkDialog::OnHelp()
+void CBenchmarkDialog::OnHelp()
{
ShowHelpWindow(NULL, kHelpTopic);
}
-void CBenchmarkDialog::OnCancel()
+void CBenchmarkDialog::OnCancel()
{
_syncInfo.Stop();
KillTimer(_timer);
@@ -245,9 +245,9 @@ void CBenchmarkDialog::OnCancel()
static void GetTimeString(UInt64 timeValue, TCHAR *s)
{
- wsprintf(s, TEXT("%02d:%02d:%02d"),
+ wsprintf(s, TEXT("%02d:%02d:%02d"),
UInt32(timeValue / 3600),
- UInt32((timeValue / 60) % 60),
+ UInt32((timeValue / 60) % 60),
UInt32(timeValue % 60));
}
@@ -281,7 +281,7 @@ void CBenchmarkDialog::PrintUsage(UInt64 usage, UINT controlID)
void CBenchmarkDialog::PrintResults(
UInt32 dictionarySize,
- const CBenchInfo2 &info,
+ const CBenchInfo2 &info,
UINT usageID, UINT speedID, UINT rpuID, UINT ratingID,
bool decompressMode)
{
@@ -327,8 +327,8 @@ bool CBenchmarkDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */)
{
UInt32 dicSizeTemp = (UInt32)MyMax(_syncInfo.ProcessedSize, UInt64(1) << 20);
- dicSizeTemp = MyMin(dicSizeTemp, _syncInfo.DictionarySize),
- PrintResults(dicSizeTemp,
+ dicSizeTemp = MyMin(dicSizeTemp, _syncInfo.DictionarySize),
+ PrintResults(dicSizeTemp,
_syncInfo.CompressingInfoTemp,
IDC_BENCHMARK_COMPRESSING_USAGE,
IDC_BENCHMARK_COMPRESSING_SPEED,
@@ -338,7 +338,7 @@ bool CBenchmarkDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */)
{
PrintResults(
- _syncInfo.DictionarySize,
+ _syncInfo.DictionarySize,
_syncInfo.CompressingInfo,
IDC_BENCHMARK_COMPRESSING_USAGE2,
IDC_BENCHMARK_COMPRESSING_SPEED2,
@@ -348,7 +348,7 @@ bool CBenchmarkDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */)
{
PrintResults(
- _syncInfo.DictionarySize,
+ _syncInfo.DictionarySize,
_syncInfo.DecompressingInfoTemp,
IDC_BENCHMARK_DECOMPRESSING_USAGE,
IDC_BENCHMARK_DECOMPRESSING_SPEED,
@@ -358,8 +358,8 @@ bool CBenchmarkDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */)
}
{
PrintResults(
- _syncInfo.DictionarySize,
- _syncInfo.DecompressingInfo,
+ _syncInfo.DictionarySize,
+ _syncInfo.DecompressingInfo,
IDC_BENCHMARK_DECOMPRESSING_USAGE2,
IDC_BENCHMARK_DECOMPRESSING_SPEED2,
IDC_BENCHMARK_DECOMPRESSING_RPU2,
@@ -368,14 +368,14 @@ bool CBenchmarkDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */)
if (_syncInfo.DecompressingInfo.GlobalTime > 0 &&
_syncInfo.CompressingInfo.GlobalTime > 0)
{
- UInt64 comprRating = GetCompressRating(_syncInfo.DictionarySize,
+ UInt64 comprRating = GetCompressRating(_syncInfo.DictionarySize,
_syncInfo.CompressingInfo.GlobalTime, _syncInfo.CompressingInfo.GlobalFreq, _syncInfo.CompressingInfo.UnpackSize);
- UInt64 decomprRating = GetDecompressRating(_syncInfo.DecompressingInfo.GlobalTime,
- _syncInfo.DecompressingInfo.GlobalFreq, _syncInfo.DecompressingInfo.UnpackSize,
+ UInt64 decomprRating = GetDecompressRating(_syncInfo.DecompressingInfo.GlobalTime,
+ _syncInfo.DecompressingInfo.GlobalFreq, _syncInfo.DecompressingInfo.UnpackSize,
_syncInfo.DecompressingInfo.PackSize, 1);
PrintRating((comprRating + decomprRating) / 2, IDC_BENCHMARK_TOTAL_RATING_VALUE);
PrintRating((
- GetRatingPerUsage(_syncInfo.CompressingInfo, comprRating) +
+ GetRatingPerUsage(_syncInfo.CompressingInfo, comprRating) +
GetRatingPerUsage(_syncInfo.DecompressingInfo, decomprRating)) / 2, IDC_BENCHMARK_TOTAL_RPU_VALUE);
PrintUsage((GetUsage(_syncInfo.CompressingInfo) + GetUsage(_syncInfo.DecompressingInfo)) / 2, IDC_BENCHMARK_TOTAL_USAGE_VALUE);
}
@@ -385,8 +385,8 @@ bool CBenchmarkDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */)
bool CBenchmarkDialog::OnCommand(int code, int itemID, LPARAM lParam)
{
- if (code == CBN_SELCHANGE &&
- (itemID == IDC_BENCHMARK_COMBO_DICTIONARY ||
+ if (code == CBN_SELCHANGE &&
+ (itemID == IDC_BENCHMARK_COMBO_DICTIONARY ||
itemID == IDC_BENCHMARK_COMBO_NUM_THREADS))
{
OnChangeSettings();
@@ -395,8 +395,8 @@ bool CBenchmarkDialog::OnCommand(int code, int itemID, LPARAM lParam)
return CModalDialog::OnCommand(code, itemID, lParam);
}
-bool CBenchmarkDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
-{
+bool CBenchmarkDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
+{
switch(buttonID)
{
case IDC_BUTTON_RESTART:
diff --git a/CPP/7zip/UI/GUI/BenchmarkDialog.h b/CPP/7zip/UI/GUI/BenchmarkDialog.h
index 2ba4a9a5..a57cdb39 100755
--- a/CPP/7zip/UI/GUI/BenchmarkDialog.h
+++ b/CPP/7zip/UI/GUI/BenchmarkDialog.h
@@ -87,7 +87,7 @@ public:
void WaitCreating() { _startEvent.Lock(); }
};
-class CBenchmarkDialog:
+class CBenchmarkDialog:
public NWindows::NControl::CModalDialog
{
NWindows::NControl::CComboBox m_Dictionary;
@@ -109,7 +109,7 @@ class CBenchmarkDialog:
void PrintUsage(UInt64 usage, UINT controlID);
void PrintResults(
UINT32 dictionarySize,
- const CBenchInfo2 &info, UINT usageID, UINT speedID, UINT rpuID, UINT ratingID,
+ const CBenchInfo2 &info, UINT usageID, UINT speedID, UINT rpuID, UINT ratingID,
bool decompressMode = false);
UInt32 GetNumberOfThreads();
@@ -122,7 +122,7 @@ public:
INT_PTR Create(HWND wndParent = 0) { return CModalDialog::Create(IDD_DIALOG_BENCHMARK, wndParent); }
};
-HRESULT Benchmark(
+HRESULT Benchmark(
#ifdef EXTERNAL_LZMA
CCodecs *codecs,
#endif
diff --git a/CPP/7zip/UI/GUI/CompressDialog.cpp b/CPP/7zip/UI/GUI/CompressDialog.cpp
index 51d215bc..9634ba02 100755
--- a/CPP/7zip/UI/GUI/CompressDialog.cpp
+++ b/CPP/7zip/UI/GUI/CompressDialog.cpp
@@ -26,7 +26,7 @@
extern bool g_IsNT;
#endif
-#ifdef LANG
+#ifdef LANG
#include "../FileManager/LangUtils.h"
#endif
@@ -34,8 +34,8 @@ extern bool g_IsNT;
#define MY_SIZE_OF_ARRAY(x) (sizeof(x) / sizeof(x[0]))
-#ifdef LANG
-static CIDLangPair kIDLangPairs[] =
+#ifdef LANG
+static CIDLangPair kIDLangPairs[] =
{
{ IDC_STATIC_COMPRESS_ARCHIVE, 0x02000D01 },
{ IDC_STATIC_COMPRESS_FORMAT, 0x02000D03 },
@@ -94,7 +94,7 @@ enum ELevel
kUltra = 9
};
-static const CLevelInfo g_Levels[] =
+static const CLevelInfo g_Levels[] =
{
{ IDS_METHOD_STORE, 0x02000D81 },
{ IDS_METHOD_FASTEST, 0x02000D85 },
@@ -118,7 +118,7 @@ enum EMethodID
kDeflate64
};
-static const LPCWSTR kMethodsNames[] =
+static const LPCWSTR kMethodsNames[] =
{
L"Copy",
L"LZMA",
@@ -128,33 +128,33 @@ static const LPCWSTR kMethodsNames[] =
L"Deflate64"
};
-static const EMethodID g_7zMethods[] =
+static const EMethodID g_7zMethods[] =
{
kLZMA,
kPPMd,
kBZip2
};
-static const EMethodID g_7zSfxMethods[] =
+static const EMethodID g_7zSfxMethods[] =
{
kCopy,
kLZMA,
kPPMd
};
-static EMethodID g_ZipMethods[] =
+static EMethodID g_ZipMethods[] =
{
kDeflate,
kDeflate64,
kBZip2
};
-static EMethodID g_GZipMethods[] =
+static EMethodID g_GZipMethods[] =
{
kDeflate
};
-static EMethodID g_BZip2Methods[] =
+static EMethodID g_BZip2Methods[] =
{
kBZip2
};
@@ -173,42 +173,42 @@ struct CFormatInfo
bool EncryptFileNames;
};
-static const CFormatInfo g_Formats[] =
+static const CFormatInfo g_Formats[] =
{
- {
- L"",
- (1 << 0) | (1 << 1) | (1 << 3) | (1 << 5) | (1 << 7) | (1 << 9),
+ {
+ L"",
+ (1 << 0) | (1 << 1) | (1 << 3) | (1 << 5) | (1 << 7) | (1 << 9),
0, 0,
false, false, false, false, false, false
},
- {
- k7zFormat,
- (1 << 0) | (1 << 1) | (1 << 3) | (1 << 5) | (1 << 7) | (1 << 9),
+ {
+ k7zFormat,
+ (1 << 0) | (1 << 1) | (1 << 3) | (1 << 5) | (1 << 7) | (1 << 9),
g_7zMethods, MY_SIZE_OF_ARRAY(g_7zMethods),
true, true, true, true, true, true
},
- {
- L"Zip",
- (1 << 0) | (1 << 1) | (1 << 3) | (1 << 5) | (1 << 7) | (1 << 9),
+ {
+ L"Zip",
+ (1 << 0) | (1 << 1) | (1 << 3) | (1 << 5) | (1 << 7) | (1 << 9),
g_ZipMethods, MY_SIZE_OF_ARRAY(g_ZipMethods) ,
false, false, true, false, true, false
},
- {
- L"GZip",
- (1 << 1) | (1 << 5) | (1 << 7) | (1 << 9),
+ {
+ L"GZip",
+ (1 << 1) | (1 << 5) | (1 << 7) | (1 << 9),
g_GZipMethods, MY_SIZE_OF_ARRAY(g_GZipMethods),
false, false, false, false, false, false
},
- {
- L"BZip2",
+ {
+ L"BZip2",
(1 << 1) | (1 << 3) | (1 << 5) | (1 << 7) | (1 << 9),
- g_BZip2Methods,
+ g_BZip2Methods,
MY_SIZE_OF_ARRAY(g_BZip2Methods),
false, false, true, false, false
},
- {
- L"Tar",
- (1 << 0),
+ {
+ L"Tar",
+ (1 << 0),
0, 0,
false, false, false, false, false, false
}
@@ -236,9 +236,9 @@ static UInt64 GetMaxRamSizeForProgram()
return physSize;
}
-bool CCompressDialog::OnInit()
+bool CCompressDialog::OnInit()
{
- #ifdef LANG
+ #ifdef LANG
LangSetWindowText(HWND(*this), 0x02000D00);
LangSetDlgItemsText(HWND(*this), kIDLangPairs, MY_SIZE_OF_ARRAY(kIDLangPairs) );
#endif
@@ -410,7 +410,7 @@ void CCompressDialog::CheckControlsEnable()
EnableItem(IDC_COMPRESS_COMBO_ENCRYPTION_METHOD, fi.Encrypt);
EnableItem(IDC_COMPRESS_CHECK_ENCRYPT_FILE_NAMES, fi.EncryptFileNames);
- ShowItem(IDC_COMPRESS_CHECK_ENCRYPT_FILE_NAMES, fi.EncryptFileNames);
+ ShowItem(IDC_COMPRESS_CHECK_ENCRYPT_FILE_NAMES, fi.EncryptFileNames ? SW_SHOW : SW_HIDE);
}
bool CCompressDialog::IsSFX()
@@ -454,7 +454,7 @@ void CCompressDialog::OnButtonSFX()
CheckVolumeEnable();
}
-void CCompressDialog::OnButtonSetArchive()
+void CCompressDialog::OnButtonSetArchive()
{
UString fileName;
m_ArchivePath.GetText(fileName);
@@ -489,14 +489,14 @@ static bool IsAsciiString(const UString &s)
return true;
}
-void CCompressDialog::OnOK()
+void CCompressDialog::OnOK()
{
_password1Control.GetText(Info.Password);
if (IsZipFormat())
{
if (!IsAsciiString(Info.Password))
{
- MyMessageBoxResource(*this, IDS_PASSWORD_USE_ASCII, 0x02000B11);
+ ShowErrorMessageHwndRes(*this, IDS_PASSWORD_USE_ASCII, 0x02000B11);
return;
}
UString method = GetEncryptionMethodSpec();
@@ -505,7 +505,7 @@ void CCompressDialog::OnOK()
{
if (Info.Password.Length() > 99)
{
- MyMessageBoxResource(*this, IDS_PASSWORD_IS_TOO_LONG, 0x02000B12);
+ ShowErrorMessageHwndRes(*this, IDS_PASSWORD_IS_TOO_LONG, 0x02000B12);
return;
}
}
@@ -516,7 +516,7 @@ void CCompressDialog::OnOK()
_password2Control.GetText(password2);
if (password2 != Info.Password)
{
- MyMessageBoxResource(*this, IDS_PASSWORD_PASSWORDS_DO_NOT_MATCH, 0x02000B10);
+ ShowErrorMessageHwndRes(*this, IDS_PASSWORD_PASSWORDS_DO_NOT_MATCH, 0x02000B10);
return;
}
}
@@ -558,7 +558,7 @@ void CCompressDialog::OnOK()
{
if (!ParseVolumeSizes(volumeString, Info.VolumeSizes))
{
- MyMessageBoxResource(*this, IDS_COMPRESS_INCORRECT_VOLUME_SIZE, 0x02000D41);
+ ShowErrorMessageHwndRes(*this, IDS_COMPRESS_INCORRECT_VOLUME_SIZE, 0x02000D41);
return;
}
if (!Info.VolumeSizes.IsEmpty())
@@ -568,7 +568,7 @@ void CCompressDialog::OnOK()
{
wchar_t s[32];
ConvertUInt64ToString(volumeSize, s);
- if (::MessageBoxW(*this, MyFormatNew(IDS_COMPRESS_SPLIT_CONFIRM_MESSAGE, 0x02000D42, s),
+ if (::MessageBoxW(*this, MyFormatNew(IDS_COMPRESS_SPLIT_CONFIRM_MESSAGE, 0x02000D42, s),
L"7-Zip", MB_YESNOCANCEL | MB_ICONQUESTION | MB_TASKMODAL) != IDYES)
return;
}
@@ -595,7 +595,7 @@ void CCompressDialog::OnOK()
static LPCWSTR kHelpTopic = L"fm/plugins/7-zip/add.htm";
-void CCompressDialog::OnHelp()
+void CCompressDialog::OnHelp()
{
ShowHelpWindow(NULL, kHelpTopic);
}
@@ -660,7 +660,7 @@ bool CCompressDialog::OnCommand(int code, int itemID, LPARAM lParam)
return CModalDialog::OnCommand(code, itemID, lParam);
}
-void CCompressDialog::CheckSFXNameChange()
+void CCompressDialog::CheckSFXNameChange()
{
bool isSFX = IsSFX();
CheckSFXControlsEnable();
@@ -668,7 +668,7 @@ void CCompressDialog::CheckSFXNameChange()
SetArchiveName2(isSFX);
}
-void CCompressDialog::SetArchiveName2(bool prevWasSFX)
+void CCompressDialog::SetArchiveName2(bool prevWasSFX)
{
UString fileName;
m_ArchivePath.GetText(fileName);
@@ -797,7 +797,7 @@ void CCompressDialog::SetLevel()
SetMethod();
}
-void CCompressDialog::SetMethod()
+void CCompressDialog::SetMethod()
{
m_Method.ResetContent();
UInt32 level = GetLevel();
@@ -814,7 +814,7 @@ void CCompressDialog::SetMethod()
if (index >= 0)
{
const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index];
- defaultMethod = fo.Method;
+ defaultMethod = fo.Method;
}
bool isSfx = IsSFX();
for(int m = 0; m < fi.NumMethods; m++)
@@ -838,7 +838,7 @@ bool CCompressDialog::IsZipFormat()
return (ai.Name.CompareNoCase(L"zip") == 0);
}
-void CCompressDialog::SetEncryptionMethod()
+void CCompressDialog::SetEncryptionMethod()
{
_encryptionMethod.ResetContent();
const CArcInfoEx &ai = m_ArchiverInfoList[m_Format.GetCurSel()];
@@ -854,7 +854,7 @@ void CCompressDialog::SetEncryptionMethod()
if (index >= 0)
{
const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index];
- encryptionMethod = fo.EncryptionMethod;
+ encryptionMethod = fo.EncryptionMethod;
}
_encryptionMethod.AddString(TEXT("ZipCrypto"));
_encryptionMethod.AddString(TEXT("AES-256"));
@@ -1365,7 +1365,7 @@ void CCompressDialog::PrintMemUsage(UINT res, UInt64 value)
void CCompressDialog::SetMemoryUsage()
{
- UInt64 decompressMem;
+ UInt64 decompressMem;
UInt64 memUsage = GetMemoryUsage(decompressMem);
PrintMemUsage(IDC_STATIC_COMPRESS_MEMORY_VALUE, memUsage);
PrintMemUsage(IDC_STATIC_COMPRESS_MEMORY_DE_VALUE, decompressMem);
diff --git a/CPP/7zip/UI/GUI/CompressDialog.h b/CPP/7zip/UI/GUI/CompressDialog.h
index 0b9e38c2..a88d472c 100755
--- a/CPP/7zip/UI/GUI/CompressDialog.h
+++ b/CPP/7zip/UI/GUI/CompressDialog.h
@@ -58,9 +58,9 @@ namespace NCompressDialog
bool EncryptHeadersIsAllowed;
bool EncryptHeaders;
- void Init()
- {
- Level = Dictionary = Order = UInt32(-1);
+ void Init()
+ {
+ Level = Dictionary = Order = UInt32(-1);
OrderMode = false;
Method.Empty();
Options.Empty();
diff --git a/CPP/7zip/UI/GUI/CompressDialog.rc b/CPP/7zip/UI/GUI/CompressDialog.rc
index d2a14104..397a2756 100755
--- a/CPP/7zip/UI/GUI/CompressDialog.rc
+++ b/CPP/7zip/UI/GUI/CompressDialog.rc
@@ -97,9 +97,9 @@ BEGIN
COMBOBOX IDC_COMPRESS_COMBO_UPDATE_MODE, g4XPos, 51, g4XSize, 80, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
GROUPBOX "Options",IDC_STATIC_COMPRESS_OPTIONS, g4XPos, OptYPos, g4XSize, 48
- CONTROL "Create SF&X archive",IDC_COMPRESS_SFX, "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
+ CONTROL "Create SF&X archive",IDC_COMPRESS_SFX, "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
g4XPos2, OptYPos + 14, g4XSize2, 10
- CONTROL "Compress shared files",IDC_COMPRESS_SHARED, "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
+ CONTROL "Compress shared files",IDC_COMPRESS_SHARED, "Button", BS_AUTOCHECKBOX | WS_TABSTOP,
g4XPos2, OptYPos + 30, g4XSize2, 10
GROUPBOX "Encryption",IDC_COMPRESS_ENCRYPTION, g4XPos, PswYPos, g4XSize, 127
diff --git a/CPP/7zip/UI/GUI/Extract.rc b/CPP/7zip/UI/GUI/Extract.rc
index 4f2a520c..0c655ce4 100755
--- a/CPP/7zip/UI/GUI/Extract.rc
+++ b/CPP/7zip/UI/GUI/Extract.rc
@@ -2,8 +2,9 @@
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
-STRINGTABLE DISCARDABLE
+STRINGTABLE DISCARDABLE
BEGIN
+ IDS_UPDATE_NOT_SUPPORTED "Update operations are not supported for this archive."
IDS_CANNOT_CREATE_FOLDER "Cannot create folder '{0}'"
IDS_OPEN_IS_NOT_SUPORTED_ARCHIVE "File is not supported archive."
IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_CRC "CRC failed in '{0}'. File is broken."
@@ -16,4 +17,7 @@ BEGIN
IDS_PROGRESS_EXTRACTING "Extracting"
IDS_CANT_OPEN_ARCHIVE "Can not open file '{0}' as archive"
IDS_CANT_OPEN_ENCRYPTED_ARCHIVE "Can not open encrypted archive '{0}'. Wrong password?"
+ IDS_MEM_ERROR "The system cannot allocate the required amount of memory"
+ IDS_UNKNOWN_ERROR "Unknown Error"
+ IDS_UNSUPPORTED_ARCHIVE_TYPE "Unsupported archive type"
END
diff --git a/CPP/7zip/UI/GUI/ExtractDialog.cpp b/CPP/7zip/UI/GUI/ExtractDialog.cpp
index 876fbbba..6b388700 100755
--- a/CPP/7zip/UI/GUI/ExtractDialog.cpp
+++ b/CPP/7zip/UI/GUI/ExtractDialog.cpp
@@ -94,7 +94,7 @@ void CExtractDialog::SetPathMode()
for (int i = 0; i < kNumPathnamesButtons; i++)
if(PathMode == kPathModeButtonsVals[i])
{
- CheckRadioButton(kPathModeButtons[0], kPathModeButtons[kNumPathnamesButtons - 1],
+ CheckRadioButton(kPathModeButtons[0], kPathModeButtons[kNumPathnamesButtons - 1],
kPathModeButtons[i]);
return;
}
@@ -121,7 +121,7 @@ void CExtractDialog::SetOverwriteMode()
for (int i = 0; i < kNumOverwriteButtons; i++)
if(OverwriteMode == kOverwriteButtonsVals[i])
{
- CheckRadioButton(kOverwriteButtons[0], kOverwriteButtons[kNumOverwriteButtons - 1],
+ CheckRadioButton(kOverwriteButtons[0], kOverwriteButtons[kNumOverwriteButtons - 1],
kOverwriteButtons[i]);
return;
}
@@ -142,8 +142,8 @@ int CExtractDialog::GetFilesMode() const
#endif
-#ifdef LANG
-static CIDLangPair kIDLangPairs[] =
+#ifdef LANG
+static CIDLangPair kIDLangPairs[] =
{
{ IDC_STATIC_EXTRACT_EXTRACT_TO, 0x02000801 },
{ IDC_EXTRACT_PATH_MODE, 0x02000810 },
@@ -174,9 +174,9 @@ static CIDLangPair kIDLangPairs[] =
static const int kHistorySize = 8;
#endif
-bool CExtractDialog::OnInit()
+bool CExtractDialog::OnInit()
{
- #ifdef LANG
+ #ifdef LANG
LangSetWindowText(HWND(*this), 0x02000800);
LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
#endif
@@ -210,7 +210,7 @@ bool CExtractDialog::OnInit()
#endif
/*
- if(extractionInfo.Paths.Size() > 0)
+ if(extractionInfo.Paths.Size() > 0)
_path.SetCurSel(0);
else
_path.SetCurSel(-1);
@@ -223,7 +223,7 @@ bool CExtractDialog::OnInit()
SetOverwriteMode();
/*
- CheckRadioButton(kFilesButtons[0], kFilesButtons[kNumFilesButtons - 1],
+ CheckRadioButton(kFilesButtons[0], kFilesButtons[kNumFilesButtons - 1],
kFilesButtons[_filesMode]);
*/
@@ -278,7 +278,7 @@ bool CExtractDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
return CModalDialog::OnButtonClicked(buttonID, buttonHWND);
}
-void CExtractDialog::OnButtonSetPath()
+void CExtractDialog::OnButtonSetPath()
{
UString currentPath;
_path.GetText(currentPath);
@@ -300,7 +300,7 @@ void AddUniqueString(UStringVector &list, const UString &s)
list.Add(s);
}
-void CExtractDialog::OnOK()
+void CExtractDialog::OnOK()
{
#ifndef _SFX
GetPathMode();
@@ -365,7 +365,7 @@ void CExtractDialog::UpdateWildCardState()
#ifndef NO_REGISTRY
static LPCWSTR kHelpTopic = L"fm/plugins/7-zip/extract.htm";
-void CExtractDialog::OnHelp()
+void CExtractDialog::OnHelp()
{
ShowHelpWindow(NULL, kHelpTopic);
CModalDialog::OnHelp();
diff --git a/CPP/7zip/UI/GUI/ExtractGUI.cpp b/CPP/7zip/UI/GUI/ExtractGUI.cpp
index 7936fa86..a03bd77a 100755
--- a/CPP/7zip/UI/GUI/ExtractGUI.cpp
+++ b/CPP/7zip/UI/GUI/ExtractGUI.cpp
@@ -21,7 +21,6 @@
#include "resource.h"
#include "ExtractRes.h"
-#include "OpenCallbackGUI.h"
#include "ExtractDialog.h"
using namespace NWindows;
@@ -32,11 +31,12 @@ struct CThreadExtracting
{
CCodecs *codecs;
CExtractCallbackImp *ExtractCallbackSpec;
+ CIntVector FormatIndices;
+
UStringVector *ArchivePaths;
UStringVector *ArchivePathsFull;
const NWildcard::CCensorNode *WildcardCensor;
const CExtractOptions *Options;
- COpenCallbackGUI *OpenCallback;
CMyComPtr<IExtractCallbackUI> ExtractCallback;
CDecompressStat Stat;
UString ErrorMessage;
@@ -48,20 +48,20 @@ struct CThreadExtracting
try
{
Result = DecompressArchives(
- codecs,
+ codecs, FormatIndices,
*ArchivePaths, *ArchivePathsFull,
- *WildcardCensor, *Options, OpenCallback, ExtractCallback, ErrorMessage, Stat);
+ *WildcardCensor, *Options, ExtractCallbackSpec, ExtractCallback, ErrorMessage, Stat);
}
catch(const UString &s)
{
ErrorMessage = s;
Result = E_FAIL;
- }
+ }
catch(const wchar_t *s)
{
ErrorMessage = s;
Result = E_FAIL;
- }
+ }
catch(const char *s)
{
ErrorMessage = GetUnicodeString(s);
@@ -110,16 +110,17 @@ static void AddSizePair(UINT resourceID, UInt32 langID, UInt64 value, UString &s
HRESULT ExtractGUI(
CCodecs *codecs,
- UStringVector &archivePaths,
+ const CIntVector &formatIndices,
+ UStringVector &archivePaths,
UStringVector &archivePathsFull,
const NWildcard::CCensorNode &wildcardCensor,
CExtractOptions &options,
bool showDialog,
- COpenCallbackGUI *openCallback,
CExtractCallbackImp *extractCallback)
{
CThreadExtracting extracter;
extracter.codecs = codecs;
+ extracter.FormatIndices = formatIndices;
if (!options.TestMode)
{
@@ -131,7 +132,7 @@ HRESULT ExtractGUI(
CExtractDialog dialog;
if (!NFile::NDirectory::MyGetFullPathName(outputDir, dialog.DirectoryPath))
{
- MyMessageBox(kIncorrectOutDir);
+ ShowErrorMessage(kIncorrectOutDir);
return E_FAIL;
}
NFile::NName::NormalizeDirPathPrefix(dialog.DirectoryPath);
@@ -145,13 +146,13 @@ HRESULT ExtractGUI(
options.OverwriteMode = dialog.OverwriteMode;
options.PathMode = dialog.PathMode;
#ifndef _SFX
- openCallback->Password = dialog.Password;
- openCallback->PasswordIsDefined = !dialog.Password.IsEmpty();
+ extractCallback->Password = dialog.Password;
+ extractCallback->PasswordIsDefined = !dialog.Password.IsEmpty();
#endif
}
if (!NFile::NDirectory::MyGetFullPathName(outputDir, options.OutputDir))
{
- MyMessageBox(kIncorrectOutDir);
+ ShowErrorMessage(kIncorrectOutDir);
return E_FAIL;
}
NFile::NName::NormalizeDirPathPrefix(options.OutputDir);
@@ -160,10 +161,10 @@ HRESULT ExtractGUI(
if(!NFile::NDirectory::CreateComplexDirectory(options.OutputDir))
{
UString s = GetUnicodeString(NError::MyFormatMessage(GetLastError()));
- UString s2 = MyFormatNew(IDS_CANNOT_CREATE_FOLDER,
- #ifdef LANG
- 0x02000603,
- #endif
+ UString s2 = MyFormatNew(IDS_CANNOT_CREATE_FOLDER,
+ #ifdef LANG
+ 0x02000603,
+ #endif
options.OutputDir);
MyMessageBox(s2 + UString(L"\n") + s);
return E_FAIL;
@@ -171,7 +172,7 @@ HRESULT ExtractGUI(
*/
}
- UString title = LangStringSpec(options.TestMode ? IDS_PROGRESS_TESTING : IDS_PROGRESS_EXTRACTING,
+ UString title = LangStringSpec(options.TestMode ? IDS_PROGRESS_TESTING : IDS_PROGRESS_EXTRACTING,
options.TestMode ? 0x02000F90: 0x02000890);
extracter.ExtractCallbackSpec = extractCallback;
@@ -182,12 +183,11 @@ HRESULT ExtractGUI(
extracter.ArchivePathsFull = &archivePathsFull;
extracter.WildcardCensor = &wildcardCensor;
extracter.Options = &options;
- extracter.OpenCallback = openCallback;
NWindows::CThread thread;
RINOK(thread.Create(CThreadExtracting::MyThreadFunction, &extracter));
extracter.ExtractCallbackSpec->StartProgressDialog(title);
- if (extracter.Result == S_OK && options.TestMode &&
+ if (extracter.Result == S_OK && options.TestMode &&
extracter.ExtractCallbackSpec->Messages.IsEmpty() &&
extracter.ExtractCallbackSpec->NumArchiveErrors == 0)
{
diff --git a/CPP/7zip/UI/GUI/ExtractGUI.h b/CPP/7zip/UI/GUI/ExtractGUI.h
index dfc59945..ffefabfe 100755
--- a/CPP/7zip/UI/GUI/ExtractGUI.h
+++ b/CPP/7zip/UI/GUI/ExtractGUI.h
@@ -4,18 +4,17 @@
#define __EXTRACT_GUI_H
#include "../Common/Extract.h"
-#include "OpenCallbackGUI.h"
#include "../FileManager/ExtractCallback.h"
HRESULT ExtractGUI(
CCodecs *codecs,
- UStringVector &archivePaths,
+ const CIntVector &formatIndices,
+ UStringVector &archivePaths,
UStringVector &archivePathsFull,
const NWildcard::CCensorNode &wildcardCensor,
CExtractOptions &options,
bool showDialog,
- COpenCallbackGUI *openCallback,
CExtractCallbackImp *extractCallback);
#endif
diff --git a/CPP/7zip/UI/GUI/ExtractRes.h b/CPP/7zip/UI/GUI/ExtractRes.h
index 917c0a34..084181ea 100755
--- a/CPP/7zip/UI/GUI/ExtractRes.h
+++ b/CPP/7zip/UI/GUI/ExtractRes.h
@@ -1,3 +1,4 @@
+#define IDS_UPDATE_NOT_SUPPORTED 199
#define IDS_CANNOT_CREATE_FOLDER 200
#define IDS_OPEN_IS_NOT_SUPORTED_ARCHIVE 201
@@ -13,3 +14,6 @@
#define IDS_CANT_OPEN_ARCHIVE 103
#define IDS_CANT_OPEN_ENCRYPTED_ARCHIVE 104
+#define IDS_MEM_ERROR 105
+#define IDS_UNKNOWN_ERROR 106
+#define IDS_UNSUPPORTED_ARCHIVE_TYPE 107
diff --git a/CPP/7zip/UI/GUI/GUI.cpp b/CPP/7zip/UI/GUI/GUI.cpp
index 65b7fafa..e1117188 100755
--- a/CPP/7zip/UI/GUI/GUI.cpp
+++ b/CPP/7zip/UI/GUI/GUI.cpp
@@ -4,8 +4,8 @@
#include <initguid.h>
-extern "C"
-{
+extern "C"
+{
#include "../../../../C/Alloc.h"
}
@@ -14,26 +14,17 @@ extern "C"
#include "Common/CommandLineParser.h"
#include "Common/MyException.h"
-#include "Windows/COM.h"
-#include "Windows/FileMapping.h"
-#include "Windows/FileDir.h"
-#include "Windows/Synchronization.h"
#include "Windows/Error.h"
-#include "Windows/FileName.h"
#ifdef _WIN32
#include "Windows/MemoryLock.h"
#endif
-#include "../../IStream.h"
-#include "../../IPassword.h"
-
#include "../FileManager/StringUtils.h"
#include "../Common/ExitCode.h"
#include "../Common/ArchiveCommandLine.h"
#include "ExtractRes.h"
-#include "../Explorer/MyMessages.h"
#include "ExtractGUI.h"
#include "UpdateGUI.h"
@@ -46,31 +37,37 @@ HINSTANCE g_hInstance;
bool g_IsNT = false;
#endif
-// static const wchar_t *kExceptionErrorMessage = L"Error:";
-// static const wchar_t *kUserBreak = L"Break signaled";
+static void ErrorMessage(LPCWSTR message)
+{
+ MessageBoxW(NULL, message, L"7-Zip", MB_ICONERROR | MB_OK);
+}
+
+static void ErrorLangMessage(UINT resourceID, UInt32 langID)
+{
+ ErrorMessage(LangString(resourceID, langID));
+}
-static const wchar_t *kMemoryExceptionMessage = L"ERROR: Can't allocate required memory!";
-static const wchar_t *kUnknownExceptionMessage = L"Unknown Error";
-// static const wchar_t *kInternalExceptionMessage = L"Internal Error #";
-// static const wchar_t *kIncorrectCommandMessage = L"Incorrect command";
+static const char *kNoFormats = "7-Zip cannot find the code that works with archives.";
-static void ErrorMessage(const wchar_t *message)
+static int ShowMemErrorMessage()
{
- MessageBoxW(0, message, L"7-Zip GUI", MB_ICONERROR);
+ ErrorLangMessage(IDS_MEM_ERROR, 0x0200060B);
+ return NExitCode::kMemoryError;
}
-int Main2()
+static int ShowSysErrorMessage(DWORD errorCode)
{
- /*
- TCHAR t[512];
- GetCurrentDirectory(512, t);
- ErrorMessage(t);
- return 0;
- */
+ if (errorCode == E_OUTOFMEMORY)
+ return ShowMemErrorMessage();
+ ErrorMessage(NError::MyFormatMessageW(errorCode));
+ return NExitCode::kFatalError;
+}
+static int Main2()
+{
UStringVector commandStrings;
NCommandLineParser::SplitCommandLine(GetCommandLineW(), commandStrings);
- if(commandStrings.Size() <= 1)
+ if (commandStrings.Size() <= 1)
{
MessageBoxW(0, L"Specify command", L"7-Zip", 0);
return 0;
@@ -95,6 +92,17 @@ int Main2()
throw CSystemException(result);
bool isExtractGroupCommand = options.Command.IsFromExtractGroup();
+ if (codecs->Formats.Size() == 0 &&
+ (isExtractGroupCommand ||
+ options.Command.IsFromUpdateGroup()))
+ throw kNoFormats;
+
+ CIntVector formatIndices;
+ if (!codecs->FindFormatForArchiveType(options.ArcType, formatIndices))
+ {
+ ErrorLangMessage(IDS_UNSUPPORTED_ARCHIVE_TYPE, 0x0200060D);
+ return NExitCode::kFatalError;
+ }
if (options.Command.CommandType == NCommandType::kBenchmark)
{
@@ -115,10 +123,6 @@ int Main2()
ecs->Password = options.Password;
ecs->Init();
- COpenCallbackGUI openCallback;
- openCallback.PasswordIsDefined = options.PasswordEnabled;
- openCallback.Password = options.Password;
-
CExtractOptions eo;
eo.StdOutMode = options.StdOutMode;
eo.OutputDir = options.OutputDir;
@@ -130,25 +134,21 @@ int Main2()
eo.Properties = options.ExtractProperties;
#endif
- HRESULT result = ExtractGUI(codecs,
- options.ArchivePathsSorted,
+ HRESULT result = ExtractGUI(codecs, formatIndices,
+ options.ArchivePathsSorted,
options.ArchivePathsFullSorted,
- options.WildcardCensor.Pairs.Front().Head,
- eo, options.ShowDialog, &openCallback, ecs);
+ options.WildcardCensor.Pairs.Front().Head,
+ eo, options.ShowDialog, ecs);
if (result != S_OK)
throw CSystemException(result);
if (ecs->Messages.Size() > 0 || ecs->NumArchiveErrors != 0)
- return NExitCode::kFatalError;
+ return NExitCode::kFatalError;
}
else if (options.Command.IsFromUpdateGroup())
{
- bool passwordIsDefined =
+ bool passwordIsDefined =
options.PasswordEnabled && !options.Password.IsEmpty();
- COpenCallbackGUI openCallback;
- openCallback.PasswordIsDefined = passwordIsDefined;
- openCallback.Password = options.Password;
-
CUpdateCallbackGUI callback;
// callback.EnablePercents = options.EnablePercents;
callback.PasswordIsDefined = passwordIsDefined;
@@ -159,27 +159,33 @@ int Main2()
CUpdateErrorInfo errorInfo;
- if (!options.UpdateOptions.Init(codecs, options.ArchiveName, options.ArcType))
- throw "Unsupported archive type";
+ if (!options.UpdateOptions.Init(codecs, formatIndices, options.ArchiveName))
+ {
+ ErrorLangMessage(IDS_UPDATE_NOT_SUPPORTED, 0x02000601);
+ return NExitCode::kFatalError;
+ }
HRESULT result = UpdateGUI(
codecs,
- options.WildcardCensor, options.UpdateOptions,
+ options.WildcardCensor, options.UpdateOptions,
options.ShowDialog,
- errorInfo, &openCallback, &callback);
+ errorInfo, &callback);
if (result != S_OK)
{
if (!errorInfo.Message.IsEmpty())
+ {
ErrorMessage(errorInfo.Message);
+ if (result == E_FAIL)
+ return NExitCode::kFatalError;
+ }
throw CSystemException(result);
}
if (callback.FailedFiles.Size() > 0)
- return NExitCode::kWarning;
+ return NExitCode::kWarning;
}
else
{
- ErrorMessage(L"Use correct command");
- return 0;
+ throw "Unsupported command";
}
return 0;
}
@@ -188,7 +194,7 @@ static bool inline IsItWindowsNT()
{
OSVERSIONINFO versionInfo;
versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
- if (!::GetVersionEx(&versionInfo))
+ if (!::GetVersionEx(&versionInfo))
return false;
return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
}
@@ -199,7 +205,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /
#ifdef _UNICODE
if (!IsItWindowsNT())
{
- MyMessageBox(L"This program requires Windows NT/2000/XP/2003");
+ ErrorMessage(L"This program requires Windows NT/2000/2003/2008/XP/Vista");
return NExitCode::kFatalError;
}
#else
@@ -221,64 +227,43 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /
}
catch(const CNewException &)
{
- MyMessageBox(kMemoryExceptionMessage);
- return (NExitCode::kMemoryError);
+ return ShowMemErrorMessage();
}
catch(const CArchiveCommandLineException &e)
{
- MyMessageBox(GetUnicodeString(e));
- return (NExitCode::kUserError);
+ ErrorMessage(GetUnicodeString(e));
+ return NExitCode::kUserError;
}
catch(const CSystemException &systemError)
{
- if (systemError.ErrorCode == E_OUTOFMEMORY)
- {
- MyMessageBox(kMemoryExceptionMessage);
- return (NExitCode::kMemoryError);
- }
if (systemError.ErrorCode == E_ABORT)
- {
- // MyMessageBox(kUserBreak);
- return (NExitCode::kUserBreak);
- }
- UString message;
- NError::MyFormatMessage(systemError.ErrorCode, message);
- MyMessageBox(message);
- return (NExitCode::kFatalError);
- }
- /*
- catch(NExitCode::EEnum &exitCode)
- {
- g_StdErr << kInternalExceptionMessage << exitCode << endl;
- return (exitCode);
+ return NExitCode::kUserBreak;
+ return ShowSysErrorMessage(systemError.ErrorCode);
}
- */
catch(const UString &s)
{
- MyMessageBox(s);
- return (NExitCode::kFatalError);
+ ErrorMessage(s);
+ return NExitCode::kFatalError;
}
catch(const AString &s)
{
- MyMessageBox(GetUnicodeString(s));
- return (NExitCode::kFatalError);
+ ErrorMessage(GetUnicodeString(s));
+ return NExitCode::kFatalError;
}
- catch(const char *s)
+ catch(const wchar_t *s)
{
- MyMessageBox(GetUnicodeString(s));
- return (NExitCode::kFatalError);
+ ErrorMessage(s);
+ return NExitCode::kFatalError;
}
- /*
- catch(int t)
+ catch(const char *s)
{
- g_StdErr << kInternalExceptionMessage << t << endl;
- return (NExitCode::kFatalError);
+ ErrorMessage(GetUnicodeString(s));
+ return NExitCode::kFatalError;
}
- */
catch(...)
{
- MyMessageBox(kUnknownExceptionMessage);
- return (NExitCode::kFatalError);
+ ErrorLangMessage(IDS_UNKNOWN_ERROR, 0x0200060C);
+ return NExitCode::kFatalError;
}
}
diff --git a/CPP/7zip/UI/GUI/GUI.dsp b/CPP/7zip/UI/GUI/GUI.dsp
index b61ef92f..1de7ac97 100755
--- a/CPP/7zip/UI/GUI/GUI.dsp
+++ b/CPP/7zip/UI/GUI/GUI.dsp
@@ -561,14 +561,6 @@ SOURCE=.\GUI.cpp
# End Source File
# Begin Source File
-SOURCE=.\OpenCallbackGUI.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\OpenCallbackGUI.h
-# End Source File
-# Begin Source File
-
SOURCE=.\UpdateCallbackGUI.cpp
# End Source File
# Begin Source File
@@ -959,6 +951,10 @@ SOURCE=..\..\..\Windows\System.h
# End Source File
# Begin Source File
+SOURCE=..\..\..\Windows\Time.cpp
+# End Source File
+# Begin Source File
+
SOURCE=..\..\..\Windows\Window.cpp
# End Source File
# Begin Source File
diff --git a/CPP/7zip/UI/GUI/OpenCallbackGUI.cpp b/CPP/7zip/UI/GUI/OpenCallbackGUI.cpp
deleted file mode 100755
index 7717de99..00000000
--- a/CPP/7zip/UI/GUI/OpenCallbackGUI.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-// OpenCallbackGUI.cpp
-
-#include "StdAfx.h"
-
-#include "OpenCallbackGUI.h"
-
-#ifndef _NO_CRYPTO
-#include "../FileManager/PasswordDialog.h"
-#endif
-
-HRESULT COpenCallbackGUI::CheckBreak()
-{
- return S_OK;
-}
-
-HRESULT COpenCallbackGUI::SetTotal(const UInt64 * /* files */, const UInt64 * /* bytes */)
-{
- return S_OK;
-}
-
-HRESULT COpenCallbackGUI::SetCompleted(const UInt64 * /* files */, const UInt64 * /* bytes */)
-{
- return S_OK;
-}
-
-#ifndef _NO_CRYPTO
-HRESULT COpenCallbackGUI::CryptoGetTextPassword(BSTR *password)
-{
- PasswordWasAsked = true;
- if (!PasswordIsDefined)
- {
- CPasswordDialog dialog;
- if (dialog.Create(ParentWindow) == IDCANCEL)
- return E_ABORT;
- Password = dialog.Password;
- PasswordIsDefined = true;
- }
- CMyComBSTR tempName(Password);
- *password = tempName.Detach();
- return S_OK;
-}
-
-HRESULT COpenCallbackGUI::GetPasswordIfAny(UString &password)
-{
- if (PasswordIsDefined)
- password = Password;
- return S_OK;
-}
-
-bool COpenCallbackGUI::WasPasswordAsked()
-{
- return PasswordWasAsked;
-}
-
-void COpenCallbackGUI::ClearPasswordWasAskedFlag()
-{
- PasswordWasAsked = false;
-}
-
-#endif
-
diff --git a/CPP/7zip/UI/GUI/OpenCallbackGUI.h b/CPP/7zip/UI/GUI/OpenCallbackGUI.h
deleted file mode 100755
index 6b531d3c..00000000
--- a/CPP/7zip/UI/GUI/OpenCallbackGUI.h
+++ /dev/null
@@ -1,35 +0,0 @@
-// OpenCallbackGUI.h
-
-#ifndef __OPEN_CALLBACK_GUI_H
-#define __OPEN_CALLBACK_GUI_H
-
-#include "../Common/ArchiveOpenCallback.h"
-
-class COpenCallbackGUI: public IOpenCallbackUI
-{
-public:
- HRESULT CheckBreak();
- HRESULT SetTotal(const UInt64 *files, const UInt64 *bytes);
- HRESULT SetCompleted(const UInt64 *files, const UInt64 *bytes);
- #ifndef _NO_CRYPTO
- HRESULT CryptoGetTextPassword(BSTR *password);
- HRESULT GetPasswordIfAny(UString &password);
- bool WasPasswordAsked();
- void ClearPasswordWasAskedFlag();
-
- bool PasswordIsDefined;
- UString Password;
- bool PasswordWasAsked;
- #endif
-
- HWND ParentWindow;
-
- COpenCallbackGUI():
- #ifndef _NO_CRYPTO
- PasswordIsDefined(false),
- PasswordWasAsked(false),
- #endif
- ParentWindow(0) {}
-};
-
-#endif
diff --git a/CPP/7zip/UI/GUI/UpdateCallbackGUI.cpp b/CPP/7zip/UI/GUI/UpdateCallbackGUI.cpp
index a17f0cac..7cd5df95 100755
--- a/CPP/7zip/UI/GUI/UpdateCallbackGUI.cpp
+++ b/CPP/7zip/UI/GUI/UpdateCallbackGUI.cpp
@@ -41,9 +41,9 @@ void CUpdateCallbackGUI::AddErrorMessage(LPCWSTR message)
void CUpdateCallbackGUI::AddErrorMessage(const wchar_t *name, DWORD systemError)
{
AddErrorMessage(
- UString(L"WARNING: ") +
- NError::MyFormatMessageW(systemError) +
- UString(L": ") +
+ UString(L"WARNING: ") +
+ NError::MyFormatMessageW(systemError) +
+ UString(L": ") +
UString(name));
}
@@ -87,15 +87,14 @@ HRESULT CUpdateCallbackGUI::FinishArchive()
HRESULT CUpdateCallbackGUI::CheckBreak()
{
- for (;;)
- {
- if(ProgressDialog.ProgressSynch.GetStopped())
- return E_ABORT;
- if(!ProgressDialog.ProgressSynch.GetPaused())
- break;
- ::Sleep(100);
- }
- return S_OK;
+ return ProgressDialog.ProgressSynch.ProcessStopAndPause();
+}
+
+HRESULT CUpdateCallbackGUI::ScanProgress(UInt64 /* numFolders */, UInt64 numFiles, const wchar_t *path)
+{
+ ProgressDialog.ProgressSynch.SetCurrentFileName(path);
+ ProgressDialog.ProgressSynch.SetNumFilesTotal(numFiles);
+ return ProgressDialog.ProgressSynch.ProcessStopAndPause();
}
HRESULT CUpdateCallbackGUI::Finilize()
@@ -151,17 +150,17 @@ HRESULT CUpdateCallbackGUI::SetOperationResult(Int32 /* operationResult */)
{
NumFiles++;
ProgressDialog.ProgressSynch.SetNumFilesCur(NumFiles);
- return S_OK;
+ return S_OK;
}
HRESULT CUpdateCallbackGUI::CryptoGetTextPassword2(Int32 *passwordIsDefined, BSTR *password)
{
- if (!PasswordIsDefined)
+ if (!PasswordIsDefined)
{
if (AskPassword)
{
CPasswordDialog dialog;
- if (dialog.Create(ParentWindow) == IDCANCEL)
+ if (dialog.Create(ProgressDialog) == IDCANCEL)
return E_ABORT;
Password = dialog.Password;
PasswordIsDefined = true;
@@ -175,9 +174,63 @@ HRESULT CUpdateCallbackGUI::CryptoGetTextPassword2(Int32 *passwordIsDefined, BST
/*
It doesn't work, since main stream waits Dialog
-HRESULT CUpdateCallbackGUI::CloseProgress()
-{
- ProgressDialog.MyClose();
+HRESULT CUpdateCallbackGUI::CloseProgress()
+{
+ ProgressDialog.MyClose();
return S_OK;
};
-*/ \ No newline at end of file
+*/
+
+
+HRESULT CUpdateCallbackGUI::Open_CheckBreak()
+{
+ return ProgressDialog.ProgressSynch.ProcessStopAndPause();
+}
+
+HRESULT CUpdateCallbackGUI::Open_SetTotal(const UInt64 * /* numFiles */, const UInt64 * /* numBytes */)
+{
+ // if (numFiles != NULL) ProgressDialog.ProgressSynch.SetNumFilesTotal(*numFiles);
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackGUI::Open_SetCompleted(const UInt64 * /* numFiles */, const UInt64 * /* numBytes */)
+{
+ return ProgressDialog.ProgressSynch.ProcessStopAndPause();
+}
+
+#ifndef _NO_CRYPTO
+
+HRESULT CUpdateCallbackGUI::Open_CryptoGetTextPassword(BSTR *password)
+{
+ PasswordWasAsked = true;
+ if (!PasswordIsDefined)
+ {
+ CPasswordDialog dialog;
+ if (dialog.Create(ProgressDialog) == IDCANCEL)
+ return E_ABORT;
+ Password = dialog.Password;
+ PasswordIsDefined = true;
+ }
+ CMyComBSTR tempName(Password);
+ *password = tempName.Detach();
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackGUI::Open_GetPasswordIfAny(UString &password)
+{
+ if (PasswordIsDefined)
+ password = Password;
+ return S_OK;
+}
+
+bool CUpdateCallbackGUI::Open_WasPasswordAsked()
+{
+ return PasswordWasAsked;
+}
+
+void CUpdateCallbackGUI::Open_ClearPasswordWasAskedFlag()
+{
+ PasswordWasAsked = false;
+}
+
+#endif
diff --git a/CPP/7zip/UI/GUI/UpdateCallbackGUI.h b/CPP/7zip/UI/GUI/UpdateCallbackGUI.h
index dc370638..1f8b70e0 100755
--- a/CPP/7zip/UI/GUI/UpdateCallbackGUI.h
+++ b/CPP/7zip/UI/GUI/UpdateCallbackGUI.h
@@ -4,19 +4,24 @@
#define __UPDATE_CALLBACK_GUI_H
#include "../Common/Update.h"
+#include "../Common/ArchiveOpenCallback.h"
#include "../FileManager/ProgressDialog2.h"
-class CUpdateCallbackGUI: public IUpdateCallbackUI2
+class CUpdateCallbackGUI:
+ public IOpenCallbackUI,
+ public IUpdateCallbackUI2
{
public:
// bool StdOutMode;
bool PasswordIsDefined;
UString Password;
bool AskPassword;
+ bool PasswordWasAsked;
UInt64 NumFiles;
- CUpdateCallbackGUI():
+ CUpdateCallbackGUI():
PasswordIsDefined(false),
+ PasswordWasAsked(false),
AskPassword(false),
// StdOutMode(false)
ParentWindow(0)
@@ -26,6 +31,7 @@ public:
void Init();
INTERFACE_IUpdateCallbackUI2(;)
+ INTERFACE_IOpenCallbackUI(;)
// HRESULT CloseProgress();
diff --git a/CPP/7zip/UI/GUI/UpdateGUI.cpp b/CPP/7zip/UI/GUI/UpdateGUI.cpp
index ca89c7c9..16edc718 100755
--- a/CPP/7zip/UI/GUI/UpdateGUI.cpp
+++ b/CPP/7zip/UI/GUI/UpdateGUI.cpp
@@ -23,7 +23,6 @@
#include "../Explorer/MyMessages.h"
#include "ExtractRes.h"
-#include "OpenCallbackGUI.h"
#include "CompressDialog.h"
#include "UpdateGUI.h"
@@ -41,7 +40,6 @@ struct CThreadUpdating
CUpdateCallbackGUI *UpdateCallbackGUI;
const NWildcard::CCensor *WildcardCensor;
CUpdateOptions *Options;
- COpenCallbackGUI *OpenCallback;
CUpdateErrorInfo *ErrorInfo;
HRESULT Result;
@@ -51,19 +49,19 @@ struct CThreadUpdating
UpdateCallbackGUI->ProgressDialog.WaitCreating();
try
{
- Result = UpdateArchive(codecs, *WildcardCensor, *Options,
- *ErrorInfo, OpenCallback, UpdateCallbackGUI);
+ Result = UpdateArchive(codecs, *WildcardCensor, *Options,
+ *ErrorInfo, UpdateCallbackGUI, UpdateCallbackGUI);
}
catch(const UString &s)
{
ErrorInfo->Message = s;
Result = E_FAIL;
- }
+ }
catch(const wchar_t *s)
{
ErrorInfo->Message = s;
Result = E_FAIL;
- }
+ }
catch(const char *s)
{
ErrorInfo->Message = GetUnicodeString(s);
@@ -126,7 +124,7 @@ static bool IsThereMethodOverride(bool is7z, const UString &propertiesString)
return false;
}
-static void ParseAndAddPropertires(CObjectVector<CProperty> &properties,
+static void ParseAndAddPropertires(CObjectVector<CProperty> &properties,
const UString &propertiesString)
{
UStringVector strings;
@@ -160,14 +158,14 @@ static UString GetNumInBytesString(UInt64 v)
static void SetOutProperties(
CObjectVector<CProperty> &properties,
bool is7z,
- UInt32 level,
+ UInt32 level,
bool setMethod,
const UString &method,
UInt32 dictionary,
bool orderMode,
UInt32 order,
- bool solidIsSpecified, UInt64 solidBlockSize,
- bool multiThreadIsAllowed, UInt32 numThreads,
+ bool solidIsSpecified, UInt64 solidBlockSize,
+ bool multiThreadIsAllowed, UInt32 numThreads,
const UString &encryptionMethod,
bool encryptHeadersIsAllowed, bool encryptHeaders,
bool /* sfxMode */)
@@ -247,7 +245,7 @@ static HRESULT ShowDialog(
if (NFind::FindFile(name, fileInfo))
{
if (censor.Pairs.Size() == 1 && pair.Head.IncludeItems.Size() == 1)
- oneFile = !fileInfo.IsDirectory();
+ oneFile = !fileInfo.IsDir();
}
}
}
@@ -263,7 +261,7 @@ static HRESULT ShowDialog(
}
if(dialog.m_ArchiverInfoList.Size() == 0)
{
- MyMessageBox(L"No Update Engines");
+ ShowErrorMessage(L"No Update Engines");
return E_FAIL;
}
@@ -324,13 +322,13 @@ static HRESULT ShowDialog(
SetOutProperties(
options.MethodMode.Properties,
is7z,
- di.Level,
+ di.Level,
!methodOverride,
- di.Method,
- di.Dictionary,
+ di.Method,
+ di.Dictionary,
di.OrderMode, di.Order,
- di.SolidIsSpecified, di.SolidBlockSize,
- di.MultiThreadIsAllowed, di.NumThreads,
+ di.SolidIsSpecified, di.SolidBlockSize,
+ di.MultiThreadIsAllowed, di.NumThreads,
di.EncryptionMethod,
di.EncryptHeadersIsAllowed, di.EncryptHeaders,
di.SFXMode);
@@ -364,11 +362,10 @@ static HRESULT ShowDialog(
HRESULT UpdateGUI(
CCodecs *codecs,
- const NWildcard::CCensor &censor,
+ const NWildcard::CCensor &censor,
CUpdateOptions &options,
bool showDialog,
CUpdateErrorInfo &errorInfo,
- COpenCallbackGUI *openCallback,
CUpdateCallbackGUI *callback)
{
if (showDialog)
@@ -387,7 +384,6 @@ HRESULT UpdateGUI(
tu.WildcardCensor = &censor;
tu.Options = &options;
- tu.OpenCallback = openCallback;
tu.ErrorInfo = &errorInfo;
NWindows::CThread thread;
@@ -395,5 +391,3 @@ HRESULT UpdateGUI(
tu.UpdateCallbackGUI->StartProgressDialog(LangString(IDS_PROGRESS_COMPRESSING, 0x02000DC0));
return tu.Result;
}
-
-
diff --git a/CPP/7zip/UI/GUI/UpdateGUI.h b/CPP/7zip/UI/GUI/UpdateGUI.h
index db58877b..112eff0f 100755
--- a/CPP/7zip/UI/GUI/UpdateGUI.h
+++ b/CPP/7zip/UI/GUI/UpdateGUI.h
@@ -4,18 +4,16 @@
#define __UPDATE_GUI_H
#include "../Common/Update.h"
-#include "OpenCallbackGUI.h"
#include "UpdateCallbackGUI.h"
#include "../FileManager/UpdateCallback100.h"
HRESULT UpdateGUI(
CCodecs *codecs,
- const NWildcard::CCensor &censor,
+ const NWildcard::CCensor &censor,
CUpdateOptions &options,
bool showDialog,
CUpdateErrorInfo &errorInfo,
- COpenCallbackGUI *openCallback,
CUpdateCallbackGUI *callback);
#endif
diff --git a/CPP/7zip/UI/GUI/makefile b/CPP/7zip/UI/GUI/makefile
index e37ce7d5..e2caf8ee 100755
--- a/CPP/7zip/UI/GUI/makefile
+++ b/CPP/7zip/UI/GUI/makefile
@@ -15,7 +15,6 @@ GUI_OBJS = \
$O\ExtractDialog.obj \
$O\ExtractGUI.obj \
$O\GUI.obj \
- $O\OpenCallbackGUI.obj \
$O\UpdateCallbackGUI.obj \
$O\UpdateGUI.obj \
@@ -50,6 +49,7 @@ WIN_OBJS = \
$O\Shell.obj \
$O\Synchronization.obj \
$O\System.obj \
+ $O\Time.obj \
$O\Window.obj \
WIN_CTRL_OBJS = \
diff --git a/CPP/7zip/UI/GUI/resource.h b/CPP/7zip/UI/GUI/resource.h
index 08517dec..e154e035 100755
--- a/CPP/7zip/UI/GUI/resource.h
+++ b/CPP/7zip/UI/GUI/resource.h
@@ -1,13 +1,13 @@
-#define IDS_CONTEXT_EXTRACT 42
-#define IDS_CONTEXT_EXTRACT_HELP 43
-#define IDS_CONTEXT_COMPRESS 44
-#define IDS_CONTEXT_COMPRESS_HELP 45
-#define IDS_CONTEXT_OPEN 46
-#define IDS_CONTEXT_OPEN_HELP 47
-#define IDS_CONTEXT_TEST 48
-#define IDS_CONTEXT_TEST_HELP 49
-#define IDS_CONTEXT_CAPTION_HELP 50
-#define IDS_CONTEXT_POPUP_CAPTION 51
+#define IDS_CONTEXT_EXTRACT 142
+#define IDS_CONTEXT_EXTRACT_HELP 143
+#define IDS_CONTEXT_COMPRESS 144
+#define IDS_CONTEXT_COMPRESS_HELP 145
+#define IDS_CONTEXT_OPEN 146
+#define IDS_CONTEXT_OPEN_HELP 147
+#define IDS_CONTEXT_TEST 148
+#define IDS_CONTEXT_TEST_HELP 149
+#define IDS_CONTEXT_CAPTION_HELP 150
+#define IDS_CONTEXT_POPUP_CAPTION 151
#define IDS_OPEN_TYPE_ALL_FILES 80
#define IDS_METHOD_STORE 81
@@ -39,7 +39,7 @@
#define IDS_PASSWORD_USE_ASCII 110
#define IDS_PASSWORD_PASSWORDS_DO_NOT_MATCH 111
-#define IDS_PASSWORD_IS_TOO_LONG 112
+#define IDS_PASSWORD_IS_TOO_LONG 112
#define IDS_FILES_COLON 2274
#define IDS_FOLDERS_COLON 2275
@@ -47,7 +47,3 @@
#define IDS_COMPRESSED_COLON 2277
#define IDS_ARCHIVES_COLON 2278
-#define IDB_DELETE 149
-#define IDC_LIST1 1067
-#define IDC_COLUMN_EDIT_WIDTH 1068
-